1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Cosmetics.

Change-Id: I78635ca74bffd3df7b51f87e70464e99dd699324
This commit is contained in:
Sergey Prigogin 2016-09-25 11:22:05 -07:00
parent d758c73e31
commit 53ec9571cb
417 changed files with 3822 additions and 3822 deletions

View file

@ -100,7 +100,7 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
boolean rc = false;
int lineBreakPos = line.length()-1;
char[] lineChars = line.toCharArray();
while(lineBreakPos >= 0 && Character.isWhitespace(lineChars[lineBreakPos])) {
while (lineBreakPos >= 0 && Character.isWhitespace(lineChars[lineBreakPos])) {
lineBreakPos--;
}
if (lineBreakPos >= 0) {

View file

@ -38,12 +38,12 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
fBinaryExpression= binaryExpression;
fCastExpression= castExpression;
}
@Override
public final IASTExpression copy() {
throw new UnsupportedOperationException();
}
@Override
public final IASTExpression copy(CopyStyle style) {
throw new UnsupportedOperationException();
@ -53,7 +53,7 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
public final void addExpression(IASTExpression e) {
throw new UnsupportedOperationException();
}
@Override
public final IASTNode[] getNodes() {
return getExpressions();
@ -77,14 +77,14 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
owner.replace(nodeToReplace, fBinaryExpression);
nodeToReplace= fBinaryExpression;
fBinaryExpression.accept(visitor);
// find nested names
final NameCollector nameCollector= new NameCollector();
fCastExpression.getTypeId().accept(nameCollector);
final IASTName[] names= nameCollector.getNames();
// resolve names
// resolve names
boolean hasIssue= false;
for (IASTName name : names) {
try {
@ -101,7 +101,7 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
if (hasIssue) {
return nodeToReplace;
}
final IASTExpression left = fBinaryExpression.getOperand1();
final IASTExpression right = fBinaryExpression.getOperand2();
left.setParent(null);
@ -154,25 +154,25 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
if (r == null) {
return middle;
}
r.setOperand1(middle);
r.setOperand1(middle);
setStart(r, middle);
middle= r;
r= (IASTBinaryExpression) r.getParent();
} else if (l instanceof IASTCastExpression) {
} else if (l instanceof IASTCastExpression) {
// cast binds stronger than binary operator
((IASTCastExpression) l).setOperand(middle);
((IASTCastExpression) l).setOperand(middle);
setEnd(l, middle);
middle= l; // middle becomes cast-expr, can be put into r (a binary-expr)
l= (IASTExpression) l.getParent();
l= (IASTExpression) l.getParent();
} else if (l instanceof IASTUnaryExpression) { //
// unary operator binds stronger than binary operator
((IASTUnaryExpression) l).setOperand(middle);
((IASTUnaryExpression) l).setOperand(middle);
setEnd(l, middle);
middle= l; // middle becomes unary-expr, can be put into r (a binary-expr)
l= (IASTExpression) l.getParent();
l= (IASTExpression) l.getParent();
} else {
if (r== null || getPrecendence((IASTBinaryExpression) l) >= getPrecendence(r)) {
((IASTBinaryExpression)l).setOperand2(middle);
((IASTBinaryExpression) l).setOperand2(middle);
setEnd(l, middle);
middle= l; // middle becomes binary, can be put into r because precedence is greater or equal.
l= (IASTExpression) l.getParent();
@ -187,19 +187,19 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
}
private int getPrecendence(IASTBinaryExpression r) {
switch(r.getOperator()) {
switch (r.getOperator()) {
case IASTBinaryExpression.op_ellipses:
case IASTBinaryExpression.op_assign:
case IASTBinaryExpression.op_binaryAndAssign:
case IASTBinaryExpression.op_binaryOrAssign:
case IASTBinaryExpression.op_binaryXorAssign:
case IASTBinaryExpression.op_divideAssign:
case IASTBinaryExpression.op_minusAssign:
case IASTBinaryExpression.op_moduloAssign:
case IASTBinaryExpression.op_minusAssign:
case IASTBinaryExpression.op_moduloAssign:
case IASTBinaryExpression.op_multiplyAssign:
case IASTBinaryExpression.op_plusAssign:
case IASTBinaryExpression.op_shiftLeftAssign:
case IASTBinaryExpression.op_shiftRightAssign:
case IASTBinaryExpression.op_plusAssign:
case IASTBinaryExpression.op_shiftLeftAssign:
case IASTBinaryExpression.op_shiftRightAssign:
return 0;
case IASTBinaryExpression.op_logicalOr:
return 1;
@ -231,8 +231,8 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
case IASTBinaryExpression.op_divide:
case IASTBinaryExpression.op_modulo:
return 10;
case IASTBinaryExpression.op_pmarrow:
case IASTBinaryExpression.op_pmdot:
case IASTBinaryExpression.op_pmarrow:
case IASTBinaryExpression.op_pmdot:
return 11;
}
assert false;
@ -240,14 +240,14 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
}
private IASTUnaryExpression findTrailingBracketedPrimaryExpression(IASTExpression expr) {
while(true) {
while (true) {
if (expr instanceof IASTBinaryExpression) {
expr= ((IASTBinaryExpression) expr).getOperand2();
expr= ((IASTBinaryExpression) expr).getOperand2();
} else if (expr instanceof IASTCastExpression) {
expr= ((IASTCastExpression)expr).getOperand();
expr= ((IASTCastExpression) expr).getOperand();
} else if (expr instanceof IASTUnaryExpression) {
IASTUnaryExpression u= (IASTUnaryExpression) expr;
if (u.getOperator() == IASTUnaryExpression.op_bracketedPrimary)
if (u.getOperator() == IASTUnaryExpression.op_bracketedPrimary)
return u;
expr= u.getOperand();
} else {
@ -255,10 +255,10 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod
}
}
}
private IASTExpression findLeadingCastExpression(IASTExpression expr) {
while (expr instanceof IASTBinaryExpression) {
expr= ((IASTBinaryExpression) expr).getOperand1();
expr= ((IASTBinaryExpression) expr).getOperand1();
}
return expr;
}

View file

@ -31,7 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbiguousNode implements IASTAmbiguousExpression {
private final IASTCastExpression fCastExpression;
private final IASTFunctionCallExpression fFunctionCallExpression;
/**
* The operand of the cast expression must start with an expression in parenthesis (which could be read as the parameter
* list of the function call).
@ -42,7 +42,7 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
fCastExpression= castExpression;
fFunctionCallExpression= functionCall;
}
@Override
public final IASTNode[] getNodes() {
return getExpressions();
@ -52,7 +52,7 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
public final IASTExpression copy() {
throw new UnsupportedOperationException();
}
@Override
public final IASTExpression copy(CopyStyle style) {
throw new UnsupportedOperationException();
@ -62,7 +62,7 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
public void addExpression(IASTExpression e) {
throw new UnsupportedOperationException();
}
@Override
public IASTExpression[] getExpressions() {
return new IASTExpression[] {fCastExpression, fFunctionCallExpression};
@ -84,13 +84,13 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
if (primaryWithParenthesis == null)
return nodeToReplace;
// find nested names
final NameCollector nameCollector= new NameCollector();
fCastExpression.getTypeId().accept(nameCollector);
final IASTName[] names= nameCollector.getNames();
// resolve names
// resolve names
boolean hasIssue= false;
for (IASTName name : names) {
try {
@ -104,7 +104,7 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
break;
}
}
if (!hasIssue)
if (!hasIssue)
return nodeToReplace;
final IASTExpression operand = primaryWithParenthesis.getOperand();
@ -117,7 +117,7 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
fFunctionCallExpression.setArguments(IASTExpression.EMPTY_EXPRESSION_ARRAY);
}
setRange(fFunctionCallExpression, fCastExpression, primaryWithParenthesis);
IASTExpression result= fFunctionCallExpression;
IASTExpression postFix= fCastExpression.getOperand();
if (postFix != primaryWithParenthesis) {
@ -155,7 +155,7 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
}
}
}
owner.replace(nodeToReplace, result);
// Resolve ambiguities in the function-call expression
fFunctionCallExpression.getFunctionNameExpression().accept(visitor);

View file

@ -54,23 +54,23 @@ public abstract class ASTAmbiguousNode extends ASTNode {
return names;
}
}
private IASTNode fResolution;
/**
* Return the alternative nodes for this ambiguity.
*/
public abstract IASTNode[] getNodes();
@Override
public final boolean accept(ASTVisitor visitor) {
if (visitor.shouldVisitAmbiguousNodes && visitor.visit(this) == ASTVisitor.PROCESS_ABORT)
return false;
// Alternatives are not visited on purpose.
return true;
}
protected void beforeResolution() {
}
@ -83,7 +83,7 @@ public abstract class ASTAmbiguousNode extends ASTNode {
public IASTNode resolveAmbiguity(ASTVisitor resolver) {
return fResolution= doResolveAmbiguity(resolver);
}
protected IASTNode doResolveAmbiguity(ASTVisitor resolver) {
beforeResolution();
final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
@ -91,14 +91,14 @@ public abstract class ASTAmbiguousNode extends ASTNode {
final IASTNode[] alternatives= getNodes();
IASTNode bestAlternative= null;
int minIssues = Integer.MAX_VALUE;
for (IASTNode alternative : alternatives) {
// Setup the ast to use the alternative
owner.replace(nodeToReplace, alternative);
beforeAlternative(alternative);
// Handle nested ambiguities
alternative= resolveNestedAmbiguities(alternative, resolver);
nodeToReplace= alternative;
@ -107,13 +107,13 @@ public abstract class ASTAmbiguousNode extends ASTNode {
final NameCollector nameCollector= new NameCollector();
alternative.accept(nameCollector);
final IASTName[] names= nameCollector.getNames();
// Resolve names and count issues
int issues= 0;
for (IASTName name : names) {
try {
// Avoid resolution of parameters (can always be resolved),
// it can triggers resolution of declaration it belongs to,
// Avoid resolution of parameters (can always be resolved),
// it can triggers resolution of declaration it belongs to,
// while the declarator is still ambiguous. Could be solved by introducing an
// intermediate binding for parameters, similar to template parameters.
if (name.getPropertyInParent() == IASTDeclarator.DECLARATOR_NAME) {
@ -127,7 +127,7 @@ public abstract class ASTAmbiguousNode extends ASTNode {
IBinding b= name.resolvePreBinding();
if (b instanceof IProblemBinding) {
issues++;
}
}
} catch (Exception t) {
issues++;
}
@ -143,7 +143,7 @@ public abstract class ASTAmbiguousNode extends ASTNode {
}
}
}
// Switch back to the best alternative, if necessary.
if (nodeToReplace != bestAlternative) {
owner.replace(nodeToReplace, bestAlternative);
@ -151,7 +151,7 @@ public abstract class ASTAmbiguousNode extends ASTNode {
afterResolution(resolver, bestAlternative);
return bestAlternative;
}
protected IASTNode resolveNestedAmbiguities(IASTNode alternative, ASTVisitor resolver) {
alternative.accept(resolver);
if (alternative instanceof ASTAmbiguousNode)
@ -178,7 +178,7 @@ public abstract class ASTAmbiguousNode extends ASTNode {
logAmbiguousNodeError();
return EvalFixed.INCOMPLETE;
}
public final ICPPExecution getExecution() {
logAmbiguousNodeError();
return null;

View file

@ -33,7 +33,7 @@ public abstract class ASTAttributeOwner extends ASTNode implements IASTAttribute
IASTAttribute[] attributes = IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
for (IASTAttributeSpecifier attributeSpecifier : getAttributeSpecifiers()) {
if (attributeSpecifier instanceof IASTAttributeList) {
attributes = ArrayUtil.addAll(attributes,
attributes = ArrayUtil.addAll(attributes,
((IASTAttributeList) attributeSpecifier).getAttributes());
}
}
@ -101,10 +101,10 @@ public abstract class ASTAttributeOwner extends ASTNode implements IASTAttribute
}
return true;
}
/*
* Having this here allows CPPASTAttributeOwner to implement IASTAmbiguityParent
* without needing to access the field attributeSpecifiers.
* without needing to access the field attributeSpecifiers.
*/
protected void replace(IASTNode child, IASTNode other) {
if (child instanceof IASTAlignmentSpecifier && other instanceof IASTAlignmentSpecifier) {

View file

@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences 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:
* Institute for Software (IFS)- initial API and implementation
* 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:
* Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;

View file

@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -104,7 +104,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
public int getRoleForName(IASTName n) {
if (n == name)
return r_definition;
return r_reference;
}
@ -125,7 +125,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
if (enumeration.startValueComputation()) { // Prevent infinite recursion.
computeEnumValues(enumeration);
}
}
}
if (integralValue == null) {
integralValue= IntegralValue.UNKNOWN;
}

View file

@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
public abstract class ASTEqualsInitializer extends ASTNode
implements IASTEqualsInitializer, IASTAmbiguityParent {
private IASTInitializerClause fArgument;
public ASTEqualsInitializer() {
}
@ -55,10 +55,10 @@ public abstract class ASTEqualsInitializer extends ASTNode
default: break;
}
}
if (fArgument != null && !fArgument.accept(action))
return false;
if (action.shouldVisitInitializers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
return false;
@ -78,7 +78,7 @@ public abstract class ASTEqualsInitializer extends ASTNode
public IASTExpression getExpression() {
if (fArgument instanceof IASTExpression)
return (IASTExpression) fArgument;
return null;
}

View file

@ -83,13 +83,13 @@ public class ASTInternal {
public static void addBinding(IScope scope, IBinding binding) {
if (scope instanceof IASTInternalScope) {
((IASTInternalScope) scope).addBinding(binding);
}
}
}
public static void addName(IScope scope, IASTName name) {
if (scope instanceof IASTInternalScope) {
((IASTInternalScope) scope).addName(name);
}
}
}
public static boolean isStatic(IFunction func, boolean resolveAll) {
@ -113,7 +113,7 @@ public class ASTInternal {
IASTNode result = getDeclaredInSourceFileOnly(binding, requireDefinition);
if (result == null)
return null;
if (requireDefinition && glob != null) {
try {
if (glob.hasDeclaration())
@ -121,7 +121,7 @@ public class ASTInternal {
} catch (CoreException e) {
}
}
IASTTranslationUnit tu= result.getTranslationUnit();
if (tu != null) {
if (tu.getIndexFileSet().containsNonLocalDeclaration(binding, forFragment))
@ -193,11 +193,11 @@ public class ASTInternal {
private static IASTNode resolveConflict(IASTNode n1, IASTNode n2) {
if (n1 == null)
return n2;
IASTFileLocation loc1= n1.getFileLocation();
if (loc1 == null)
return n2;
IASTFileLocation loc2= n2.getFileLocation();
if (loc2 != null && loc1.getContextInclusionStatement() != loc2.getContextInclusionStatement())
return null;

View file

@ -405,7 +405,7 @@ public abstract class ASTNode implements IASTNode {
/**
* Helper method for use in {{@link #accept(ASTVisitor)} methods.
*
*
* @param action the visitor to accept
* @param nodes the array of nodes accepting the visitor
* @return continue on ({@code true}) or quit ({@code false})

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
@ -30,7 +30,7 @@ public class ASTNodeSearch extends ASTGenericVisitor {
fNode= node;
fParent= node.getParent();
}
public IASTNode findLeftSibling() {
if (fParent == null)
return null;
@ -55,8 +55,8 @@ public class ASTNodeSearch extends ASTGenericVisitor {
protected int genericVisit(IASTNode node) {
if (node == fParent)
return PROCESS_CONTINUE;
switch(fMode) {
switch (fMode) {
case LEFT:
if (node == fNode)
return PROCESS_ABORT;

View file

@ -174,7 +174,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
}
final int endOffset= offset + length;
switch(fRelation) {
switch (fRelation) {
case EXACT_MATCH:
return isParent(fBestNode, cand);
case FIRST_CONTAINED:
@ -202,7 +202,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
}
private boolean isParent(IASTNode cand1, IASTNode cand2) {
while(cand2 != null) {
while (cand2 != null) {
if (cand2 == cand1) {
return true;
}

View file

@ -20,16 +20,16 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
public class ASTPreprocessorSelectionResult {
IASTNode selectedNode = null;
int globalOffset = 0;
public ASTPreprocessorSelectionResult(IASTNode node, int offset) {
this.selectedNode = node;
this.globalOffset = offset;
}
public IASTNode getSelectedNode() {
return selectedNode;
}
public void setSelectedNode(IASTNode selectedNode) {
this.selectedNode = selectedNode;
}
@ -37,10 +37,10 @@ public class ASTPreprocessorSelectionResult {
public int getGlobalOffset() {
return globalOffset;
}
public void setGlobalOffset(int globalOffset) {
this.globalOffset = globalOffset;
}
}

View file

@ -55,9 +55,9 @@ public class ASTProblem extends ASTNode implements IASTProblem {
errorMessages.put(Integer.valueOf(PREPROCESSOR_MACRO_PASTING_ERROR),
ParserMessages.getString("ScannerProblemFactory.error.preproc.macroPasting")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(PREPROCESSOR_MISSING_RPAREN_PARMLIST),
ParserMessages.getString("ScannerProblemFactory.error.preproc.missingRParen")); //$NON-NLS-1$
ParserMessages.getString("ScannerProblemFactory.error.preproc.missingRParen")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(PREPROCESSOR_INVALID_VA_ARGS),
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidVaArgs")); //$NON-NLS-1$
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidVaArgs")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(SCANNER_INVALID_ESCAPECHAR),
ParserMessages.getString("ScannerProblemFactory.error.scanner.invalidEscapeChar")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(SCANNER_UNBOUNDED_STRING),
@ -73,7 +73,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
errorMessages.put(Integer.valueOf(SCANNER_BAD_DECIMAL_FORMAT),
ParserMessages.getString("ScannerProblemFactory.error.scanner.badDecimalFormat")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(SCANNER_ASSIGNMENT_NOT_ALLOWED),
ParserMessages.getString("ScannerProblemFactory.error.scanner.assignmentNotAllowed")); //$NON-NLS-1$
ParserMessages.getString("ScannerProblemFactory.error.scanner.assignmentNotAllowed")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(SCANNER_DIVIDE_BY_ZERO),
ParserMessages.getString("ScannerProblemFactory.error.scanner.divideByZero")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(SCANNER_MISSING_R_PAREN),
@ -83,7 +83,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
errorMessages.put(Integer.valueOf(SCANNER_ILLEGAL_IDENTIFIER),
ParserMessages.getString("ScannerProblemFactory.error.scanner.illegalIdentifier")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(SCANNER_BAD_CONDITIONAL_EXPRESSION),
ParserMessages.getString("ScannerProblemFactory.error.scanner.badConditionalExpression")); //$NON-NLS-1$
ParserMessages.getString("ScannerProblemFactory.error.scanner.badConditionalExpression")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(SCANNER_UNEXPECTED_EOF),
ParserMessages.getString("ScannerProblemFactory.error.scanner.unexpectedEOF")); //$NON-NLS-1$
errorMessages.put(Integer.valueOf(SCANNER_BAD_CHARACTER),
@ -126,7 +126,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
public ASTProblem copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public ASTProblem copy(CopyStyle style) {
ASTProblem copy = new ASTProblem(id, arg == null ? null : arg.clone(), isError);
@ -142,7 +142,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
public boolean isError() {
return isError;
}
@Override
public boolean isWarning() {
return !isError;
@ -168,7 +168,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
}
return msg;
}
@Override
public String getMessage() {
return getMessage(id, arg == null ? null : new String(arg));

View file

@ -78,10 +78,10 @@ public class ASTTokenList extends ASTNode implements IASTTokenList {
break;
if (!token.accept(action)) return false;
}
if (action.shouldVisitTokens && action.leave(this) == ASTVisitor.PROCESS_ABORT)
return false;
return true;
}
}

View file

@ -9,7 +9,7 @@
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import java.util.Arrays;
@ -89,7 +89,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
public final IASTTranslationUnit getTranslationUnit() {
return this;
}
@Override
public final void addDeclaration(IASTDeclaration d) {
if (d != null) {
@ -133,7 +133,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
}
}
}
@Override
public final IName[] getDeclarations(IBinding binding) {
IName[] names= getDeclarationsInAST(binding);
@ -148,11 +148,11 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
return names;
}
protected final IASTName[] getMacroDefinitionsInAST(IMacroBinding binding) {
if (fLocationResolver == null)
return IASTName.EMPTY_NAME_ARRAY;
IASTName[] declarations = fLocationResolver.getDeclarations(binding);
int j = 0;
for (int i = 0; i < declarations.length; i++) {
@ -185,21 +185,21 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
}
return names;
}
@Override
public final IASTPreprocessorMacroDefinition[] getMacroDefinitions() {
if (fLocationResolver == null)
return EMPTY_PREPROCESSOR_MACRODEF_ARRAY;
return fLocationResolver.getMacroDefinitions();
}
@Override
public IASTPreprocessorMacroExpansion[] getMacroExpansions() {
if (fLocationResolver == null)
return IASTPreprocessorMacroExpansion.EMPTY_ARRAY;
return fLocationResolver.getMacroExpansions(getFileLocation());
}
@Override
public final IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
if (fLocationResolver == null)
@ -264,7 +264,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
for (IASTDeclaration decl : decls) {
if (!decl.accept(action)) return false;
}
if (action.shouldVisitTranslationUnit && action.leave(this) == ASTVisitor.PROCESS_ABORT)
return false;
@ -296,7 +296,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
public final IIndex getIndex() {
return fIndex;
}
@Override
public final void setIndex(IIndex index) {
this.fIndex = index;
@ -310,11 +310,11 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
public final INodeFactory getASTNodeFactory() {
return fNodeFactory;
}
public final void setASTNodeFactory(INodeFactory nodeFactory) {
this.fNodeFactory = nodeFactory;
}
@Override
public final IASTComment[] getComments() {
if (fLocationResolver != null) {
@ -347,7 +347,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
public final void setIsHeaderUnit(boolean headerUnit) {
fIsHeader= headerUnit;
}
public boolean isForContentAssist() {
return fForContentAssist;
}
@ -374,13 +374,13 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
fIndexFileSet.add(indexFile);
}
}
}
}
@Override
public final IIndexFileSet getIndexFileSet() {
return fIndexFileSet;
}
@Override
public void parsingFile(InternalFileContentProvider provider, InternalFileContent fc) {
if (fASTFileSet != null) {
@ -396,8 +396,8 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
}
}
}
}
}
@Override
public final IIndexFileSet getASTFileSet() {
return fASTFileSet;
@ -407,7 +407,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
public final IASTNode selectNodeForLocation(String path, int realOffset, int realLength) {
return getNodeSelector(path).findNode(realOffset, realLength);
}
@Override
public final IASTNodeSelector getNodeSelector(String filePath) {
return new ASTNodeSelector(this, fLocationResolver, filePath);
@ -441,14 +441,14 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
target.fForContentAssist = fForContentAssist;
target.fOriginatingTranslationUnit = fOriginatingTranslationUnit;
target.fNodesOmitted = fNodesOmitted;
for (IASTDeclaration declaration : getDeclarations()) {
copy.addDeclaration(declaration == null ? null : declaration.copy(style));
}
return super.copy(copy, style);
}
@Override
public final void freeze() {
accept(new ASTGenericVisitor(true) {
@ -480,12 +480,12 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
if (sigMacros != null)
fSignificantMacros= sigMacros;
}
@Override
public boolean hasPragmaOnceSemantics() {
return fPragmaOnceSemantics;
}
@Override
public void setPragmaOnceSemantics(boolean value) {
assertNotFrozen();
@ -493,7 +493,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
}
/**
* Starts exclusive access
* Starts exclusive access
* @throws InterruptedException
*/
public void beginExclusiveAccess() throws InterruptedException {
@ -523,7 +523,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
}
/**
* If ambiguity resolution is in progress, and processing of 'node' has been deferred,
* If ambiguity resolution is in progress, and processing of 'node' has been deferred,
* process it now. Has no effect if ambiguity resolution is not in progress.
*/
public void resolvePendingAmbiguities(IASTNode node) {}

View file

@ -256,7 +256,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
backtrack.initialize(offset, (length < 0) ? 0 : length);
throw backtrack;
}
protected INodeFactory getNodeFactory() {
return nodeFactory;
}
@ -1165,7 +1165,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected abstract IASTExpression unaryExpression(CastExprCtx ctx, ITemplateIdStrategy strat) throws BacktrackException, EndOfFileException;
protected abstract IASTExpression primaryExpression(CastExprCtx ctx, ITemplateIdStrategy strat) throws BacktrackException, EndOfFileException;
protected abstract IASTTypeId typeId(DeclarationOptions option) throws EndOfFileException, BacktrackException;
// Methods for parsing a type-id and an expression with an optional trailing ellipsis.
// The optional trailing ellipsis can only appear in C++ code, and only the C++ parser
// allows it, but being able to invoke this from here allows reusing more productions
@ -1649,7 +1649,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
// try second variant, if possible
if (dtorMark2 == null)
throw e;
backup(dtorMark2);
dtor2= initDeclarator(declspec2, option);
return result.set(declspec2, dtor2, dtorMark2);
@ -1796,9 +1796,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
final int compoundOffset= LA(1).getOffset();
final int endOffset= skipOverCompoundStatement(false).getEndOffset();
IASTCompoundStatement cs = nodeFactory.newCompoundStatement(); //createCompoundStatement();
((ASTNode)cs).setOffsetAndLength(compoundOffset, endOffset - compoundOffset);
((ASTNode) cs).setOffsetAndLength(compoundOffset, endOffset - compoundOffset);
IASTFunctionDefinition funcDefinition = nodeFactory.newFunctionDefinition(declSpec, (IASTFunctionDeclarator)fdtor, cs);
IASTFunctionDefinition funcDefinition = nodeFactory.newFunctionDefinition(declSpec, (IASTFunctionDeclarator) fdtor, cs);
((ASTNode) funcDefinition).setOffsetAndLength(offset, endOffset - offset);
return funcDefinition;
@ -1978,9 +1978,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
*/
protected static boolean isImplicitInt(IASTDeclaration declaration) {
if (declaration instanceof IASTSimpleDeclaration) {
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)declaration).getDeclSpecifier();
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) declaration).getDeclSpecifier();
if (declSpec instanceof IASTSimpleDeclSpecifier &&
((IASTSimpleDeclSpecifier)declSpec).getType() == IASTSimpleDeclSpecifier.t_unspecified) {
((IASTSimpleDeclSpecifier) declSpec).getType() == IASTSimpleDeclSpecifier.t_unspecified) {
return true;
}
}
@ -2466,17 +2466,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
* @param endType the type of the token to stop before
* @return a token sequence, possibly empty but never {@code null}
*/
protected IASTTokenList balancedTokenSeq(int offset, int endType)
protected IASTTokenList balancedTokenSeq(int offset, int endType)
throws EndOfFileException, BacktrackException {
IASTTokenList result = nodeFactory.newTokenList();
IToken t;
while ((t = LA(1)).getType() != endType) {
t = consume();
if (t.getType() == IToken.tCOMPLETION || t.getType() == IToken.tEOC) {
break;
}
result.addToken(createASTToken(t));
IASTToken token;
@ -2716,15 +2716,15 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected abstract IASTAlignmentSpecifier createAmbiguousAlignmentSpecifier(IASTAlignmentSpecifier expression,
IASTAlignmentSpecifier typeId);
protected IASTAlignmentSpecifier alignmentSpecifier() throws BacktrackException, EndOfFileException {
int startOffset = consume(IToken.t_alignas, IToken.t__Alignas).getOffset();
consume(IToken.tLPAREN);
IASTTypeId typeId = null;
IASTExpression expression = null;
// Try parsing a type-id.
IToken beginning = mark();
IToken typeIdEnd = null;
@ -2733,7 +2733,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
typeIdEnd = mark();
} catch (BacktrackException e) {
}
// Back up and try parsing an expression.
backup(beginning);
try {
@ -2744,7 +2744,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
throw e;
}
}
IASTAlignmentSpecifier result;
if (typeId == null) {
// No type id - use the expression.
@ -2771,7 +2771,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
backup(typeIdEnd);
result = nodeFactory.newAlignmentSpecifier(typeId);
}
int endOffset = consume(IToken.tRPAREN).getEndOffset();
setRange(result, startOffset, endOffset);

View file

@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Nathan Ridge
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
@ -28,26 +28,26 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
*/
public abstract class ArithmeticConversion {
private static final int DOMAIN_FLAGS = IBasicType.IS_IMAGINARY | IBasicType.IS_COMPLEX;
private enum Domain {
eReal(0),
eImaginary(IBasicType.IS_IMAGINARY),
eReal(0),
eImaginary(IBasicType.IS_IMAGINARY),
eComplex(IBasicType.IS_COMPLEX);
private final int fModifier;
private Domain(int modifier) {
fModifier= modifier;
}
int getModifier() {
return fModifier;
}
}
private enum Rank {eInt, eLong, eLongLong}
protected abstract IBasicType createBasicType(IBasicType.Kind kind, int modifiers);
/**
* Performs an arithmetic conversion as described in section 6.3.1.8 of the C99 standard,
* or 5.0.9 of C++ standard
@ -78,19 +78,19 @@ public abstract class ArithmeticConversion {
case IASTBinaryExpression.op_shiftLeft:
case IASTBinaryExpression.op_shiftRight:
return promote(op1, getDomain(op1));
default:
return null;
}
}
public final IType promoteType(IType type) {
if (!isIntegralOrUnscopedEnum(type))
return null;
return promote(type, getDomain(type));
}
private boolean isArithmeticOrUnscopedEnum(IType op1) {
if (op1 instanceof IBasicType) {
final Kind kind = ((IBasicType) op1).getKind();
@ -114,10 +114,10 @@ public abstract class ArithmeticConversion {
private boolean isIntegralOrUnscopedEnum(IType op1) {
if (op1 instanceof IEnumeration)
return true;
if (op1 instanceof IBasicType) {
Kind kind= ((IBasicType) op1).getKind();
switch(kind) {
switch (kind) {
case eBoolean:
case eChar:
case eChar16:
@ -126,7 +126,7 @@ public abstract class ArithmeticConversion {
case eInt128:
case eWChar:
return true;
case eDouble:
case eFloat:
case eFloat128:
@ -144,7 +144,7 @@ public abstract class ArithmeticConversion {
private final IType convert(IType type1, IType type2) {
Domain domain= getDomain(type1, type2);
// If either type is a long double, return that type
if (isLongDouble(type1)) {
return adjustDomain((IBasicType) type1, domain);
@ -152,7 +152,7 @@ public abstract class ArithmeticConversion {
if (isLongDouble(type2)) {
return adjustDomain((IBasicType) type2, domain);
}
// Else if either type is a double return that type
if (isDouble(type1)) {
return adjustDomain((IBasicType) type1, domain);
@ -160,7 +160,7 @@ public abstract class ArithmeticConversion {
if (isDouble(type2)) {
return adjustDomain((IBasicType) type2, domain);
}
// Else if either type is a float return that type
if (isFloat(type1)) {
return adjustDomain((IBasicType) type1, domain);
@ -168,19 +168,19 @@ public abstract class ArithmeticConversion {
if (isFloat(type2)) {
return adjustDomain((IBasicType) type2, domain);
}
// We're dealing with integer types so perform integer promotion
IBasicType btype1 = promote(type1, domain);
IBasicType btype2 = promote(type2, domain);
if (btype1.isSameType(btype2)) {
return btype1;
}
if (btype1.isUnsigned() == btype2.isUnsigned()) {
return getIntegerRank(btype1).ordinal() >= getIntegerRank(btype2).ordinal() ? btype1 : btype2;
}
}
IBasicType unsignedType, signedType;
if (btype1.isUnsigned()) {
unsignedType= btype1;
@ -192,32 +192,32 @@ public abstract class ArithmeticConversion {
final Rank signedRank= getIntegerRank(signedType);
final Rank unsignedRank= getIntegerRank(unsignedType);
// same rank -> use unsigned
if (unsignedRank.ordinal() >= signedRank.ordinal()) {
return unsignedType;
}
// The signed has the higher rank.
if (signedRank.ordinal() > unsignedRank.ordinal()) {
return signedType;
}
return createBasicType(signedType.getKind(),
changeModifier(signedType.getModifiers(), IBasicType.IS_SIGNED, IBasicType.IS_UNSIGNED));
}
private IBasicType promote(IType type, Domain domain) {
if (type instanceof IEnumeration) {
IType fixedType= null;
if (type instanceof ICPPEnumeration) {
fixedType= ((ICPPEnumeration) type).getFixedType();
}
if (fixedType == null)
if (fixedType == null)
return createBasicType(Kind.eInt, domain.getModifier() | getEnumIntTypeModifiers((IEnumeration) type));
type= fixedType;
}
}
if (type instanceof IBasicType) {
final IBasicType bt = (IBasicType) type;
final Kind kind = bt.getKind();
@ -251,7 +251,7 @@ public abstract class ArithmeticConversion {
case eNullPtr:
assert false;
}
}
}
return createBasicType(Kind.eInt, domain.getModifier());
}
@ -278,10 +278,10 @@ public abstract class ArithmeticConversion {
Domain myDomain= getDomain(t);
if (myDomain == d)
return t;
return createBasicType(t.getKind(), changeModifier(t.getModifiers(), DOMAIN_FLAGS, d.getModifier()));
}
private int changeModifier(int modifiers, int remove, int add) {
return (modifiers & ~remove) | add;
}
@ -321,7 +321,7 @@ public abstract class ArithmeticConversion {
}
return false;
}
public static int getEnumIntTypeModifiers(IEnumeration enumeration) {
final long minValue = enumeration.getMinValue();
final long maxValue = enumeration.getMaxValue();
@ -333,7 +333,7 @@ public abstract class ArithmeticConversion {
} else if (minValue >= Long.MIN_VALUE && maxValue <= Long.MAX_VALUE) {
return IBasicType.IS_LONG;
} else {
// This branch is unreachable due to limitations of Java long type.
// This branch is unreachable due to limitations of Java long type.
return IBasicType.IS_UNSIGNED | IBasicType.IS_LONG;
}
}
@ -354,7 +354,7 @@ public abstract class ArithmeticConversion {
}
if (n < 0)
return false;
if (basicTarget.isShort()) {
return n < (Short.MAX_VALUE + 1L) * 2;
}
@ -380,30 +380,30 @@ public abstract class ArithmeticConversion {
case eFloat:
float f= n;
return (long) f == n;
case eDouble:
double d= n;
return (long) d == n;
default:
return false;
}
}
/**
* Makes a best-effort guess at the sizeof() of an integral type.
* Makes a best-effort guess at the sizeof() of an integral type.
*/
private static long getApproximateSize(IBasicType type) {
switch (type.getKind()) {
case eChar: return 1;
case eWChar: return 2;
case eInt:
// Note: we return 6 for long so that both long -> int
// and long long -> long conversions are reported
case eInt:
// Note: we return 6 for long so that both long -> int
// and long long -> long conversions are reported
// as narrowing, to be on the safe side.
return type.isShort() ? 2
return type.isShort() ? 2
: type.isLong() ? 6
: type.isLongLong() ? 8
: type.isLongLong() ? 8
: 4;
case eBoolean: return 1;
case eChar16: return 2;
@ -434,7 +434,7 @@ public abstract class ArithmeticConversion {
return false;
// Otherwise, go by the size and signedness of the type.
SizeAndAlignment sourceSizeAndAlignment = SizeofCalculator.getSizeAndAlignment(source, point);
SizeAndAlignment sourceSizeAndAlignment = SizeofCalculator.getSizeAndAlignment(source, point);
SizeAndAlignment targetSizeAndAlignment = SizeofCalculator.getSizeAndAlignment(target, point);
long sizeofSource = sourceSizeAndAlignment == null ? getApproximateSize(source) : sourceSizeAndAlignment.size;
long sizeofTarget = targetSizeAndAlignment == null ? getApproximateSize(target) : targetSizeAndAlignment.size;

View file

@ -23,11 +23,11 @@ public class BacktrackException extends Exception {
private IASTProblem problem;
private IASTNode nodeBeforeProblem; // a node has been created in spite of the problem.
private int offset, length;
public BacktrackException() {
private int offset, length;
public BacktrackException() {
}
public BacktrackException(BacktrackException e) {
problem= e.problem;
nodeBeforeProblem= e.nodeBeforeProblem;
@ -47,7 +47,7 @@ public class BacktrackException extends Exception {
}
/**
*
*
*/
private void reset() {
nodeBeforeProblem= null;
@ -61,12 +61,12 @@ public class BacktrackException extends Exception {
public final IASTProblem getProblem() {
return problem;
}
public final IASTNode getNodeBeforeProblem() {
return nodeBeforeProblem;
}
public void initialize(int start, int l ) {
public void initialize(int start, int l) {
reset();
offset = start;
length = l;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -39,65 +39,65 @@ public class CStringValue implements IValue {
map.put('v', '\013');
escapeSequences = Collections.unmodifiableMap(map);
}
private final char[] fFixedValue;
private String fParsedValue;
private CStringValue(char[] fixedValue) {
fFixedValue = fixedValue;
}
public static IValue create(char[] fixedValue) {
return new CStringValue(fixedValue);
}
public String cStringValue() {
if (fParsedValue == null) {
fParsedValue = parseString();
}
return fParsedValue;
}
private int indexOfStartQuote() {
final int len = fFixedValue.length;
int i = 0;
while(i < len && fFixedValue[i] != '"') {
while (i < len && fFixedValue[i] != '"') {
++i;
}
if(i >= len) {
if (i >= len) {
return -1;
} else {
return i;
}
}
private int indexOfEndQuote() {
int i = fFixedValue.length - 1;
while(i >= 0 && fFixedValue[i] != '"') {
while (i >= 0 && fFixedValue[i] != '"') {
--i;
}
if(i < 0) {
if (i < 0) {
return -1;
} else {
return i;
}
}
private boolean isRawStringLiteral() {
for(int i = 0; i < indexOfStartQuote(); ++i) {
if(fFixedValue[i] == 'R') {
for (int i = 0; i < indexOfStartQuote(); ++i) {
if (fFixedValue[i] == 'R') {
return true;
}
}
return false;
}
private int getDelimiterLength() {
if(isRawStringLiteral()) {
if (isRawStringLiteral()) {
int i = indexOfStartQuote();
int len = 0;
while(i < fFixedValue.length && fFixedValue[i] != '(') {
while (i < fFixedValue.length && fFixedValue[i] != '(') {
++i;
++len;
}
@ -105,29 +105,29 @@ public class CStringValue implements IValue {
}
return 0;
}
private int getStart() {
return indexOfStartQuote() + getDelimiterLength() + 1;
}
private int getEnd() {
return indexOfEndQuote() - getDelimiterLength() - 1;
}
private String parseString() {
// TODO: Reuse code between this and CPPASTLiteralExpression.computeStringLiteralSize().
boolean isRaw = isRawStringLiteral();
int end = getEnd();
StringBuilder builder = new StringBuilder();
for(int i = getStart(); i <= end; ++i) {
if(!isRaw && fFixedValue[i] == '\\' && i < end) {
for (int i = getStart(); i <= end; ++i) {
if (!isRaw && fFixedValue[i] == '\\' && i < end) {
++i;
//C-Strings are null-terminated. Therefore, a '\0' character
//denotes the end of the string, even if the literal contains
//more characters after that
if(fFixedValue[i] == '0') {
if (fFixedValue[i] == '0') {
break;
} else {
i = parseEscapeSequence(i, builder);
@ -138,16 +138,16 @@ public class CStringValue implements IValue {
}
return builder.toString();
}
private int parseEscapeSequence(int i, StringBuilder builder) {
char c = fFixedValue[i];
Character escapeSequence = escapeSequences.get(c);
if(escapeSequence != null) {
if (escapeSequence != null) {
builder.append(escapeSequence);
} else if(c == 'u' && i + 4 <= getEnd()) {
} else if (c == 'u' && i + 4 <= getEnd()) {
StringBuilder hexStr = new StringBuilder();
++i;
for(int end = i + 4; i < end; ++i) {
for (int end = i + 4; i < end; ++i) {
hexStr.append(fFixedValue[i]);
}
int codePoint = Integer.parseInt(hexStr.toString(), 16);
@ -155,12 +155,12 @@ public class CStringValue implements IValue {
}
return i;
}
@Override
public Long numericalValue() {
return null;
}
@Override
public Number numberValue() {
return null;
@ -176,13 +176,13 @@ public class CStringValue implements IValue {
public ICPPEvaluation getSubValue(int index) {
String str = cStringValue();
Character c = null;
if(index >= 0 && index < str.length()) {
if (index >= 0 && index < str.length()) {
c = str.charAt(index);
} else if(index == str.length()) {
} else if (index == str.length()) {
c = '\0';
}
if(c != null) {
if (c != null) {
IValue val = IntegralValue.create(c);
return new EvalFixed(CPPBasicType.CHAR, ValueCategory.PRVALUE, val);
}
@ -203,12 +203,12 @@ public class CStringValue implements IValue {
public char[] getSignature() {
return fFixedValue;
}
@Override
public int hashCode() {
return CharArrayUtils.hash(getSignature());
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof CStringValue)) {
@ -247,7 +247,7 @@ public class CStringValue implements IValue {
buf.putShort(ITypeMarshalBuffer.C_STRING_VALUE);
buf.putCharArray(fFixedValue);
}
public static IValue unmarshal(short firstBytes, ITypeMarshalBuffer buf) throws CoreException {
return new CStringValue(buf.getCharArray());
}

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import java.util.ArrayList;
@ -32,10 +32,10 @@ class ChildCollector extends ASTGenericVisitor {
fNode.accept(this);
if (fNodes == null)
return IASTNode.EMPTY_NODE_ARRAY;
return fNodes.toArray(new IASTNode[fNodes.size()]);
}
@Override
protected int genericVisit(IASTNode child) {
if (fNodes == null) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -48,7 +48,7 @@ public class CompositeValue implements IValue {
public Number numberValue() {
return null;
}
@Override
public ICPPEvaluation getEvaluation() {
return evaluation;
@ -56,7 +56,7 @@ public class CompositeValue implements IValue {
@Override
public char[] getSignature() {
if(evaluation != null) {
if (evaluation != null) {
return evaluation.getSignature();
}
return new char[]{};
@ -152,15 +152,15 @@ public class CompositeValue implements IValue {
}
// The set of class types for which composite value creation is in progress on each thread.
// Used to guard against infinite recursion due to a class (invalidly) aggregating itself.
private static final ThreadLocal<Set<ICPPClassType>> fCreateInProgress =
// Used to guard against infinite recursion due to a class (invalidly) aggregating itself.
private static final ThreadLocal<Set<ICPPClassType>> fCreateInProgress =
new ThreadLocal<Set<ICPPClassType>>() {
@Override
protected Set<ICPPClassType> initialValue() {
return new HashSet<>();
}
};
/**
* Creates a value representing an instance of a class type, with the values of the fields
* determined by the default member initializers only. Constructors are not considered
@ -174,16 +174,16 @@ public class CompositeValue implements IValue {
try {
ActivationRecord record = new ActivationRecord();
ICPPEvaluation[] values = new ICPPEvaluation[ClassTypeHelper.getFields(classType, null).length];
// recursively create all the base class member variables
ICPPBase[] bases = ClassTypeHelper.getBases(classType, null);
for(ICPPBase base : bases) {
for (ICPPBase base : bases) {
IBinding baseClass = base.getBaseClass();
if(baseClass instanceof ICPPClassType) {
if (baseClass instanceof ICPPClassType) {
ICPPClassType baseClassType = (ICPPClassType) baseClass;
ICPPField[] baseFields = ClassTypeHelper.getDeclaredFields(baseClassType, null);
IValue compValue = CompositeValue.create(baseClassType);
for(ICPPField baseField : baseFields) {
for (ICPPField baseField : baseFields) {
int fieldPos = CPPASTFieldReference.getFieldPosition(baseField);
record.update(baseField, compValue.getSubValue(fieldPos));
// TODO(nathanridge): This won't work with multiple inheritance, since 'fieldPos'
@ -193,12 +193,12 @@ public class CompositeValue implements IValue {
}
}
}
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, null);
for (ICPPField field : fields) {
final ICPPEvaluation value = EvalUtil.getVariableValue(field, record);
int fieldPos = CPPASTFieldReference.getFieldPosition(field);
record.update(field, value);
record.update(field, value);
values[fieldPos] = value;
}
return new CompositeValue(null, values);
@ -221,24 +221,24 @@ public class CompositeValue implements IValue {
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("["); //$NON-NLS-1$
for(int i = 0; i < values.length; i++) {
if(values[i] != null) {
for (int i = 0; i < values.length; i++) {
if (values[i] != null) {
builder.append(values[i].toString());
} else {
builder.append("<null>"); //$NON-NLS-1$
}
if(i != values.length-1) {
if (i != values.length-1) {
builder.append(", "); //$NON-NLS-1$
}
}
builder.append("]"); //$NON-NLS-1$
return builder.toString();
}
@Override
public IValue clone() {
ICPPEvaluation[] newValues = new ICPPEvaluation[values.length];
for(int i = 0; i < newValues.length; i++) {
for (int i = 0; i < newValues.length; i++) {
ICPPEvaluation eval = values[i];
IValue newValue = eval.getValue(null).clone();
newValues[i] = new EvalFixed(eval.getType(null), eval.getValueCategory(null), newValue);
@ -251,17 +251,17 @@ public class CompositeValue implements IValue {
buf.putShort(ITypeMarshalBuffer.COMPOSITE_VALUE);
buf.marshalEvaluation(evaluation, true);
buf.putInt(values.length);
for(ICPPEvaluation value : values) {
for (ICPPEvaluation value : values) {
buf.marshalEvaluation(value, true);
}
}
public static IValue unmarshal(short firstBytes, ITypeMarshalBuffer buf) throws CoreException {
ICPPEvaluation evaluation = (ICPPEvaluation)buf.unmarshalEvaluation();
ICPPEvaluation evaluation = (ICPPEvaluation) buf.unmarshalEvaluation();
int len = buf.getInt();
ICPPEvaluation values[] = new ICPPEvaluation[len];
for(int i = 0; i < len; i++) {
values[i] = (ICPPEvaluation)buf.unmarshalEvaluation();
for (int i = 0; i < len; i++) {
values[i] = (ICPPEvaluation) buf.unmarshalEvaluation();
}
return new CompositeValue(evaluation, values);
}

View file

@ -7,10 +7,10 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
/**
/**
* Configures the parsing of a declaration in various contexts.
*/
public class DeclarationOptions {
@ -31,7 +31,7 @@ public class DeclarationOptions {
final public static int SINGLE_DTOR= 0x4000;
final public static int ALLOW_FUNCTION_DEFINITION= 0x8000;
public static final DeclarationOptions
public static final DeclarationOptions
GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_OPAQUE_ENUM | ALLOW_FUNCTION_DEFINITION),
FUNCTION_STYLE_ASM= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER | ALLOW_ABSTRACT | ALLOW_FUNCTION_DEFINITION),
C_MEMBER= new DeclarationOptions(ALLOW_BITFIELD | ALLOW_ABSTRACT),
@ -62,7 +62,7 @@ public class DeclarationOptions {
final public boolean fAllowOpaqueEnum;
final public boolean fSingleDtor;
final public boolean fAllowFunctionDefinition;
public DeclarationOptions(int options) {
fAllowEmptySpecifier= (options & ALLOW_EMPTY_SPECIFIER) != 0;
fRequireAbstract= (options & REQUIRE_ABSTRACT) != 0;

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
@ -32,9 +32,9 @@ public class FindNodeForOffsetAction extends ASTGenericVisitor {
shouldVisitNames = true;
shouldVisitDeclarations= true;
includeInactiveNodes= true;
// only visit implicit names if asked
shouldVisitImplicitNames =
shouldVisitImplicitNames =
shouldVisitImplicitNameAlternates = nodeSpec.requiresClass(IASTImplicitName.class);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -17,77 +17,77 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
import org.eclipse.core.runtime.CoreException;
public class FloatingPointValue implements IValue {
public class FloatingPointValue implements IValue {
private final char[] fFixedValue;
private FloatingPointValue(char[] fixedValue) {
fFixedValue = fixedValue;
}
public static FloatingPointValue create(char[] fixedValue) {
return new FloatingPointValue(fixedValue);
}
public static FloatingPointValue create(double value) {
return new FloatingPointValue(toCharArray(value));
}
@Override
public Long numericalValue() {
return null; // not a Long
}
@Override
public Number numberValue() {
return parseDouble(fFixedValue);
}
private static Double parseDouble(char[] value) {
double result = 0.0;
int i = 0;
int len = value.length;
while(i < len && value[i] >= '0' && value[i] <= '9') {
while (i < len && value[i] >= '0' && value[i] <= '9') {
int digit = value[i] - '0';
result = result * 10 + digit;
++i;
}
if(i < len && value[i] == '.') {
if (i < len && value[i] == '.') {
++i;
}
double div = 10.0;
while(i < len && value[i] >= '0' && value[i] <= '9') {
while (i < len && value[i] >= '0' && value[i] <= '9') {
int digit = value[i] - '0';
result += digit / div;
div *= 10.0;
++i;
}
if(i < len && (value[i] == 'e' || value[i] == 'E')) {
if (i < len && (value[i] == 'e' || value[i] == 'E')) {
++i;
}
boolean exponentIsPositive = true;
if(i < len && (value[i] == '+' || value[i] == '-')) {
if (i < len && (value[i] == '+' || value[i] == '-')) {
exponentIsPositive = (value[i] == '+');
++i;
}
int exponent = 0;
while(i < len && value[i] >= '0' && value[i] <= '9') {
while (i < len && value[i] >= '0' && value[i] <= '9') {
int digit = value[i] - '0';
exponent = exponent * 10 + digit;
++i;
}
if(i < len && (value[i] == 'l' || value[i] == 'L' || value[i] == 'f' || value[i] == 'F')) {
if (i < len && (value[i] == 'l' || value[i] == 'L' || value[i] == 'f' || value[i] == 'F')) {
++i;
}
if(i == len) {
if(!exponentIsPositive) {
if (i == len) {
if (!exponentIsPositive) {
exponent *= -1;
}
return result * Math.pow(10, exponent);
@ -102,7 +102,7 @@ public class FloatingPointValue implements IValue {
@Override
public ICPPEvaluation getSubValue(int index) {
if(index == 0) {
if (index == 0) {
return getEvaluation();
}
return EvalFixed.INCOMPLETE;
@ -122,12 +122,12 @@ public class FloatingPointValue implements IValue {
public char[] getSignature() {
return fFixedValue;
}
@Override
public int hashCode() {
return CharArrayUtils.hash(getSignature());
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof FloatingPointValue)) {
@ -160,7 +160,7 @@ public class FloatingPointValue implements IValue {
buf.append(value);
return CharArrayUtils.extractChars(buf);
}
@Override
public String toString() {
return new String(getSignature());
@ -177,7 +177,7 @@ public class FloatingPointValue implements IValue {
buf.putShort(ITypeMarshalBuffer.FLOATING_POINT_VALUE);
buf.putCharArray(fFixedValue);
}
public static IValue unmarshal(short firstBytes, ITypeMarshalBuffer buf) throws CoreException {
return new FloatingPointValue(buf.getCharArray());
}

View file

@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
*/
public interface IASTAmbiguousDeclarator extends IASTDeclarator {
public static final ASTNodeProperty SUBDECLARATOR = new ASTNodeProperty( "IASTAmbiguousDeclarator.SUBDECLARATOR"); //$NON-NLS-1$
public static final ASTNodeProperty SUBDECLARATOR = new ASTNodeProperty("IASTAmbiguousDeclarator.SUBDECLARATOR"); //$NON-NLS-1$
/**
* Add an alternative to this ambiguous declarator.
*/

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
public interface IASTAmbiguousExpression extends IASTExpression {
public static final ASTNodeProperty SUBEXPRESSION = new ASTNodeProperty( "IASTAmbiguousExpression.SUBEXPRESSION"); //$NON-NLS-1$
public void addExpression( IASTExpression e );
public static final ASTNodeProperty SUBEXPRESSION = new ASTNodeProperty("IASTAmbiguousExpression.SUBEXPRESSION"); //$NON-NLS-1$
public void addExpression(IASTExpression e);
public IASTExpression [] getExpressions();
}

View file

@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
*/
public interface IASTAmbiguousParameterDeclaration extends IASTParameterDeclaration {
public static final ASTNodeProperty SUBDECLARATION = new ASTNodeProperty( "IASTAmbiguousParameterDeclaration.SUBDECLARATION"); //$NON-NLS-1$
public static final ASTNodeProperty SUBDECLARATION = new ASTNodeProperty("IASTAmbiguousParameterDeclaration.SUBDECLARATION"); //$NON-NLS-1$
/**
* Add an alternative to this ambiguous parameter declaration.
*/

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;

View file

@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
@ -32,7 +32,7 @@ public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifi
* Returns {@code true} if the value computation has started but hasn't finished yet.
*/
boolean isValueComputationInProgress();
/**
* @since 5.1
*/

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -18,10 +18,10 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
*/
public interface IASTInternalNameOwner extends IASTNameOwner {
/**
* Get the role for the name. If the name needs to be resolved to determine that and
* Get the role for the name. If the name needs to be resolved to determine that and
* <code>allowResolution</code> is set to <code>false</code>, then {@link IASTNameOwner#r_unclear}
* is returned.
*
* is returned.
*
* @param n a name to determine the role of.
* @param allowResolution whether or not resolving the name is allowed.
* @return r_definition, r_declaration, r_reference or r_unclear.

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTName;
@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
/**
/**
* Interface for methods on scopes that are internal to the AST.
*/
public interface IASTInternalScope extends IScope {
@ -23,7 +23,7 @@ public interface IASTInternalScope extends IScope {
* Returns the physical IASTNode that this scope was created for
*/
public IASTNode getPhysicalNode();
/**
* Adds an IBinding to the scope. It is primarily used by the parser to add
* implicit IBindings to the scope (such as GCC built-in functions).
@ -34,14 +34,14 @@ public interface IASTInternalScope extends IScope {
* Adds an IASTName to be cached in this scope
*/
public void addName(IASTName name);
/**
* Can be called during ambiguity resolution to populate a scope without considering
* the ambiguous branches. The rest of the names has to be cached one by one after
* the ambiguities have been resolved.
*/
public void populateCache();
/**
* Can be called during ambiguity resolution to remove the names within the given
* node from the cache.

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Nathan Ridge - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.core.runtime.CoreException;
@ -18,7 +18,7 @@ import org.eclipse.core.runtime.CoreException;
public interface ISerializableEvaluation {
/**
* Marshals an ICPPEvaluation object for storage in the index.
*
*
* @param buffer The buffer that will hold the marshalled ICPPEvaluation object.
* @param includeValue Specifies whether nested IValue objects should be marshalled as well.
* */

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2016 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -16,7 +16,7 @@ import org.eclipse.core.runtime.CoreException;
public interface ISerializableExecution {
/**
* Marshals an ICPPExecution object for storage in the index.
*
*
* @param buffer The buffer that will hold the marshalled ICPPExecution object.
* @param includeValue Specifies whether nested IValue objects should be marshalled as well.
* */

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.core.runtime.CoreException;

View file

@ -23,7 +23,7 @@ import org.eclipse.core.runtime.CoreException;
* Buffer for marshalling and unmarshalling types.
*/
public interface ITypeMarshalBuffer {
final static byte
final static byte
BASIC_TYPE = 0x01,
POINTER_TYPE = 0x02,
ARRAY_TYPE = 0x03,
@ -42,9 +42,9 @@ public interface ITypeMarshalBuffer {
UNKNOWN_MEMBER_TYPE = 0x10,
INITIALIZER_LIST_TYPE = 0x11,
DEFERRED_FUNCTION = 0x12;
// Can add more types up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE.
final static byte
// Can add more types up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE.
final static byte
INTEGRAL_VALUE = 0x01,
FLOATING_POINT_VALUE = 0x02,
C_STRING_VALUE = 0x03,
@ -73,7 +73,7 @@ public interface ITypeMarshalBuffer {
EVAL_POINTER = 0x13,
EVAL_COMPOSITE_ACCESS = 0x14;
// Can add more evaluations up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE.
final static byte
EXEC_COMPOUND_STATEMENT = 0x01,
EXEC_BREAK = 0x02,
@ -105,7 +105,7 @@ public interface ITypeMarshalBuffer {
final static short FLAG7 = 0x0800;
final static short FLAG8 = 0x1000;
final static short FLAG9 = 0x2000;
final static short FIRST_FLAG = FLAG1;
final static short SECOND_LAST_FLAG = FLAG8;
final static short LAST_FLAG = FLAG9;
@ -122,10 +122,10 @@ public interface ITypeMarshalBuffer {
int getFixedInt() throws CoreException;
/**
* Reads a 16-bit integer stored in the variable length base-128 encoding.
* Reads a 16-bit integer stored in the variable length base-128 encoding.
*/
public short getShort() throws CoreException;
/**
* Reads a 32-bit integer stored in the variable length base-128 encoding.
*/
@ -152,13 +152,13 @@ public interface ITypeMarshalBuffer {
* @param value the value to write
*/
public void putShort(short value);
/**
* Writes a 32-bit integer in the variable length base-128 encoding. Each byte, except the last
* byte, has the most significant bit set this indicates that there are further bytes to come.
* The lower 7 bits of each byte are used to store the two-complement representation of
* the number in groups of 7 bits, least significant group first.
*
*
* <p>Here is number of bytes depending on the encoded value:
* <pre>
* Value Number of bytes
@ -179,7 +179,7 @@ public interface ITypeMarshalBuffer {
* byte, has the most significant bit set this indicates that there are further bytes to come.
* The lower 7 bits of each byte are used to store the two-complement representation of
* the number in groups of 7 bits, least significant group first.
*
*
* <p>Here is number of bytes depending on the encoded value:
* <pre>
* Value Number of bytes

View file

@ -34,10 +34,10 @@ import org.eclipse.core.runtime.CoreException;
*/
public class IntegralValue implements IValue {
public static final int MAX_RECURSION_DEPTH = 25;
// IntegralValue.THIS represents the this pointer inside a member function / constructor.
public static final IntegralValue THIS = new IntegralValue("this".toCharArray(), null); //$NON-NLS-1$
// IntegralValue.UNKNOWN indicates general inability to determine a value. It doesn't have to be an error,
// it could be that evaluation ran into a performance limit, or that we can't model this kind of
// value (such as a pointer to a function).
@ -47,14 +47,14 @@ public class IntegralValue implements IValue {
throw new UnsupportedOperationException();
}
};
// IntegralValue.ERROR indicates that an error, such as a substitution failure, occurred during evaluation.
public static final IntegralValue ERROR= new IntegralValue("<error>".toCharArray(), null); //$NON-NLS-1$
public static final IntegralValue NOT_INITIALIZED= new IntegralValue("<__>".toCharArray(), null); //$NON-NLS-1$
private static final char UNIQUE_CHAR = '_';
private final static IntegralValue[] TYPICAL= {
new IntegralValue(new char[] {'0'}, null),
new IntegralValue(new char[] {'1'}, null),
@ -81,7 +81,7 @@ public class IntegralValue implements IValue {
public Long numericalValue() {
return (Long) numberValue(); // IntegralValue.numberValue() always returns a Long
}
@Override
public Number numberValue() {
return fFixedValue == null ? null : parseLong(fFixedValue);
@ -116,7 +116,7 @@ public class IntegralValue implements IValue {
public void marshal(ITypeMarshalBuffer buf) throws CoreException {
if (UNKNOWN == this) {
buf.putShort((short) (ITypeMarshalBuffer.INTEGRAL_VALUE | ITypeMarshalBuffer.FLAG1));
} else if(THIS == this) {
} else if (THIS == this) {
buf.putShort((short) (ITypeMarshalBuffer.INTEGRAL_VALUE | ITypeMarshalBuffer.FLAG5));
} else {
Number num= numberValue();

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -35,13 +35,13 @@ public abstract class NodeFactory implements INodeFactory {
ASTNode e= (ASTNode) endNode;
a.setLength(e.getOffset() + e.getLength() - a.getOffset());
}
@Deprecated
@Override
public org.eclipse.cdt.core.dom.ast.gnu.IGCCASTAttributeSpecifier newGCCAttributeSpecifier() {
return new GCCASTAttributeList();
}
@Override
public IGCCASTAttributeList newGCCAttributeList() {
return new GCCASTAttributeList();

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.parser.AbstractParserLogService;

View file

@ -328,7 +328,7 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
public IValue getInitialValue() {
return null;
}
public ICPPEvaluation getInitializerEvaluation() {
return EvalFixed.INCOMPLETE;
}

View file

@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IPointerType;
@ -27,13 +27,13 @@ public class ProblemFunctionType extends ProblemType implements ICPPFunctionType
public ProblemFunctionType(int id) {
super(id);
}
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putShort((short) (ITypeMarshalBuffer.PROBLEM_TYPE | ITypeMarshalBuffer.FLAG1));
buffer.putInt(getID());
}
public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
return new ProblemFunctionType(buffer.getInt());
}

View file

@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IProblemType;
@ -24,13 +24,13 @@ public class ProblemType implements IProblemType, ISerializableType {
public static final IType UNKNOWN_FOR_EXPRESSION = new ProblemType(TYPE_UNKNOWN_FOR_EXPRESSION);
public static final IType ENUMERATION_EXPECTED = new ProblemType(TYPE_ENUMERATION_EXPECTED);
public static final IType RECURSION_IN_LOOKUP = new ProblemType(BINDING_RECURSION_IN_LOOKUP);
private final int fID;
public ProblemType(int id) {
fID= id;
}
@Override
public int getID() {
return fID;
@ -60,11 +60,11 @@ public class ProblemType implements IProblemType, ISerializableType {
buffer.putShort(ITypeMarshalBuffer.PROBLEM_TYPE);
buffer.putInt(getID());
}
public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0)
return ProblemFunctionType.unmarshal(firstBytes, buffer);
return new ProblemType(buffer.getInt());
}
}

View file

@ -86,39 +86,39 @@ public class ValueFactory {
}
return IntegralValue.UNKNOWN;
}
public static IValue evaluateUnaryExpression(final int unaryOp, final IValue value) {
IValue val = applyUnaryOperator(unaryOp, value);
if (isInvalidValue(val))
return IntegralValue.UNKNOWN;
return val;
return val;
}
public static IValue evaluateBinaryExpression(final int op, final IValue v1, final IValue v2) {
if(v1 instanceof FloatingPointValue && v2 instanceof FloatingPointValue) {
FloatingPointValue fv1 = (FloatingPointValue)v1;
FloatingPointValue fv2 = (FloatingPointValue)v2;
if (v1 instanceof FloatingPointValue && v2 instanceof FloatingPointValue) {
FloatingPointValue fv1 = (FloatingPointValue) v1;
FloatingPointValue fv2 = (FloatingPointValue) v2;
return applyBinaryOperator(op, fv1.numberValue().doubleValue(), fv2.numberValue().doubleValue());
} else if(v1 instanceof FloatingPointValue && v2 instanceof IntegralValue) {
FloatingPointValue fv1 = (FloatingPointValue)v1;
IntegralValue iv2 = (IntegralValue)v2;
} else if (v1 instanceof FloatingPointValue && v2 instanceof IntegralValue) {
FloatingPointValue fv1 = (FloatingPointValue) v1;
IntegralValue iv2 = (IntegralValue) v2;
return applyBinaryOperator(op, fv1.numberValue().doubleValue(), iv2.numberValue().doubleValue());
} else if(v1 instanceof IntegralValue && v2 instanceof FloatingPointValue) {
IntegralValue iv1 = (IntegralValue)v1;
FloatingPointValue fv2 = (FloatingPointValue)v2;
} else if (v1 instanceof IntegralValue && v2 instanceof FloatingPointValue) {
IntegralValue iv1 = (IntegralValue) v1;
FloatingPointValue fv2 = (FloatingPointValue) v2;
return applyBinaryOperator(op, iv1.numberValue().doubleValue(), fv2.numberValue().doubleValue());
} else if(v1 instanceof IntegralValue && v2 instanceof IntegralValue) {
IntegralValue iv1 = (IntegralValue)v1;
IntegralValue iv2 = (IntegralValue)v2;
return applyBinaryOperator(op, iv1.numberValue().longValue(), iv2.numberValue().longValue());
} else if (v1 instanceof IntegralValue && v2 instanceof IntegralValue) {
IntegralValue iv1 = (IntegralValue) v1;
IntegralValue iv2 = (IntegralValue) v2;
return applyBinaryOperator(op, iv1.numberValue().longValue(), iv2.numberValue().longValue());
}
return IntegralValue.UNKNOWN;
}
private static IValue applyBinaryOperator(final int op, final double v1, final double v2) {
Double doubleValue = null;
Long longValue = null;
switch (op) {
case IASTBinaryExpression.op_multiply:
doubleValue = v1 * v2;
@ -159,16 +159,16 @@ public class ValueFactory {
longValue = v1 != v2 ? 1l : 0l;
break;
}
if(doubleValue != null) {
if (doubleValue != null) {
return FloatingPointValue.create(doubleValue);
} else if(longValue != null) {
} else if (longValue != null) {
return IntegralValue.create(longValue);
} else {
return IntegralValue.UNKNOWN;
}
}
private static IntegralValue applyBinaryOperator(final int op, final long v1, final long v2) {
Long value = null;
switch (op) {
@ -237,8 +237,8 @@ public class ValueFactory {
value = Math.min(v1, v2);
break;
}
if(value != null) {
if (value != null) {
return IntegralValue.create(value);
} else {
return IntegralValue.UNKNOWN;
@ -259,7 +259,7 @@ public class ValueFactory {
return IntegralValue.UNKNOWN;
return val;
}
/**
* Computes the canonical representation of the value of the expression.
*/
@ -325,7 +325,7 @@ public class ValueFactory {
return CStringValue.create(litEx.getValue());
}
}
if (exp instanceof IASTTypeIdExpression) {
IASTTypeIdExpression typeIdExp = (IASTTypeIdExpression) exp;
ASTTranslationUnit ast = (ASTTranslationUnit) exp.getTranslationUnit();
@ -371,11 +371,11 @@ public class ValueFactory {
value= ((IEnumerator) b).getValue();
}
if (isInvalidValue(value)) {
return IntegralValue.UNKNOWN;
return IntegralValue.UNKNOWN;
}
return value;
}
private static IValue applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) {
switch (operator) {
case op_sizeof:
@ -433,7 +433,7 @@ public class ValueFactory {
}
return IntegralValue.UNKNOWN;
}
private static IValue getAlignment(IType type, IASTNode point) {
SizeAndAlignment sizeAndAlignment = SizeofCalculator.getSizeAndAlignment(type, point);
if (sizeAndAlignment == null)
@ -447,7 +447,7 @@ public class ValueFactory {
return IntegralValue.UNKNOWN;
return IntegralValue.create(sizeAndAlignment.size);
}
private static IValue evaluateUnaryExpression(IASTUnaryExpression exp) {
final int unaryOp= exp.getOperator();
@ -480,21 +480,21 @@ public class ValueFactory {
}
private static IValue applyUnaryOperator(final int unaryOp, final IValue value) {
if(isInvalidValue(value) || value.numberValue() == null) {
if (isInvalidValue(value) || value.numberValue() == null) {
return IntegralValue.UNKNOWN;
}
if(!(value instanceof IntegralValue) && !(value instanceof FloatingPointValue)) {
if (!(value instanceof IntegralValue) && !(value instanceof FloatingPointValue)) {
return IntegralValue.UNKNOWN;
}
switch (unaryOp) {
case IASTUnaryExpression.op_bracketedPrimary:
case IASTUnaryExpression.op_plus:
return value;
case IASTUnaryExpression.op_prefixIncr:
case IASTUnaryExpression.op_postFixIncr:
if(value instanceof IntegralValue) {
if (value instanceof IntegralValue) {
return IntegralValue.create(value.numberValue().longValue() + 1);
} else {
FloatingPointValue fpv = (FloatingPointValue) value;
@ -502,27 +502,27 @@ public class ValueFactory {
}
case IASTUnaryExpression.op_prefixDecr:
case IASTUnaryExpression.op_postFixDecr:
if(value instanceof IntegralValue) {
if (value instanceof IntegralValue) {
return IntegralValue.create(value.numberValue().longValue() - 1);
} else {
FloatingPointValue fpv = (FloatingPointValue) value;
return FloatingPointValue.create(fpv.numberValue().doubleValue() - 1);
}
case IASTUnaryExpression.op_minus:
if(value instanceof IntegralValue) {
if (value instanceof IntegralValue) {
return IntegralValue.create(-value.numberValue().longValue());
} else {
FloatingPointValue fpv = (FloatingPointValue) value;
return FloatingPointValue.create(-fpv.numberValue().doubleValue());
}
case IASTUnaryExpression.op_tilde:
if(value instanceof IntegralValue) {
if (value instanceof IntegralValue) {
return IntegralValue.create(~value.numberValue().longValue());
} else {
return IntegralValue.UNKNOWN;
}
case IASTUnaryExpression.op_not:
if(value instanceof IntegralValue) {
if (value instanceof IntegralValue) {
Long num = value.numberValue().longValue();
return IntegralValue.create(num == 0 ? 1 : 0);
} else {
@ -536,7 +536,7 @@ public class ValueFactory {
private static IValue evaluateBinaryExpression(IASTBinaryExpression exp) {
final int op= exp.getOperator();
// Optimization: if the operator is == or != and the AST nodes
// themselves are equal, we know the answer without having to
// do any evaluation.
@ -546,7 +546,7 @@ public class ValueFactory {
if (op == IASTBinaryExpression.op_notequals && exp.getOperand1().equals(exp.getOperand2())) {
return IntegralValue.create(false);
}
final IValue o1= evaluate(exp.getOperand1());
if (isInvalidValue(o1))
return o1;
@ -557,7 +557,7 @@ public class ValueFactory {
return null; // the value will be computed using the evaluation
return evaluateBinaryExpression(op, o1, o2);
}
private static IValue applyBinaryTypeIdOperator(IASTBinaryTypeIdExpression.Operator operator,
IType type1, IType type2, IASTNode point) {
switch (operator) {
@ -575,11 +575,11 @@ public class ValueFactory {
}
return IntegralValue.UNKNOWN;
}
private static boolean isInvalidValue(IValue value) {
return value == null || value == IntegralValue.UNKNOWN || value == IntegralValue.ERROR;
}
private static boolean isDeferredValue(IValue value) {
return value instanceof IntegralValue && ((IntegralValue) value).numberValue() == null;
}

View file

@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
@ -62,7 +62,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
public abstract class VariableReadWriteFlags {
protected static final int READ = PDOMName.READ_ACCESS;
protected static final int WRITE = PDOMName.WRITE_ACCESS;
protected int rwAnyNode(IASTNode node, int indirection) {
final IASTNode parent = node.getParent();
if (parent instanceof IASTExpression) {
@ -103,7 +103,7 @@ public abstract class VariableReadWriteFlags {
if (grand instanceof IASTEqualsInitializer) {
IASTNode grandGrand= grand.getParent();
if (grandGrand instanceof IASTDeclarator) {
IBinding binding= ((IASTDeclarator) grandGrand).getName().resolveBinding();
IBinding binding= ((IASTDeclarator) grandGrand).getName().resolveBinding();
if (binding instanceof IVariable) {
IType type= ((IVariable) binding).getType();
if (type instanceof IArrayType) {
@ -120,7 +120,7 @@ public abstract class VariableReadWriteFlags {
return rwAnyNode(expr, indirection);
}
if (expr instanceof IASTBinaryExpression) {
return rwInBinaryExpression(node, (IASTBinaryExpression) expr, indirection);
return rwInBinaryExpression(node, (IASTBinaryExpression) expr, indirection);
}
if (expr instanceof IASTFieldReference) {
return rwInFieldReference(node, (IASTFieldReference) expr, indirection);
@ -129,7 +129,7 @@ public abstract class VariableReadWriteFlags {
return rwAnyNode(expr, indirection);
}
if (expr instanceof IASTUnaryExpression) {
return rwInUnaryExpression(node, (IASTUnaryExpression) expr, indirection);
return rwInUnaryExpression(node, (IASTUnaryExpression) expr, indirection);
}
if (expr instanceof IASTArraySubscriptExpression) {
if (indirection > 0 && node.getPropertyInParent() == IASTArraySubscriptExpression.ARRAY) {
@ -158,7 +158,7 @@ public abstract class VariableReadWriteFlags {
return rwArgumentForFunctionCall((IASTFunctionCallExpression) expr, node, indirection);
}
if (expr instanceof IASTProblemExpression) {
return READ | WRITE;
return READ | WRITE;
}
if (expr instanceof IASTTypeIdExpression) {
return 0;
@ -200,7 +200,7 @@ public abstract class VariableReadWriteFlags {
IASTImplicitName name = implicitNames[0];
IBinding binding = name.resolveBinding();
if (binding instanceof IFunction) {
return rwArgumentForFunctionCall(((IFunction) binding).getType(), i,
return rwArgumentForFunctionCall(((IFunction) binding).getType(), i,
args[i], indirection);
}
}
@ -220,8 +220,8 @@ public abstract class VariableReadWriteFlags {
}
return null;
}
protected int rwArgumentForFunctionCall(IFunctionType type, int parameterIdx,
protected int rwArgumentForFunctionCall(IFunctionType type, int parameterIdx,
IASTInitializerClause argument, int indirection) {
IType[] ptypes= type.getParameterTypes();
IType parameterType = null;
@ -232,7 +232,7 @@ public abstract class VariableReadWriteFlags {
// equal to the argument type.
parameterType = getArgumentType(argument);
}
if (parameterType != null) {
return rwAssignmentToType(parameterType, indirection);
}
@ -240,7 +240,7 @@ public abstract class VariableReadWriteFlags {
}
protected abstract int rwAssignmentToType(IType type, int indirection);
protected int rwInStatement(IASTStatement stmt, IASTNode node, int indirection) {
if (stmt instanceof IASTCaseStatement) {
if (node.getPropertyInParent() == IASTCaseStatement.EXPRESSION) {
@ -293,10 +293,10 @@ public abstract class VariableReadWriteFlags {
}
protected int rwInUnaryExpression(IASTNode node, IASTUnaryExpression expr, int indirection) {
switch(expr.getOperator()) {
switch (expr.getOperator()) {
case IASTUnaryExpression.op_bracketedPrimary:
return rwAnyNode(expr, indirection);
case IASTUnaryExpression.op_amper:
return rwAnyNode(expr, indirection + 1);
@ -305,13 +305,13 @@ public abstract class VariableReadWriteFlags {
return rwAnyNode(expr, indirection - 1);
}
return READ;
case IASTUnaryExpression.op_postFixDecr:
case IASTUnaryExpression.op_postFixIncr:
case IASTUnaryExpression.op_prefixDecr:
case IASTUnaryExpression.op_prefixIncr:
return READ | WRITE;
case IASTUnaryExpression.op_minus:
case IASTUnaryExpression.op_not:
case IASTUnaryExpression.op_plus:
@ -327,13 +327,13 @@ public abstract class VariableReadWriteFlags {
}
protected int rwInBinaryExpression(IASTNode node, IASTBinaryExpression expr, int indirection) {
switch(expr.getOperator()) {
switch (expr.getOperator()) {
case IASTBinaryExpression.op_assign:
if (node.getPropertyInParent() == IASTBinaryExpression.OPERAND_ONE) {
return WRITE;
}
return rwAssignmentToType(expr.getOperand1().getExpressionType(), indirection);
case IASTBinaryExpression.op_binaryAndAssign:
case IASTBinaryExpression.op_binaryOrAssign:
case IASTBinaryExpression.op_binaryXorAssign:
@ -348,7 +348,7 @@ public abstract class VariableReadWriteFlags {
return READ | WRITE;
}
return READ;
case IASTBinaryExpression.op_binaryAnd:
case IASTBinaryExpression.op_binaryOr:
case IASTBinaryExpression.op_binaryXor:

View file

@ -33,7 +33,7 @@ public class CASTASMDeclaration extends ASTNode implements IASTASMDeclaration {
public CASTASMDeclaration copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTASMDeclaration copy(CopyStyle style) {
CASTASMDeclaration copy = new CASTASMDeclaration();
@ -43,8 +43,8 @@ public class CASTASMDeclaration extends ASTNode implements IASTASMDeclaration {
@Override
public String getAssembly() {
if( assembly == null ) return ""; //$NON-NLS-1$
return new String( assembly );
if (assembly == null) return ""; //$NON-NLS-1$
return new String(assembly);
}
@Override
@ -54,17 +54,17 @@ public class CASTASMDeclaration extends ASTNode implements IASTASMDeclaration {
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclarations ){
switch( action.visit( this ) ){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclarations) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if( action.shouldVisitDeclarations ){
switch( action.leave( this ) ){
if (action.shouldVisitDeclarations) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;

View file

@ -4,7 +4,7 @@
* 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:
* Nathan Ridge - Initial API and implementation
*******************************************************************************/
@ -20,19 +20,19 @@ public class CASTAlignmentSpecifier extends ASTNode implements IASTAlignmentSpec
// Precisely one of these is null.
private IASTExpression fExpression;
private IASTTypeId fTypeId;
CASTAlignmentSpecifier(IASTExpression expression) {
fExpression = expression;
fExpression.setParent(this);
fExpression.setPropertyInParent(ALIGNMENT_EXPRESSION);
}
CASTAlignmentSpecifier(IASTTypeId typeId) {
fTypeId = typeId;
fTypeId.setParent(this);
fTypeId.setPropertyInParent(ALIGNMENT_TYPEID);
}
@Override
public IASTExpression getExpression() {
return fExpression;
@ -58,7 +58,7 @@ public class CASTAlignmentSpecifier extends ASTNode implements IASTAlignmentSpec
}
return copy(copy, style);
}
@Override
public boolean accept(ASTVisitor visitor) {
if (fExpression != null) {

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -34,22 +34,22 @@ public final class CASTAmbiguityResolver extends ASTVisitor {
@Override
public int visit(ASTAmbiguousNode astAmbiguousNode) {
IASTNode node= astAmbiguousNode.resolveAmbiguity(this);
if (node instanceof IASTDeclarator || node instanceof IASTParameterDeclaration
if (node instanceof IASTDeclarator || node instanceof IASTParameterDeclaration
|| node instanceof IASTDeclaration) {
while(node != null) {
while (node != null) {
if (node instanceof IASTDeclaration || node instanceof IASTParameterDeclaration) {
repopulateScope(node);
break;
}
if (node instanceof IASTExpression) {
break;
}
}
node= node.getParent();
}
}
}
return PROCESS_SKIP;
}
private void repopulateScope(IASTNode node) {
IScope scope= CVisitor.getContainingScope(node);
if (scope instanceof CScope) {

View file

@ -4,7 +4,7 @@
* 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:
* Nathan Ridge - Initial API and implementation
*******************************************************************************/
@ -19,12 +19,12 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
public class CASTAmbiguousAlignmentSpecifier extends ASTAmbiguousNode implements IASTAlignmentSpecifier {
IASTAlignmentSpecifier fExpression;
IASTAlignmentSpecifier fTypeId;
CASTAmbiguousAlignmentSpecifier(IASTAlignmentSpecifier expression, IASTAlignmentSpecifier typeId) {
fExpression = expression;
fTypeId = typeId;
}
@Override
public IASTExpression getExpression() {
return fExpression.getExpression();

View file

@ -35,7 +35,7 @@ import org.eclipse.core.runtime.Assert;
public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmbiguousDeclarator {
private IASTDeclarator[] dtors = new IASTDeclarator[2];
private int dtorPos= -1;
public CASTAmbiguousDeclarator(IASTDeclarator... decls) {
for (IASTDeclarator d : decls) {
if (d != null) {
@ -43,7 +43,7 @@ public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmb
}
}
}
@Override
protected void beforeResolution() {
// populate containing scope, so that it will not be affected by the alternative branches.
@ -65,7 +65,7 @@ public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmb
@Override
public IASTDeclarator[] getDeclarators() {
dtors = ArrayUtil.trimAt(IASTDeclarator.class, dtors, dtorPos);
dtors = ArrayUtil.trimAt(IASTDeclarator.class, dtors, dtorPos);
return dtors;
}

View file

@ -22,9 +22,9 @@ public class CASTAmbiguousExpression extends ASTAmbiguousNode implements IASTAmb
private IASTExpression [] expressions = new IASTExpression[2];
private int expressionsPos=-1;
public CASTAmbiguousExpression(IASTExpression... expressions) {
for(IASTExpression e : expressions)
for (IASTExpression e : expressions)
addExpression(e);
}
@ -32,7 +32,7 @@ public class CASTAmbiguousExpression extends ASTAmbiguousNode implements IASTAmb
public void addExpression(IASTExpression e) {
assertNotFrozen();
if (e != null) {
expressions = ArrayUtil.appendAt( IASTExpression.class, expressions, ++expressionsPos, e );
expressions = ArrayUtil.appendAt(IASTExpression.class, expressions, ++expressionsPos, e);
e.setParent(this);
e.setPropertyInParent(SUBEXPRESSION);
}
@ -40,7 +40,7 @@ public class CASTAmbiguousExpression extends ASTAmbiguousNode implements IASTAmb
@Override
public IASTExpression[] getExpressions() {
expressions = ArrayUtil.trimAt( IASTExpression.class, expressions, expressionsPos );
expressions = ArrayUtil.trimAt(IASTExpression.class, expressions, expressionsPos);
return expressions;
}
@ -53,7 +53,7 @@ public class CASTAmbiguousExpression extends ASTAmbiguousNode implements IASTAmb
public IASTExpression copy() {
throw new UnsupportedOperationException();
}
@Override
public IASTExpression copy(CopyStyle style) {
throw new UnsupportedOperationException();

View file

@ -32,9 +32,9 @@ public class CASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implemen
private IASTParameterDeclaration[] paramDecls = new IASTParameterDeclaration[2];
private int declPos=-1;
public CASTAmbiguousParameterDeclaration(IASTParameterDeclaration... decls) {
for(IASTParameterDeclaration d : decls)
for (IASTParameterDeclaration d : decls)
addParameterDeclaration(d);
}
@ -59,7 +59,7 @@ public class CASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implemen
@Override
public IASTParameterDeclaration[] getParameterDeclarations() {
paramDecls = ArrayUtil.trimAt(IASTParameterDeclaration.class, paramDecls, declPos );
paramDecls = ArrayUtil.trimAt(IASTParameterDeclaration.class, paramDecls, declPos);
return paramDecls;
}
@ -94,7 +94,7 @@ public class CASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implemen
public IASTParameterDeclaration copy() {
throw new UnsupportedOperationException();
}
@Override
public IASTParameterDeclaration copy(CopyStyle style) {
throw new UnsupportedOperationException();

View file

@ -39,7 +39,7 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements
private IASTSimpleDeclaration fSimpleDecl;
private IASTDeclSpecifier fAltDeclSpec;
private IASTDeclarator fAltDtor;
public CASTAmbiguousSimpleDeclaration(IASTSimpleDeclaration decl, IASTDeclSpecifier declSpec, IASTDeclarator dtor) {
fSimpleDecl= decl;
fAltDeclSpec= declSpec;
@ -120,14 +120,14 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements
owner.replace(nodeToReplace, fSimpleDecl);
IASTDeclSpecifier declSpec= fSimpleDecl.getDeclSpecifier();
declSpec.accept(resolver);
// Find nested names.
final NameCollector nameCollector= new NameCollector();
declSpec.accept(nameCollector);
final IASTName[] names= nameCollector.getNames();
// Resolve names.
// Resolve names.
boolean hasIssue= false;
for (IASTName name : names) {
try {
@ -147,7 +147,7 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements
parent.replace(declSpec, fAltDeclSpec);
parent.replace(fSimpleDecl.getDeclarators()[0], fAltDtor);
}
// Resolve further nested ambiguities.
fSimpleDecl.accept(resolver);
return fSimpleDecl;

View file

@ -32,15 +32,15 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi
private int stmtsPos= -1;
private IScope fScope;
private IASTDeclaration fDeclaration;
public CASTAmbiguousStatement(IASTStatement... statements) {
for (IASTStatement s : statements)
addStatement(s);
}
@Override
protected void beforeResolution() {
// Populate containing scope, so that it will not be affected by the alternative
// Populate containing scope, so that it will not be affected by the alternative
// branches.
fScope= CVisitor.getContainingScope(this);
if (fScope instanceof ICPPASTInternalScope) {
@ -58,7 +58,7 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi
}
}
}
private void cleanupScope() {
if (fScope instanceof IASTInternalScope && fDeclaration != null) {
((IASTInternalScope) fScope).removeNestedFromCache(fDeclaration);

View file

@ -36,7 +36,7 @@ public class CASTArrayDeclarator extends CASTDeclarator implements IASTArrayDecl
public CASTArrayDeclarator(IASTName name) {
super(name);
}
@Override
public CASTArrayDeclarator copy() {
return copy(CopyStyle.withoutLocations);
@ -66,7 +66,7 @@ public class CASTArrayDeclarator extends CASTDeclarator implements IASTArrayDecl
arrayModifier.setParent(this);
arrayModifier.setPropertyInParent(ARRAY_MODIFIER);
arrayMods = ArrayUtil.appendAt(IASTArrayModifier.class, arrayMods,
++arrayModsPos, arrayModifier);
++arrayModsPos, arrayModifier);
}
}

View file

@ -43,7 +43,7 @@ public class CASTArrayDesignator extends ASTNode implements ICASTArrayDesignator
new CASTArrayDesignator(expression == null ? null : expression.copy(style));
return copy(copy, style);
}
@Override
public IASTExpression getSubscriptExpression() {
return expression;

View file

@ -30,7 +30,7 @@ public class CASTArrayModifier extends ASTAttributeOwner implements ICASTArrayMo
private boolean isStatic;
private boolean isConst;
private boolean isVarSized;
public CASTArrayModifier() {
}
@ -53,7 +53,7 @@ public class CASTArrayModifier extends ASTAttributeOwner implements ICASTArrayMo
copy.isVarSized = isVarSized;
return copy(copy, style);
}
@Override
public IASTExpression getConstantExpression() {
return exp;
@ -63,12 +63,12 @@ public class CASTArrayModifier extends ASTAttributeOwner implements ICASTArrayMo
public void setConstantExpression(IASTExpression expression) {
assertNotFrozen();
this.exp = expression;
if(expression != null) {
if (expression != null) {
expression.setParent(this);
expression.setPropertyInParent(CONSTANT_EXPRESSION);
}
}
@Override
public boolean isConst() {
return isConst;
@ -126,8 +126,8 @@ public class CASTArrayModifier extends ASTAttributeOwner implements ICASTArrayMo
@Override
public boolean accept(ASTVisitor action) {
if( action.shouldVisitArrayModifiers ){
switch( action.visit( this ) ){
if (action.shouldVisitArrayModifiers) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
@ -147,10 +147,10 @@ public class CASTArrayModifier extends ASTAttributeOwner implements ICASTArrayMo
@Override
public void replace(IASTNode child, IASTNode other) {
if( child == exp )
if (child == exp)
{
other.setPropertyInParent( child.getPropertyInParent() );
other.setParent( child.getParent() );
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
exp = (IASTExpression) other;
}
}

View file

@ -47,7 +47,7 @@ public class CASTArrayRangeDesignator extends ASTNode
copy.setRangeCeiling(ceiling == null ? null : ceiling.copy(style));
return copy(copy, style);
}
@Override
public IASTExpression getRangeFloor() {
return this.floor;
@ -65,7 +65,7 @@ public class CASTArrayRangeDesignator extends ASTNode
@Override
public IASTExpression getRangeCeiling() {
return ceiling;
return ceiling;
}
@Override
@ -97,7 +97,7 @@ public class CASTArrayRangeDesignator extends ASTNode
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (child == floor) {

View file

@ -43,7 +43,7 @@ public class CASTArraySubscriptExpression extends ASTNode implements
public CASTArraySubscriptExpression copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTArraySubscriptExpression copy(CopyStyle style) {
CASTArraySubscriptExpression copy = new CASTArraySubscriptExpression();
@ -61,7 +61,7 @@ public class CASTArraySubscriptExpression extends ASTNode implements
public void setArrayExpression(IASTExpression expression) {
assertNotFrozen();
array = expression;
if(expression != null) {
if (expression != null) {
expression.setParent(this);
expression.setPropertyInParent(ARRAY);
}
@ -76,7 +76,7 @@ public class CASTArraySubscriptExpression extends ASTNode implements
public void setSubscriptExpression(IASTExpression expression) {
assertNotFrozen();
this.subscript = expression;
if(expression != null) {
if (expression != null) {
expression.setParent(this);
expression.setPropertyInParent(SUBSCRIPT);
}
@ -105,7 +105,7 @@ public class CASTArraySubscriptExpression extends ASTNode implements
default: break;
}
}
if (array != null && !array.accept(action)) return false;
if (subscript != null && !subscript.accept(action)) return false;
@ -118,7 +118,7 @@ public class CASTArraySubscriptExpression extends ASTNode implements
}
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (child == array) {
@ -132,15 +132,15 @@ public class CASTArraySubscriptExpression extends ASTNode implements
subscript = (IASTExpression) other;
}
}
@Override
public IType getExpressionType() {
IType t = getArrayExpression().getExpressionType();
t = CVisitor.unwrapTypedefs(t);
if (t instanceof IPointerType)
return ((IPointerType)t).getType();
return ((IPointerType) t).getType();
else if (t instanceof IArrayType)
return ((IArrayType)t).getType();
return ((IArrayType) t).getType();
return t;
}
@ -148,7 +148,7 @@ public class CASTArraySubscriptExpression extends ASTNode implements
public boolean isLValue() {
return true;
}
@Override
public final ValueCategory getValueCategory() {
return ValueCategory.LVALUE;

View file

@ -17,11 +17,11 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
* C-specific attribute.
*/
public class CASTAttribute extends ASTAttribute {
public CASTAttribute(char[] name, IASTToken argumentClause) {
super(name, argumentClause);
}
@Override
public CASTAttribute copy() {
return copy(CopyStyle.withoutLocations);
@ -31,7 +31,7 @@ public class CASTAttribute extends ASTAttribute {
public CASTAttribute copy(CopyStyle style) {
IASTToken argumentClause = getArgumentClause();
if (argumentClause != null)
argumentClause = argumentClause.copy(style);
argumentClause = argumentClause.copy(style);
return copy(new CASTAttribute(getName(), argumentClause), style);
}
}

View file

@ -4,7 +4,7 @@
* 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:
* IBM Rational Software - Initial API and implementation
*******************************************************************************/
@ -21,7 +21,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public abstract class CASTBaseDeclSpecifier extends ASTNode
public abstract class CASTBaseDeclSpecifier extends ASTNode
implements ICASTDeclSpecifier, IASTAmbiguityParent {
protected int storageClass;
@ -29,9 +29,9 @@ public abstract class CASTBaseDeclSpecifier extends ASTNode
protected boolean isVolatile;
protected boolean isRestrict;
protected boolean isInline;
protected IASTAlignmentSpecifier[] alignmentSpecifiers =
protected IASTAlignmentSpecifier[] alignmentSpecifiers =
IASTAlignmentSpecifier.EMPTY_ALIGNMENT_SPECIFIER_ARRAY;
@Override
public boolean isRestrict() {
return isRestrict;
@ -56,12 +56,12 @@ public abstract class CASTBaseDeclSpecifier extends ASTNode
public boolean isInline() {
return isInline;
}
@Override
public IASTAlignmentSpecifier[] getAlignmentSpecifiers() {
return alignmentSpecifiers;
}
@Override
public void setStorageClass(int storageClass) {
assertNotFrozen();
@ -73,25 +73,25 @@ public abstract class CASTBaseDeclSpecifier extends ASTNode
assertNotFrozen();
this.isConst = value;
}
@Override
public void setVolatile(boolean value) {
assertNotFrozen();
this.isVolatile = value;
}
@Override
public void setRestrict(boolean value) {
assertNotFrozen();
this.isRestrict = value;
}
@Override
public void setInline(boolean value) {
assertNotFrozen();
this.isInline = value;
}
@Override
public void setAlignmentSpecifiers(IASTAlignmentSpecifier[] alignmentSpecifiers) {
assertNotFrozen();
@ -101,7 +101,7 @@ public abstract class CASTBaseDeclSpecifier extends ASTNode
}
this.alignmentSpecifiers = alignmentSpecifiers;
}
protected <T extends CASTBaseDeclSpecifier> T copy(T copy, CopyStyle style) {
copy.storageClass = storageClass;
copy.isConst = isConst;
@ -115,7 +115,7 @@ public abstract class CASTBaseDeclSpecifier extends ASTNode
}
return super.copy(copy, style);
}
protected boolean visitAlignmentSpecifiers(ASTVisitor visitor) {
for (IASTAlignmentSpecifier specifier : alignmentSpecifiers) {
if (!specifier.accept(visitor)) {
@ -124,7 +124,7 @@ public abstract class CASTBaseDeclSpecifier extends ASTNode
}
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (child instanceof IASTAlignmentSpecifier && other instanceof IASTAlignmentSpecifier) {

View file

@ -45,7 +45,7 @@ public class CASTBinaryExpression extends ASTNode
setOperand1(operand1);
setOperand2(operand2);
}
@Override
public CASTBinaryExpression copy() {
return copy(CopyStyle.withoutLocations);
@ -114,7 +114,7 @@ public class CASTBinaryExpression extends ASTNode
if (operand1 instanceof IASTBinaryExpression || operand2 instanceof IASTBinaryExpression) {
return acceptWithoutRecursion(this, action);
}
if (action.shouldVisitExpressions) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
@ -122,13 +122,13 @@ public class CASTBinaryExpression extends ASTNode
default: break;
}
}
if (operand1 != null && !operand1.accept(action))
if (operand1 != null && !operand1.accept(action))
return false;
if (operand2 != null && !operand2.accept(action))
if (operand2 != null && !operand2.accept(action))
return false;
if (action.shouldVisitExpressions && action.leave(this) == ASTVisitor.PROCESS_ABORT)
if (action.shouldVisitExpressions && action.leave(this) == ASTVisitor.PROCESS_ABORT)
return false;
return true;
@ -143,7 +143,7 @@ public class CASTBinaryExpression extends ASTNode
fExpression = expr;
}
}
public static boolean acceptWithoutRecursion(IASTBinaryExpression bexpr, ASTVisitor action) {
N stack= new N(bexpr);
while (stack != null) {
@ -151,9 +151,9 @@ public class CASTBinaryExpression extends ASTNode
if (stack.fState == 0) {
if (action.shouldVisitExpressions) {
switch (action.visit(expr)) {
case ASTVisitor.PROCESS_ABORT:
case ASTVisitor.PROCESS_ABORT:
return false;
case ASTVisitor.PROCESS_SKIP:
case ASTVisitor.PROCESS_SKIP:
stack= stack.fNext;
continue;
}
@ -166,33 +166,33 @@ public class CASTBinaryExpression extends ASTNode
stack= n;
continue;
}
if (op1 != null && !op1.accept(action))
if (op1 != null && !op1.accept(action))
return false;
}
if (stack.fState == 1) {
stack.fState= 2;
IASTExpression op2 = expr.getOperand2();
if (op2 instanceof IASTBinaryExpression) {
N n= new N((IASTBinaryExpression) op2);
n.fNext= stack;
stack= n;
continue;
}
if (op2 != null && !op2.accept(action))
}
if (op2 != null && !op2.accept(action))
return false;
}
if (action.shouldVisitExpressions && action.leave(expr) == ASTVisitor.PROCESS_ABORT)
if (action.shouldVisitExpressions && action.leave(expr) == ASTVisitor.PROCESS_ABORT)
return false;
stack= stack.fNext;
}
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (child == operand1) {
@ -206,7 +206,7 @@ public class CASTBinaryExpression extends ASTNode
operand2 = (IASTExpression) other;
}
}
@Override
public IType getExpressionType() {
final int op = getOperator();
@ -258,7 +258,7 @@ public class CASTBinaryExpression extends ASTNode
(type.isRestrict() ? CPointerType.IS_RESTRICT : 0) |
(type.isVolatile() ? CPointerType.IS_VOLATILE : 0));
}
@Override
public boolean isLValue() {
switch (getOperator()) {
@ -277,7 +277,7 @@ public class CASTBinaryExpression extends ASTNode
}
return false;
}
@Override
public final ValueCategory getValueCategory() {
return isLValue() ? ValueCategory.LVALUE : ValueCategory.PRVALUE;

View file

@ -39,10 +39,10 @@ public class CASTBreakStatement extends ASTAttributeOwner implements IASTBreakSt
default: break;
}
}
return true;
}
@Override
public CASTBreakStatement copy() {
return copy(CopyStyle.withoutLocations);

View file

@ -31,7 +31,7 @@ public class CASTCaseStatement extends ASTAttributeOwner implements IASTCaseStat
public CASTCaseStatement(IASTExpression expression) {
setExpression(expression);
}
@Override
public CASTCaseStatement copy() {
return copy(CopyStyle.withoutLocations);
@ -74,8 +74,8 @@ public class CASTCaseStatement extends ASTAttributeOwner implements IASTCaseStat
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
}
return true;
}

View file

@ -37,7 +37,7 @@ public class CASTCastExpression extends ASTNode implements IASTCastExpression, I
setOperand(operand);
setTypeId(typeId);
}
@Override
public CASTCastExpression copy() {
return copy(CopyStyle.withoutLocations);
@ -77,7 +77,7 @@ public class CASTCastExpression extends ASTNode implements IASTCastExpression, I
expression.setPropertyInParent(OPERAND);
}
}
@Override
public void setTypeId(IASTTypeId typeId) {
assertNotFrozen();
@ -94,40 +94,40 @@ public class CASTCastExpression extends ASTNode implements IASTCastExpression, I
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitExpressions ){
switch( action.visit( this ) ){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitExpressions) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if( typeId != null ) if( !typeId.accept( action ) ) return false;
if (typeId != null) if (!typeId.accept(action)) return false;
IASTExpression operand = getOperand();
if( operand != null ) if( !operand.accept( action ) ) return false;
if( action.shouldVisitExpressions ){
switch( action.leave( this ) ){
if (operand != null) if (!operand.accept(action)) return false;
if (action.shouldVisitExpressions) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (child == operand) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
operand = (IASTExpression) other;
}
}
}
@Override
public IType getExpressionType() {
IASTTypeId id= getTypeId();
@ -138,7 +138,7 @@ public class CASTCastExpression extends ASTNode implements IASTCastExpression, I
public boolean isLValue() {
return false;
}
@Override
public final ValueCategory getValueCategory() {
return ValueCategory.PRVALUE;

View file

@ -32,7 +32,7 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
private IASTDeclaration[] fAllDeclarations;
private int fDeclarationsPos = -1;
private IScope fScope;
public CASTCompositeTypeSpecifier() {
}
@ -40,12 +40,12 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
this.fKey = key;
setName(name);
}
@Override
public CASTCompositeTypeSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTCompositeTypeSpecifier copy(CopyStyle style) {
CASTCompositeTypeSpecifier copy = new CASTCompositeTypeSpecifier();
@ -60,7 +60,7 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
}
return super.copy(copy, style);
}
@Override
public int getKey() {
return fKey;
@ -76,7 +76,7 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
public IASTName getName() {
return fName;
}
@Override
public void setName(IASTName name) {
assertNotFrozen();
@ -118,7 +118,7 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
fActiveDeclarations= null;
}
}
@Override
public void addDeclaration(IASTDeclaration declaration) {
addMemberDeclaration(declaration);
@ -132,7 +132,7 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
}
@Override
public boolean accept(ASTVisitor action){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
@ -146,7 +146,7 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
if (fName != null && !fName.accept(action))
return false;
IASTDeclaration[] decls= getDeclarations(action.includeInactiveNodes);
for (int i = 0; i < decls.length; i++) {
if (!decls[i].accept(action))

View file

@ -8,7 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
* Yuan Zhang / Beth Tibbitts (IBM Research)
* Sergey Prigogin (Google)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@ -33,7 +33,7 @@ public class CASTCompoundStatement extends ASTAttributeOwner implements IASTComp
public CASTCompoundStatement copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTCompoundStatement copy(CopyStyle style) {
CASTCompoundStatement copy = new CASTCompoundStatement();

View file

@ -35,7 +35,7 @@ public class CASTCompoundStatementExpression extends ASTNode implements IGNUASTC
public CASTCompoundStatementExpression(IASTCompoundStatement statement) {
setCompoundStatement(statement);
}
@Override
public CASTCompoundStatementExpression copy() {
return copy(CopyStyle.withoutLocations);
@ -64,18 +64,18 @@ public class CASTCompoundStatementExpression extends ASTNode implements IGNUASTC
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitExpressions ){
switch( action.visit( this ) ){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitExpressions) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if( statement != null ) if( !statement.accept( action ) ) return false;
if( action.shouldVisitExpressions ){
switch( action.leave( this ) ){
if (statement != null) if (!statement.accept(action)) return false;
if (action.shouldVisitExpressions) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
@ -83,7 +83,7 @@ public class CASTCompoundStatementExpression extends ASTNode implements IGNUASTC
}
return true;
}
@Override
public IType getExpressionType() {
IASTCompoundStatement compound = getCompoundStatement();
@ -91,7 +91,7 @@ public class CASTCompoundStatementExpression extends ASTNode implements IGNUASTC
if (statements.length > 0) {
IASTStatement st = statements[statements.length - 1];
if (st instanceof IASTExpressionStatement)
return ((IASTExpressionStatement)st).getExpression().getExpressionType();
return ((IASTExpressionStatement) st).getExpression().getExpressionType();
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
}
@ -103,11 +103,11 @@ public class CASTCompoundStatementExpression extends ASTNode implements IGNUASTC
if (statements.length > 0) {
IASTStatement st = statements[statements.length - 1];
if (st instanceof IASTExpressionStatement)
return ((IASTExpressionStatement)st).getExpression().isLValue();
return ((IASTExpressionStatement) st).getExpression().isLValue();
}
return false;
}
@Override
public final ValueCategory getValueCategory() {
return isLValue() ? ValueCategory.LVALUE : ValueCategory.PRVALUE;

View file

@ -39,13 +39,13 @@ public class CASTConditionalExpression extends ASTNode implements
public CASTConditionalExpression() {
}
public CASTConditionalExpression(IASTExpression condition,
public CASTConditionalExpression(IASTExpression condition,
IASTExpression positive, IASTExpression negative) {
setLogicalConditionExpression(condition);
setPositiveResultExpression(positive);
setNegativeResultExpression(negative);
}
@Override
public CASTConditionalExpression copy() {
return copy(CopyStyle.withoutLocations);
@ -106,20 +106,20 @@ public class CASTConditionalExpression extends ASTNode implements
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitExpressions ){
switch( action.visit( this ) ){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitExpressions) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if( condition != null ) if( !condition.accept( action ) ) return false;
if( positive != null ) if( !positive.accept( action ) ) return false;
if( negative != null ) if( !negative.accept( action ) ) return false;
if( action.shouldVisitExpressions ){
switch( action.leave( this ) ){
if (condition != null) if (!condition.accept(action)) return false;
if (positive != null) if (!positive.accept(action)) return false;
if (negative != null) if (!negative.accept(action)) return false;
if (action.shouldVisitExpressions) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
@ -127,29 +127,29 @@ public class CASTConditionalExpression extends ASTNode implements
}
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if( child == condition )
if (child == condition)
{
other.setPropertyInParent( child.getPropertyInParent() );
other.setParent( child.getParent() );
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
condition = (IASTExpression) other;
}
if( child == positive)
if (child == positive)
{
other.setPropertyInParent( child.getPropertyInParent() );
other.setParent( child.getParent() );
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
positive= (IASTExpression) other;
}
if( child == negative)
if (child == negative)
{
other.setPropertyInParent( child.getPropertyInParent() );
other.setParent( child.getParent() );
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
negative= (IASTExpression) other;
}
}
@Override
public IType getExpressionType() {
IASTExpression positiveExpression = getPositiveResultExpression();
@ -161,15 +161,15 @@ public class CASTConditionalExpression extends ASTNode implements
IType originalNegativeType = getNegativeResultExpression().getExpressionType();
IType positiveType = CVisitor.unwrapTypedefs(originalPositiveType);
IType negativeType = CVisitor.unwrapTypedefs(originalNegativeType);
IType resultType = computeResultType(positiveExpression, negativeExpression,
IType resultType = computeResultType(positiveExpression, negativeExpression,
positiveType, negativeType);
if (resultType == null) {
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
return ExpressionTypes.restoreTypedefs(resultType, originalPositiveType, originalPositiveType);
}
private IType computeResultType(IASTExpression positiveExpression, IASTExpression negativeExpression,
IType positiveType, IType negativeType) {
// [6.5.15] p5: If both the second and third operands have arithmetic type, the result type
@ -181,12 +181,12 @@ public class CASTConditionalExpression extends ASTNode implements
&& ((IBasicType) negativeType).getKind() == IBasicType.Kind.eVoid) {
return CBasicType.VOID;
}
// It doesn't really matter which operator we use here, so we'll use op_plus.
return CArithmeticConversion.convertCOperandTypes(IASTBinaryExpression.op_plus,
return CArithmeticConversion.convertCOperandTypes(IASTBinaryExpression.op_plus,
positiveType, negativeType);
}
// If both the operands have structure or union type, the result has that type.
if (positiveType instanceof ICompositeType && negativeType instanceof ICompositeType) {
// Both operands must have the same structure or union type as per p3.
@ -194,14 +194,14 @@ public class CASTConditionalExpression extends ASTNode implements
return positiveType;
}
}
// [6.5.15] p6: If both the second and third operands are pointers or one is a null pointer
// [6.5.15] p6: If both the second and third operands are pointers or one is a null pointer
// constant and the other is a pointer, the result type is a pointer to a type qualified with
// all the type qualifiers of the types referenced by both operands. Furthermore, if both
// operands are pointers to compatible types or to differently qualified versions of compatible
// types, the result type is a pointer to an appropriately qualified version of the composite
// type; if one operand is a null pointer constant, the result has the type of the other operand;
// otherwise, one operand is a pointer to void or a qualified version of void, in which case the
// all the type qualifiers of the types referenced by both operands. Furthermore, if both
// operands are pointers to compatible types or to differently qualified versions of compatible
// types, the result type is a pointer to an appropriately qualified version of the composite
// type; if one operand is a null pointer constant, the result has the type of the other operand;
// otherwise, one operand is a pointer to void or a qualified version of void, in which case the
// result type is a pointer to an appropriately qualified version of void.
if (CVisitor.isNullPointerConstant(positiveExpression) && negativeType instanceof IPointerType) {
return negativeType;
@ -222,7 +222,7 @@ public class CASTConditionalExpression extends ASTNode implements
return new CPointerType(
ExpressionTypes.restoreCV(resultPointee, positivePointeeCV, negativePointeeCV), 0);
}
return null;
}
@ -230,7 +230,7 @@ public class CASTConditionalExpression extends ASTNode implements
public boolean isLValue() {
return false;
}
@Override
public final ValueCategory getValueCategory() {
return ValueCategory.PRVALUE;

View file

@ -41,7 +41,7 @@ public class CASTContinueStatement extends ASTAttributeOwner implements IASTCont
}
return true;
}
@Override
public CASTContinueStatement copy() {
return copy(CopyStyle.withoutLocations);

View file

@ -46,12 +46,12 @@ public class CASTDeclarator extends ASTAttributeOwner implements IASTDeclarator,
public CASTDeclarator(IASTName name) {
setName(name);
}
public CASTDeclarator(IASTName name, IASTInitializer initializer) {
setInitializer(initializer);
setName(name);
}
@Override
public CASTDeclarator copy() {
return copy(CopyStyle.withoutLocations);
@ -61,7 +61,7 @@ public class CASTDeclarator extends ASTAttributeOwner implements IASTDeclarator,
public CASTDeclarator copy(CopyStyle style) {
return copy(new CASTDeclarator(), style);
}
protected <T extends CASTDeclarator> T copy(T copy, CopyStyle style) {
copy.setName(name == null ? null : name.copy(style));
copy.setInitializer(initializer == null ? null : initializer.copy(style));
@ -143,7 +143,7 @@ public class CASTDeclarator extends ASTAttributeOwner implements IASTDeclarator,
default: break;
}
}
for (int i = 0; i <= pointerOpsPos; i++) {
if (!pointerOps[i].accept(action))
return false;
@ -167,7 +167,7 @@ public class CASTDeclarator extends ASTAttributeOwner implements IASTDeclarator,
if (nestedDeclarator != null && !nestedDeclarator.accept(action)) {
return false;
}
if (!postAccept(action))
return false;
@ -176,14 +176,14 @@ public class CASTDeclarator extends ASTAttributeOwner implements IASTDeclarator,
}
return true;
}
protected boolean postAccept(ASTVisitor action) {
if (initializer != null && !initializer.accept(action))
return false;
return true;
}
@Override
public int getRoleForName(IASTName n) {
if (n == this.name) {
@ -194,14 +194,14 @@ public class CASTDeclarator extends ASTAttributeOwner implements IASTDeclarator,
return r_definition;
if (getParent instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
int storage = sd.getDeclSpecifier().getStorageClass();
int storage = sd.getDeclSpecifier().getStorageClass();
if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef)
return r_definition;
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) {
return r_declaration;
}
return fnDtor ? r_declaration : r_definition;
}
}
@ -228,7 +228,7 @@ public class CASTDeclarator extends ASTAttributeOwner implements IASTDeclarator,
if (t instanceof IASTTypeId)
return r_reference;
}
if (getParent instanceof IASTParameterDeclaration)
return (n.toCharArray().length > 0) ? r_definition : r_declaration;
}

View file

@ -39,7 +39,7 @@ public class CASTDoStatement extends ASTAttributeOwner implements IASTDoStatemen
public CASTDoStatement copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTDoStatement copy(CopyStyle style) {
CASTDoStatement copy = new CASTDoStatement();
@ -52,7 +52,7 @@ public class CASTDoStatement extends ASTAttributeOwner implements IASTDoStatemen
public IASTStatement getBody() {
return body;
}
@Override
public void setBody(IASTStatement body) {
assertNotFrozen();

View file

@ -47,7 +47,7 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement
public CASTElaboratedTypeSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTElaboratedTypeSpecifier copy(CopyStyle style) {
CASTElaboratedTypeSpecifier copy = new CASTElaboratedTypeSpecifier(kind,
@ -82,9 +82,9 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclSpecifiers ){
switch( action.visit( this ) ){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
@ -93,9 +93,9 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement
if (!visitAlignmentSpecifiers(action)) {
return false;
}
if( name != null ) if( !name.accept( action ) ) return false;
if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){
if (name != null) if (!name.accept(action)) return false;
if (action.shouldVisitDeclSpecifiers) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
@ -105,24 +105,24 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement
}
@Override
public int getRoleForName(IASTName n ) {
if( n != name ) return r_unclear;
public int getRoleForName(IASTName n) {
if (n != name) return r_unclear;
IASTNode parent = getParent();
if( !( parent instanceof IASTDeclaration ) )
if (!(parent instanceof IASTDeclaration))
return r_reference;
if( parent instanceof IASTSimpleDeclaration ){
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)parent).getDeclarators();
if( dtors.length == 0 )
if (parent instanceof IASTSimpleDeclaration) {
IASTDeclarator [] dtors = ((IASTSimpleDeclaration) parent).getDeclarators();
if (dtors.length == 0)
return r_declaration;
}
//can't tell, resolve the binding
IBinding binding = name.resolveBinding();
if( binding instanceof ICInternalBinding ){
IASTNode node = ((ICInternalBinding)binding).getPhysicalNode();
if( node == name )
if (binding instanceof ICInternalBinding) {
IASTNode node = ((ICInternalBinding) binding).getPhysicalNode();
if (node == name)
return r_declaration;
}
return r_reference;
@ -138,11 +138,11 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement
ICompositeType ct= (ICompositeType) b;
switch (ct.getKey()) {
case ICompositeType.k_struct:
if (getKind() != k_struct)
if (getKind() != k_struct)
b= null;
break;
case ICompositeType.k_union:
if (getKind() != k_union)
if (getKind() != k_union)
b= null;
break;
}

View file

@ -22,7 +22,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalEnumerationSpecifier
/**
* AST node for enumeration specifiers.
*/
public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
implements IASTInternalEnumerationSpecifier, ICASTEnumerationSpecifier {
private IASTName fName;
private Boolean fValuesComputed;
@ -40,7 +40,7 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
public CASTEnumerationSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTEnumerationSpecifier copy(CopyStyle style) {
CASTEnumerationSpecifier copy = new CASTEnumerationSpecifier();
@ -54,12 +54,12 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
}
return super.copy(copy, style);
}
@Override
public boolean startValueComputation() {
if (fValuesComputed != null)
return false;
fValuesComputed= Boolean.FALSE;
return true;
}
@ -85,7 +85,7 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
}
@Override
public IASTEnumerator[] getEnumerators() {
public IASTEnumerator[] getEnumerators() {
fEnumerators = ArrayUtil.trim(fEnumerators, fNumEnumerators);
return fEnumerators;
}
@ -108,7 +108,7 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) {
switch(action.visit(this)) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
@ -125,7 +125,7 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier
return false;
}
if (action.shouldVisitDeclSpecifiers) {
switch(action.leave(this)) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;

View file

@ -18,7 +18,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTEnumerator;
* C-specific enumerator
*/
public class CASTEnumerator extends ASTEnumerator {
public CASTEnumerator() {
super();
}
@ -26,7 +26,7 @@ public class CASTEnumerator extends ASTEnumerator {
public CASTEnumerator(IASTName name, IASTExpression value) {
super(name, value);
}
@Override
public CASTEnumerator copy() {
return copy(CopyStyle.withoutLocations);

View file

@ -37,23 +37,23 @@ public class CASTExpressionList extends ASTNode implements IASTExpressionList,
@Override
public CASTExpressionList copy(CopyStyle style) {
CASTExpressionList copy = new CASTExpressionList();
for(IASTExpression expr : getExpressions())
for (IASTExpression expr : getExpressions())
copy.addExpression(expr == null ? null : expr.copy(style));
return copy(copy, style);
}
@Override
public IASTExpression[] getExpressions() {
if (expressions == null)
return IASTExpression.EMPTY_EXPRESSION_ARRAY;
return ArrayUtil.trim( IASTExpression.class, expressions );
return ArrayUtil.trim(IASTExpression.class, expressions);
}
@Override
public void addExpression(IASTExpression expression) {
assertNotFrozen();
expressions = ArrayUtil.append( IASTExpression.class, expressions, expression );
if(expression != null) {
expressions = ArrayUtil.append(IASTExpression.class, expressions, expression);
if (expression != null) {
expression.setParent(this);
expression.setPropertyInParent(NESTED_EXPRESSION);
}
@ -94,7 +94,7 @@ public class CASTExpressionList extends ASTNode implements IASTExpressionList,
@Override
public void replace(IASTNode child, IASTNode other) {
if( expressions == null ) return;
if (expressions == null) return;
for (int i = 0; i < expressions.length; ++i) {
if (child == expressions[i]) {
other.setPropertyInParent(child.getPropertyInParent());
@ -103,7 +103,7 @@ public class CASTExpressionList extends ASTNode implements IASTExpressionList,
}
}
}
@Override
public IType getExpressionType() {
for (int i = expressions.length-1; i >= 0; i--) {
@ -123,7 +123,7 @@ public class CASTExpressionList extends ASTNode implements IASTExpressionList,
}
return false;
}
@Override
public final ValueCategory getValueCategory() {
return isLValue() ? ValueCategory.LVALUE : ValueCategory.PRVALUE;

View file

@ -44,7 +44,7 @@ public class CASTExpressionStatement extends ASTAttributeOwner
copy.setExpression(expression == null ? null : expression.copy(style));
return copy(copy, style);
}
@Override
public IASTExpression getExpression() {
return expression;

View file

@ -36,7 +36,7 @@ public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDecl
public CASTFieldDeclarator copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTFieldDeclarator copy(CopyStyle style) {
CASTFieldDeclarator copy = new CASTFieldDeclarator();
@ -63,15 +63,15 @@ public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDecl
protected boolean postAccept(ASTVisitor action) {
if (bitFieldSize != null && !bitFieldSize.accept(action))
return false;
return super.postAccept(action);
}
@Override
public void replace(IASTNode child, IASTNode other) {
if( child == bitFieldSize) {
other.setPropertyInParent( child.getPropertyInParent() );
other.setParent( child.getParent() );
if (child == bitFieldSize) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
bitFieldSize = (IASTExpression) other;
} else {
super.replace(child, other);

View file

@ -31,7 +31,7 @@ public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator
public CASTFieldDesignator(IASTName name) {
setName(name);
}
@Override
public CASTFieldDesignator copy() {
return copy(CopyStyle.withoutLocations);
@ -59,7 +59,7 @@ public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator
}
@Override
public boolean accept( ASTVisitor action) {
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDesignators) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
@ -71,10 +71,10 @@ public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator
return false;
if (action.shouldVisitDesignators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
return false;
return true;
}
@Override
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
return CVisitor.findBindingsForContentAssist(n, isPrefix);

View file

@ -38,7 +38,7 @@ public class CASTFieldReference extends ASTNode
public CASTFieldReference() {
}
public CASTFieldReference(IASTName name, IASTExpression owner) {
this(name, owner, false);
}
@ -48,7 +48,7 @@ public class CASTFieldReference extends ASTNode
setFieldName(name);
this.ptr = ptr;
}
@Override
public CASTFieldReference copy() {
return copy(CopyStyle.withoutLocations);
@ -113,7 +113,7 @@ public class CASTFieldReference extends ASTNode
default: break;
}
}
if (owner != null && !owner.accept(action)) return false;
if (name != null && !name.accept(action)) return false;
@ -142,12 +142,12 @@ public class CASTFieldReference extends ASTNode
owner = (IASTExpression) other;
}
}
@Override
public IType getExpressionType() {
IBinding binding = getFieldName().resolveBinding();
if (binding instanceof IVariable) {
return ((IVariable)binding).getType();
return ((IVariable) binding).getType();
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
}

View file

@ -53,7 +53,7 @@ public class CASTForStatement extends ASTAttributeOwner implements IASTForStatem
CASTForStatement copy = new CASTForStatement();
return copy(copy, style);
}
protected <T extends CASTForStatement> T copy(T copy, CopyStyle style) {
copy.setInitializerStatement(init == null ? null : init.copy(style));
copy.setConditionExpression(condition == null ? null : condition.copy(style));
@ -62,7 +62,7 @@ public class CASTForStatement extends ASTAttributeOwner implements IASTForStatem
copy.setBody(body == null ? null : body.copy(style));
return super.copy(copy, style);
}
@Override
public IASTExpression getConditionExpression() {
return condition;
@ -92,7 +92,7 @@ public class CASTForStatement extends ASTAttributeOwner implements IASTForStatem
iterator.setPropertyInParent(ITERATION);
}
}
@Override
public IASTStatement getInitializerStatement() {
return init;

View file

@ -33,7 +33,7 @@ public class CASTFunctionCallExpression extends ASTNode
private IASTExpression functionName;
private IASTInitializerClause[] fArguments;
public CASTFunctionCallExpression() {
setArguments(null);
}
@ -47,7 +47,7 @@ public class CASTFunctionCallExpression extends ASTNode
public CASTFunctionCallExpression copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTFunctionCallExpression copy(CopyStyle style) {
IASTInitializerClause[] args = null;
@ -106,9 +106,9 @@ public class CASTFunctionCallExpression extends ASTNode
default: break;
}
}
if (functionName != null && !functionName.accept(action))
return false;
return false;
for (IASTInitializerClause arg : fArguments) {
if (!arg.accept(action))
@ -151,7 +151,7 @@ public class CASTFunctionCallExpression extends ASTNode
public boolean isLValue() {
return false;
}
@Override
public final ValueCategory getValueCategory() {
return ValueCategory.PRVALUE;

View file

@ -33,7 +33,7 @@ public class CASTFunctionDefinition extends ASTNode implements IASTFunctionDefin
private IASTFunctionDeclarator declarator;
private IASTStatement bodyStatement;
private ICFunctionScope scope;
public CASTFunctionDefinition() {
}
@ -53,17 +53,17 @@ public class CASTFunctionDefinition extends ASTNode implements IASTFunctionDefin
public CASTFunctionDefinition copy(CopyStyle style) {
CASTFunctionDefinition copy = new CASTFunctionDefinition();
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
if (declarator != null) {
IASTDeclarator outer = ASTQueries.findOutermostDeclarator(declarator);
outer = outer.copy(style);
copy.setDeclarator((IASTFunctionDeclarator) ASTQueries.findTypeRelevantDeclarator(outer));
}
}
copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style));
return copy(copy, style);
}
@Override
public IASTDeclSpecifier getDeclSpecifier() {
return declSpecifier;
@ -126,12 +126,12 @@ public class CASTFunctionDefinition extends ASTNode implements IASTFunctionDefin
default: break;
}
}
if (declSpecifier != null && !declSpecifier.accept(action)) return false;
final IASTDeclarator outerDtor= ASTQueries.findOutermostDeclarator(declarator);
if (outerDtor != null && !outerDtor.accept(action)) return false;
if (bodyStatement != null && !bodyStatement.accept(action)) return false;
if (action.shouldVisitDeclarations) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;

View file

@ -40,7 +40,7 @@ public class CASTGotoStatement extends ASTAttributeOwner implements IASTGotoStat
CASTGotoStatement copy = new CASTGotoStatement(name == null ? null : name.copy(style));
return copy(copy, style);
}
@Override
public IASTName getName() {
return this.name;

View file

@ -47,7 +47,7 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
public CASTIdExpression copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTIdExpression copy(CopyStyle style) {
CASTIdExpression copy = new CASTIdExpression(name == null ? null : name.copy(style));
@ -78,7 +78,7 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
default: break;
}
}
if (name != null && !name.accept(action)) return false;
if (action.shouldVisitExpressions) {
@ -96,13 +96,13 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
if (n == name) return r_reference;
return r_unclear;
}
@Override
public IType getExpressionType() {
IBinding binding = getName().resolveBinding();
if (binding instanceof IVariable) {
return ((IVariable) binding).getType();
}
}
if (binding instanceof IFunction) {
return ((IFunction) binding).getType();
}
@ -114,12 +114,12 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
}
@Override
public boolean isLValue() {
return true;
}
@Override
public final ValueCategory getValueCategory() {
return ValueCategory.LVALUE;
@ -134,7 +134,7 @@ public class CASTIdExpression extends ASTNode implements IASTIdExpression, IASTC
bindings[i]= null;
}
}
return ArrayUtil.removeNulls(IBinding.class, bindings);
}
}

View file

@ -28,10 +28,10 @@ public class CASTIfStatement extends ASTAttributeOwner implements IASTIfStatemen
private IASTExpression condition;
private IASTStatement thenClause;
private IASTStatement elseClause;
public CASTIfStatement() {
}
public CASTIfStatement(IASTExpression condition, IASTStatement thenClause) {
setConditionExpression(condition);
setThenClause(thenClause);
@ -55,7 +55,7 @@ public class CASTIfStatement extends ASTAttributeOwner implements IASTIfStatemen
copy.setElseClause(elseClause == null ? null : elseClause.copy(style));
return copy(copy, style);
}
@Override
public IASTExpression getConditionExpression() {
return condition;
@ -118,7 +118,7 @@ public class CASTIfStatement extends ASTAttributeOwner implements IASTIfStatemen
if (action.shouldVisitStatements) {
switch (action.visit(stmt)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP:
case ASTVisitor.PROCESS_SKIP:
stmt= null;
break loop;
default: break;
@ -169,7 +169,7 @@ public class CASTIfStatement extends ASTAttributeOwner implements IASTIfStatemen
if (elseClause == child) {
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
elseClause = (IASTStatement) other;
elseClause = (IASTStatement) other;
}
if (child == condition) {
other.setPropertyInParent(child.getPropertyInParent());

View file

@ -35,7 +35,7 @@ public class CASTInitializerList extends ASTNode implements IASTInitializerList,
public CASTInitializerList copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTInitializerList copy(CopyStyle style) {
CASTInitializerList copy = new CASTInitializerList();
@ -45,7 +45,7 @@ public class CASTInitializerList extends ASTNode implements IASTInitializerList,
copy.actualSize = getSize();
return copy(copy, style);
}
@Override
public int getSize() {
return actualSize;
@ -65,10 +65,10 @@ public class CASTInitializerList extends ASTNode implements IASTInitializerList,
IASTInitializerClause[] clauses= getClauses();
if (clauses.length == 0)
return IASTInitializer.EMPTY_INITIALIZER_ARRAY;
IASTInitializer[] inits= new IASTInitializer[clauses.length];
for (int i = 0; i < inits.length; i++) {
IASTInitializerClause clause= clauses[i];
IASTInitializerClause clause= clauses[i];
if (clause instanceof IASTInitializer) {
inits[i]= (IASTInitializer) clause;
} else if (clause instanceof IASTExpression) {
@ -104,7 +104,7 @@ public class CASTInitializerList extends ASTNode implements IASTInitializerList,
addClause(null);
}
}
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitInitializers) {

View file

@ -70,8 +70,8 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
public void setParameterNames(IASTName[] names) {
assertNotFrozen();
parameterNames = names;
if(names != null) {
for(IASTName name : names) {
if (names != null) {
for (IASTName name : names) {
if (name != null) {
name.setParent(this);
name.setPropertyInParent(PARAMETER_NAME);
@ -89,14 +89,14 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
public void setParameterDeclarations(IASTDeclaration[] decls) {
assertNotFrozen();
parameterDeclarations = decls;
if(decls != null) {
for(IASTDeclaration decl : decls) {
if (decls != null) {
for (IASTDeclaration decl : decls) {
if (decl != null) {
decl.setParent(this);
decl.setPropertyInParent(FUNCTION_PARAMETER);
}
}
}
}
}
@Override
@ -120,7 +120,7 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
return super.postAccept(action);
}
@Override
public IASTDeclarator getDeclaratorForParameterName(IASTName name) {
boolean found= false;
@ -130,7 +130,7 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
}
if (!found)
return null;
for (int i= 0; i < parameterDeclarations.length; i++) {
if (parameterDeclarations[i] instanceof IASTSimpleDeclaration) {
IASTDeclarator[] decltors = ((IASTSimpleDeclaration) parameterDeclarations[i]).getDeclarators();
@ -140,10 +140,10 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
}
}
}
return null;
}
@Override
public int getRoleForName(IASTName name) {
IASTName [] n = getParameterNames();

View file

@ -26,7 +26,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CASTLabelStatement extends ASTAttributeOwner implements IASTLabelStatement, IASTAmbiguityParent {
private IASTName name;
private IASTStatement nestedStatement;
public CASTLabelStatement() {
}
@ -34,7 +34,7 @@ public class CASTLabelStatement extends ASTAttributeOwner implements IASTLabelSt
setName(name);
setNestedStatement(nestedStatement);
}
@Override
public CASTLabelStatement copy() {
return copy(CopyStyle.withoutLocations);
@ -93,7 +93,7 @@ public class CASTLabelStatement extends ASTAttributeOwner implements IASTLabelSt
return r_declaration;
return r_unclear;
}
@Override
public IASTStatement getNestedStatement() {
return nestedStatement;

View file

@ -36,7 +36,7 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
this.kind = kind;
this.value = value;
}
@Override
public CASTLiteralExpression copy() {
return copy(CopyStyle.withoutLocations);
@ -69,7 +69,7 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
assertNotFrozen();
this.value= value;
}
@Override
public String toString() {
return new String(value);
@ -90,7 +90,7 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
}
return true;
}
@ -110,7 +110,7 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
}
@Override
public boolean isLValue() {
return getKind() == IASTLiteralExpression.lk_string_literal;
@ -143,7 +143,7 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
private IType classifyTypeOfIntLiteral() {
int makelong= 0;
boolean unsigned= false;
final char[] lit= getValue();
for (int i= lit.length - 1; i >= 0; i--) {
final char c= lit[i];
@ -165,17 +165,17 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
int flags= 0;
if (unsigned) {
flags |= IBasicType.IS_UNSIGNED;
}
}
if (makelong > 1) {
flags |= IBasicType.IS_LONG_LONG;
} else if (makelong == 1) {
flags |= IBasicType.IS_LONG;
}
}
return new CBasicType(IBasicType.Kind.eInt, flags, this);
}
/**
* @deprecated, use {@link #setValue(char[])}, instead.
*/
@ -185,7 +185,7 @@ public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpress
assertNotFrozen();
this.value = value.toCharArray();
}
/**
* @deprecated use {@link #CASTLiteralExpression(int, char[])}, instead.
*/

View file

@ -37,7 +37,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private IBinding binding;
public CASTName(char[] name) {
this.name = name;
}
@ -50,7 +50,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
public CASTName copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTName copy(CopyStyle style) {
CASTName copy = new CASTName(name == null ? null : name.clone());
@ -65,7 +65,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return binding;
}
@Override
public IBinding resolvePreBinding() {
return resolveBinding();
@ -75,7 +75,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
public IBinding getBinding() {
return binding;
}
@Override
public IBinding getPreBinding() {
return binding;
@ -117,7 +117,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
public char[] getSimpleID() {
return name;
}
@Override
public char[] getLookupKey() {
return name;
@ -135,7 +135,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
break;
}
}
if (action.shouldVisitNames) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT:
@ -235,8 +235,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
for (int i = 0; i < bindings.length; i++) {
if (bindings[i] instanceof ICompositeType) {
ICompositeType type = (ICompositeType) bindings[i];
switch (type.getKey()) {
switch (type.getKey()) {
case ICompositeType.k_struct:
if (kind != IASTElaboratedTypeSpecifier.k_struct) {
bindings[i] = null;

View file

@ -41,7 +41,7 @@ public class CASTNullStatement extends ASTAttributeOwner implements IASTNullStat
}
return true;
}
@Override
public CASTNullStatement copy() {
return copy(CopyStyle.withoutLocations);

View file

@ -24,7 +24,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
* @author jcamelon
*/
public class CASTParameterDeclaration extends ASTNode implements IASTParameterDeclaration, IASTAmbiguityParent {
private IASTDeclSpecifier declSpec;
private IASTDeclarator declarator;
@ -48,7 +48,7 @@ public class CASTParameterDeclaration extends ASTNode implements IASTParameterDe
copy.setDeclarator(declarator == null ? null : declarator.copy(style));
return copy(copy, style);
}
@Override
public IASTDeclSpecifier getDeclSpecifier() {
return declSpec;
@ -80,19 +80,19 @@ public class CASTParameterDeclaration extends ASTNode implements IASTParameterDe
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitParameterDeclarations ){
switch( action.visit( this ) ){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitParameterDeclarations) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if( declSpec != null ) if( !declSpec.accept( action ) ) return false;
if( declarator != null ) if( !declarator.accept( action ) ) return false;
if( action.shouldVisitParameterDeclarations ){
switch( action.leave( this ) ){
if (declSpec != null) if (!declSpec.accept(action)) return false;
if (declarator != null) if (!declarator.accept(action)) return false;
if (action.shouldVisitParameterDeclarations) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;

View file

@ -35,7 +35,7 @@ public class CASTPointer extends ASTAttributeOwner implements ICASTPointer {
copy.isConst = isConst;
return copy(copy, style);
}
@Override
public boolean isRestrict() {
return isRestrict;

View file

@ -39,7 +39,7 @@ public class CASTProblemDeclaration extends CASTProblemOwner implements IASTProb
CASTProblemDeclaration copy = new CASTProblemDeclaration();
return copy(copy, style);
}
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclarations) {

View file

@ -39,7 +39,7 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl
CASTProblemExpression copy = new CASTProblemExpression();
return copy(copy, style);
}
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitExpressions) {
@ -61,7 +61,7 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl
}
return true;
}
@Override
public IType getExpressionType() {
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
@ -71,7 +71,7 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl
public boolean isLValue() {
return false;
}
@Override
public ValueCategory getValueCategory() {
return ValueCategory.PRVALUE;

View file

@ -33,12 +33,12 @@ abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder {
copy.setProblem(problem == null ? null : problem.copy(style));
return super.copy(copy, style);
}
@Override
public IASTProblem getProblem() {
return problem;
}
@Override
public void setProblem(IASTProblem p) {
assertNotFrozen();
@ -48,9 +48,9 @@ abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder {
p.setPropertyInParent(PROBLEM);
}
}
@Override
public boolean accept(ASTVisitor action){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitProblems) {
switch (action.visit(getProblem())) {
case ASTVisitor.PROCESS_ABORT: return false;

View file

@ -42,7 +42,7 @@ public class CASTProblemStatement extends CASTProblemOwner implements IASTProble
CASTProblemStatement copy = new CASTProblemStatement();
return copy(copy, style);
}
@Override
public boolean accept(ASTVisitor action) {
if (action.shouldVisitStatements) {
@ -54,7 +54,7 @@ public class CASTProblemStatement extends CASTProblemOwner implements IASTProble
}
super.accept(action); // visits the problem
if (action.shouldVisitStatements) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;

View file

@ -30,7 +30,7 @@ public class CASTReturnStatement extends ASTAttributeOwner implements IASTReturn
public CASTReturnStatement(IASTExpression retValue) {
setReturnValue(retValue);
}
@Override
public CASTReturnStatement copy() {
return copy(CopyStyle.withoutLocations);

View file

@ -33,7 +33,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
public CASTSimpleDeclSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTSimpleDeclSpecifier copy(CopyStyle style) {
CASTSimpleDeclSpecifier copy = new CASTSimpleDeclSpecifier();
@ -54,7 +54,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
copy.setDeclTypeExpression(fDeclTypeExpression.copy(style));
return super.copy(copy, style);
}
@Override
public int getType() {
return simpleType;
@ -79,18 +79,18 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
public boolean isLong() {
return isLong;
}
@Override
public void setType(int type) {
assertNotFrozen();
simpleType = type;
}
@Override
public void setType(Kind kind) {
setType(getType(kind));
}
private int getType(Kind kind) {
switch (kind) {
case eBoolean:
@ -126,25 +126,25 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
}
return t_unspecified;
}
@Override
public void setShort(boolean value) {
assertNotFrozen();
isShort = value;
}
@Override
public void setLong(boolean value) {
assertNotFrozen();
isLong = value;
}
@Override
public void setUnsigned(boolean value) {
assertNotFrozen();
isUnsigned = value;
}
@Override
public void setSigned(boolean value) {
assertNotFrozen();
@ -163,24 +163,24 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
}
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclSpecifiers ){
switch( action.visit( this ) ){
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
if (!visitAlignmentSpecifiers(action)) {
return false;
}
if (fDeclTypeExpression != null && !fDeclTypeExpression.accept(action))
return false;
if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){
if (action.shouldVisitDeclSpecifiers) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
@ -208,7 +208,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
@Override
public void setImaginary(boolean value) {
assertNotFrozen();
this.imaginary = value;
this.imaginary = value;
}
@Override
@ -225,7 +225,7 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
expression.setParent(this);
}
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (child == fDeclTypeExpression) {

Some files were not shown because too many files have changed in this diff Show more