diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 2f399c978b1..cd24fbcc7d0 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,7 @@ +2004-02-08 John Camelon + Moved testErrorHandling_1() from failed tests to CompleteParseASTTest. + Moved testBug44340() from failed tests to CompleteParseASTTest. + 2004-02-04 John Camelon Added preliminary SelectionParseTests to test SELECTION_PARSE clients. Added SelectionParseTests to ParserTestSuite. diff --git a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/model/failedTests/CModelElementsFailedTests.java b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/model/failedTests/CModelElementsFailedTests.java index 3b092533e6a..7d6c8cfb761 100644 --- a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/model/failedTests/CModelElementsFailedTests.java +++ b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/model/failedTests/CModelElementsFailedTests.java @@ -12,19 +12,12 @@ package org.eclipse.cdt.core.model.failedTests; ***********************************************************************/ import java.io.FileInputStream; -import java.util.ArrayList; -import java.util.Map; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.INamespace; -import org.eclipse.cdt.core.model.IStructure; -import org.eclipse.cdt.internal.core.model.CElement; -import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.testplugin.CProjectHelper; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; diff --git a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java index d8cc9031a22..da883da614e 100644 --- a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java @@ -142,38 +142,7 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest // assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2))); } - public void testErrorHandling_1() throws Exception - { - Iterator i = parse( "A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false ).getDeclarations(); - IASTVariable x = (IASTVariable)i.next(); - assertEquals( x.getName(), "x"); - IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); - IASTVariable anotherA = (IASTVariable)i.next(); - assertFalse(i.hasNext()); // should be true - // this variable is skipped because of wrong error handling -// IASTVariable b = (IASTVariable)i.next(); -// assertEquals( b.getName(), "b"); -// assertFalse(i.hasNext()); - } - public void testBug44340() throws Exception { - try { - // inline function with reference to variables declared after them - IASTScope scope = parse ("class A{ int getX() {return x[1];} int x[10];};"); - Iterator i = scope.getDeclarations(); - IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); - Iterator j = getDeclarations(classA); - IASTMethod g = (IASTMethod)j.next(); - IASTField x = (IASTField)j.next(); - assertFalse(j.hasNext()); - assertAllReferences( 1, createTaskList( new Task( x ))); - - } catch (ParserException e){ - // parsing fails for now - } - - - } public void testBug47926() throws Exception{ StringBuffer buffer = new StringBuffer(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java index e152da730f2..54cf0be64db 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java @@ -1178,4 +1178,30 @@ public class CompleteParseASTTest extends CompleteParseBaseTest assertTrue( foo.takesVarArgs() ); assertAllReferences( 1, createTaskList( new Task( foo ) ) ); } + + public void testErrorHandling_1() throws Exception + { + Iterator i = parse( "A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false ).getDeclarations(); + IASTVariable x = (IASTVariable)i.next(); + assertEquals( x.getName(), "x"); + IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); + assertEquals( A.getName(), "A"); + IASTVariable anotherA = (IASTVariable)i.next(); + assertEquals( anotherA.getName(), "b"); + assertFalse(i.hasNext()); // should be true + } + + public void testBug44340() throws Exception { + // inline function with reference to variables declared after them + IASTScope scope = parse ("class A{ int getX() {return x[1];} int x[10];};", false ); + Iterator i = scope.getDeclarations(); + IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); + Iterator j = getDeclarations(classA); + IASTMethod g = (IASTMethod)j.next(); + IASTField x = (IASTField)j.next(); + assertFalse(j.hasNext()); + assertAllReferences( 1, createTaskList( new Task( x ))); + } + + } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java index e0e099f4721..6c3ff56e896 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java @@ -177,6 +177,14 @@ public class CompleteParseBaseTest extends TestCase { return nestedScopes.iterator(); } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTCodeScope#getContainingFunction() + */ + public IASTFunction getContainingFunction() { + // TODO Auto-generated method stub + return null; + } } public static class FullParseCallback implements ISourceElementRequestor diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index 4e7ec65ad71..5873078d813 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -1,3 +1,8 @@ +2004-02-08 John Camelon + Added support for inline method x-references. + Fixed Bug 44340 - Inline functions fail to resolve references + Fixed Bug 51243 - Content Assist in an empty document causes a NPE + 2004-02-04 John Camelon Added preliminary (crude) bSelectionParser IParser implementation for SELECTION_PARSE clients. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCodeScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCodeScope.java index ceaa395ac1b..e945d6e5907 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCodeScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTCodeScope.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate; */ public interface IASTCodeScope extends IASTScope, ISourceElementCallbackDelegate{ - public IASTCodeScope getOwnerCodeScope(); + public IASTCodeScope getOwnerCodeScope(); + public IASTFunction getContainingFunction(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java index 6acc88dee8c..26b1a987917 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java @@ -30,4 +30,6 @@ public interface IASTMethod extends IASTFunction, IASTMember { public boolean isPureVirtual(); public Iterator getConstructorChainInitializers(); + + public IASTClassSpecifier getOwnerClassSpecifier(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompleteParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompleteParser.java index 0f17626fdc9..20f20a1fc5b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompleteParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompleteParser.java @@ -41,12 +41,9 @@ public class CompleteParser extends Parser { scanner.setASTFactory(astFactory); } - protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws BacktrackException, EndOfFileException + protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException { - if ( isInlineFunction ) - skipOverCompoundStatement(); - else - functionBody(scope); + functionBody(scope); } protected void catchBlockCompoundStatement(IASTScope scope) throws BacktrackException, EndOfFileException diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompletionParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompletionParser.java index b90e8bb3214..7ec4f6893b9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompletionParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompletionParser.java @@ -77,6 +77,7 @@ public class CompletionParser extends CompleteParser implements IParser { * @return */ private Set reconcileKeywords(Set keywords, String prefix) { + if( keywords == null ) return null; Set resultSet = new TreeSet(); Iterator i = keywords.iterator(); while( i.hasNext() ) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index ee95bfab343..ac1c88f5917 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -1067,9 +1067,8 @@ public abstract class Parser implements IParser if ( !( declaration instanceof IASTScope ) ) throw backtrack; - - handleFunctionBody((IASTScope)declaration, - sdw.isInline() ); + + handleFunctionBody((IASTScope)declaration ); ((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber()); @@ -1100,7 +1099,7 @@ public abstract class Parser implements IParser } } - protected abstract void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws BacktrackException, EndOfFileException; + protected abstract void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException; protected void skipOverCompoundStatement() throws BacktrackException, EndOfFileException { @@ -2838,6 +2837,7 @@ public abstract class Parser implements IParser astClassSpecifier.exitScope( requestor ); + } } /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/QuickParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/QuickParser.java index f756b64e414..caa390aa8d7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/QuickParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/QuickParser.java @@ -42,7 +42,7 @@ public class QuickParser extends Parser { scanner.setASTFactory(astFactory); } - protected void handleFunctionBody(IASTScope scope, boolean isInlineFunction) throws BacktrackException, EndOfFileException + protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException { skipOverCompoundStatement(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/StructuralParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/StructuralParser.java index 325371c7d10..0d7df121124 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/StructuralParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/StructuralParser.java @@ -46,8 +46,7 @@ public class StructuralParser extends Parser implements IParser { * @see org.eclipse.cdt.internal.core.parser.Parser#handleFunctionBody(org.eclipse.cdt.core.parser.ast.IASTScope, boolean) */ protected void handleFunctionBody( - IASTScope scope, - boolean isInlineFunction) + IASTScope scope) throws BacktrackException, EndOfFileException { skipOverCompoundStatement(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTClassSpecifier.java index 2bccf9d9c2c..2248b64eb71 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTClassSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTClassSpecifier.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.parser.ast.ASTClassKind; import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTReference; import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement; import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; @@ -193,6 +194,11 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier */ public void exitScope(ISourceElementRequestor requestor) { + Iterator i = resolvedCrossReferences.iterator(); + while( i.hasNext() ) + { + ((IASTReference)i.next()).acceptElement( requestor ); + } try { requestor.exitClassSpecifier(this); @@ -201,6 +207,7 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier { /* do nothing */ } + } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int) @@ -263,6 +270,7 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier { return declarations.iterator(); } + public void addDeclaration(IASTDeclaration declaration) { declarations.add(declaration); @@ -287,4 +295,24 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier public int getNameLineNumber() { return offsets.getNameLineNumber(); } + + private List unresolvedCrossReferences = new ArrayList(); + + public void addUnresolvedReference( UnresolvedReferenceDuple duple) + { + unresolvedCrossReferences.add( duple ); + } + + public Iterator getUnresolvedReferences() + { + return unresolvedCrossReferences.iterator(); + } + + private List resolvedCrossReferences = new ArrayList(); + /** + * @param references2 + */ + public void setExtraReferences(List references) { + resolvedCrossReferences.addAll( references ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTCodeScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTCodeScope.java index 218dc24809d..611e0330a3e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTCodeScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTCodeScope.java @@ -13,13 +13,12 @@ import java.util.List; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ast.IASTCodeScope; import org.eclipse.cdt.core.parser.ast.IASTDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTFunction; import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol; /** * @author jcamelon * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments */ public class ASTCodeScope extends ASTScope implements IASTCodeScope { @@ -88,4 +87,14 @@ public class ASTCodeScope extends ASTScope implements IASTCodeScope { declarations.add(declaration); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTCodeScope#getContainingFunction() + */ + public IASTFunction getContainingFunction() { + IASTCodeScope i = getOwnerCodeScope(); + while( (i != null ) && !( i instanceof IASTFunction )) + i = i.getOwnerCodeScope(); + return (IASTFunction) i; + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java index b10c19741c1..3da495759eb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTFunction.java @@ -356,4 +356,12 @@ public class ASTFunction extends ASTScope implements IASTFunction public int getNameLineNumber() { return offsets.getNameLineNumber(); } + + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTCodeScope#getContainingFunction() + */ + public IASTFunction getContainingFunction() { + return this; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java index f105692aeaa..3b6fde599f7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTMethod.java @@ -16,6 +16,7 @@ import java.util.List; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTConstructorMemberInitializer; import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; import org.eclipse.cdt.core.parser.ast.IASTMethod; @@ -192,4 +193,10 @@ public class ASTMethod extends ASTFunction implements IASTMethod return new EmptyIterator(); return constructorChain.iterator(); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#getOwnerClassSpecifier() + */ + public IASTClassSpecifier getOwnerClassSpecifier() { + return (IASTClassSpecifier) getOwnerScope(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java index 11b3e772872..08082772187 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java @@ -95,12 +95,9 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension.ExtensionExc */ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFactory { - /** - * - */ - + private final static List SUBSCRIPT; - private final IASTExtensionFactory extensionFactory; + //private final IASTExtensionFactory extensionFactory; static { @@ -124,7 +121,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto { super(); pst = new ParserSymbolTable( language, mode ); - extensionFactory = factory; +// extensionFactory = factory; } /* @@ -271,7 +268,18 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto if( result != null ) addReference( references, createReference( result, firstSymbol.getImage(), firstSymbol.getOffset() )); else - throw new ASTSemanticException(); + { + if( startingScope.getASTExtension().getPrimaryDeclaration() instanceof IASTCodeScope ) + { + if( ((IASTCodeScope) startingScope.getASTExtension().getPrimaryDeclaration()).getContainingFunction() instanceof IASTMethod ) + { + IASTClassSpecifier classSpecifier = ((IASTMethod) ((IASTCodeScope) startingScope.getASTExtension().getPrimaryDeclaration()).getContainingFunction()).getOwnerClassSpecifier(); + ((ASTClassSpecifier)classSpecifier).addUnresolvedReference( new UnresolvedReferenceDuple( startingScope, name )); + break; + } + } + throw new ASTSemanticException(); + } } catch (ParserSymbolTableException e) { @@ -667,8 +675,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto */ protected IASTReference createReference(ISymbol symbol, String string, int offset ) throws ASTSemanticException { - if( symbol == null ) - throw new ASTSemanticException(); + if( symbol == null ) throw new ASTSemanticException(); if( symbol.getType() == TypeInfo.t_namespace ) { @@ -2489,7 +2496,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto ISymbol newSymbol = pst.newSymbol( name, TypeInfo.t_type); newSymbol.getTypeInfo().setBit( true,TypeInfo.isTypedef ); - List references = new ArrayList(); if( mapping.getTypeSpecifier() instanceof ASTSimpleTypeSpecifier ) { @@ -2786,15 +2792,41 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto */ public void signalEndOfClassSpecifier(IASTClassSpecifier astClassSpecifier) { - if( astClassSpecifier == null ) return; + ASTClassSpecifier astImplementation = (ASTClassSpecifier)astClassSpecifier; try - { - ((IDerivableContainerSymbol)((ASTClassSpecifier)astClassSpecifier).getSymbol()).addCopyConstructor(); + { + ((IDerivableContainerSymbol)(astImplementation).getSymbol()).addCopyConstructor(); } catch (ParserSymbolTableException e) { // do nothing, this is best effort } + + Iterator i = astImplementation.getUnresolvedReferences(); + List references = new ArrayList(); + while( i.hasNext() ) + { + UnresolvedReferenceDuple duple = (UnresolvedReferenceDuple) i.next(); + ISymbol s = null; + + List subReferences = new ArrayList(); + try + { + s = lookupQualifiedName( duple.getScope(), duple.getName(), subReferences, false ); + } + catch( ASTSemanticException ase ) + { + } + + if( s != null ) + references.addAll( subReferences ); + + + } + + if( ! references.isEmpty() ) + astImplementation.setExtraReferences( references ); + } public IASTInitializerClause createInitializerClause(IASTScope scope, IASTInitializerClause.Kind kind, IASTExpression assignmentExpression, List initializerClauses, List designators) @@ -2835,4 +2867,5 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto return null; return s.getASTExtension().getPrimaryDeclaration(); } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/UnresolvedReferenceDuple.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/UnresolvedReferenceDuple.java new file mode 100644 index 00000000000..611bd720f5a --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/UnresolvedReferenceDuple.java @@ -0,0 +1,38 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.internal.core.parser.ast.complete; + +import org.eclipse.cdt.core.parser.ITokenDuple; +import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol; + +/** + * @author jcamelon + */ +public class UnresolvedReferenceDuple { + + public UnresolvedReferenceDuple( IContainerSymbol scope, ITokenDuple name ){ + this.scope = scope; + this.name = name; + } + + private final IContainerSymbol scope; + private final ITokenDuple name; + + public IContainerSymbol getScope() + { + return scope; + } + + public ITokenDuple getName() + { + return name; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java index 23c3ab05233..e0e7cd1c73d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java @@ -308,4 +308,10 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction public int getNameLineNumber() { return offsets.getNameLineNumber(); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTCodeScope#getContainingFunction() + */ + public IASTFunction getContainingFunction() { + return this; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java index daa1169569b..23d9406beda 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java @@ -15,6 +15,7 @@ import java.util.List; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; import org.eclipse.cdt.core.parser.ast.IASTMethod; import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement; @@ -210,4 +211,10 @@ public class ASTMethod extends ASTFunction implements IASTMethod return new EmptyIterator(); return constructorChainElements.iterator(); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTMethod#getOwnerClassSpecifier() + */ + public IASTClassSpecifier getOwnerClassSpecifier() { + return (IASTClassSpecifier) getOwnerScope(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java index 2f910b1b2ac..6ad4e77f11c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java @@ -353,5 +353,4 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory public IASTNode lookupSymbolInContext(IASTScope scope, ITokenDuple duple) throws ASTNotImplementedException { throw new ASTNotImplementedException(); } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java index e6d4bdb27b0..4c2e966acf9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java @@ -2098,7 +2098,7 @@ public class Scanner implements IScanner { if( offsetLimit == NO_OFFSET_LIMIT ) throw new EndOfFileException(); - if( finalToken.getEndOffset() == offsetLimit ) + if( finalToken != null && finalToken.getEndOffset() == offsetLimit ) throw new OffsetLimitReachedException(finalToken); throw new OffsetLimitReachedException( (IToken)null ); }