From b916d1065e8fbdbd5ab0af1f2a0a089ac0fd5f29 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 20 Oct 2006 15:02:43 +0000 Subject: [PATCH] Moves further AST-specific methods out of IScope --- .../org/eclipse/cdt/core/dom/ast/IScope.java | 36 ++----------------- .../internal/core/dom/parser/ASTInternal.java | 19 ++++++++++ .../core/dom/parser/IASTInternalScope.java | 27 ++++++++++++++ .../core/dom/parser/c/CStructure.java | 4 +-- .../internal/core/dom/parser/c/CVisitor.java | 32 ++++++++--------- .../core/dom/parser/c/GNUCSourceParser.java | 5 +-- .../dom/parser/cpp/CPPASTTranslationUnit.java | 9 ++--- .../core/dom/parser/cpp/CPPClassTemplate.java | 4 +-- .../core/dom/parser/cpp/CPPClassType.java | 4 +-- .../core/dom/parser/cpp/CPPSemantics.java | 18 +++++----- .../core/dom/parser/cpp/CPPVisitor.java | 18 +++++----- .../dom/parser/cpp/GNUCPPSourceParser.java | 3 +- .../core/pdom/dom/cpp/PDOMCPPClassType.java | 10 ------ .../core/pdom/dom/cpp/PDOMCPPNamespace.java | 9 ++--- 14 files changed, 101 insertions(+), 97 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java index 7e78b9825c4..3879ab514a9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope.java @@ -45,29 +45,7 @@ public interface IScope { * @return List of IBinding */ public IBinding[] find(String name) throws DOMException; - - /** - * The IScope serves as a mechanism for caching IASTNames and bindings to - * speed up resolution. - * mstodo more work: remove the ast-specific methods. - */ - - /** - * Add an IASTName to be cached in this scope - * - * @param name - * @throws DOMException - */ - public void addName(IASTName name) throws DOMException; - - /** - * remove the given binding from this scope - * - * @param binding - * @throws DOMException - */ - void removeBinding(IBinding binding) throws DOMException; - + /** * Get the binding in this scope that the given name would resolve to. Could * return null if there is no matching binding in this scope, if the binding has not @@ -81,15 +59,5 @@ public interface IScope { * @return : the binding in this scope that matches the name, or null * @throws DOMException */ - public IBinding getBinding(IASTName name, boolean resolve) - throws DOMException; - - /** - * This adds an IBinding to the scope. It is primarily used by the parser to add - * implicit IBindings to the scope (such as GCC built-in functions). - * - * @param binding - * @throws DOMException - */ - public void addBinding(IBinding binding) throws DOMException; + public IBinding getBinding(IASTName name, boolean resolve) throws DOMException; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java index 30b9d849e3e..fbbd74b036d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; @@ -57,4 +58,22 @@ public class ASTInternal { ((IASTInternalScope) scope).setFullyCached(val); } } + + public static void addBinding(IScope scope, IBinding binding) throws DOMException { + if (scope instanceof IASTInternalScope) { + ((IASTInternalScope) scope).addBinding(binding); + } + } + + public static void removeBinding(IScope scope, IBinding binding) throws DOMException { + if (scope instanceof IASTInternalScope) { + ((IASTInternalScope) scope).removeBinding(binding); + } + } + + public static void addName(IScope scope, IASTName name) throws DOMException { + if (scope instanceof IASTInternalScope) { + ((IASTInternalScope) scope).addName(name); + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java index d54aef351f0..5bb39d6c464 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java @@ -12,7 +12,9 @@ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBinding; /** * Interface for methods on scopes that are internal to the AST. @@ -44,4 +46,29 @@ public interface IASTInternalScope { * @throws DOMException */ public void flushCache() throws DOMException; + + /** + * This adds an IBinding to the scope. It is primarily used by the parser to add + * implicit IBindings to the scope (such as GCC built-in functions). + * + * @param binding + * @throws DOMException + */ + public void addBinding(IBinding binding) throws DOMException; + + /** + * remove the given binding from this scope + * + * @param binding + * @throws DOMException + */ + void removeBinding(IBinding binding) throws DOMException; + + /** + * Add an IASTName to be cached in this scope + * + * @param name + * @throws DOMException + */ + public void addName(IASTName name) throws DOMException; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java index 0765f4b79ed..257cb7b02c0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java @@ -122,7 +122,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte IASTName name = declarator.getName(); IBinding binding = name.resolveBinding(); if( scope != null ) - scope.addName( name ); + ASTInternal.addName(scope, name ); if( binding != null ) fields = (IField[]) ArrayUtil.append( IField.class, fields, binding ); } @@ -166,7 +166,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte IASTDeclarator declarator = declarators[j]; IASTName dtorName = declarator.getName(); if( scope != null ) - scope.addName( dtorName ); + ASTInternal.addName( scope, dtorName ); if( name.equals( dtorName.toString() ) ){ IBinding binding = dtorName.resolveBinding(); if( binding instanceof IField ) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index 35fce23eb05..e44c9e73487 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -113,8 +113,8 @@ public class CVisitor { ICScope scope; try { scope = (ICScope)name.resolveBinding().getScope(); - if ( scope != null ) - scope.removeBinding(name.resolveBinding()); + if ( scope != null ) + ASTInternal.removeBinding(scope, name.resolveBinding()); } catch ( DOMException e ) { } name.setBinding( null ); @@ -498,7 +498,7 @@ public class CVisitor { } else { binding = new CEnumeration( name ); try { - scope.addName( name ); + ASTInternal.addName(scope, name); } catch ( DOMException e1 ) { } } @@ -507,7 +507,7 @@ public class CVisitor { private static IBinding createBinding( IASTEnumerator enumerator ){ IEnumerator binding = new CEnumerator( enumerator ); try { - ((ICScope)binding.getScope()).addName( enumerator.getName() ); + ASTInternal.addName(binding.getScope(), enumerator.getName() ); } catch ( DOMException e ) { } return binding; @@ -534,7 +534,7 @@ public class CVisitor { try { IScope scope = binding.getScope(); if (scope instanceof ICFunctionScope) - ((ICFunctionScope) binding.getScope()).addName( name ); + ASTInternal.addName(binding.getScope(), name ); } catch ( DOMException e ) { } return binding; @@ -562,7 +562,7 @@ public class CVisitor { } try { - ((ICScope) binding.getScope()).addName( name ); + ASTInternal.addName(binding.getScope(), name ); } catch ( DOMException e ) { } } @@ -803,7 +803,7 @@ public class CVisitor { ICScope scope = (ICScope) ((IASTCompoundStatement)((IASTFunctionDefinition)declarator.getParent()).getBody()).getScope(); if ( scope != null && binding != null ) try { - scope.addName(name); + ASTInternal.addName( scope, name); } catch ( DOMException e ) { } } @@ -903,7 +903,7 @@ public class CVisitor { if( scope != null && binding != null ) try { - scope.addName( name ); + ASTInternal.addName( scope, name ); } catch ( DOMException e ) { } return binding; @@ -932,7 +932,7 @@ public class CVisitor { try { scope = (ICScope) binding.getScope(); - scope.addName( name ); + ASTInternal.addName( scope, name ); } catch ( DOMException e ) { } @@ -1350,7 +1350,7 @@ public class CVisitor { if( declSpec instanceof ICASTElaboratedTypeSpecifier ){ tempName = ((ICASTElaboratedTypeSpecifier)declSpec).getName(); if( scope != null ) - scope.addName( tempName ); + ASTInternal.addName( scope, tempName ); if( typesOnly ){ if( prefixMap != null ) prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap ); @@ -1360,7 +1360,7 @@ public class CVisitor { } else if( declSpec instanceof ICASTCompositeTypeSpecifier ){ tempName = ((ICASTCompositeTypeSpecifier)declSpec).getName(); if( scope != null ) - scope.addName( tempName ); + ASTInternal.addName( scope, tempName ); if( typesOnly ){ if( prefixMap != null ) @@ -1385,7 +1385,7 @@ public class CVisitor { ICASTEnumerationSpecifier enumeration = (ICASTEnumerationSpecifier) declSpec; tempName = enumeration.getName(); if( scope != null ) - scope.addName( tempName ); + ASTInternal.addName( scope, tempName ); if( typesOnly ){ if( prefixMap != null ) prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap ); @@ -1399,7 +1399,7 @@ public class CVisitor { if( enumerator == null ) break; tempName = enumerator.getName(); if( scope != null ) - scope.addName( tempName ); + ASTInternal.addName( scope, tempName ); if( !typesOnly ){ if( prefixMap != null ) prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap ); @@ -1430,7 +1430,7 @@ public class CVisitor { } IASTName tempName = dtor.getName(); if( scope != null ) - scope.addName( tempName ); + ASTInternal.addName( scope, tempName ); if( !typesOnly ) { char [] c = tempName.toCharArray(); @@ -1478,7 +1478,7 @@ public class CVisitor { } tempName = declarator.getName(); if( scope != null ) - scope.addName( tempName ); + ASTInternal.addName( scope, tempName ); if( !typesOnly ){ if( prefixMap != null ) @@ -1498,7 +1498,7 @@ public class CVisitor { IASTDeclarator dtor = functionDef.getDeclarator(); tempName = dtor.getName(); if( scope != null ) - scope.addName( tempName ); + ASTInternal.addName( scope, tempName ); if( !typesOnly ){ if( prefixMap != null ) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 846d360f49c..5e7197a5e77 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -102,6 +102,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; import org.eclipse.cdt.internal.core.dom.parser.BacktrackException; @@ -583,7 +584,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { IBinding[] bindings = new GCCBuiltinSymbolProvider(translationUnit.getScope(), ParserLanguage.C).getBuiltinBindings(); for(int i=0; i 0) //$NON-NLS-1$ + if (declarator == null || declarator.getName().toCharArray().length > 0) { return null; // backup(mark); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java index 841623d0895..f481d9ca4d9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java @@ -59,6 +59,7 @@ import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ast.IASTEnumerator; import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; @@ -145,14 +146,14 @@ public class CPPASTTranslationUnit extends CPPASTNode implements newTheParms[0] = new CPPBuiltinParameter(newParms[0]); temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_NEW, theScope, newFunctionType, newTheParms, false); try { - theScope.addBinding(temp); + ASTInternal.addBinding(theScope, temp); } catch (DOMException de) {} // void * operator new[] (std::size_t); temp = null; temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_NEW_ARRAY, theScope, newFunctionType, newTheParms, false); try { - theScope.addBinding(temp); + ASTInternal.addBinding(theScope, temp); } catch (DOMException de) {} // void operator delete(void*); @@ -164,14 +165,14 @@ public class CPPASTTranslationUnit extends CPPASTNode implements deleteTheParms[0] = new CPPBuiltinParameter(deleteParms[0]); temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_DELETE, theScope, deleteFunctionType, deleteTheParms, false); try { - theScope.addBinding(temp); + ASTInternal.addBinding(theScope, temp); } catch (DOMException de) {} // void operator delete[](void*); temp = null; temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_DELETE_ARRAY, theScope, deleteFunctionType, deleteTheParms, false); try { - theScope.addBinding(temp); + ASTInternal.addBinding(theScope, temp); } catch (DOMException de) {} } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java index a3fce21fa1f..797e2c97db6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java @@ -402,11 +402,11 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators(); for( int j = 0; j < dtors.length; j++ ){ if( dtors[j] == null ) break; - scope.addName( dtors[j].getName() ); + ASTInternal.addName(scope, dtors[j].getName() ); } } else if( decl instanceof IASTFunctionDefinition ){ IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator(); - scope.addName( dtor.getName() ); + ASTInternal.addName(scope, dtor.getName() ); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java index 9970496865d..5efddcac574 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java @@ -693,11 +693,11 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators(); for( int j = 0; j < dtors.length; j++ ){ if( dtors[j] == null ) break; - scope.addName( dtors[j].getName() ); + ASTInternal.addName(scope, dtors[j].getName() ); } } else if( decl instanceof IASTFunctionDefinition ){ IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator(); - scope.addName( dtor.getName() ); + ASTInternal.addName(scope, dtor.getName() ); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java index b8f123a87cd..5b667d23431 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java @@ -1626,14 +1626,14 @@ public class CPPSemantics { while( dtor.getNestedDeclarator() != null ) dtor = dtor.getNestedDeclarator(); IASTName declName = dtor.getName(); - scope.addName( declName ); + ASTInternal.addName( scope, declName ); if( !data.typesOnly && nameMatches( data, declName ) ) { return declName; } } } else if( node instanceof ICPPASTTemplateParameter ){ IASTName name = CPPTemplates.getTemplateParameterName( (ICPPASTTemplateParameter) node ); - scope.addName( name ); + ASTInternal.addName( scope, name ); if( nameMatches( data, name ) ) { return name; } @@ -1651,7 +1651,7 @@ public class CPPSemantics { while( declarator.getNestedDeclarator() != null ) declarator = declarator.getNestedDeclarator(); IASTName declaratorName = declarator.getName(); - scope.addName( declaratorName ); + ASTInternal.addName( scope, declaratorName ); if( !data.typesOnly || simpleDeclaration.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ) { if( nameMatches( data, declaratorName ) ) { if( resultName == null ) @@ -1715,7 +1715,7 @@ public class CPPSemantics { IASTEnumerator enumerator = list[i]; if( enumerator == null ) break; tempName = enumerator.getName(); - scope.addName( tempName ); + ASTInternal.addName( scope, tempName ); if( !data.typesOnly && nameMatches( data, tempName ) ) { if( resultName == null ) resultName = tempName; @@ -1727,7 +1727,7 @@ public class CPPSemantics { } } if( specName != null ) { - scope.addName( specName ); + ASTInternal.addName( scope, specName ); if( nameMatches( data, specName ) ) { if( resultName == null ) resultName = specName; @@ -1744,18 +1744,18 @@ public class CPPSemantics { IASTName [] ns = ((ICPPASTQualifiedName)name).getNames(); name = ns[ ns.length - 1 ]; } - scope.addName( name ); + ASTInternal.addName( scope, name ); if( nameMatches( data, name ) ) { return name; } } else if( declaration instanceof ICPPASTNamespaceDefinition ){ IASTName namespaceName = ((ICPPASTNamespaceDefinition) declaration).getName(); - scope.addName( namespaceName ); + ASTInternal.addName( scope, namespaceName ); if( nameMatches( data, namespaceName ) ) return namespaceName; } else if( declaration instanceof ICPPASTNamespaceAlias ){ IASTName alias = ((ICPPASTNamespaceAlias) declaration).getAlias(); - scope.addName( alias ); + ASTInternal.addName( scope, alias ); if( nameMatches( data, alias ) ) return alias; } else if( declaration instanceof IASTFunctionDefinition ){ @@ -1765,7 +1765,7 @@ public class CPPSemantics { //check the function itself IASTName declName = declarator.getName(); - scope.addName( declName ); + ASTInternal.addName( scope, declName ); if( !data.typesOnly && nameMatches( data, declName ) ) { return declName; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index a52e8b53810..3e0ce25b51a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -219,7 +219,7 @@ public class CPPVisitor { binding = functionScope.getBinding( name, false ); if( binding == null || !(binding instanceof ILabel) ){ binding = new CPPLabel( name ); - functionScope.addName( name ); + ASTInternal.addName( functionScope, name ); } } catch ( DOMException e ) { binding = e.getProblem(); @@ -236,7 +236,7 @@ public class CPPVisitor { binding = functionScope.getBinding( name, false ); if( binding == null || !(binding instanceof ILabel) ){ binding = new CPPLabel( name ); - functionScope.addName( name ); + ASTInternal.addName( functionScope, name ); } else { ((CPPLabel)binding).setLabelStatement( name ); } @@ -254,7 +254,7 @@ public class CPPVisitor { enumtor = scope.getBinding( enumerator.getName(), false ); if( enumtor == null || !( enumtor instanceof IEnumerator ) ){ enumtor = new CPPEnumerator( enumerator.getName() ); - scope.addName( enumerator.getName() ); + ASTInternal.addName( scope, enumerator.getName() ); } } catch ( DOMException e ) { enumtor = e.getProblem(); @@ -271,7 +271,7 @@ public class CPPVisitor { enumeration = scope.getBinding( specifier.getName(), false ); if( enumeration == null || !(enumeration instanceof IEnumeration) ){ enumeration = new CPPEnumeration( specifier.getName() ); - scope.addName( specifier.getName() ); + ASTInternal.addName( scope, specifier.getName() ); } } catch ( DOMException e ) { enumeration = e.getProblem(); @@ -357,7 +357,7 @@ public class CPPVisitor { binding = new CPPClassTemplate( name ); else binding = new CPPClassType( name ); - scope.addName( elabType.getName() ); + ASTInternal.addName( scope, elabType.getName() ); } } else if( binding instanceof ICPPInternalBinding ){ ((ICPPInternalBinding)binding).addDeclaration( elabType ); @@ -398,7 +398,7 @@ public class CPPVisitor { else binding = new CPPClassType( name ); if( scope != null ) - scope.addName( compType.getName() ); + ASTInternal.addName( scope, compType.getName() ); } else { if( binding instanceof ICPPInternalBinding ){ ICPPInternalBinding internal = (ICPPInternalBinding) binding; @@ -423,7 +423,7 @@ public class CPPVisitor { binding = scope.getBinding( namespaceDef.getName(), false ); if( binding == null || binding instanceof IProblemBinding ){ binding = new CPPNamespace( namespaceDef ); - scope.addName( namespaceDef.getName() ); + ASTInternal.addName( scope, namespaceDef.getName() ); } } catch ( DOMException e ) { binding = e.getProblem(); @@ -445,7 +445,7 @@ public class CPPVisitor { } if( namespace instanceof ICPPNamespace ) { binding = new CPPNamespaceAlias( alias.getAlias(), (ICPPNamespace) namespace ); - scope.addName( alias.getAlias() ); + ASTInternal.addName( scope, alias.getAlias() ); } else { binding = new ProblemBinding( alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND, alias.getAlias().toCharArray() ); } @@ -605,7 +605,7 @@ public class CPPVisitor { if( scope != null && binding != null ){ try { - scope.addName( name ); + ASTInternal.addName( scope, name ); } catch ( DOMException e1 ) { } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index ca8954d7e48..56c4f5ac2bc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -141,6 +141,7 @@ import org.eclipse.cdt.core.parser.ParseError; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; import org.eclipse.cdt.internal.core.dom.parser.BacktrackException; @@ -4642,7 +4643,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { translationUnit.getScope(), ParserLanguage.CPP) .getBuiltinBindings(); for (int i = 0; i < bindings.length; i++) { - tuScope.addBinding(bindings[i]); + ASTInternal.addBinding(tuScope, bindings[i]); } } } catch (Exception e2) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java index a2c2a17a0b9..ce83121b5a0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java @@ -283,11 +283,6 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType, return this; } - public void addName(IASTName name) throws DOMException { - // TODO - this might be a better way of adding names to scopes - // but for now do nothing. - } - public IName getScopeName() throws DOMException { try { PDOMName name = getFirstDefinition(); @@ -323,13 +318,8 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType, public IField findField(String name) throws DOMException {fail();return null;} public IBinding[] getFriends() throws DOMException {fail();return null;} public ICPPMethod[] getImplicitMethods() {fail(); return null;} - public void addBinding(IBinding binding) throws DOMException {fail();} public IBinding[] find(String name) throws DOMException {fail();return null;} - public void flushCache() throws DOMException {fail();} public ICPPField[] getDeclaredFields() throws DOMException {fail();return null;} - public void removeBinding(IBinding binding) throws DOMException {fail();} - public void setFullyCached(boolean b) throws DOMException {fail();} - public IASTNode getPhysicalNode() throws DOMException {fail();return null;} public IScope getScope() throws DOMException { try { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java index 01ae69fd6a2..7089a946e1f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java @@ -100,6 +100,9 @@ class PDOMCPPNamespace extends PDOMCPPBinding return new IASTNode[0]; } + // mstodo this method currently does not get called, we could try to remove it. + // an alternative an appropriate method in CPPSemantics. This implementation is not + // correct for sure. public IBinding[] find(String name) throws DOMException { try { FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray()); @@ -199,12 +202,6 @@ class PDOMCPPNamespace extends PDOMCPPBinding } public IBinding[] getMemberBindings() throws DOMException {fail(); return null;} - public IASTNode getPhysicalNode() throws DOMException {fail(); return null;} public IName getScopeName() throws DOMException {fail(); return null;} - public void removeBinding(IBinding binding) throws DOMException {fail();} - public void setFullyCached(boolean b) throws DOMException {fail();} - public void flushCache() throws DOMException {fail();} public void addUsingDirective(IASTNode directive) throws DOMException {fail();} - public void addBinding(IBinding binding) throws DOMException {fail();} - public void addName(IASTName name) throws DOMException {fail();} }