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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-04-08 22:25:36 -07:00
parent 2ab852ece0
commit 07561ca883
3 changed files with 25 additions and 33 deletions

View file

@ -563,10 +563,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
} }
/** /**
* Parse an identifier. * Parses an identifier.
* *
* @throws BacktrackException * @throws BacktrackException request a backtrack
* request a backtrack
*/ */
protected abstract IASTName identifier() throws EndOfFileException, BacktrackException; protected abstract IASTName identifier() throws EndOfFileException, BacktrackException;
@ -1242,7 +1241,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
} }
IASTCastExpression result = buildCastExpression(IASTCastExpression.op_cast, IASTCastExpression result = buildCastExpression(IASTCastExpression.op_cast,
typeId, rhs, startingOffset, calculateEndOffset(rhs)); typeId, rhs, startingOffset, calculateEndOffset(rhs));
if (!unaryFailed && couldBeFunctionCall && rhs instanceof IASTCastExpression == false) { if (!unaryFailed && couldBeFunctionCall && !(rhs instanceof IASTCastExpression)) {
IToken markEnd= mark(); IToken markEnd= mark();
backup(mark); backup(mark);
try { try {
@ -2164,27 +2163,25 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
return cs; return cs;
} }
protected int figureEndOffset(IASTDeclSpecifier declSpec, IASTDeclarator[] declarators) { protected int figureEndOffset(IASTDeclSpecifier declSpec, IASTDeclarator[] declarators) {
if (declarators.length == 0) if (declarators.length == 0)
return calculateEndOffset(declSpec); return calculateEndOffset(declSpec);
return calculateEndOffset(declarators[declarators.length - 1]); return calculateEndOffset(declarators[declarators.length - 1]);
} }
protected int figureEndOffset(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) { protected int figureEndOffset(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
if (declarator == null || ((ASTNode) declarator).getLength() == 0) if (declarator == null || ((ASTNode) declarator).getLength() == 0)
return calculateEndOffset(declSpecifier); return calculateEndOffset(declSpecifier);
return calculateEndOffset(declarator); return calculateEndOffset(declarator);
} }
protected void throwBacktrack(IToken token) throws BacktrackException { protected void throwBacktrack(IToken token) throws BacktrackException {
throwBacktrack(token.getOffset(), token.getLength()); throwBacktrack(token.getOffset(), token.getLength());
} }
protected IASTExpression parseTypeidInParenthesisOrUnaryExpression(boolean exprIsLimitedToParenthesis, protected IASTExpression parseTypeidInParenthesisOrUnaryExpression(boolean exprIsLimitedToParenthesis,
int offset, int typeExprKind, int unaryExprKind, CastExprCtx ctx, ITemplateIdStrategy strat) throws BacktrackException, EndOfFileException { int offset, int typeExprKind, int unaryExprKind, CastExprCtx ctx, ITemplateIdStrategy strat)
throws BacktrackException, EndOfFileException {
IASTTypeId typeid; IASTTypeId typeid;
IASTExpression expr= null; IASTExpression expr= null;
IToken typeidLA= null; IToken typeidLA= null;
@ -2315,7 +2312,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
} }
/** /**
* Accept a sequence of __attribute__ or __declspec * Accepts a sequence of __attribute__ or __declspec.
* *
* @param allowAttrib if true accept any number of __attribute__ * @param allowAttrib if true accept any number of __attribute__
* @param allowDeclspec if true accept any number of __declspec * @param allowDeclspec if true accept any number of __declspec
@ -2416,7 +2413,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
* @throws EndOfFileException * @throws EndOfFileException
*/ */
protected void handleOtherDeclSpecModifier() throws BacktrackException, EndOfFileException { protected void handleOtherDeclSpecModifier() throws BacktrackException, EndOfFileException {
// default action: consume keyword plus optional parenthesised "something" // default action: consume keyword plus optional parenthesized "something"
consume(); consume();
IToken token = LA(1); IToken token = LA(1);

View file

@ -415,7 +415,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
final IASTDeclarator outerDtor= declarators[0]; final IASTDeclarator outerDtor= declarators[0];
final IASTDeclarator fdtor= ASTQueries.findTypeRelevantDeclarator(outerDtor); final IASTDeclarator fdtor= ASTQueries.findTypeRelevantDeclarator(outerDtor);
if (fdtor instanceof IASTFunctionDeclarator == false) if (!(fdtor instanceof IASTFunctionDeclarator))
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset); throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
IASTFunctionDefinition funcDefinition = nodeFactory.newFunctionDefinition(declSpec, (IASTFunctionDeclarator) fdtor, null); IASTFunctionDefinition funcDefinition = nodeFactory.newFunctionDefinition(declSpec, (IASTFunctionDeclarator) fdtor, null);
@ -1597,7 +1597,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
} }
private IASTSimpleDeclaration checkKnrParameterDeclaration(IASTDeclaration decl, final IASTName[] parmNames) { private IASTSimpleDeclaration checkKnrParameterDeclaration(IASTDeclaration decl, final IASTName[] parmNames) {
if (decl instanceof IASTSimpleDeclaration == false) if (!(decl instanceof IASTSimpleDeclaration))
return null; return null;
IASTSimpleDeclaration declaration= ((IASTSimpleDeclaration) decl); IASTSimpleDeclaration declaration= ((IASTSimpleDeclaration) decl);
@ -1839,7 +1839,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
return parseDeclarationOrExpressionStatement(); return parseDeclarationOrExpressionStatement();
} }
} }
@Override @Override
@ -1863,7 +1862,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
previousWasIdentifier = false; previousWasIdentifier = false;
} else if (LT(1) == IToken.tIDENTIFIER) { } else if (LT(1) == IToken.tIDENTIFIER) {
consume(); consume();
if (previousWasIdentifier == true) { if (previousWasIdentifier) {
backup(mark); backup(mark);
return 0; // i.e. KnR C won't have int f(typedef x) return 0; // i.e. KnR C won't have int f(typedef x)
// char // char
@ -2011,8 +2010,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
if (if_statement != null) { if (if_statement != null) {
if_statement.setElseClause(new_if_statement); if_statement.setElseClause(new_if_statement);
((ASTNode) if_statement) ((ASTNode) if_statement).setLength(calculateEndOffset(new_if_statement)
.setLength(calculateEndOffset(new_if_statement)
- ((ASTNode) if_statement).getOffset()); - ((ASTNode) if_statement).getOffset());
} }
if (result == null && if_statement != null) if (result == null && if_statement != null)
@ -2027,8 +2025,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
new_if_statement.setElseClause(elseStatement); new_if_statement.setElseClause(elseStatement);
if (if_statement != null) { if (if_statement != null) {
if_statement.setElseClause(new_if_statement); if_statement.setElseClause(new_if_statement);
((ASTNode) if_statement) ((ASTNode) if_statement).setLength(calculateEndOffset(new_if_statement)
.setLength(calculateEndOffset(new_if_statement)
- ((ASTNode) if_statement).getOffset()); - ((ASTNode) if_statement).getOffset());
} else { } else {
if (result == null) if (result == null)
@ -2037,12 +2034,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
} }
} else { } else {
if( thenClause != null ) if( thenClause != null )
((ASTNode) new_if_statement) ((ASTNode) new_if_statement).setLength(calculateEndOffset(thenClause) - start);
.setLength(calculateEndOffset(thenClause) - start);
if (if_statement != null) { if (if_statement != null) {
if_statement.setElseClause(new_if_statement); if_statement.setElseClause(new_if_statement);
((ASTNode) new_if_statement) ((ASTNode) new_if_statement).setLength(calculateEndOffset(new_if_statement) - start);
.setLength(calculateEndOffset(new_if_statement) - start);
} }
if (result == null && if_statement != null) if (result == null && if_statement != null)
result = if_statement; result = if_statement;

View file

@ -2454,7 +2454,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
IASTDeclarator outerDtor) throws EndOfFileException, BacktrackException { IASTDeclarator outerDtor) throws EndOfFileException, BacktrackException {
final IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator(outerDtor); final IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator(outerDtor);
if (dtor instanceof ICPPASTFunctionDeclarator == false) if (!(dtor instanceof ICPPASTFunctionDeclarator))
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset); throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);