[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied [HEAD] Offset & Scanner fixes
|
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
JohnC
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.149
diff -u -r1.149 ChangeLog
--- parser/ChangeLog 1 Oct 2003 19:43:06 -0000 1.149
+++ parser/ChangeLog 1 Oct 2003 20:28:42 -0000
@@ -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
Index: parser/org/eclipse/cdt/core/parser/ITokenDuple.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ITokenDuple.java,v
retrieving revision 1.3
diff -u -r1.3 ITokenDuple.java
--- parser/org/eclipse/cdt/core/parser/ITokenDuple.java 12 Aug 2003 18:19:38 -0000 1.3
+++ parser/org/eclipse/cdt/core/parser/ITokenDuple.java 1 Oct 2003 20:28:42 -0000
@@ -32,4 +32,6 @@
public abstract ITokenDuple getSubrange( int startIndex, int endIndex );
public IToken getToken(int index);
+
+ public int findLastTokenType( int type );
}
Index: parser/org/eclipse/cdt/core/parser/ScannerException.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ScannerException.java,v
retrieving revision 1.2
diff -u -r1.2 ScannerException.java
--- parser/org/eclipse/cdt/core/parser/ScannerException.java 9 Sep 2003 18:02:40 -0000 1.2
+++ parser/org/eclipse/cdt/core/parser/ScannerException.java 1 Oct 2003 20:28:42 -0000
@@ -33,7 +33,6 @@
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 @@
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 @@
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, "" );
Index: parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java,v
retrieving revision 1.37
diff -u -r1.37 IASTFactory.java
--- parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 30 Sep 2003 20:42:24 -0000 1.37
+++ parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 1 Oct 2003 20:28:42 -0000
@@ -132,7 +132,7 @@
boolean isUnsigned, boolean isTypename) throws ASTSemanticException, Exception;
public IASTFunction createFunction(
IASTScope scope,
- String name,
+ ITokenDuple name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
Index: parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java,v
retrieving revision 1.24
diff -u -r1.24 DeclarationWrapper.java
--- parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 30 Sep 2003 20:42:24 -0000 1.24
+++ parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java 1 Oct 2003 20:28:42 -0000
@@ -503,7 +503,7 @@
{
return astFactory.createFunction(
scope,
- nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
+ nested ? declarator.getOwnedDeclarator().getNamedDuple() : declarator.getNamedDuple(),
createParameterList(declarator.getParameters()),
astFactory.createAbstractDeclaration(
constt,
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.119
diff -u -r1.119 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java 1 Oct 2003 19:43:06 -0000 1.119
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java 1 Oct 2003 20:28:44 -0000
@@ -2602,7 +2602,7 @@
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)
{
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.58
diff -u -r1.58 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 Oct 2003 17:10:15 -0000 1.58
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 Oct 2003 20:28:45 -0000
@@ -1047,8 +1047,7 @@
// 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();
Index: parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java,v
retrieving revision 1.12
diff -u -r1.12 TokenDuple.java
--- parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java 26 Sep 2003 19:21:12 -0000 1.12
+++ parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java 1 Oct 2003 20:28:45 -0000
@@ -153,5 +153,24 @@
}
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;
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java,v
retrieving revision 1.51
diff -u -r1.51 CompleteParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 30 Sep 2003 20:42:24 -0000 1.51
+++ parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java 1 Oct 2003 20:28:46 -0000
@@ -1418,7 +1418,7 @@
*/
public IASTFunction createFunction(
IASTScope scope,
- String name,
+ ITokenDuple name,
List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
@@ -1441,43 +1441,15 @@
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);
- }
-
- String functionName = oneToken;
-// String parentName = name.substring(0, name.lastIndexOf(DOUBLE_COLON));
+ Iterator tokenizer = name.iterator();
+ if(name.length() > 1){
+ IContainerSymbol parentScope = (IContainerSymbol)
+ lookupQualifiedName(
+ ownerScope,
+ name.getSubrange( 0, name.findLastTokenType( IToken.tCOLONCOLON ) - 1),
+ references,
+ false );
- 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 @@
|| (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 @@
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 @@
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,8 +1743,7 @@
public IASTMethod createMethod(
IASTScope scope,
String name,
- int nameEndOffset,
- List parameters,
+ List parameters,
IASTAbstractDeclaration returnType,
IASTExceptionSpecification exception,
boolean isInline,
@@ -1759,6 +1751,7 @@
boolean isStatic,
int startOffset,
int nameOffset,
+ int nameEndOffset,
IASTTemplate ownerTemplate,
boolean isConst,
boolean isVolatile,
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java,v
retrieving revision 1.38
diff -u -r1.38 QuickParseASTFactory.java
--- parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 29 Sep 2003 19:22:08 -0000 1.38
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 1 Oct 2003 20:28:47 -0000
@@ -184,9 +184,9 @@
/* (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)