1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
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:
John Camelon 2003-10-01 20:34:58 +00:00
parent c570364866
commit 9b33f17d3f
10 changed files with 72 additions and 57 deletions

View file

@ -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
Modified CDT log dump in Parser.fetchToken to include error message

View file

@ -32,4 +32,6 @@ public interface ITokenDuple {
public abstract ITokenDuple getSubrange( int startIndex, int endIndex );
public IToken getToken(int index);
public int findLastTokenType( int type );
}

View file

@ -33,7 +33,6 @@ public class ScannerException extends Exception {
public static final ErrorCode BAD_HEXIDECIMAL_FORMAT = new ErrorCode( 7 );
public static final ErrorCode INVALID_PREPROCESSOR_DIRECTIVE = new ErrorCode( 8 );
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 EXPRESSION_EVALUATION_ERROR = new ErrorCode( 12 );
public static final ErrorCode UNEXPECTED_EOF = new ErrorCode(13);
@ -82,7 +81,6 @@ public class ScannerException extends Exception {
this == ErrorCode.UNEXPECTED_EOF ||
this == ErrorCode.MACRO_USAGE_ERROR ||
this == ErrorCode.MACRO_PASTING_ERROR ||
this == ErrorCode.UNDEF_DEFINITION_NOT_FOUND ||
this == ErrorCode.EXPRESSION_EVALUATION_ERROR ||
this == ErrorCode.INVALID_PREPROCESSOR_DIRECTIVE ||
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.MALFORMED_MACRO_DEFN, "Macro definition malformed: " );
errorMessages.put( ErrorCode.ATTEMPTED_REDEFINITION, "" );
errorMessages.put( ErrorCode.UNDEF_DEFINITION_NOT_FOUND, "" );
errorMessages.put( ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE, "" );
errorMessages.put( ErrorCode.EXPRESSION_EVALUATION_ERROR, "" );
errorMessages.put( ErrorCode.MACRO_USAGE_ERROR, "" );

View file

@ -132,7 +132,7 @@ public interface IASTFactory
boolean isUnsigned, boolean isTypename) throws ASTSemanticException, Exception;
public IASTFunction createFunction(
IASTScope scope,
String name,
ITokenDuple name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,

View file

@ -503,7 +503,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
{
return astFactory.createFunction(
scope,
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
nested ? declarator.getOwnedDeclarator().getNamedDuple() : declarator.getNamedDuple(),
createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration(
constt,

View file

@ -2602,7 +2602,7 @@ public class Parser implements IParser
access,
classKey.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)
{

View file

@ -1047,8 +1047,7 @@ public class Scanner implements IScanner {
// definition
String toBeUndefined = getNextIdentifier();
if( ( definitions.remove(toBeUndefined) == null ) && mode == ParserMode.COMPLETE_PARSE )
throw new ScannerException( ScannerException.ErrorCode.UNDEF_DEFINITION_NOT_FOUND, toBeUndefined, getCurrentFile(), getCurrentOffset() );
definitions.remove(toBeUndefined);
skipOverTextUntilNewline();
c = getChar();

View file

@ -154,4 +154,23 @@ public class TokenDuple implements ITokenDuple {
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;
}
}

View file

@ -1418,7 +1418,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
*/
public IASTFunction createFunction(
IASTScope scope,
String name,
ITokenDuple name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@ -1441,43 +1441,15 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
IContainerSymbol ownerScope = scopeToSymbol( scope );
// check if this is a method in a body file
StringTokenizer tokenizer = new StringTokenizer(name,DOUBLE_COLON);
int tokencount = tokenizer.countTokens();
if(tokencount > 1){
List tokens = new ArrayList();
String oneToken = "";
// This is NOT a function. This is a method definition
while (tokenizer.hasMoreTokens()){
oneToken = tokenizer.nextToken();
tokens.add(oneToken);
}
Iterator tokenizer = name.iterator();
if(name.length() > 1){
IContainerSymbol parentScope = (IContainerSymbol)
lookupQualifiedName(
ownerScope,
name.getSubrange( 0, name.findLastTokenType( IToken.tCOLONCOLON ) - 1),
references,
false );
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) &&
( (parentScope.getType() == TypeInfo.t_class)
@ -1485,14 +1457,35 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|| (parentScope.getType() == TypeInfo.t_union))
){
IASTScope methodParentScope = (IASTScope)parentScope.getASTExtension().getPrimaryDeclaration();
return createMethod(methodParentScope, functionName,nameEndOffset, parameters, returnType,
exception, isInline, isFriend, isStatic, startOffset, offset,
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
ASTAccessVisibility.PRIVATE, constructorChain, references, isFunctionDefinition);
ITokenDuple newName = name.getSubrange(
name.findLastTokenType( IToken.tCOLONCOLON) + 1,
name.length() - 1 );
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);
setParameter( symbol, returnType, false, references );
@ -1514,7 +1507,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
IParameterizedSymbol functionDeclaration = null;
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 )
{
@ -1741,8 +1734,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean isPureVirtual,
ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition ) throws ASTSemanticException
{
return createMethod(scope, name, nameEndOffset, parameters, returnType,
exception, isInline, isFriend, isStatic, startOffset, nameOffset,
return createMethod(scope, name, parameters, returnType, exception,
isInline, isFriend, isStatic, startOffset, nameOffset, nameEndOffset,
ownerTemplate, isConst, isVolatile, isVirtual, isExplicit, isPureVirtual,
visibility, constructorChain, null, isFunctionDefinition );
}
@ -1750,7 +1743,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
public IASTMethod createMethod(
IASTScope scope,
String name,
int nameEndOffset,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@ -1759,6 +1751,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
boolean isStatic,
int startOffset,
int nameOffset,
int nameEndOffset,
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,

View file

@ -184,9 +184,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
/* (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)
*/
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)