mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Fixed Bug 43987 : Search results: Declaration of class not highlighted when selected Fixed Bug 43997 : Search results: selection includes preceding whitespace Fixed Bug 44034 : Scanner failure on #undef
This commit is contained in:
parent
c570364866
commit
9b33f17d3f
10 changed files with 72 additions and 57 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-10-01 John Camelon
|
||||||
|
Fixed Bug 43987 : Search results: Declaration of class not highlighted when selected
|
||||||
|
Fixed Bug 43997 : Search results: selection includes preceding whitespace
|
||||||
|
Fixed Bug 44034 : Scanner failure on #undef
|
||||||
|
|
||||||
2003-10-01 Bogdan Gheorghe
|
2003-10-01 Bogdan Gheorghe
|
||||||
Modified CDT log dump in Parser.fetchToken to include error message
|
Modified CDT log dump in Parser.fetchToken to include error message
|
||||||
|
|
||||||
|
|
|
@ -32,4 +32,6 @@ public interface ITokenDuple {
|
||||||
|
|
||||||
public abstract ITokenDuple getSubrange( int startIndex, int endIndex );
|
public abstract ITokenDuple getSubrange( int startIndex, int endIndex );
|
||||||
public IToken getToken(int index);
|
public IToken getToken(int index);
|
||||||
|
|
||||||
|
public int findLastTokenType( int type );
|
||||||
}
|
}
|
|
@ -33,7 +33,6 @@ public class ScannerException extends Exception {
|
||||||
public static final ErrorCode BAD_HEXIDECIMAL_FORMAT = new ErrorCode( 7 );
|
public static final ErrorCode BAD_HEXIDECIMAL_FORMAT = new ErrorCode( 7 );
|
||||||
public static final ErrorCode INVALID_PREPROCESSOR_DIRECTIVE = new ErrorCode( 8 );
|
public static final ErrorCode INVALID_PREPROCESSOR_DIRECTIVE = new ErrorCode( 8 );
|
||||||
public static final ErrorCode ATTEMPTED_REDEFINITION = new ErrorCode( 9 );
|
public static final ErrorCode ATTEMPTED_REDEFINITION = new ErrorCode( 9 );
|
||||||
public static final ErrorCode UNDEF_DEFINITION_NOT_FOUND = new ErrorCode( 10 );
|
|
||||||
public static final ErrorCode INVALID_ESCAPE_CHARACTER_SEQUENCE = new ErrorCode( 11 );
|
public static final ErrorCode INVALID_ESCAPE_CHARACTER_SEQUENCE = new ErrorCode( 11 );
|
||||||
public static final ErrorCode EXPRESSION_EVALUATION_ERROR = new ErrorCode( 12 );
|
public static final ErrorCode EXPRESSION_EVALUATION_ERROR = new ErrorCode( 12 );
|
||||||
public static final ErrorCode UNEXPECTED_EOF = new ErrorCode(13);
|
public static final ErrorCode UNEXPECTED_EOF = new ErrorCode(13);
|
||||||
|
@ -82,7 +81,6 @@ public class ScannerException extends Exception {
|
||||||
this == ErrorCode.UNEXPECTED_EOF ||
|
this == ErrorCode.UNEXPECTED_EOF ||
|
||||||
this == ErrorCode.MACRO_USAGE_ERROR ||
|
this == ErrorCode.MACRO_USAGE_ERROR ||
|
||||||
this == ErrorCode.MACRO_PASTING_ERROR ||
|
this == ErrorCode.MACRO_PASTING_ERROR ||
|
||||||
this == ErrorCode.UNDEF_DEFINITION_NOT_FOUND ||
|
|
||||||
this == ErrorCode.EXPRESSION_EVALUATION_ERROR ||
|
this == ErrorCode.EXPRESSION_EVALUATION_ERROR ||
|
||||||
this == ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE ||
|
this == ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE ||
|
||||||
this == ErrorCode.ATTEMPTED_REDEFINITION )
|
this == ErrorCode.ATTEMPTED_REDEFINITION )
|
||||||
|
@ -114,7 +112,6 @@ public class ScannerException extends Exception {
|
||||||
errorMessages.put( ErrorCode.DEFINITION_NOT_FOUND, "Definition not found: " );
|
errorMessages.put( ErrorCode.DEFINITION_NOT_FOUND, "Definition not found: " );
|
||||||
errorMessages.put( ErrorCode.MALFORMED_MACRO_DEFN, "Macro definition malformed: " );
|
errorMessages.put( ErrorCode.MALFORMED_MACRO_DEFN, "Macro definition malformed: " );
|
||||||
errorMessages.put( ErrorCode.ATTEMPTED_REDEFINITION, "" );
|
errorMessages.put( ErrorCode.ATTEMPTED_REDEFINITION, "" );
|
||||||
errorMessages.put( ErrorCode.UNDEF_DEFINITION_NOT_FOUND, "" );
|
|
||||||
errorMessages.put( ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, "" );
|
errorMessages.put( ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, "" );
|
||||||
errorMessages.put( ErrorCode.EXPRESSION_EVALUATION_ERROR, "" );
|
errorMessages.put( ErrorCode.EXPRESSION_EVALUATION_ERROR, "" );
|
||||||
errorMessages.put( ErrorCode.MACRO_USAGE_ERROR, "" );
|
errorMessages.put( ErrorCode.MACRO_USAGE_ERROR, "" );
|
||||||
|
|
|
@ -132,7 +132,7 @@ public interface IASTFactory
|
||||||
boolean isUnsigned, boolean isTypename) throws ASTSemanticException, Exception;
|
boolean isUnsigned, boolean isTypename) throws ASTSemanticException, Exception;
|
||||||
public IASTFunction createFunction(
|
public IASTFunction createFunction(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String name,
|
ITokenDuple name,
|
||||||
List parameters,
|
List parameters,
|
||||||
IASTAbstractDeclaration returnType,
|
IASTAbstractDeclaration returnType,
|
||||||
IASTExceptionSpecification exception,
|
IASTExceptionSpecification exception,
|
||||||
|
|
|
@ -503,7 +503,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
{
|
{
|
||||||
return astFactory.createFunction(
|
return astFactory.createFunction(
|
||||||
scope,
|
scope,
|
||||||
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
|
nested ? declarator.getOwnedDeclarator().getNamedDuple() : declarator.getNamedDuple(),
|
||||||
createParameterList(declarator.getParameters()),
|
createParameterList(declarator.getParameters()),
|
||||||
astFactory.createAbstractDeclaration(
|
astFactory.createAbstractDeclaration(
|
||||||
constt,
|
constt,
|
||||||
|
|
|
@ -2602,7 +2602,7 @@ public class Parser implements IParser
|
||||||
access,
|
access,
|
||||||
classKey.getOffset(),
|
classKey.getOffset(),
|
||||||
duple == null ? classKey.getOffset() : duple.getFirstToken().getOffset(),
|
duple == null ? classKey.getOffset() : duple.getFirstToken().getOffset(),
|
||||||
duple == null ? classKey.getEndOffset() : duple.getFirstToken().getOffset() );
|
duple == null ? classKey.getEndOffset() : duple.getFirstToken().getEndOffset() );
|
||||||
}
|
}
|
||||||
catch (ASTSemanticException e)
|
catch (ASTSemanticException e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1047,8 +1047,7 @@ public class Scanner implements IScanner {
|
||||||
// definition
|
// definition
|
||||||
String toBeUndefined = getNextIdentifier();
|
String toBeUndefined = getNextIdentifier();
|
||||||
|
|
||||||
if( ( definitions.remove(toBeUndefined) == null ) && mode == ParserMode.COMPLETE_PARSE )
|
definitions.remove(toBeUndefined);
|
||||||
throw new ScannerException( ScannerException.ErrorCode.UNDEF_DEFINITION_NOT_FOUND, toBeUndefined, getCurrentFile(), getCurrentOffset() );
|
|
||||||
|
|
||||||
skipOverTextUntilNewline();
|
skipOverTextUntilNewline();
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
|
|
@ -153,5 +153,24 @@ public class TokenDuple implements ITokenDuple {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#findLastTokenType(int)
|
||||||
|
*/
|
||||||
|
public int findLastTokenType(int type)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
int lastFound = -1;
|
||||||
|
Iterator i = iterator();
|
||||||
|
while( i.hasNext() )
|
||||||
|
{
|
||||||
|
IToken token = (IToken)i.next();
|
||||||
|
if( token.getType() == type )
|
||||||
|
lastFound = count;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastFound;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1418,7 +1418,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
*/
|
*/
|
||||||
public IASTFunction createFunction(
|
public IASTFunction createFunction(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String name,
|
ITokenDuple name,
|
||||||
List parameters,
|
List parameters,
|
||||||
IASTAbstractDeclaration returnType,
|
IASTAbstractDeclaration returnType,
|
||||||
IASTExceptionSpecification exception,
|
IASTExceptionSpecification exception,
|
||||||
|
@ -1441,43 +1441,15 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
IContainerSymbol ownerScope = scopeToSymbol( scope );
|
||||||
|
|
||||||
// check if this is a method in a body file
|
// check if this is a method in a body file
|
||||||
StringTokenizer tokenizer = new StringTokenizer(name,DOUBLE_COLON);
|
Iterator tokenizer = name.iterator();
|
||||||
int tokencount = tokenizer.countTokens();
|
if(name.length() > 1){
|
||||||
if(tokencount > 1){
|
IContainerSymbol parentScope = (IContainerSymbol)
|
||||||
List tokens = new ArrayList();
|
lookupQualifiedName(
|
||||||
String oneToken = "";
|
ownerScope,
|
||||||
// This is NOT a function. This is a method definition
|
name.getSubrange( 0, name.findLastTokenType( IToken.tCOLONCOLON ) - 1),
|
||||||
while (tokenizer.hasMoreTokens()){
|
references,
|
||||||
oneToken = tokenizer.nextToken();
|
false );
|
||||||
tokens.add(oneToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
String functionName = oneToken;
|
|
||||||
// String parentName = name.substring(0, name.lastIndexOf(DOUBLE_COLON));
|
|
||||||
|
|
||||||
int numOfTokens = 1;
|
|
||||||
int offset = nameOffset;
|
|
||||||
IContainerSymbol parentScope = ownerScope;
|
|
||||||
Iterator i = tokens.iterator();
|
|
||||||
while (i.hasNext() && (numOfTokens++) < tokens.size()){
|
|
||||||
String token = (String) i.next();
|
|
||||||
IContainerSymbol parentSymbol =
|
|
||||||
(IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_class, null, offset, references, false);
|
|
||||||
if(parentSymbol == null){
|
|
||||||
parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_namespace, null, offset, references, false);
|
|
||||||
}
|
|
||||||
if(parentSymbol == null){
|
|
||||||
parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_struct, null, offset, references, false);
|
|
||||||
}
|
|
||||||
if(parentSymbol == null){
|
|
||||||
parentSymbol = (IContainerSymbol) lookupQualifiedName(parentScope, token, TypeInfo.t_union, null, offset, references, false);
|
|
||||||
} if(parentSymbol == null)
|
|
||||||
break;
|
|
||||||
else {
|
|
||||||
parentScope = parentSymbol;
|
|
||||||
offset += token.length()+ DOUBLE_COLON.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if((parentScope != null) &&
|
if((parentScope != null) &&
|
||||||
( (parentScope.getType() == TypeInfo.t_class)
|
( (parentScope.getType() == TypeInfo.t_class)
|
||||||
|
@ -1485,14 +1457,35 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
|| (parentScope.getType() == TypeInfo.t_union))
|
|| (parentScope.getType() == TypeInfo.t_union))
|
||||||
){
|
){
|
||||||
IASTScope methodParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration();
|
IASTScope methodParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration();
|
||||||
return createMethod(methodParentScope, functionName,nameEndOffset, parameters, returnType,
|
ITokenDuple newName = name.getSubrange(
|
||||||
exception, isInline, isFriend, isStatic, startOffset, offset,
|
name.findLastTokenType( IToken.tCOLONCOLON) + 1,
|
||||||
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
name.length() - 1 );
|
||||||
ASTAccessVisibility.PRIVATE, constructorChain, references, isFunctionDefinition);
|
return createMethod(
|
||||||
|
methodParentScope,
|
||||||
|
newName.toString(),
|
||||||
|
parameters,
|
||||||
|
returnType,
|
||||||
|
exception,
|
||||||
|
isInline,
|
||||||
|
isFriend,
|
||||||
|
isStatic,
|
||||||
|
startOffset,
|
||||||
|
newName.getFirstToken().getOffset(),
|
||||||
|
nameEndOffset,
|
||||||
|
ownerTemplate,
|
||||||
|
isConst,
|
||||||
|
isVolatile,
|
||||||
|
isVirtual,
|
||||||
|
isExplicit,
|
||||||
|
isPureVirtual,
|
||||||
|
ASTAccessVisibility.PRIVATE,
|
||||||
|
constructorChain,
|
||||||
|
references,
|
||||||
|
isFunctionDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name, TypeInfo.t_function );
|
IParameterizedSymbol symbol = pst.newParameterizedSymbol( name.getLastToken().getImage(), TypeInfo.t_function );
|
||||||
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
setFunctionTypeInfoBits(isInline, isFriend, isStatic, symbol);
|
||||||
|
|
||||||
setParameter( symbol, returnType, false, references );
|
setParameter( symbol, returnType, false, references );
|
||||||
|
@ -1514,7 +1507,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IParameterizedSymbol functionDeclaration = null;
|
IParameterizedSymbol functionDeclaration = null;
|
||||||
|
|
||||||
functionDeclaration =
|
functionDeclaration =
|
||||||
(IParameterizedSymbol) lookupQualifiedName(ownerScope, name, TypeInfo.t_function, functionParameters, 0, new ArrayList(), false);
|
(IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getLastToken().getImage(), TypeInfo.t_function, functionParameters, 0, new ArrayList(), false);
|
||||||
|
|
||||||
if( functionDeclaration != null )
|
if( functionDeclaration != null )
|
||||||
{
|
{
|
||||||
|
@ -1741,8 +1734,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
boolean isPureVirtual,
|
boolean isPureVirtual,
|
||||||
ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
|
ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
return createMethod(scope, name, nameEndOffset, parameters, returnType,
|
return createMethod(scope, name, parameters, returnType, exception,
|
||||||
exception, isInline, isFriend, isStatic, startOffset, nameOffset,
|
isInline, isFriend, isStatic, startOffset, nameOffset, nameEndOffset,
|
||||||
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
|
||||||
visibility, constructorChain, null, isFunctionDefinition );
|
visibility, constructorChain, null, isFunctionDefinition );
|
||||||
}
|
}
|
||||||
|
@ -1750,8 +1743,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
public IASTMethod createMethod(
|
public IASTMethod createMethod(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
String name,
|
String name,
|
||||||
int nameEndOffset,
|
List parameters,
|
||||||
List parameters,
|
|
||||||
IASTAbstractDeclaration returnType,
|
IASTAbstractDeclaration returnType,
|
||||||
IASTExceptionSpecification exception,
|
IASTExceptionSpecification exception,
|
||||||
boolean isInline,
|
boolean isInline,
|
||||||
|
@ -1759,6 +1751,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
boolean isStatic,
|
boolean isStatic,
|
||||||
int startOffset,
|
int startOffset,
|
||||||
int nameOffset,
|
int nameOffset,
|
||||||
|
int nameEndOffset,
|
||||||
IASTTemplate ownerTemplate,
|
IASTTemplate ownerTemplate,
|
||||||
boolean isConst,
|
boolean isConst,
|
||||||
boolean isVolatile,
|
boolean isVolatile,
|
||||||
|
|
|
@ -184,9 +184,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createFunction(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, java.util.List, org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration, org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification, boolean, boolean, boolean, int, int, org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
||||||
*/
|
*/
|
||||||
public IASTFunction createFunction(IASTScope scope, String name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, int nameEndOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, List constructorChain, boolean isFunctionDefinition )
|
public IASTFunction createFunction(IASTScope scope, ITokenDuple name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int nameOffset, int nameEndOffset, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, List constructorChain, boolean isFunctionDefinition )
|
||||||
{
|
{
|
||||||
return new ASTFunction(scope, name, nameEndOffset, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate );
|
return new ASTFunction(scope, name.toString(), nameEndOffset, parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, nameOffset, ownerTemplate );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue