mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Cosmetics.
This commit is contained in:
parent
860489475c
commit
1f90d6b612
10 changed files with 66 additions and 103 deletions
|
@ -77,11 +77,10 @@ public interface IIndexFile extends IFileNomination {
|
||||||
int getScannerConfigurationHashcode() throws CoreException;
|
int getScannerConfigurationHashcode() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the hash-code of the file encoding that was used to parse the file.
|
|
||||||
* <code>0</code> will be returned in case the hash-code is unknown.
|
|
||||||
* @return the hash-code of the file encoding or <code>0</code>.
|
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
* @deprecated Returns 0.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
int getEncodingHashcode() throws CoreException;
|
int getEncodingHashcode() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.index;
|
package org.eclipse.cdt.core.index;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public interface IIndexInclude {
|
public interface IIndexInclude {
|
||||||
IIndexInclude[] EMPTY_INCLUDES_ARRAY = new IIndexInclude[0];
|
IIndexInclude[] EMPTY_INCLUDES_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file that contains this directive.
|
* Returns the file that contains this directive.
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Mike Kucera (IBM) - bug #206952
|
* Mike Kucera (IBM) - bug #206952
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
// Use to create the completion node
|
// Use to create the completion node
|
||||||
protected ASTCompletionNode createCompletionNode(IToken token) {
|
protected ASTCompletionNode createCompletionNode(IToken token) {
|
||||||
// the preprocessor may deliver tokens for literals or header-names.
|
// the preprocessor may deliver tokens for literals or header-names.
|
||||||
if(completionNode == null && token != null && token.getType() == IToken.tCOMPLETION) {
|
if (completionNode == null && token != null && token.getType() == IToken.tCOMPLETION) {
|
||||||
completionNode = new ASTCompletionNode(token, getTranslationUnit());
|
completionNode = new ASTCompletionNode(token, getTranslationUnit());
|
||||||
}
|
}
|
||||||
return completionNode;
|
return completionNode;
|
||||||
|
@ -585,14 +585,12 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected final IASTProblem createProblem(int signal, int offset, int length) {
|
protected final IASTProblem createProblem(int signal, int offset, int length) {
|
||||||
IASTProblem result = nodeFactory.newProblem(signal, CharArrayUtils.EMPTY, true);
|
IASTProblem result = nodeFactory.newProblem(signal, CharArrayUtils.EMPTY, true);
|
||||||
((ASTNode) result).setOffsetAndLength(offset, length);
|
((ASTNode) result).setOffsetAndLength(offset, length);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void logThrowable(String methodName, Throwable e) {
|
protected void logThrowable(String methodName, Throwable e) {
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
if (log.isTracing()) {
|
if (log.isTracing()) {
|
||||||
|
@ -604,8 +602,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
log.traceException(e);
|
log.traceException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -656,8 +652,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
resolveAmbiguities();
|
resolveAmbiguities();
|
||||||
log.traceLog("Ambiguity resolution : " //$NON-NLS-1$
|
log.traceLog("Ambiguity resolution : " //$NON-NLS-1$
|
||||||
+ (System.currentTimeMillis() - startTime) + "ms" //$NON-NLS-1$
|
+ (System.currentTimeMillis() - startTime) + "ms"); //$NON-NLS-1$
|
||||||
);
|
|
||||||
IASTTranslationUnit result = getTranslationUnit();
|
IASTTranslationUnit result = getTranslationUnit();
|
||||||
nullifyTranslationUnit();
|
nullifyTranslationUnit();
|
||||||
result.freeze(); // make the AST immutable
|
result.freeze(); // make the AST immutable
|
||||||
|
@ -736,7 +731,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
int endOffset;
|
int endOffset;
|
||||||
loop: try {
|
loop: try {
|
||||||
endOffset= LA(1).getOffset();
|
endOffset= LA(1).getOffset();
|
||||||
while(true) {
|
while (true) {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
endOffset= getEndOffset();
|
endOffset= getEndOffset();
|
||||||
|
@ -776,7 +771,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
int depth= 0;
|
int depth= 0;
|
||||||
int endOffset= offset;
|
int endOffset= offset;
|
||||||
loop: try {
|
loop: try {
|
||||||
while(true) {
|
while (true) {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
endOffset= getEndOffset();
|
endOffset= getEndOffset();
|
||||||
|
@ -827,7 +822,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
int endOffset= consume(IToken.tLBRACE).getOffset();
|
int endOffset= consume(IToken.tLBRACE).getOffset();
|
||||||
|
|
||||||
int stmtOffset= -1;
|
int stmtOffset= -1;
|
||||||
while(true) {
|
while (true) {
|
||||||
IToken next= LAcatchEOF(1);
|
IToken next= LAcatchEOF(1);
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
((ASTNode) result).setOffsetAndLength(offset, endOffset-offset);
|
((ASTNode) result).setOffsetAndLength(offset, endOffset-offset);
|
||||||
|
@ -882,7 +877,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private IASTProblemDeclaration buildProblemDeclaration(IASTProblem problem) {
|
private IASTProblemDeclaration buildProblemDeclaration(IASTProblem problem) {
|
||||||
IASTProblemDeclaration pd = nodeFactory.newProblemDeclaration(problem);
|
IASTProblemDeclaration pd = nodeFactory.newProblemDeclaration(problem);
|
||||||
((ASTNode) pd).setOffsetAndLength(((ASTNode) problem));
|
((ASTNode) pd).setOffsetAndLength(((ASTNode) problem));
|
||||||
|
@ -992,7 +986,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
private IASTExpression buildExpression(IASTExpression left, BinaryOperator operator) {
|
private IASTExpression buildExpression(IASTExpression left, BinaryOperator operator) {
|
||||||
int op, unaryOp= 0;
|
int op, unaryOp= 0;
|
||||||
final IASTInitializerClause right= operator.fExpression;
|
final IASTInitializerClause right= operator.fExpression;
|
||||||
switch(operator.fOperatorToken) {
|
switch (operator.fOperatorToken) {
|
||||||
case IToken.tQUESTION:
|
case IToken.tQUESTION:
|
||||||
final IASTInitializerClause negative;
|
final IASTInitializerClause negative;
|
||||||
if (operator.fNext == null || operator.fNext.fOperatorToken != IToken.tCOLON) {
|
if (operator.fNext == null || operator.fNext.fOperatorToken != IToken.tCOLON) {
|
||||||
|
@ -1220,7 +1214,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
consume();
|
consume();
|
||||||
boolean unaryFailed= false;
|
boolean unaryFailed= false;
|
||||||
if (ctx == CastExprCtx.eDirectlyInBExpr) {
|
if (ctx == CastExprCtx.eDirectlyInBExpr) {
|
||||||
switch (LT(1)){
|
switch (LT(1)) {
|
||||||
// ambiguity with unary operator
|
// ambiguity with unary operator
|
||||||
case IToken.tPLUS: case IToken.tMINUS:
|
case IToken.tPLUS: case IToken.tMINUS:
|
||||||
case IToken.tSTAR: case IToken.tAMPER:
|
case IToken.tSTAR: case IToken.tAMPER:
|
||||||
|
@ -1280,8 +1274,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected void translationUnit() {
|
protected void translationUnit() {
|
||||||
try {
|
try {
|
||||||
setupTranslationUnit();
|
setupTranslationUnit();
|
||||||
} catch (Exception e2) {
|
} catch (Exception e) {
|
||||||
logException("translationUnit::createCompilationUnit()", e2); //$NON-NLS-1$
|
logException("translationUnit::createCompilationUnit()", e); //$NON-NLS-1$
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
parseTranslationUnit();
|
parseTranslationUnit();
|
||||||
|
@ -1403,7 +1397,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
if (operator == IASTUnaryExpression.op_star && operand instanceof IASTLiteralExpression) {
|
if (operator == IASTUnaryExpression.op_star && operand instanceof IASTLiteralExpression) {
|
||||||
IASTLiteralExpression lit= (IASTLiteralExpression) operand;
|
IASTLiteralExpression lit= (IASTLiteralExpression) operand;
|
||||||
switch(lit.getKind()) {
|
switch (lit.getKind()) {
|
||||||
case IASTLiteralExpression.lk_char_constant:
|
case IASTLiteralExpression.lk_char_constant:
|
||||||
case IASTLiteralExpression.lk_float_constant:
|
case IASTLiteralExpression.lk_float_constant:
|
||||||
case IASTLiteralExpression.lk_integer_constant:
|
case IASTLiteralExpression.lk_integer_constant:
|
||||||
|
@ -1423,7 +1417,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected IASTStatement handleFunctionBody() throws BacktrackException, EndOfFileException {
|
protected IASTStatement handleFunctionBody() throws BacktrackException, EndOfFileException {
|
||||||
declarationMark= null;
|
declarationMark= null;
|
||||||
if (mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE || !isActiveCode()) {
|
if (mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE || !isActiveCode()) {
|
||||||
|
@ -1449,7 +1442,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
/**
|
/**
|
||||||
* Parses a function body.
|
* Parses a function body.
|
||||||
*
|
*
|
||||||
* @return TODO
|
* @return the compound statement representing the function body.
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* request a backtrack
|
* request a backtrack
|
||||||
*/
|
*/
|
||||||
|
@ -1579,7 +1572,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return !parsePassed;
|
return !parsePassed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException;
|
protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1603,7 +1595,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
// support simple declarations without declarators
|
// support simple declarations without declarators
|
||||||
final boolean acceptEmpty = acceptCompoundWithoutDtor && isLegalWithoutDtor(result.fDeclSpec1);
|
final boolean acceptEmpty = acceptCompoundWithoutDtor && isLegalWithoutDtor(result.fDeclSpec1);
|
||||||
if (acceptEmpty) {
|
if (acceptEmpty) {
|
||||||
switch(lt1) {
|
switch (lt1) {
|
||||||
case 0:
|
case 0:
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
case IToken.tSEMI:
|
case IToken.tSEMI:
|
||||||
|
@ -1698,7 +1690,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
if (declarationMark != null) {
|
if (declarationMark != null) {
|
||||||
backup(declarationMark);
|
backup(declarationMark);
|
||||||
// avoid creating an empty declaration
|
// avoid creating an empty declaration
|
||||||
switch(LTcatchEOF(1)) {
|
switch (LTcatchEOF(1)) {
|
||||||
case 0: // eof
|
case 0: // eof
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
case IToken.tSEMI:
|
case IToken.tSEMI:
|
||||||
|
@ -1751,7 +1743,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return buildASMDirective(offset, buffer.toString(), lastOffset);
|
return buildASMDirective(offset, buffer.toString(), lastOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected IASTDeclaration functionStyleAsmDeclaration() throws BacktrackException, EndOfFileException {
|
protected IASTDeclaration functionStyleAsmDeclaration() throws BacktrackException, EndOfFileException {
|
||||||
final int offset= LA(1).getOffset();
|
final int offset= LA(1).getOffset();
|
||||||
IASTDeclSpecifier declSpec;
|
IASTDeclSpecifier declSpec;
|
||||||
|
@ -1803,7 +1794,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
int open= 1;
|
int open= 1;
|
||||||
while (open > 0) {
|
while (open > 0) {
|
||||||
t= consume();
|
t= consume();
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tLPAREN:
|
case IToken.tLPAREN:
|
||||||
open++;
|
open++;
|
||||||
break;
|
break;
|
||||||
|
@ -1948,9 +1939,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
* in this case the type defaults to int and is know as "implicit int".
|
* in this case the type defaults to int and is know as "implicit int".
|
||||||
*/
|
*/
|
||||||
protected static boolean isImplicitInt(IASTDeclaration declaration) {
|
protected static boolean isImplicitInt(IASTDeclaration declaration) {
|
||||||
if(declaration instanceof IASTSimpleDeclaration) {
|
if (declaration instanceof IASTSimpleDeclaration) {
|
||||||
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)declaration).getDeclSpecifier();
|
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)declaration).getDeclSpecifier();
|
||||||
if(declSpec instanceof IASTSimpleDeclSpecifier &&
|
if (declSpec instanceof IASTSimpleDeclSpecifier &&
|
||||||
((IASTSimpleDeclSpecifier)declSpec).getType() == IASTSimpleDeclSpecifier.t_unspecified) {
|
((IASTSimpleDeclSpecifier)declSpec).getType() == IASTSimpleDeclSpecifier.t_unspecified) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1966,7 +1957,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
IASTName name = identifier(); // tIDENTIFIER
|
IASTName name = identifier(); // tIDENTIFIER
|
||||||
consume(IToken.tCOLON); // tCOLON
|
consume(IToken.tCOLON); // tCOLON
|
||||||
IASTStatement nestedStatement = statement();
|
IASTStatement nestedStatement = statement();
|
||||||
int lastOffset = calculateEndOffset( nestedStatement );
|
int lastOffset = calculateEndOffset(nestedStatement);
|
||||||
|
|
||||||
|
|
||||||
IASTLabelStatement label_statement = nodeFactory.newLabelStatement(name, nestedStatement);
|
IASTLabelStatement label_statement = nodeFactory.newLabelStatement(name, nestedStatement);
|
||||||
|
@ -2208,7 +2199,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
if (!isValidTypeIDForUnaryExpression(unaryExprKind, typeid)) {
|
if (!isValidTypeIDForUnaryExpression(unaryExprKind, typeid)) {
|
||||||
typeid= null;
|
typeid= null;
|
||||||
} else {
|
} else {
|
||||||
switch(LT(1)) {
|
switch (LT(1)) {
|
||||||
case IToken.tRPAREN:
|
case IToken.tRPAREN:
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
endOffset1= consume().getEndOffset();
|
endOffset1= consume().getEndOffset();
|
||||||
|
@ -2309,7 +2300,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected abstract IASTAmbiguousExpression createAmbiguousCastVsFunctionCallExpression(IASTCastExpression castExpr, IASTFunctionCallExpression funcCall);
|
protected abstract IASTAmbiguousExpression createAmbiguousCastVsFunctionCallExpression(IASTCastExpression castExpr, IASTFunctionCallExpression funcCall);
|
||||||
|
|
||||||
protected IASTStatement forInitStatement() throws BacktrackException, EndOfFileException {
|
protected IASTStatement forInitStatement() throws BacktrackException, EndOfFileException {
|
||||||
if( LT(1) == IToken.tSEMI )
|
if (LT(1) == IToken.tSEMI)
|
||||||
return parseNullStatement();
|
return parseNullStatement();
|
||||||
try {
|
try {
|
||||||
return parseDeclarationOrExpressionStatement();
|
return parseDeclarationOrExpressionStatement();
|
||||||
|
@ -2334,7 +2325,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected void __attribute_decl_seq(boolean allowAttrib, boolean allowDeclspec) throws BacktrackException, EndOfFileException {
|
protected void __attribute_decl_seq(boolean allowAttrib, boolean allowDeclspec) throws BacktrackException, EndOfFileException {
|
||||||
while (true) {
|
while (true) {
|
||||||
final int lt = LTcatchEOF(1);
|
final int lt = LTcatchEOF(1);
|
||||||
if ( allowAttrib && (lt == IGCCToken.t__attribute__)) {
|
if (allowAttrib && (lt == IGCCToken.t__attribute__)) {
|
||||||
__attribute__();
|
__attribute__();
|
||||||
} else if (allowDeclspec && (lt == IGCCToken.t__declspec)) {
|
} else if (allowDeclspec && (lt == IGCCToken.t__declspec)) {
|
||||||
__declspec();
|
__declspec();
|
||||||
|
@ -2433,7 +2424,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
if (token.getType() == IToken.tLPAREN) {
|
if (token.getType() == IToken.tLPAREN) {
|
||||||
consume();
|
consume();
|
||||||
int openParen= 1;
|
int openParen= 1;
|
||||||
while(true) {
|
while (true) {
|
||||||
token = LA(1);
|
token = LA(1);
|
||||||
consume();
|
consume();
|
||||||
if (token.getType() == IToken.tLPAREN) {
|
if (token.getType() == IToken.tLPAREN) {
|
||||||
|
@ -2573,7 +2564,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected void skipBrackets(int left, int right, int terminator) throws EndOfFileException, BacktrackException {
|
protected void skipBrackets(int left, int right, int terminator) throws EndOfFileException, BacktrackException {
|
||||||
consume(left);
|
consume(left);
|
||||||
int nesting= 0;
|
int nesting= 0;
|
||||||
while(true) {
|
while (true) {
|
||||||
final int lt1= LT(1);
|
final int lt1= LT(1);
|
||||||
if (lt1 == IToken.tEOC || lt1 == terminator)
|
if (lt1 == IToken.tEOC || lt1 == terminator)
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
|
|
|
@ -6,12 +6,15 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeOrFunctionSet;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeOrFunctionSet;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -59,7 +62,8 @@ class BuiltinOperators {
|
||||||
private static final int SECOND = 1;
|
private static final int SECOND = 1;
|
||||||
private static final IType PTR_DIFF = new CPPBasicType(Kind.eInt, 0);
|
private static final IType PTR_DIFF = new CPPBasicType(Kind.eInt, 0);
|
||||||
|
|
||||||
public static ICPPFunction[] create(OverloadableOperator operator, IASTInitializerClause[] args, IASTTranslationUnit tu, Object[] globCandidates) {
|
public static ICPPFunction[] create(OverloadableOperator operator, IASTInitializerClause[] args,
|
||||||
|
IASTTranslationUnit tu, Object[] globCandidates) {
|
||||||
if (operator == null || args == null || args.length == 0)
|
if (operator == null || args == null || args.length == 0)
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
|
|
||||||
|
@ -70,14 +74,15 @@ class BuiltinOperators {
|
||||||
private final boolean fUnary;
|
private final boolean fUnary;
|
||||||
private IType fType1;
|
private IType fType1;
|
||||||
private IType fType2;
|
private IType fType2;
|
||||||
private IType[][] fClassConversionTypes= {null, null};
|
private IType[][] fClassConversionTypes= { null, null };
|
||||||
private boolean[] fIsClass= {false,false};
|
private boolean[] fIsClass= { false, false };
|
||||||
private IScope fFileScope;
|
private IScope fFileScope;
|
||||||
private List<ICPPFunction> fResult;
|
private List<ICPPFunction> fResult;
|
||||||
private Set<String> fSignatures;
|
private Set<String> fSignatures;
|
||||||
private Object[] fGlobalCandidates;
|
private Object[] fGlobalCandidates;
|
||||||
|
|
||||||
BuiltinOperators(OverloadableOperator operator, IASTInitializerClause[] args, IScope fileScope, Object[] globCandidates) {
|
BuiltinOperators(OverloadableOperator operator, IASTInitializerClause[] args, IScope fileScope,
|
||||||
|
Object[] globCandidates) {
|
||||||
fFileScope= fileScope;
|
fFileScope= fileScope;
|
||||||
fOperator= operator;
|
fOperator= operator;
|
||||||
fUnary= args.length<2;
|
fUnary= args.length<2;
|
||||||
|
@ -97,7 +102,7 @@ class BuiltinOperators {
|
||||||
|
|
||||||
|
|
||||||
private ICPPFunction[] create() {
|
private ICPPFunction[] create() {
|
||||||
switch(fOperator) {
|
switch (fOperator) {
|
||||||
case ARROW:
|
case ARROW:
|
||||||
case COMMA:
|
case COMMA:
|
||||||
case DELETE:
|
case DELETE:
|
||||||
|
@ -390,7 +395,7 @@ class BuiltinOperators {
|
||||||
for (IType t1 : p1) {
|
for (IType t1 : p1) {
|
||||||
for (IType t2 : p2) {
|
for (IType t2 : p2) {
|
||||||
IType rt= null;
|
IType rt= null;
|
||||||
switch(rstrat) {
|
switch (rstrat) {
|
||||||
case USE_BOOL:
|
case USE_BOOL:
|
||||||
rt= CPPBasicType.BOOLEAN;
|
rt= CPPBasicType.BOOLEAN;
|
||||||
break;
|
break;
|
||||||
|
@ -491,7 +496,7 @@ class BuiltinOperators {
|
||||||
if (refType instanceof ICPPReferenceType) {
|
if (refType instanceof ICPPReferenceType) {
|
||||||
IType t= SemanticUtil.getNestedType(((ICPPReferenceType) refType).getType(), TDEF);
|
IType t= SemanticUtil.getNestedType(((ICPPReferenceType) refType).getType(), TDEF);
|
||||||
if (!SemanticUtil.getCVQualifier(t).isConst()) {
|
if (!SemanticUtil.getCVQualifier(t).isConst()) {
|
||||||
switch(assign) {
|
switch (assign) {
|
||||||
case WITHOUT_OPERATION:
|
case WITHOUT_OPERATION:
|
||||||
if (isEnumeration(t) || isPointerToMember(t) || isPointer(t)) {
|
if (isEnumeration(t) || isPointerToMember(t) || isPointer(t)) {
|
||||||
addFunction(refType, refType, SemanticUtil.getNestedType(t, TDEF|ALLCVQ));
|
addFunction(refType, refType, SemanticUtil.getNestedType(t, TDEF|ALLCVQ));
|
||||||
|
@ -592,7 +597,7 @@ class BuiltinOperators {
|
||||||
private boolean isFloatingPoint(IType type) {
|
private boolean isFloatingPoint(IType type) {
|
||||||
if (type instanceof IBasicType) {
|
if (type instanceof IBasicType) {
|
||||||
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
||||||
switch(kind) {
|
switch (kind) {
|
||||||
case eDouble:
|
case eDouble:
|
||||||
case eFloat:
|
case eFloat:
|
||||||
return true;
|
return true;
|
||||||
|
@ -613,7 +618,7 @@ class BuiltinOperators {
|
||||||
private boolean isArithmetic(IType type) {
|
private boolean isArithmetic(IType type) {
|
||||||
if (type instanceof IBasicType) {
|
if (type instanceof IBasicType) {
|
||||||
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
||||||
switch(kind) {
|
switch (kind) {
|
||||||
case eBoolean:
|
case eBoolean:
|
||||||
case eChar:
|
case eChar:
|
||||||
case eChar16:
|
case eChar16:
|
||||||
|
@ -634,7 +639,7 @@ class BuiltinOperators {
|
||||||
private boolean isIntegral(IType type) {
|
private boolean isIntegral(IType type) {
|
||||||
if (type instanceof IBasicType) {
|
if (type instanceof IBasicType) {
|
||||||
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
||||||
switch(kind) {
|
switch (kind) {
|
||||||
case eBoolean:
|
case eBoolean:
|
||||||
case eChar:
|
case eChar:
|
||||||
case eChar16:
|
case eChar16:
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.indexer;
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
return new File(URIUtil.toPath(location.getURI()).toOSString()).lastModified();
|
return new File(URIUtil.toPath(location.getURI()).toOSString()).lastModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getEncoding(IIndexFileLocation ifl) {
|
public String getEncoding(IIndexFileLocation ifl) {
|
||||||
String encoding= getFileEncoding(getASTPath(ifl));
|
String encoding= getFileEncoding(getASTPath(ifl));
|
||||||
|
@ -116,7 +115,6 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doesIncludeFileExist(String includePath) {
|
public boolean doesIncludeFileExist(String includePath) {
|
||||||
return fExistsCache.isFile(includePath);
|
return fExistsCache.isFile(includePath);
|
||||||
|
@ -182,7 +180,7 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
public AbstractLanguage[] getLanguages(Object tu, UnusedHeaderStrategy strat) {
|
public AbstractLanguage[] getLanguages(Object tu, UnusedHeaderStrategy strat) {
|
||||||
ILanguage language = fIndexer.getLanguageMapper().getLanguage(tu.toString());
|
ILanguage language = fIndexer.getLanguageMapper().getLanguage(tu.toString());
|
||||||
if (language instanceof AbstractLanguage) {
|
if (language instanceof AbstractLanguage) {
|
||||||
return new AbstractLanguage[] {(AbstractLanguage) language};
|
return new AbstractLanguage[] { (AbstractLanguage) language };
|
||||||
}
|
}
|
||||||
return new AbstractLanguage[0];
|
return new AbstractLanguage[0];
|
||||||
}
|
}
|
||||||
|
@ -199,5 +197,4 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
||||||
public boolean isCaseInsensitiveFileSystem() {
|
public boolean isCaseInsensitiveFileSystem() {
|
||||||
return new File("a").equals(new File("A"));
|
return new File("a").equals(new File("A"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.indexer;
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ import com.ibm.icu.text.MessageFormat;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
|
|
||||||
protected StandaloneIndexer fIndexer;
|
protected StandaloneIndexer fIndexer;
|
||||||
protected IParserLogService fLogger;
|
protected IParserLogService fLogger;
|
||||||
|
|
||||||
|
@ -47,7 +46,8 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID, ILinkage.FORTRAN_LINKAGE_ID
|
ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID, ILinkage.FORTRAN_LINKAGE_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
protected StandaloneIndexerTask(StandaloneIndexer indexer, Collection<String> added, Collection<String> changed, Collection<String> removed, boolean isFast) {
|
protected StandaloneIndexerTask(StandaloneIndexer indexer, Collection<String> added,
|
||||||
|
Collection<String> changed, Collection<String> removed, boolean isFast) {
|
||||||
super(concat(added, changed), removed.toArray(), new StandaloneIndexerInputAdapter(indexer), isFast);
|
super(concat(added, changed), removed.toArray(), new StandaloneIndexerInputAdapter(indexer), isFast);
|
||||||
fIndexer= indexer;
|
fIndexer= indexer;
|
||||||
setShowActivity(fIndexer.getShowActivity());
|
setShowActivity(fIndexer.getShowActivity());
|
||||||
|
@ -57,8 +57,7 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
if (getIndexAllFiles()) {
|
if (getIndexAllFiles()) {
|
||||||
setIndexFilesWithoutBuildConfiguration(true);
|
setIndexFilesWithoutBuildConfiguration(true);
|
||||||
setIndexHeadersWithoutContext(UnusedHeaderStrategy.useDefaultLanguage);
|
setIndexHeadersWithoutContext(UnusedHeaderStrategy.useDefaultLanguage);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setIndexFilesWithoutBuildConfiguration(false);
|
setIndexFilesWithoutBuildConfiguration(false);
|
||||||
setIndexHeadersWithoutContext(UnusedHeaderStrategy.skip);
|
setIndexHeadersWithoutContext(UnusedHeaderStrategy.skip);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +103,6 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
protected final IWritableIndex createIndex() {
|
protected final IWritableIndex createIndex() {
|
||||||
return fIndexer.getIndex();
|
return fIndexer.getIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void run(IProgressMonitor monitor) throws InterruptedException {
|
public final void run(IProgressMonitor monitor) throws InterruptedException {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
@ -160,33 +158,22 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#createStatus(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected IStatus createStatus(String msg) {
|
protected IStatus createStatus(String msg) {
|
||||||
return new Status(IStatus.ERROR, "org.eclipse.cdt.core", msg, null); //$NON-NLS-1$
|
return new Status(IStatus.ERROR, "org.eclipse.cdt.core", msg, null); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.PDOMWriter#createStatus(java.lang.String, java.lang.Throwable)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected IStatus createStatus(String msg, Throwable e) {
|
protected IStatus createStatus(String msg, Throwable e) {
|
||||||
return new Status(IStatus.ERROR, "org.eclipse.cdt.core", msg, e); //$NON-NLS-1$
|
return new Status(IStatus.ERROR, "org.eclipse.cdt.core", msg, e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#getMessage(org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask.MessageKind, java.lang.Object[])
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected String getMessage(MessageKind kind, Object... arguments) {
|
protected String getMessage(MessageKind kind, Object... arguments) {
|
||||||
// unfortunately we don't have OSGi on the remote system so for now we'll just settle for
|
// Unfortunately we don't have OSGi on the remote system so for now we'll just settle for
|
||||||
// English strings
|
// English strings
|
||||||
// TODO: find a way to do non-OSGi NLS
|
// TODO: find a way to do non-OSGi NLS
|
||||||
switch(kind) {
|
switch (kind) {
|
||||||
case parsingFileTask:
|
case parsingFileTask:
|
||||||
return MessageFormat.format("parsing {0} ({1})", arguments); //$NON-NLS-1$
|
return MessageFormat.format("parsing {0} ({1})", arguments); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -200,9 +187,6 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#getLogService()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected IParserLogService getLogService() {
|
protected IParserLogService getLogService() {
|
||||||
if (fLogger != null)
|
if (fLogger != null)
|
||||||
|
@ -214,36 +198,23 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
fLogger = logService;
|
fLogger = logService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#logError(org.eclipse.core.runtime.IStatus)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void logError(IStatus s) {
|
protected void logError(IStatus s) {
|
||||||
trace(s.getMessage());
|
trace(s.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#logException(java.lang.Throwable)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void logException(Throwable e) {
|
protected void logException(Throwable e) {
|
||||||
trace(e.getMessage());
|
trace(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask#getLinkagesToParse()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected int[] getLinkagesToParse() {
|
protected int[] getLinkagesToParse() {
|
||||||
return IDS_FOR_LINKAGES_TO_INDEX;
|
return IDS_FOR_LINKAGES_TO_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.pdom.PDOMWriter#trace(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void trace(String message) {
|
protected void trace(String message) {
|
||||||
getLogService().traceLog(message);
|
getLogService().traceLog(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
* Abstract class for resolving paths as computed by the parser.
|
* Abstract class for resolving paths as computed by the parser.
|
||||||
*/
|
*/
|
||||||
public abstract class ASTFilePathResolver {
|
public abstract class ASTFilePathResolver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve a path as stored in the AST.
|
* Resolve a path as stored in the AST.
|
||||||
* @return an index file location.
|
* @return an index file location.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ public abstract class IndexerInputAdapter extends ASTFilePathResolver {
|
||||||
* Returns a code reader for the given input file.
|
* Returns a code reader for the given input file.
|
||||||
*/
|
*/
|
||||||
public abstract FileContent getCodeReader(Object tu);
|
public abstract FileContent getCodeReader(Object tu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the encoding for the file.
|
* Returns the encoding for the file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
return new IIndexInclude[0];
|
return IIndexInclude.EMPTY_INCLUDES_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexInclude[] findIncludesTo(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
|
public IIndexInclude[] findIncludesTo(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
|
||||||
|
@ -199,6 +199,6 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
return new IIndexInclude[0];
|
return IIndexInclude.EMPTY_INCLUDES_ARRAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue