mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 90817: promote caching methods to IScope and support remove binding
This commit is contained in:
parent
bd75012bd8
commit
e832d582ff
10 changed files with 170 additions and 147 deletions
|
@ -1,5 +1,5 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -48,4 +48,56 @@ public interface IScope {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IASTNode getPhysicalNode() throws DOMException;
|
public IASTNode getPhysicalNode() throws DOMException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IScope serves as a mechanism for caching IASTNames and bindings to
|
||||||
|
* speed up resolution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* yet been cached in this scope, or if resolve == false and the appropriate binding
|
||||||
|
* has not yet been resolved.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param resolve :
|
||||||
|
* whether or not to resolve the matching binding if it has not
|
||||||
|
* been so already.
|
||||||
|
* @return : the binding in this scope that matches the name, or null
|
||||||
|
* @throws DOMException
|
||||||
|
*/
|
||||||
|
public IBinding getBinding(IASTName name, boolean resolve)
|
||||||
|
throws DOMException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether or not all the names in this scope have been cached
|
||||||
|
*
|
||||||
|
* @param b
|
||||||
|
*/
|
||||||
|
public void setFullyCached(boolean b) throws DOMException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether or not this scope's cache contains all the names
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isFullyCached() throws DOMException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,57 +14,10 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.dom.ast.c;
|
package org.eclipse.cdt.core.dom.ast.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public interface ICScope extends IScope {
|
public interface ICScope extends IScope {
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the binding that the given name would resolve to in this scope. Could
|
|
||||||
* return null if there is no matching binding in this scope, or if resolve ==
|
|
||||||
* false and the appropriate binding has not yet been resolved.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param resolve :
|
|
||||||
* whether or not to resolve the matching binding if it has not
|
|
||||||
* been so already.
|
|
||||||
* @return : the binding in this scope that matches the name, or null
|
|
||||||
* @throws DOMException
|
|
||||||
*/
|
|
||||||
public IBinding getBinding(IASTName name, boolean resolve)
|
|
||||||
throws DOMException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether or not all the names in this scope have been cached
|
|
||||||
*
|
|
||||||
* @param b
|
|
||||||
*/
|
|
||||||
public void setFullyCached(boolean b) throws DOMException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* whether or not this scope's cache contains all the names
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isFullyCached() throws DOMException;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,53 +13,11 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ICPPScope serves as a mechanism for caching IASTNames and bindings to
|
|
||||||
* speed up resolution.
|
|
||||||
*
|
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public interface ICPPScope extends IScope {
|
public interface ICPPScope extends IScope {
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an IASTName to be cached in this scope
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @throws DOMException
|
|
||||||
*/
|
|
||||||
public void addName(IASTName name) throws DOMException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the binding that the given name would resolve to in this scope. Could
|
|
||||||
* return null if there is no matching binding in this scope, or if resolve ==
|
|
||||||
* false and the appropriate binding has not yet been resolved.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param resolve :
|
|
||||||
* whether or not to resolve the matching binding if it has not
|
|
||||||
* been so already.
|
|
||||||
* @return : the binding in this scope that matches the name, or null
|
|
||||||
* @throws DOMException
|
|
||||||
*/
|
|
||||||
public IBinding getBinding(IASTName name, boolean resolve)
|
|
||||||
throws DOMException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether or not all the names in this scope have been cached
|
|
||||||
*
|
|
||||||
* @param b
|
|
||||||
*/
|
|
||||||
public void setFullyCached(boolean b) throws DOMException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* whether or not this scope's cache contains all the names
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isFullyCached() throws DOMException;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,41 @@ public class ProblemBinding implements IProblemBinding, IType, IScope {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
|
* @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
|
||||||
*/
|
*/
|
||||||
public IASTName getScopeName() throws DOMException {
|
public IASTName getScopeName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
|
*/
|
||||||
|
public void addName( IASTName name ) throws DOMException {
|
||||||
|
throw new DOMException( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||||
|
*/
|
||||||
|
public void removeBinding( IBinding binding ) throws DOMException {
|
||||||
|
throw new DOMException( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
|
||||||
|
*/
|
||||||
|
public IBinding getBinding( IASTName name, boolean resolve ) throws DOMException {
|
||||||
|
throw new DOMException( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IScope#setFullyCached(boolean)
|
||||||
|
*/
|
||||||
|
public void setFullyCached( boolean b ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IScope#isFullyCached()
|
||||||
|
*/
|
||||||
|
public boolean isFullyCached() throws DOMException {
|
||||||
|
throw new DOMException( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class CScope implements ICScope {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
|
* @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
|
||||||
*/
|
*/
|
||||||
public IASTName getScopeName() throws DOMException {
|
public IASTName getScopeName() {
|
||||||
if( physicalNode instanceof IASTCompositeTypeSpecifier ){
|
if( physicalNode instanceof IASTCompositeTypeSpecifier ){
|
||||||
return ((IASTCompositeTypeSpecifier) physicalNode).getName();
|
return ((IASTCompositeTypeSpecifier) physicalNode).getName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -28,7 +27,7 @@ public class CPPBlockScope extends CPPNamespaceScope implements ICPPBlockScope {
|
||||||
super( physicalNode );
|
super( physicalNode );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTName getScopeName() throws DOMException{
|
public IASTName getScopeName(){
|
||||||
IASTNode node = getPhysicalNode();
|
IASTNode node = getPhysicalNode();
|
||||||
if( node instanceof IASTCompoundStatement && node.getParent() instanceof IASTFunctionDefinition ){
|
if( node instanceof IASTCompoundStatement && node.getParent() instanceof IASTFunctionDefinition ){
|
||||||
return ((IASTFunctionDefinition)node.getParent()).getDeclarator().getName();
|
return ((IASTFunctionDefinition)node.getParent()).getDeclarator().getName();
|
||||||
|
|
|
@ -21,8 +21,8 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
|
@ -195,4 +195,25 @@ public class CPPClassInstanceScope implements ICPPClassScope {
|
||||||
ICPPClassScope scope = (ICPPClassScope) getOriginalClass().getCompositeScope();
|
ICPPClassScope scope = (ICPPClassScope) getOriginalClass().getCompositeScope();
|
||||||
return scope.getPhysicalNode();
|
return scope.getPhysicalNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||||
|
*/
|
||||||
|
public void removeBinding(IBinding binding) {
|
||||||
|
char [] name = binding.getNameCharArray();
|
||||||
|
if( ! bindings.containsKey( name ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Object obj = bindings.get( name );
|
||||||
|
if( obj instanceof ObjectSet ){
|
||||||
|
ObjectSet set = (ObjectSet) obj;
|
||||||
|
set.remove( binding );
|
||||||
|
if( set.size() == 0 )
|
||||||
|
bindings.remove( name, 0, name.length );
|
||||||
|
} else {
|
||||||
|
bindings.remove( name, 0, name.length );
|
||||||
|
}
|
||||||
|
|
||||||
|
isFullyCached = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
private void createImplicitMembers(){
|
private void createImplicitMembers(){
|
||||||
//create bindings for the implicit members, if the user declared them then those declarations
|
//create bindings for the implicit members, if the user declared them then those declarations
|
||||||
//will resolve to these bindings.
|
//will resolve to these bindings.
|
||||||
ICPPASTCompositeTypeSpecifier compTypeSpec;
|
ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||||
try {
|
|
||||||
compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
|
||||||
} catch ( DOMException e ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IASTName name = compTypeSpec.getName();
|
IASTName name = compTypeSpec.getName();
|
||||||
if( name instanceof ICPPASTQualifiedName ){
|
if( name instanceof ICPPASTQualifiedName ){
|
||||||
|
@ -118,10 +113,13 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
char [] c = binding.getNameCharArray();
|
char [] c = binding.getNameCharArray();
|
||||||
Object o = bindings.get( c );
|
Object o = bindings.get( c );
|
||||||
if( o != null ){
|
if( o != null ){
|
||||||
if( o instanceof Object[] ){
|
if( o instanceof ObjectSet ){
|
||||||
bindings.put( c, ArrayUtil.append( Object.class, (Object[]) o, binding ) );
|
((ObjectSet)o).put( binding );
|
||||||
} else {
|
} else {
|
||||||
bindings.put( c, new Object[] { o, binding } );
|
ObjectSet set = new ObjectSet(2);
|
||||||
|
set.put( o );
|
||||||
|
set.put( binding );
|
||||||
|
bindings.put( c, set );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bindings.put( c, binding );
|
bindings.put( c, binding );
|
||||||
|
@ -228,12 +226,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getClassType()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getClassType()
|
||||||
*/
|
*/
|
||||||
public ICPPClassType getClassType() {
|
public ICPPClassType getClassType() {
|
||||||
ICPPASTCompositeTypeSpecifier compSpec;
|
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||||
try {
|
|
||||||
compSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
|
||||||
} catch (DOMException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (ICPPClassType) compSpec.getName().resolveBinding();
|
return (ICPPClassType) compSpec.getName().resolveBinding();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -250,11 +243,24 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||||
*/
|
*/
|
||||||
public IASTName getScopeName() throws DOMException {
|
public IASTName getScopeName() {
|
||||||
IASTNode node = getPhysicalNode();
|
IASTNode node = getPhysicalNode();
|
||||||
if( node instanceof ICPPASTCompositeTypeSpecifier ){
|
if( node instanceof ICPPASTCompositeTypeSpecifier ){
|
||||||
return ((ICPPASTCompositeTypeSpecifier)node).getName();
|
return ((ICPPASTCompositeTypeSpecifier)node).getName();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||||
|
*/
|
||||||
|
public void removeBinding(IBinding binding) {
|
||||||
|
if( binding instanceof ICPPConstructor ){
|
||||||
|
if( constructorBindings.containsKey( binding ) )
|
||||||
|
constructorBindings.remove( binding );
|
||||||
|
setFullyCached( false );
|
||||||
|
} else {
|
||||||
|
super.removeBinding( binding );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope#getBodyScope()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope#getBodyScope()
|
||||||
*/
|
*/
|
||||||
public IScope getBodyScope() throws DOMException {
|
public IScope getBodyScope() {
|
||||||
IASTFunctionDeclarator fnDtor = (IASTFunctionDeclarator) getPhysicalNode();
|
IASTFunctionDeclarator fnDtor = (IASTFunctionDeclarator) getPhysicalNode();
|
||||||
IASTNode parent = fnDtor.getParent();
|
IASTNode parent = fnDtor.getParent();
|
||||||
if( parent instanceof IASTFunctionDefinition ){
|
if( parent instanceof IASTFunctionDefinition ){
|
||||||
|
@ -116,7 +116,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||||
*/
|
*/
|
||||||
public IASTName getScopeName() throws DOMException {
|
public IASTName getScopeName() {
|
||||||
IASTNode node = getPhysicalNode();
|
IASTNode node = getPhysicalNode();
|
||||||
if( node instanceof ICPPASTFunctionDeclarator ){
|
if( node instanceof ICPPASTFunctionDeclarator ){
|
||||||
return ((ICPPASTFunctionDeclarator)node).getName();
|
return ((ICPPASTFunctionDeclarator)node).getName();
|
||||||
|
|
|
@ -35,38 +35,9 @@ abstract public class CPPScope implements ICPPScope{
|
||||||
public CPPScopeProblem( IASTNode node, int id, char[] arg ) {
|
public CPPScopeProblem( IASTNode node, int id, char[] arg ) {
|
||||||
super( node, id, arg );
|
super( node, id, arg );
|
||||||
}
|
}
|
||||||
public void addName( IASTName name ) throws DOMException {
|
|
||||||
throw new DOMException( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding getBinding( IASTName name, boolean resolve ) throws DOMException {
|
|
||||||
throw new DOMException( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public IScope getParent() throws DOMException {
|
|
||||||
throw new DOMException( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding[] find( String name ) throws DOMException {
|
|
||||||
throw new DOMException( this );
|
|
||||||
}
|
|
||||||
public void setFullyCached(boolean b) {
|
|
||||||
}
|
|
||||||
public boolean isFullyCached() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public IASTName getScopeName() throws DOMException {
|
|
||||||
throw new DOMException( this );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class CPPTemplateProblem extends CPPScopeProblem {
|
|
||||||
public CPPTemplateProblem( IASTNode node, int id, char[] arg) {
|
|
||||||
super( node, id, arg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IASTNode physicalNode;
|
||||||
private IASTNode physicalNode;
|
|
||||||
public CPPScope( IASTNode physicalNode ) {
|
public CPPScope( IASTNode physicalNode ) {
|
||||||
this.physicalNode = physicalNode;
|
this.physicalNode = physicalNode;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +49,7 @@ abstract public class CPPScope implements ICPPScope{
|
||||||
return CPPVisitor.getContainingScope( physicalNode );
|
return CPPVisitor.getContainingScope( physicalNode );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTNode getPhysicalNode() throws DOMException{
|
public IASTNode getPhysicalNode() {
|
||||||
return physicalNode;
|
return physicalNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +70,6 @@ abstract public class CPPScope implements ICPPScope{
|
||||||
if( o != null ){
|
if( o != null ){
|
||||||
if( o instanceof ObjectSet ){
|
if( o instanceof ObjectSet ){
|
||||||
((ObjectSet)o).put( name );
|
((ObjectSet)o).put( name );
|
||||||
//bindings.put( c, ArrayUtil.append( Object.class, (Object[]) o, name ) );
|
|
||||||
} else {
|
} else {
|
||||||
ObjectSet temp = new ObjectSet( 2 );
|
ObjectSet temp = new ObjectSet( 2 );
|
||||||
temp.put( o );
|
temp.put( o );
|
||||||
|
@ -167,6 +137,36 @@ abstract public class CPPScope implements ICPPScope{
|
||||||
return isfull;
|
return isfull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||||
|
*/
|
||||||
|
public void removeBinding(IBinding binding) {
|
||||||
|
char [] name = binding.getNameCharArray();
|
||||||
|
if( ! bindings.containsKey( name ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Object obj = bindings.get( name );
|
||||||
|
if( obj instanceof ObjectSet ){
|
||||||
|
ObjectSet set = (ObjectSet) obj;
|
||||||
|
for ( int i = set.size() - 1; i > 0; i-- ) {
|
||||||
|
Object o = set.keyAt( i );
|
||||||
|
if( (o instanceof IBinding && o == binding) ||
|
||||||
|
(o instanceof IASTName && ((IASTName)o).getBinding() == binding) )
|
||||||
|
{
|
||||||
|
set.remove( o );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( set.size() == 0 )
|
||||||
|
bindings.remove( name, 0, name.length );
|
||||||
|
} else if( (obj instanceof IBinding && obj == binding) ||
|
||||||
|
(obj instanceof IASTName && ((IASTName)obj).getBinding() == binding) )
|
||||||
|
{
|
||||||
|
bindings.remove( name, 0, name.length );
|
||||||
|
}
|
||||||
|
|
||||||
|
isfull = false;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue