diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayDesignator.java index f1a460525eb..b418065a86a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTArrayDesignator.java @@ -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 { - /** * SUBSCRIPT_EXPRESSION represents the relationship between * the designator and the subscript expression. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignator.java index 59606cd7fcb..c929e4c6835 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignator.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation + * John Camelon (IBM Rational Software) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.c; @@ -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 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTArrayRangeDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTArrayRangeDesignator.java index cae2ac013c4..d8d878ad9b6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTArrayRangeDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/IGCCASTArrayRangeDesignator.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation + * John Camelon (IBM Rational Software) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.gnu.c; @@ -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 { - /** * SUSBCRIPT_FLOOR_EXPRESSION represents the lower value in * the range of expressions. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java index 01c17b32bf6..b24377328c7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java @@ -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; } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java index 8254836c6c7..0483fe5b46f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Markus Schorn (Wind River Systems) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -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() { } @@ -57,7 +57,7 @@ public class CASTArrayRangeDesignator extends ASTNode implements public void setRangeFloor(IASTExpression expression) { assertNotFrozen(); floor = expression; - if(expression != null) { + if (expression != null) { expression.setParent(this); expression.setPropertyInParent(SUBSCRIPT_FLOOR_EXPRESSION); } @@ -72,19 +72,19 @@ public class CASTArrayRangeDesignator extends ASTNode implements public void setRangeCeiling(IASTExpression expression) { assertNotFrozen(); ceiling = expression; - if(expression != null) { + if (expression != null) { expression.setParent(this); expression.setPropertyInParent(SUBSCRIPT_CEILING_EXPRESSION); } } @Override - public boolean accept( ASTVisitor action ){ - if (action.shouldVisitDesignators ) { + public boolean accept(ASTVisitor action) { + if (action.shouldVisitDesignators) { switch (action.visit(this)) { - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } if (floor != null && !floor.accept(action)) @@ -100,18 +100,15 @@ public class CASTArrayRangeDesignator extends ASTNode implements @Override public void replace(IASTNode child, IASTNode other) { - if( child == floor ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == floor) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); floor = (IASTExpression) other; } - if( child == ceiling) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == ceiling) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); ceiling = (IASTExpression) other; } } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java index ac233f35958..48f893b6410 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Markus Schorn (Wind River Systems) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -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() { } @@ -61,12 +59,12 @@ public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator } @Override - public boolean accept( ASTVisitor action ){ - if (action.shouldVisitDesignators ) { + public boolean accept( ASTVisitor action) { + if (action.shouldVisitDesignators) { switch (action.visit(this)) { - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } if (name != null && !name.accept(action)) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index b2e55a3984a..4e794266027 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -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(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(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(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(); + 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 pointerOps = new ArrayList(DEFAULT_POINTEROPS_LIST_SIZE); + List 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(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 arrayMods = new ArrayList(DEFAULT_POINTEROPS_LIST_SIZE); + ArrayList arrayMods = new ArrayList<>(DEFAULT_POINTEROPS_LIST_SIZE); int start= LA(1).getOffset(); consumeArrayModifiers(arrayMods); if (arrayMods.isEmpty()) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index d0cc7208ab5..158db100e24 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -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 createContextSensitiveTokenMap( ICPPParserExtensionConfiguration config) { - Map result = new HashMap(); + Map result = new HashMap<>(); result.put(Keywords.OVERRIDE, ContextSensitiveTokenType.OVERRIDE); result.put(Keywords.FINAL, ContextSensitiveTokenType.FINAL); result.putAll(config.getAdditionalContextSensitiveKeywords()); @@ -438,7 +427,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } else { char[] nchars= nt.getCharImage(); final int len= nchars.length; - char[] image = new char[len+1]; + char[] image = new char[len + 1]; image[0]= '~'; System.arraycopy(nchars, 0, image, 1, len); name= getNodeFactory().newName(image); @@ -702,7 +691,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { IASTNode node= templateArgument(strat); if (list == null) { - list= new ArrayList(); + list= new ArrayList<>(); } list.add(node); lt1= LT(1); @@ -2309,7 +2298,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { protected List outerTemplateParameterList() throws BacktrackException, EndOfFileException { fTemplateParameterListStrategy= new TemplateIdStrategy(); try { - List result = new ArrayList(DEFAULT_PARM_LIST_SIZE); + List 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 tparList = templateParameterList(new ArrayList()); + List 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(); + specifiers = new ArrayList<>(); int offset = consumeOrEOC(IToken.tLBRACKET).getOffset(); consumeOrEOC(IToken.tLBRACKET); ICPPASTAttributeSpecifier attributeSpecifier = getNodeFactory().newAttributeSpecifier(); @@ -2691,7 +2680,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; if (dtor != null) { - declarators= new IASTDeclarator[]{dtor}; + declarators= new IASTDeclarator[] { dtor }; if (!declOption.fSingleDtor) { while (LTcatchEOF(1) == IToken.tCOMMA) { consume(); @@ -2842,7 +2831,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { if (fdef instanceof ICPPASTFunctionWithTryBlock) { ICPPASTFunctionWithTryBlock tryblock= (ICPPASTFunctionWithTryBlock) fdef; - List handlers = new ArrayList(DEFAULT_CATCH_HANDLER_LIST_SIZE); + List 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 initializerList(boolean allowSkipping) throws EndOfFileException, BacktrackException { - List result= new ArrayList(); + List 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(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 arrayMods = new ArrayList(4); + ArrayList 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 catchHandlers = new ArrayList(DEFAULT_CATCH_HANDLER_LIST_SIZE); + List catchHandlers = new ArrayList<>(DEFAULT_CATCH_HANDLER_LIST_SIZE); catchHandlerSequence(catchHandlers); ICPPASTTryBlockStatement tryStatement = getNodeFactory().newTryBlockStatement(tryBlock); ((ASTNode) tryStatement).setOffset(startO); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java index 9f00db17dbe..2289eeffe2f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java @@ -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 }