1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2015-11-16 19:45:28 -08:00
parent 3e81f0437c
commit 4316da89b5
9 changed files with 62 additions and 80 deletions

View file

@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICASTArrayDesignator extends ICASTDesignator {
/**
* <code>SUBSCRIPT_EXPRESSION</code> represents the relationship between
* the designator and the subscript expression.

View file

@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICASTDesignator extends IASTNode {
/**
* @since 5.1
*/

View file

@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IGCCASTArrayRangeDesignator extends ICASTDesignator {
/**
* <code>SUSBCRIPT_FLOOR_EXPRESSION</code> represents the lower value in
* the range of expressions.

View file

@ -20,10 +20,10 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* Implementation of array designators
* Implementation of array designator.
*/
public class CASTArrayDesignator extends ASTNode implements ICASTArrayDesignator, IASTAmbiguityParent {
private IASTExpression exp;
private IASTExpression expression;
public CASTArrayDesignator() {
}
@ -39,19 +39,20 @@ public class CASTArrayDesignator extends ASTNode implements ICASTArrayDesignator
@Override
public CASTArrayDesignator copy(CopyStyle style) {
CASTArrayDesignator copy = new CASTArrayDesignator(exp == null ? null : exp.copy(style));
CASTArrayDesignator copy =
new CASTArrayDesignator(expression == null ? null : expression.copy(style));
return copy(copy, style);
}
@Override
public IASTExpression getSubscriptExpression() {
return exp;
return expression;
}
@Override
public void setSubscriptExpression(IASTExpression value) {
assertNotFrozen();
exp = value;
expression = value;
if (value != null) {
value.setParent(this);
value.setPropertyInParent(SUBSCRIPT_EXPRESSION);
@ -67,7 +68,7 @@ public class CASTArrayDesignator extends ASTNode implements ICASTArrayDesignator
default: break;
}
}
if (exp != null && !exp.accept(action))
if (expression != null && !expression.accept(action))
return false;
if (action.shouldVisitDesignators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
@ -78,10 +79,10 @@ public class CASTArrayDesignator extends ASTNode implements ICASTArrayDesignator
@Override
public void replace(IASTNode child, IASTNode other) {
if (child == exp) {
if (child == expression) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
exp = (IASTExpression) other;
expression = (IASTExpression) other;
}
}
}

View file

@ -20,12 +20,12 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* Implementation of array range designators.
* Implementation of array range designator.
*/
public class CASTArrayRangeDesignator extends ASTNode implements
IGCCASTArrayRangeDesignator, IASTAmbiguityParent {
private IASTExpression floor, ceiling;
public class CASTArrayRangeDesignator extends ASTNode
implements IGCCASTArrayRangeDesignator, IASTAmbiguityParent {
private IASTExpression floor;
private IASTExpression ceiling;
public CASTArrayRangeDesignator() {
}
@ -100,18 +100,15 @@ public class CASTArrayRangeDesignator extends ASTNode implements
@Override
public void replace(IASTNode child, IASTNode other) {
if( child == floor )
{
if (child == floor) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
floor = (IASTExpression) other;
}
if( child == ceiling)
{
if (child == ceiling) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
ceiling = (IASTExpression) other;
}
}
}

View file

@ -20,13 +20,11 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
* Implementation of field designators
* Implementation of field designator.
*/
public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator, IASTCompletionContext {
private IASTName name;
public CASTFieldDesignator() {
}

View file

@ -238,7 +238,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
ICASTFieldDesignator fieldDesignator = getNodeFactory().newFieldDesignator(n);
setRange(fieldDesignator, offset, calculateEndOffset(n));
if (designatorList == null)
designatorList = new ArrayList<ICASTDesignator>(DEFAULT_DESIGNATOR_LIST_SIZE);
designatorList = new ArrayList<>(DEFAULT_DESIGNATOR_LIST_SIZE);
designatorList.add(fieldDesignator);
break;
@ -252,14 +252,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
IGCCASTArrayRangeDesignator designator = getNodeFactory().newArrayRangeDesignatorGCC(constantExpression, constantExpression2);
setRange(designator, offset, lastOffset);
if (designatorList == null)
designatorList = new ArrayList<ICASTDesignator>(DEFAULT_DESIGNATOR_LIST_SIZE);
designatorList = new ArrayList<>(DEFAULT_DESIGNATOR_LIST_SIZE);
designatorList.add(designator);
} else {
int lastOffset = consume(IToken.tRBRACKET).getEndOffset();
ICASTArrayDesignator designator = getNodeFactory().newArrayDesignator(constantExpression);
setRange(designator, offset, lastOffset);
if (designatorList == null)
designatorList = new ArrayList<ICASTDesignator>(DEFAULT_DESIGNATOR_LIST_SIZE);
designatorList = new ArrayList<>(DEFAULT_DESIGNATOR_LIST_SIZE);
designatorList.add(designator);
}
break;
@ -700,7 +700,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
IASTExpression expr= expression(ExprKind.eAssignment);
if (argList == null) {
argList= new ArrayList<IASTExpression>();
argList= new ArrayList<>();
}
argList.add(expr);
}
@ -1379,7 +1379,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
final int startingOffset = LA(1).getOffset();
int endOffset = startingOffset;
List<IASTPointerOperator> pointerOps = new ArrayList<IASTPointerOperator>(DEFAULT_POINTEROPS_LIST_SIZE);
List<IASTPointerOperator> pointerOps = new ArrayList<>(DEFAULT_POINTEROPS_LIST_SIZE);
consumePointerOperators(pointerOps);
if (!pointerOps.isEmpty()) {
endOffset = calculateEndOffset(pointerOps.get(pointerOps.size() - 1));
@ -1643,7 +1643,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
IASTParameterDeclaration pd = parameterDeclaration(paramOption);
endOffset = calculateEndOffset(pd);
if (parameters == null)
parameters = new ArrayList<IASTParameterDeclaration>(DEFAULT_PARAMETERS_LIST_SIZE);
parameters = new ArrayList<>(DEFAULT_PARAMETERS_LIST_SIZE);
parameters.add(pd);
seenParameter = true;
break;
@ -1685,7 +1685,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
* Parse an array declarator starting at the square bracket.
*/
private IASTArrayDeclarator arrayDeclarator() throws EndOfFileException, BacktrackException {
ArrayList<IASTArrayModifier> arrayMods = new ArrayList<IASTArrayModifier>(DEFAULT_POINTEROPS_LIST_SIZE);
ArrayList<IASTArrayModifier> arrayMods = new ArrayList<>(DEFAULT_POINTEROPS_LIST_SIZE);
int start= LA(1).getOffset();
consumeArrayModifiers(arrayMods);
if (arrayMods.isEmpty())

View file

@ -17,6 +17,7 @@
* Anders Dahlberg (Ericsson) - bug 84144
* Nathan Ridge
* Richard Eames
* Alexander Nyßen (itemis AG) - bug 475908
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -169,18 +170,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.NameOrTemplateIDVariants.Bra
import org.eclipse.cdt.internal.core.dom.parser.cpp.NameOrTemplateIDVariants.Variant;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/*******************************************************************************
* Copyright (c) 2005, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* Alexander Nyßen (itemis AG) - bug 475908
*******************************************************************************/
/**
* This is our implementation of the IParser interface, serving as a parser for
* GNU C and C++. From time to time we will make reference to the ANSI ISO
@ -246,7 +235,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private Map<String, ContextSensitiveTokenType> createContextSensitiveTokenMap(
ICPPParserExtensionConfiguration config) {
Map<String, ContextSensitiveTokenType> result = new HashMap<String, ContextSensitiveTokenType>();
Map<String, ContextSensitiveTokenType> result = new HashMap<>();
result.put(Keywords.OVERRIDE, ContextSensitiveTokenType.OVERRIDE);
result.put(Keywords.FINAL, ContextSensitiveTokenType.FINAL);
result.putAll(config.getAdditionalContextSensitiveKeywords());
@ -702,7 +691,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
IASTNode node= templateArgument(strat);
if (list == null) {
list= new ArrayList<IASTNode>();
list= new ArrayList<>();
}
list.add(node);
lt1= LT(1);
@ -2309,7 +2298,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected List<ICPPASTTemplateParameter> outerTemplateParameterList() throws BacktrackException, EndOfFileException {
fTemplateParameterListStrategy= new TemplateIdStrategy();
try {
List<ICPPASTTemplateParameter> result = new ArrayList<ICPPASTTemplateParameter>(DEFAULT_PARM_LIST_SIZE);
List<ICPPASTTemplateParameter> result = new ArrayList<>(DEFAULT_PARM_LIST_SIZE);
IToken m= mark();
while (true) {
try {
@ -2400,7 +2389,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
consume();
consume(IToken.tLT);
List<ICPPASTTemplateParameter> tparList = templateParameterList(new ArrayList<ICPPASTTemplateParameter>());
List<ICPPASTTemplateParameter> tparList = templateParameterList(new ArrayList<>());
consume(IToken.tGT, IToken.tGT_in_SHIFTR);
int endOffset = consume(IToken.t_class).getEndOffset();
@ -2583,7 +2572,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
while (LTcatchEOF(1) == IToken.tLBRACKET && LTcatchEOF(2) == IToken.tLBRACKET) {
if (specifiers == null)
specifiers = new ArrayList<IASTAttributeSpecifier>();
specifiers = new ArrayList<>();
int offset = consumeOrEOC(IToken.tLBRACKET).getOffset();
consumeOrEOC(IToken.tLBRACKET);
ICPPASTAttributeSpecifier attributeSpecifier = getNodeFactory().newAttributeSpecifier();
@ -2842,7 +2831,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (fdef instanceof ICPPASTFunctionWithTryBlock) {
ICPPASTFunctionWithTryBlock tryblock= (ICPPASTFunctionWithTryBlock) fdef;
List<ICPPASTCatchHandler> handlers = new ArrayList<ICPPASTCatchHandler>(DEFAULT_CATCH_HANDLER_LIST_SIZE);
List<ICPPASTCatchHandler> handlers = new ArrayList<>(DEFAULT_CATCH_HANDLER_LIST_SIZE);
catchHandlerSequence(handlers);
ICPPASTCatchHandler last= null;
for (ICPPASTCatchHandler catchHandler : handlers) {
@ -3925,7 +3914,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
*/
private List<IASTInitializerClause> initializerList(boolean allowSkipping) throws EndOfFileException,
BacktrackException {
List<IASTInitializerClause> result= new ArrayList<IASTInitializerClause>();
List<IASTInitializerClause> result= new ArrayList<>();
// List of initializer clauses
loop: while (true) {
// Clause may be null, add to initializer anyways, such that the size can be computed.
@ -4207,7 +4196,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
pointer.setRestrict(isRestrict);
setRange(pointer, startOffset, endOffset);
if (result == null) {
result= new ArrayList<IASTPointerOperator>(4);
result= new ArrayList<>(4);
}
attributes = CollectionUtils.merge(attributes, attributeSpecifierSeq());
@ -4470,7 +4459,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* Parse an array declarator starting at the square bracket.
*/
private ICPPASTArrayDeclarator arrayDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
ArrayList<IASTArrayModifier> arrayMods = new ArrayList<IASTArrayModifier>(4);
ArrayList<IASTArrayModifier> arrayMods = new ArrayList<>(4);
int start= LA(1).getOffset();
consumeArrayModifiers(option, arrayMods);
if (arrayMods.isEmpty())
@ -4890,7 +4879,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected IASTStatement parseTryStatement() throws EndOfFileException, BacktrackException {
int startO = consume().getOffset();
IASTStatement tryBlock = compoundStatement();
List<ICPPASTCatchHandler> catchHandlers = new ArrayList<ICPPASTCatchHandler>(DEFAULT_CATCH_HANDLER_LIST_SIZE);
List<ICPPASTCatchHandler> catchHandlers = new ArrayList<>(DEFAULT_CATCH_HANDLER_LIST_SIZE);
catchHandlerSequence(catchHandlers);
ICPPASTTryBlockStatement tryStatement = getNodeFactory().newTryBlockStatement(tryBlock);
((ASTNode) tryStatement).setOffset(startO);

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.ui.text.IColorManager;
import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
@ -46,7 +47,6 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
* @since 5.1
*/
public final class CDTUITools {
private CDTUITools() {
// prevent instantiation
}