1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-16 20:55:44 +02:00

Moves further AST-specific methods out of IScope

This commit is contained in:
Markus Schorn 2006-10-20 15:02:43 +00:00
parent 5c70bbcd1b
commit b916d1065e
14 changed files with 101 additions and 97 deletions

View file

@ -46,28 +46,6 @@ public interface IScope {
*/ */
public IBinding[] find(String name) throws DOMException; 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 * 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 * 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 * @return : the binding in this scope that matches the name, or null
* @throws DOMException * @throws DOMException
*/ */
public IBinding getBinding(IASTName name, boolean resolve) public IBinding getBinding(IASTName name, boolean resolve) throws DOMException;
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;
} }

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.DOMException; 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.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
@ -57,4 +58,22 @@ public class ASTInternal {
((IASTInternalScope) scope).setFullyCached(val); ((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);
}
}
} }

View file

@ -12,7 +12,9 @@
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.DOMException; 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.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
/** /**
* Interface for methods on scopes that are internal to the AST. * Interface for methods on scopes that are internal to the AST.
@ -44,4 +46,29 @@ public interface IASTInternalScope {
* @throws DOMException * @throws DOMException
*/ */
public void flushCache() 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;
} }

View file

@ -122,7 +122,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
IASTName name = declarator.getName(); IASTName name = declarator.getName();
IBinding binding = name.resolveBinding(); IBinding binding = name.resolveBinding();
if( scope != null ) if( scope != null )
scope.addName( name ); ASTInternal.addName(scope, name );
if( binding != null ) if( binding != null )
fields = (IField[]) ArrayUtil.append( IField.class, fields, binding ); fields = (IField[]) ArrayUtil.append( IField.class, fields, binding );
} }
@ -166,7 +166,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
IASTDeclarator declarator = declarators[j]; IASTDeclarator declarator = declarators[j];
IASTName dtorName = declarator.getName(); IASTName dtorName = declarator.getName();
if( scope != null ) if( scope != null )
scope.addName( dtorName ); ASTInternal.addName( scope, dtorName );
if( name.equals( dtorName.toString() ) ){ if( name.equals( dtorName.toString() ) ){
IBinding binding = dtorName.resolveBinding(); IBinding binding = dtorName.resolveBinding();
if( binding instanceof IField ) if( binding instanceof IField )

View file

@ -114,7 +114,7 @@ public class CVisitor {
try { try {
scope = (ICScope)name.resolveBinding().getScope(); scope = (ICScope)name.resolveBinding().getScope();
if ( scope != null ) if ( scope != null )
scope.removeBinding(name.resolveBinding()); ASTInternal.removeBinding(scope, name.resolveBinding());
} catch ( DOMException e ) { } catch ( DOMException e ) {
} }
name.setBinding( null ); name.setBinding( null );
@ -498,7 +498,7 @@ public class CVisitor {
} else { } else {
binding = new CEnumeration( name ); binding = new CEnumeration( name );
try { try {
scope.addName( name ); ASTInternal.addName(scope, name);
} catch ( DOMException e1 ) { } catch ( DOMException e1 ) {
} }
} }
@ -507,7 +507,7 @@ public class CVisitor {
private static IBinding createBinding( IASTEnumerator enumerator ){ private static IBinding createBinding( IASTEnumerator enumerator ){
IEnumerator binding = new CEnumerator( enumerator ); IEnumerator binding = new CEnumerator( enumerator );
try { try {
((ICScope)binding.getScope()).addName( enumerator.getName() ); ASTInternal.addName(binding.getScope(), enumerator.getName() );
} catch ( DOMException e ) { } catch ( DOMException e ) {
} }
return binding; return binding;
@ -534,7 +534,7 @@ public class CVisitor {
try { try {
IScope scope = binding.getScope(); IScope scope = binding.getScope();
if (scope instanceof ICFunctionScope) if (scope instanceof ICFunctionScope)
((ICFunctionScope) binding.getScope()).addName( name ); ASTInternal.addName(binding.getScope(), name );
} catch ( DOMException e ) { } catch ( DOMException e ) {
} }
return binding; return binding;
@ -562,7 +562,7 @@ public class CVisitor {
} }
try { try {
((ICScope) binding.getScope()).addName( name ); ASTInternal.addName(binding.getScope(), name );
} catch ( DOMException e ) { } catch ( DOMException e ) {
} }
} }
@ -803,7 +803,7 @@ public class CVisitor {
ICScope scope = (ICScope) ((IASTCompoundStatement)((IASTFunctionDefinition)declarator.getParent()).getBody()).getScope(); ICScope scope = (ICScope) ((IASTCompoundStatement)((IASTFunctionDefinition)declarator.getParent()).getBody()).getScope();
if ( scope != null && binding != null ) if ( scope != null && binding != null )
try { try {
scope.addName(name); ASTInternal.addName( scope, name);
} catch ( DOMException e ) { } catch ( DOMException e ) {
} }
} }
@ -903,7 +903,7 @@ public class CVisitor {
if( scope != null && binding != null ) if( scope != null && binding != null )
try { try {
scope.addName( name ); ASTInternal.addName( scope, name );
} catch ( DOMException e ) { } catch ( DOMException e ) {
} }
return binding; return binding;
@ -932,7 +932,7 @@ public class CVisitor {
try { try {
scope = (ICScope) binding.getScope(); scope = (ICScope) binding.getScope();
scope.addName( name ); ASTInternal.addName( scope, name );
} catch ( DOMException e ) { } catch ( DOMException e ) {
} }
@ -1350,7 +1350,7 @@ public class CVisitor {
if( declSpec instanceof ICASTElaboratedTypeSpecifier ){ if( declSpec instanceof ICASTElaboratedTypeSpecifier ){
tempName = ((ICASTElaboratedTypeSpecifier)declSpec).getName(); tempName = ((ICASTElaboratedTypeSpecifier)declSpec).getName();
if( scope != null ) if( scope != null )
scope.addName( tempName ); ASTInternal.addName( scope, tempName );
if( typesOnly ){ if( typesOnly ){
if( prefixMap != null ) if( prefixMap != null )
prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap ); prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap );
@ -1360,7 +1360,7 @@ public class CVisitor {
} else if( declSpec instanceof ICASTCompositeTypeSpecifier ){ } else if( declSpec instanceof ICASTCompositeTypeSpecifier ){
tempName = ((ICASTCompositeTypeSpecifier)declSpec).getName(); tempName = ((ICASTCompositeTypeSpecifier)declSpec).getName();
if( scope != null ) if( scope != null )
scope.addName( tempName ); ASTInternal.addName( scope, tempName );
if( typesOnly ){ if( typesOnly ){
if( prefixMap != null ) if( prefixMap != null )
@ -1385,7 +1385,7 @@ public class CVisitor {
ICASTEnumerationSpecifier enumeration = (ICASTEnumerationSpecifier) declSpec; ICASTEnumerationSpecifier enumeration = (ICASTEnumerationSpecifier) declSpec;
tempName = enumeration.getName(); tempName = enumeration.getName();
if( scope != null ) if( scope != null )
scope.addName( tempName ); ASTInternal.addName( scope, tempName );
if( typesOnly ){ if( typesOnly ){
if( prefixMap != null ) if( prefixMap != null )
prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap ); prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap );
@ -1399,7 +1399,7 @@ public class CVisitor {
if( enumerator == null ) break; if( enumerator == null ) break;
tempName = enumerator.getName(); tempName = enumerator.getName();
if( scope != null ) if( scope != null )
scope.addName( tempName ); ASTInternal.addName( scope, tempName );
if( !typesOnly ){ if( !typesOnly ){
if( prefixMap != null ) if( prefixMap != null )
prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap ); prefixMap = (CharArrayObjectMap) collectResult( tempName, n, prefixMap );
@ -1430,7 +1430,7 @@ public class CVisitor {
} }
IASTName tempName = dtor.getName(); IASTName tempName = dtor.getName();
if( scope != null ) if( scope != null )
scope.addName( tempName ); ASTInternal.addName( scope, tempName );
if( !typesOnly ) { if( !typesOnly ) {
char [] c = tempName.toCharArray(); char [] c = tempName.toCharArray();
@ -1478,7 +1478,7 @@ public class CVisitor {
} }
tempName = declarator.getName(); tempName = declarator.getName();
if( scope != null ) if( scope != null )
scope.addName( tempName ); ASTInternal.addName( scope, tempName );
if( !typesOnly ){ if( !typesOnly ){
if( prefixMap != null ) if( prefixMap != null )
@ -1498,7 +1498,7 @@ public class CVisitor {
IASTDeclarator dtor = functionDef.getDeclarator(); IASTDeclarator dtor = functionDef.getDeclarator();
tempName = dtor.getName(); tempName = dtor.getName();
if( scope != null ) if( scope != null )
scope.addName( tempName ); ASTInternal.addName( scope, tempName );
if( !typesOnly ){ if( !typesOnly ){
if( prefixMap != null ) if( prefixMap != null )

View file

@ -102,6 +102,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; 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.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException; 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(); IBinding[] bindings = new GCCBuiltinSymbolProvider(translationUnit.getScope(), ParserLanguage.C).getBuiltinBindings();
for(int i=0; i<bindings.length; i++) { for(int i=0; i<bindings.length; i++) {
tuScope.addBinding(bindings[i]); ASTInternal.addBinding(tuScope, bindings[i]);
} }
} }
} catch (Exception e2) { } catch (Exception e2) {
@ -1295,7 +1296,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
// backup(mark); // backup(mark);
// throwBacktrack(bt); // throwBacktrack(bt);
} }
if (declarator == null || declarator.getName().toCharArray().length > 0) //$NON-NLS-1$ if (declarator == null || declarator.getName().toCharArray().length > 0)
{ {
return null; return null;
// backup(mark); // backup(mark);

View file

@ -59,6 +59,7 @@ import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator; import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.util.ArrayUtil; 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.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult; import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; 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]); newTheParms[0] = new CPPBuiltinParameter(newParms[0]);
temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_NEW, theScope, newFunctionType, newTheParms, false); temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_NEW, theScope, newFunctionType, newTheParms, false);
try { try {
theScope.addBinding(temp); ASTInternal.addBinding(theScope, temp);
} catch (DOMException de) {} } catch (DOMException de) {}
// void * operator new[] (std::size_t); // void * operator new[] (std::size_t);
temp = null; temp = null;
temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_NEW_ARRAY, theScope, newFunctionType, newTheParms, false); temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_NEW_ARRAY, theScope, newFunctionType, newTheParms, false);
try { try {
theScope.addBinding(temp); ASTInternal.addBinding(theScope, temp);
} catch (DOMException de) {} } catch (DOMException de) {}
// void operator delete(void*); // void operator delete(void*);
@ -164,14 +165,14 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
deleteTheParms[0] = new CPPBuiltinParameter(deleteParms[0]); deleteTheParms[0] = new CPPBuiltinParameter(deleteParms[0]);
temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_DELETE, theScope, deleteFunctionType, deleteTheParms, false); temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_DELETE, theScope, deleteFunctionType, deleteTheParms, false);
try { try {
theScope.addBinding(temp); ASTInternal.addBinding(theScope, temp);
} catch (DOMException de) {} } catch (DOMException de) {}
// void operator delete[](void*); // void operator delete[](void*);
temp = null; temp = null;
temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_DELETE_ARRAY, theScope, deleteFunctionType, deleteTheParms, false); temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_DELETE_ARRAY, theScope, deleteFunctionType, deleteTheParms, false);
try { try {
theScope.addBinding(temp); ASTInternal.addBinding(theScope, temp);
} catch (DOMException de) {} } catch (DOMException de) {}
} }

View file

@ -402,11 +402,11 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators(); IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
for( int j = 0; j < dtors.length; j++ ){ for( int j = 0; j < dtors.length; j++ ){
if( dtors[j] == null ) break; if( dtors[j] == null ) break;
scope.addName( dtors[j].getName() ); ASTInternal.addName(scope, dtors[j].getName() );
} }
} else if( decl instanceof IASTFunctionDefinition ){ } else if( decl instanceof IASTFunctionDefinition ){
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator(); IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
scope.addName( dtor.getName() ); ASTInternal.addName(scope, dtor.getName() );
} }
} }

View file

@ -693,11 +693,11 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators(); IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
for( int j = 0; j < dtors.length; j++ ){ for( int j = 0; j < dtors.length; j++ ){
if( dtors[j] == null ) break; if( dtors[j] == null ) break;
scope.addName( dtors[j].getName() ); ASTInternal.addName(scope, dtors[j].getName() );
} }
} else if( decl instanceof IASTFunctionDefinition ){ } else if( decl instanceof IASTFunctionDefinition ){
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator(); IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
scope.addName( dtor.getName() ); ASTInternal.addName(scope, dtor.getName() );
} }
} }

View file

@ -1626,14 +1626,14 @@ public class CPPSemantics {
while( dtor.getNestedDeclarator() != null ) while( dtor.getNestedDeclarator() != null )
dtor = dtor.getNestedDeclarator(); dtor = dtor.getNestedDeclarator();
IASTName declName = dtor.getName(); IASTName declName = dtor.getName();
scope.addName( declName ); ASTInternal.addName( scope, declName );
if( !data.typesOnly && nameMatches( data, declName ) ) { if( !data.typesOnly && nameMatches( data, declName ) ) {
return declName; return declName;
} }
} }
} else if( node instanceof ICPPASTTemplateParameter ){ } else if( node instanceof ICPPASTTemplateParameter ){
IASTName name = CPPTemplates.getTemplateParameterName( (ICPPASTTemplateParameter) node ); IASTName name = CPPTemplates.getTemplateParameterName( (ICPPASTTemplateParameter) node );
scope.addName( name ); ASTInternal.addName( scope, name );
if( nameMatches( data, name ) ) { if( nameMatches( data, name ) ) {
return name; return name;
} }
@ -1651,7 +1651,7 @@ public class CPPSemantics {
while( declarator.getNestedDeclarator() != null ) while( declarator.getNestedDeclarator() != null )
declarator = declarator.getNestedDeclarator(); declarator = declarator.getNestedDeclarator();
IASTName declaratorName = declarator.getName(); IASTName declaratorName = declarator.getName();
scope.addName( declaratorName ); ASTInternal.addName( scope, declaratorName );
if( !data.typesOnly || simpleDeclaration.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ) { if( !data.typesOnly || simpleDeclaration.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ) {
if( nameMatches( data, declaratorName ) ) { if( nameMatches( data, declaratorName ) ) {
if( resultName == null ) if( resultName == null )
@ -1715,7 +1715,7 @@ public class CPPSemantics {
IASTEnumerator enumerator = list[i]; IASTEnumerator enumerator = list[i];
if( enumerator == null ) break; if( enumerator == null ) break;
tempName = enumerator.getName(); tempName = enumerator.getName();
scope.addName( tempName ); ASTInternal.addName( scope, tempName );
if( !data.typesOnly && nameMatches( data, tempName ) ) { if( !data.typesOnly && nameMatches( data, tempName ) ) {
if( resultName == null ) if( resultName == null )
resultName = tempName; resultName = tempName;
@ -1727,7 +1727,7 @@ public class CPPSemantics {
} }
} }
if( specName != null ) { if( specName != null ) {
scope.addName( specName ); ASTInternal.addName( scope, specName );
if( nameMatches( data, specName ) ) { if( nameMatches( data, specName ) ) {
if( resultName == null ) if( resultName == null )
resultName = specName; resultName = specName;
@ -1744,18 +1744,18 @@ public class CPPSemantics {
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames(); IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
name = ns[ ns.length - 1 ]; name = ns[ ns.length - 1 ];
} }
scope.addName( name ); ASTInternal.addName( scope, name );
if( nameMatches( data, name ) ) { if( nameMatches( data, name ) ) {
return name; return name;
} }
} else if( declaration instanceof ICPPASTNamespaceDefinition ){ } else if( declaration instanceof ICPPASTNamespaceDefinition ){
IASTName namespaceName = ((ICPPASTNamespaceDefinition) declaration).getName(); IASTName namespaceName = ((ICPPASTNamespaceDefinition) declaration).getName();
scope.addName( namespaceName ); ASTInternal.addName( scope, namespaceName );
if( nameMatches( data, namespaceName ) ) if( nameMatches( data, namespaceName ) )
return namespaceName; return namespaceName;
} else if( declaration instanceof ICPPASTNamespaceAlias ){ } else if( declaration instanceof ICPPASTNamespaceAlias ){
IASTName alias = ((ICPPASTNamespaceAlias) declaration).getAlias(); IASTName alias = ((ICPPASTNamespaceAlias) declaration).getAlias();
scope.addName( alias ); ASTInternal.addName( scope, alias );
if( nameMatches( data, alias ) ) if( nameMatches( data, alias ) )
return alias; return alias;
} else if( declaration instanceof IASTFunctionDefinition ){ } else if( declaration instanceof IASTFunctionDefinition ){
@ -1765,7 +1765,7 @@ public class CPPSemantics {
//check the function itself //check the function itself
IASTName declName = declarator.getName(); IASTName declName = declarator.getName();
scope.addName( declName ); ASTInternal.addName( scope, declName );
if( !data.typesOnly && nameMatches( data, declName ) ) { if( !data.typesOnly && nameMatches( data, declName ) ) {
return declName; return declName;

View file

@ -219,7 +219,7 @@ public class CPPVisitor {
binding = functionScope.getBinding( name, false ); binding = functionScope.getBinding( name, false );
if( binding == null || !(binding instanceof ILabel) ){ if( binding == null || !(binding instanceof ILabel) ){
binding = new CPPLabel( name ); binding = new CPPLabel( name );
functionScope.addName( name ); ASTInternal.addName( functionScope, name );
} }
} catch ( DOMException e ) { } catch ( DOMException e ) {
binding = e.getProblem(); binding = e.getProblem();
@ -236,7 +236,7 @@ public class CPPVisitor {
binding = functionScope.getBinding( name, false ); binding = functionScope.getBinding( name, false );
if( binding == null || !(binding instanceof ILabel) ){ if( binding == null || !(binding instanceof ILabel) ){
binding = new CPPLabel( name ); binding = new CPPLabel( name );
functionScope.addName( name ); ASTInternal.addName( functionScope, name );
} else { } else {
((CPPLabel)binding).setLabelStatement( name ); ((CPPLabel)binding).setLabelStatement( name );
} }
@ -254,7 +254,7 @@ public class CPPVisitor {
enumtor = scope.getBinding( enumerator.getName(), false ); enumtor = scope.getBinding( enumerator.getName(), false );
if( enumtor == null || !( enumtor instanceof IEnumerator ) ){ if( enumtor == null || !( enumtor instanceof IEnumerator ) ){
enumtor = new CPPEnumerator( enumerator.getName() ); enumtor = new CPPEnumerator( enumerator.getName() );
scope.addName( enumerator.getName() ); ASTInternal.addName( scope, enumerator.getName() );
} }
} catch ( DOMException e ) { } catch ( DOMException e ) {
enumtor = e.getProblem(); enumtor = e.getProblem();
@ -271,7 +271,7 @@ public class CPPVisitor {
enumeration = scope.getBinding( specifier.getName(), false ); enumeration = scope.getBinding( specifier.getName(), false );
if( enumeration == null || !(enumeration instanceof IEnumeration) ){ if( enumeration == null || !(enumeration instanceof IEnumeration) ){
enumeration = new CPPEnumeration( specifier.getName() ); enumeration = new CPPEnumeration( specifier.getName() );
scope.addName( specifier.getName() ); ASTInternal.addName( scope, specifier.getName() );
} }
} catch ( DOMException e ) { } catch ( DOMException e ) {
enumeration = e.getProblem(); enumeration = e.getProblem();
@ -357,7 +357,7 @@ public class CPPVisitor {
binding = new CPPClassTemplate( name ); binding = new CPPClassTemplate( name );
else else
binding = new CPPClassType( name ); binding = new CPPClassType( name );
scope.addName( elabType.getName() ); ASTInternal.addName( scope, elabType.getName() );
} }
} else if( binding instanceof ICPPInternalBinding ){ } else if( binding instanceof ICPPInternalBinding ){
((ICPPInternalBinding)binding).addDeclaration( elabType ); ((ICPPInternalBinding)binding).addDeclaration( elabType );
@ -398,7 +398,7 @@ public class CPPVisitor {
else else
binding = new CPPClassType( name ); binding = new CPPClassType( name );
if( scope != null ) if( scope != null )
scope.addName( compType.getName() ); ASTInternal.addName( scope, compType.getName() );
} else { } else {
if( binding instanceof ICPPInternalBinding ){ if( binding instanceof ICPPInternalBinding ){
ICPPInternalBinding internal = (ICPPInternalBinding) binding; ICPPInternalBinding internal = (ICPPInternalBinding) binding;
@ -423,7 +423,7 @@ public class CPPVisitor {
binding = scope.getBinding( namespaceDef.getName(), false ); binding = scope.getBinding( namespaceDef.getName(), false );
if( binding == null || binding instanceof IProblemBinding ){ if( binding == null || binding instanceof IProblemBinding ){
binding = new CPPNamespace( namespaceDef ); binding = new CPPNamespace( namespaceDef );
scope.addName( namespaceDef.getName() ); ASTInternal.addName( scope, namespaceDef.getName() );
} }
} catch ( DOMException e ) { } catch ( DOMException e ) {
binding = e.getProblem(); binding = e.getProblem();
@ -445,7 +445,7 @@ public class CPPVisitor {
} }
if( namespace instanceof ICPPNamespace ) { if( namespace instanceof ICPPNamespace ) {
binding = new CPPNamespaceAlias( alias.getAlias(), (ICPPNamespace) namespace ); binding = new CPPNamespaceAlias( alias.getAlias(), (ICPPNamespace) namespace );
scope.addName( alias.getAlias() ); ASTInternal.addName( scope, alias.getAlias() );
} else { } else {
binding = new ProblemBinding( alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND, alias.getAlias().toCharArray() ); 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 ){ if( scope != null && binding != null ){
try { try {
scope.addName( name ); ASTInternal.addName( scope, name );
} catch ( DOMException e1 ) { } catch ( DOMException e1 ) {
} }
} }

View file

@ -141,6 +141,7 @@ import org.eclipse.cdt.core.parser.ParseError;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.util.ArrayUtil; 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.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException; import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
@ -4642,7 +4643,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
translationUnit.getScope(), ParserLanguage.CPP) translationUnit.getScope(), ParserLanguage.CPP)
.getBuiltinBindings(); .getBuiltinBindings();
for (int i = 0; i < bindings.length; i++) { for (int i = 0; i < bindings.length; i++) {
tuScope.addBinding(bindings[i]); ASTInternal.addBinding(tuScope, bindings[i]);
} }
} }
} catch (Exception e2) { } catch (Exception e2) {

View file

@ -283,11 +283,6 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
return this; 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 { public IName getScopeName() throws DOMException {
try { try {
PDOMName name = getFirstDefinition(); PDOMName name = getFirstDefinition();
@ -323,13 +318,8 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
public IField findField(String name) throws DOMException {fail();return null;} public IField findField(String name) throws DOMException {fail();return null;}
public IBinding[] getFriends() throws DOMException {fail();return null;} public IBinding[] getFriends() throws DOMException {fail();return null;}
public ICPPMethod[] getImplicitMethods() {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 IBinding[] find(String name) throws DOMException {fail();return null;}
public void flushCache() throws DOMException {fail();}
public ICPPField[] getDeclaredFields() throws DOMException {fail();return null;} 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 { public IScope getScope() throws DOMException {
try { try {

View file

@ -100,6 +100,9 @@ class PDOMCPPNamespace extends PDOMCPPBinding
return new IASTNode[0]; 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 { public IBinding[] find(String name) throws DOMException {
try { try {
FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray()); FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray());
@ -199,12 +202,6 @@ class PDOMCPPNamespace extends PDOMCPPBinding
} }
public IBinding[] getMemberBindings() throws DOMException {fail(); return null;} 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 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 addUsingDirective(IASTNode directive) throws DOMException {fail();}
public void addBinding(IBinding binding) throws DOMException {fail();}
public void addName(IASTName name) throws DOMException {fail();}
} }