1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-16 04:35:45 +02:00

Fixed Bugzilla Bug 87548 : [DOM AST] IASTName interface lacks methods to determine if name is a declaration, a definition or a reference

This commit is contained in:
John Camelon 2005-03-14 20:14:37 +00:00
parent 79386d0400
commit f83e7a7c6f
62 changed files with 802 additions and 267 deletions

View file

@ -241,6 +241,8 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(IASTDeclSpecifier.sc_typedef, type.getStorageClass());
// this an anonymous struct
IASTName name_struct = type.getName();
assertTrue( name_struct.isDeclaration() );
assertFalse( name_struct.isReference() );
assertNull("", name_struct.toString()); //$NON-NLS-1$
// member - x
IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) type
@ -1707,6 +1709,7 @@ public class AST2Tests extends AST2BaseTest {
.getDeclSpecifier();
ICompositeType A = (ICompositeType) elabSpec.getName().resolveBinding();
IASTName name_A1 = elabSpec.getName();
assertTrue( name_A1.isDeclaration() );
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IFunction f = (IFunction) decl.getDeclarators()[0].getName()

View file

@ -16,7 +16,7 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author Doug Schaefer
*/
public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier {
public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier , IASTNameOwner {
/**
* <code>TYPE_NAME</code> represents the relationship between an

View file

@ -15,7 +15,7 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author Doug Schaefer
*/
public interface IASTDeclarator extends IASTNode {
public interface IASTDeclarator extends IASTNode, IASTNameOwner {
/**
* Constant - empty declarator array

View file

@ -14,7 +14,7 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author jcamelon
*/
public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier {
public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/**
* Enumeration.

View file

@ -14,14 +14,14 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author jcamelon
*/
public interface IASTEnumerationSpecifier extends IASTDeclSpecifier {
public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/**
* This interface represents an enumerator member of an enum specifier.
*
* @author jcamelon
*/
public interface IASTEnumerator extends IASTNode {
public interface IASTEnumerator extends IASTNode, IASTNameOwner {
/**
* Empty array (constant).
*/

View file

@ -17,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author Doug Schaefer
*/
public interface IASTFieldReference extends IASTExpression {
public interface IASTFieldReference extends IASTExpression, IASTNameOwner {
/**
* <code>FIELD_OWNER</code> represents the relationship between a

View file

@ -15,7 +15,7 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author Doug Schaefer
*/
public interface IASTGotoStatement extends IASTStatement {
public interface IASTGotoStatement extends IASTStatement, IASTNameOwner {
public static final ASTNodeProperty NAME = new ASTNodeProperty("name"); //$NON-NLS-1$

View file

@ -15,7 +15,7 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author Doug Schaefer
*/
public interface IASTIdExpression extends IASTExpression {
public interface IASTIdExpression extends IASTExpression, IASTNameOwner {
/**
* <code>ID_NAME</code> represents the relationship between an

View file

@ -15,7 +15,7 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author Doug Schaefer
*/
public interface IASTLabelStatement extends IASTStatement {
public interface IASTLabelStatement extends IASTStatement, IASTNameOwner {
public static final ASTNodeProperty NAME = new ASTNodeProperty("name"); //$NON-NLS-1$

View file

@ -47,4 +47,16 @@ public interface IASTName extends IASTNode {
* @return ~ toString().toCharArray()
*/
public char[] toCharArray();
/**
* Is this name being used in the AST as the introduction of a declaration?
* @return boolean
*/
public boolean isDeclaration();
/**
* Is this name being used in the AST as a reference rather than a declaration?
* @return
*/
public boolean isReference();
}

View file

@ -0,0 +1,32 @@
package org.eclipse.cdt.core.dom.ast;
/**
* This interface repesents a mechanism for a name to discover more information about it's parent.
* All interfaces that claim ownership/residence of a name should extend this interface.
*
* @author jcamelon
*/
public interface IASTNameOwner {
/**
* Role of name in this context is a declaration.
*/
public static final int r_declaration = 0;
/**
* Role of name in this construct is a reference.
*/
public static final int r_reference = 1;
/**
* Role is unclear.
*/
public static final int r_unclear = 2;
/**
* Get the role for the name.
*
* @param name <code>IASTName</code>
* @return r_declaration, r_reference or r_unclear.
*/
public int getRoleForName( IASTName n );
}

View file

@ -16,7 +16,7 @@ package org.eclipse.cdt.core.dom.ast;
*
* @author Doug Schaefer
*/
public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier {
public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/**
* <code>NAME</code> describes the relationship between an

View file

@ -16,7 +16,7 @@ package org.eclipse.cdt.core.dom.ast;
* @author Doug Schaefer
*/
public interface IASTPreprocessorMacroDefinition extends
IASTPreprocessorStatement {
IASTPreprocessorStatement, IASTNameOwner {
/**
* <code>MACRO_NAME</code> describes the relationship between a macro

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
/**
@ -50,7 +51,7 @@ public interface ICPPASTCompositeTypeSpecifier extends
*
* @author jcamelon
*/
public static interface ICPPASTBaseSpecifier extends IASTNode {
public static interface ICPPASTBaseSpecifier extends IASTNode, IASTNameOwner {
/**
* Constant.
*/

View file

@ -13,12 +13,13 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
/**
* @author jcamelon
*/
public interface ICPPASTConstructorChainInitializer extends IASTNode {
public interface ICPPASTConstructorChainInitializer extends IASTNode, IASTNameOwner {
/**
* Constant.
*/

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
* This interface represents a namespace alias in C++. e.g. namespace ABC { int
@ -20,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
*
* @author jcamelon
*/
public interface ICPPASTNamespaceAlias extends IASTDeclaration {
public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner {
/**
* <code>ALIAS_NAME</code> represents the new namespace name being

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IScope;
/**
@ -20,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
*
* @author jcamelon
*/
public interface ICPPASTNamespaceDefinition extends IASTDeclaration {
public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwner {
/**
* <code>OWNED_DECLARATION</code> is the role served by all the nested

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTPointer;
/**
@ -19,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPointer;
*
* @author Doug Schaefer
*/
public interface ICPPASTPointerToMember extends IASTPointer {
public interface ICPPASTPointerToMember extends IASTPointer, IASTNameOwner {
/**
* This property refers to the nested name.

View file

@ -12,13 +12,14 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
* This interface is a qualified name in C++.
*
* @author jcamelon
*/
public interface ICPPASTQualifiedName extends IASTName {
public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner {
/**
* Each IASTName segment has property being <code>SEGMENT_NAME</code>.

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
/**
@ -20,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
* @author jcamelon
*/
public interface ICPPASTSimpleTypeTemplateParameter extends
ICPPASTTemplateParameter {
ICPPASTTemplateParameter, IASTNameOwner {
/**
* <code>st_class</code> represents a class.

View file

@ -13,13 +13,14 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
/**
* @author jcamelon
*/
public interface ICPPASTTemplateId extends IASTName {
public interface ICPPASTTemplateId extends IASTName, IASTNameOwner {
/**
* TEMPLATE_NAME is the IASTName.

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
* This is a templated template parameter.
@ -20,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
* @author jcamelon
*/
public interface ICPPASTTemplatedTypeTemplateParameter extends
ICPPASTTemplateParameter {
ICPPASTTemplateParameter, IASTNameOwner {
/**
* PARAMETER

View file

@ -13,11 +13,12 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
* @author jcamelon
*/
public interface ICPPASTTypenameExpression extends IASTExpression {
public interface ICPPASTTypenameExpression extends IASTExpression, IASTNameOwner {
/**
* Was template token consumed?

View file

@ -13,13 +13,14 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
* This interface represents a using declaration.
*
* @author jcamelon
*/
public interface ICPPASTUsingDeclaration extends IASTDeclaration {
public interface ICPPASTUsingDeclaration extends IASTDeclaration, IASTNameOwner {
/**
* <code>NAME</code> is the qualified name brought into scope.

View file

@ -13,13 +13,14 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
* This interface represents a C++ using directive.
*
* @author jcamelon
*/
public interface ICPPASTUsingDirective extends IASTDeclaration {
public interface ICPPASTUsingDirective extends IASTDeclaration, IASTNameOwner {
/**
* Constant.
*/

View file

@ -15,13 +15,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
* This is the declarator for a K&R C Function.
*
* @author dsteffle
*/
public interface ICASTKnRFunctionDeclarator extends IASTFunctionDeclarator {
public interface ICASTKnRFunctionDeclarator extends IASTFunctionDeclarator, IASTNameOwner {
/**
* <code>PARAMETER_NAME</code> refers to the names qualified in a K&R C

View file

@ -135,4 +135,13 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName name) {
if( name == this.name )
return r_declaration;
return r_unclear;
}
}

View file

@ -10,9 +10,11 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
@ -140,4 +142,29 @@ public class CASTDeclarator extends CASTNode implements IASTDeclarator {
if( initializer != null ) if( !initializer.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName name) {
if( name == this.name )
{
IASTNode getParent = getParent();
if( getParent instanceof IASTDeclaration )
return r_declaration;
if( getParent instanceof IASTTypeId )
return r_reference;
if( getParent instanceof IASTDeclarator )
{
IASTNode t = getParent;
while ( t instanceof IASTDeclarator )
t = t.getParent();
if( t instanceof IASTDeclaration )
return r_declaration;
if( t instanceof IASTTypeId )
return r_reference;
}
}
return r_unclear;
}
}

View file

@ -61,4 +61,13 @@ public class CASTElaboratedTypeSpecifier extends CASTBaseDeclSpecifier implement
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName name) {
if( this.name == name )
return r_declaration;
return r_unclear;
}
}

View file

@ -104,4 +104,13 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier implements
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName name) {
if( this.name == name )
return r_declaration;
return r_unclear;
}
}

View file

@ -63,4 +63,12 @@ public class CASTEnumerator extends CASTNode implements IASTEnumerator {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name )return r_declaration;
return r_unclear;
}
}

View file

@ -78,4 +78,13 @@ public class CASTFieldReference extends CASTNode implements IASTFieldReference {
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName name) {
if( name == this.name )
return r_reference;
return r_unclear;
}
}

View file

@ -45,4 +45,12 @@ public class CASTGotoStatement extends CASTNode implements IASTGotoStatement {
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name ) return r_reference;
return r_unclear;
}
}

View file

@ -46,4 +46,12 @@ public class CASTIdExpression extends CASTNode implements IASTIdExpression {
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name ) return r_reference;
return r_unclear;
}
}

View file

@ -91,4 +91,14 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.c.CASTDeclarator#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName name) {
IASTName [] n = getParameterNames();
for( int i = 0; i < n.length; ++i )
if( n[i] == name ) return r_unclear;
return super.getRoleForName(name);
}
}

View file

@ -45,4 +45,12 @@ public class CASTLabelStatement extends CASTNode implements IASTLabelStatement {
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name ) return r_declaration;
return r_unclear;
}
}

View file

@ -11,6 +11,8 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
/**
@ -82,4 +84,30 @@ public class CASTName extends CASTNode implements IASTName {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isDeclaration()
*/
public boolean isDeclaration() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if( role == IASTNameOwner.r_reference ) return false;
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isReference()
*/
public boolean isReference() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if( role == IASTNameOwner.r_reference ) return true;
return false;
}
return false;
}
}

View file

@ -46,4 +46,12 @@ public class CASTTypedefNameSpecifier extends CASTBaseDeclSpecifier implements
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name ) return r_reference;
return r_unclear;
}
}

View file

@ -81,4 +81,12 @@ public class CPPASTBaseSpecifier extends CPPASTNode implements
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n ) return r_reference;
return r_unclear;
}
}

View file

@ -186,4 +186,13 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName name) {
if( name == this.n )
return r_declaration;
return r_unclear;
}
}

View file

@ -57,4 +57,12 @@ public class CPPASTConstructorChainInitializer extends CPPASTNode implements
if( value != null ) if( !value.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n ) return r_reference;
return r_unclear;
}
}

View file

@ -141,4 +141,16 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
if( initializer != null ) if( !initializer.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n )
{
}
return r_unclear;
}
}

View file

@ -62,4 +62,12 @@ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name ) return r_reference; //TODO is this right?
return r_unclear;
}
}

View file

@ -19,90 +19,119 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
* @author jcamelon
*/
public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
implements IASTEnumerationSpecifier, ICPPASTDeclSpecifier {
implements IASTEnumerationSpecifier, ICPPASTDeclSpecifier {
private IASTName name;
private IASTName name;
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#addEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
*/
public void addEnumerator(IASTEnumerator enumerator) {
if( enumerators == null )
{
enumerators = new IASTEnumerator[ DEFAULT_ENUMERATORS_LIST_SIZE ];
currentIndex = 0;
}
if( enumerators.length == currentIndex )
{
IASTEnumerator [] old = enumerators;
enumerators = new IASTEnumerator[ old.length * 2 ];
for( int i = 0; i < old.length; ++i )
enumerators[i] = old[i];
}
enumerators[ currentIndex++ ] = enumerator;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#getEnumerators()
*/
public IASTEnumerator[] getEnumerators() {
if( enumerators == null ) return IASTEnumerator.EMPTY_ENUMERATOR_ARRAY;
removeNullEnumerators();
return enumerators;
}
private void removeNullEnumerators() {
int nullCount = 0;
for( int i = 0; i < enumerators.length; ++i )
if( enumerators[i] == null )
++nullCount;
if( nullCount == 0 ) return;
IASTEnumerator [] old = enumerators;
int newSize = old.length - nullCount;
enumerators = new IASTEnumerator[ newSize ];
for( int i = 0; i < newSize; ++i )
enumerators[i] = old[i];
currentIndex = newSize;
}
private int currentIndex = 0;
private IASTEnumerator [] enumerators = null;
private static final int DEFAULT_ENUMERATORS_LIST_SIZE = 4;
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#setName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public void setName(IASTName name) {
this.name = name;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#getName()
*/
public IASTName getName() {
return name;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#getUnpreprocessedSignature()
*/
public String getUnpreprocessedSignature() {
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
}
public boolean accept( ASTVisitor action ){
if( action.shouldVisitDeclSpecifiers ){
switch( action.visit( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#addEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
*/
public void addEnumerator(IASTEnumerator enumerator) {
if (enumerators == null) {
enumerators = new IASTEnumerator[DEFAULT_ENUMERATORS_LIST_SIZE];
currentIndex = 0;
}
if( name != null ) if( !name.accept( action ) ) return false;
IASTEnumerator[] enums = getEnumerators();
for( int i = 0; i < enums.length; i++ )
if( !enums[i].accept( action ) ) return false;
return true;
}
if (enumerators.length == currentIndex) {
IASTEnumerator[] old = enumerators;
enumerators = new IASTEnumerator[old.length * 2];
for (int i = 0; i < old.length; ++i)
enumerators[i] = old[i];
}
enumerators[currentIndex++] = enumerator;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#getEnumerators()
*/
public IASTEnumerator[] getEnumerators() {
if (enumerators == null)
return IASTEnumerator.EMPTY_ENUMERATOR_ARRAY;
removeNullEnumerators();
return enumerators;
}
private void removeNullEnumerators() {
int nullCount = 0;
for (int i = 0; i < enumerators.length; ++i)
if (enumerators[i] == null)
++nullCount;
if (nullCount == 0)
return;
IASTEnumerator[] old = enumerators;
int newSize = old.length - nullCount;
enumerators = new IASTEnumerator[newSize];
for (int i = 0; i < newSize; ++i)
enumerators[i] = old[i];
currentIndex = newSize;
}
private int currentIndex = 0;
private IASTEnumerator[] enumerators = null;
private static final int DEFAULT_ENUMERATORS_LIST_SIZE = 4;
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#setName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public void setName(IASTName name) {
this.name = name;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier#getName()
*/
public IASTName getName() {
return name;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier#getUnpreprocessedSignature()
*/
public String getUnpreprocessedSignature() {
return getName().toString() == null ? "" : getName().toString(); //$NON-NLS-1$
}
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT:
return false;
case ASTVisitor.PROCESS_SKIP:
return true;
default:
break;
}
}
if (name != null)
if (!name.accept(action))
return false;
IASTEnumerator[] enums = getEnumerators();
for (int i = 0; i < enums.length; i++)
if (!enums[i].accept(action))
return false;
return true;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if (name == n)
return r_declaration;
return r_unclear;
}
}

View file

@ -62,4 +62,13 @@ public class CPPASTEnumerator extends CPPASTNode implements IASTEnumerator {
if( value != null ) if( !value.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n )
return r_declaration;
return r_reference;
}
}

View file

@ -96,5 +96,14 @@ public class CPPASTFieldReference extends CPPASTNode implements
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name )
return r_reference;
return r_unclear;
}
}

View file

@ -46,4 +46,12 @@ public class CPPASTGotoStatement extends CPPASTNode implements
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n ) return r_reference;
return r_unclear;
}
}

View file

@ -46,4 +46,12 @@ public class CPPASTIdExpression extends CPPASTNode implements IASTIdExpression {
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n )return r_reference;
return r_unclear;
}
}

View file

@ -46,4 +46,12 @@ public class CPPASTLabelStatement extends CPPASTNode implements
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name ) return r_declaration;
return r_unclear;
}
}

View file

@ -12,6 +12,8 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
/**
@ -85,4 +87,30 @@ public class CPPASTName extends CPPASTNode implements IASTName {
}
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isDeclaration()
*/
public boolean isDeclaration() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if( role == IASTNameOwner.r_reference ) return false;
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isReference()
*/
public boolean isReference() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if( role == IASTNameOwner.r_reference ) return true;
return false;
}
return false;
}
}

View file

@ -62,4 +62,13 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name )
return r_reference;
return r_unclear;
}
}

View file

@ -65,4 +65,13 @@ public class CPPASTNamespaceAlias extends CPPASTNode implements
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( alias == n ) return r_declaration;
if( qualifiedName == n ) return r_reference;
return r_unclear;
}
}

View file

@ -116,4 +116,12 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n ) return r_declaration;
return r_unclear;
}
}

View file

@ -40,4 +40,13 @@ public class CPPASTPointerToMember extends CPPASTPointer implements
if( n != null ) if( !n.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName name ) {
if( name == this.n )
return r_declaration;
return r_unclear;
}
}

View file

@ -12,6 +12,8 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
@ -19,171 +21,226 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
* @author jcamelon
*/
public class CPPASTQualifiedName extends CPPASTNode implements
ICPPASTQualifiedName {
ICPPASTQualifiedName {
/**
* @param duple
*/
public CPPASTQualifiedName() {
}
/**
* @param duple
*/
public CPPASTQualifiedName() {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
*/
public IBinding resolveBinding() {
//The full qualified name resolves to the same thing as the last name
removeNullNames();
return names[names.length - 1].resolveBinding();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
*/
public IBinding resolveBinding() {
// The full qualified name resolves to the same thing as the last name
removeNullNames();
return names[names.length - 1].resolveBinding();
}
public IBinding[] resolvePrefix() {
removeNullNames();
return names[names.length - 1].resolvePrefix();
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
public String toString() {
if( signature == null ) return ""; //$NON-NLS-1$
return signature;
}
public IBinding[] resolvePrefix() {
removeNullNames();
return names[names.length - 1].resolvePrefix();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#addName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public void addName(IASTName name) {
if (names == null) {
names = new IASTName[DEFAULT_NAMES_LIST_SIZE];
currentIndex = 0;
}
if (names.length == currentIndex) {
IASTName[] old = names;
names = new IASTName[old.length * 2];
for (int i = 0; i < old.length; ++i)
names[i] = old[i];
}
names[currentIndex++] = name;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
public String toString() {
if (signature == null)
return ""; //$NON-NLS-1$
return signature;
}
/**
* @param decls2
*/
private void removeNullNames() {
int nullCount = 0;
for (int i = 0; i < names.length; ++i)
if (names[i] == null)
++nullCount;
if (nullCount == 0)
return;
IASTName[] old = names;
int newSize = old.length - nullCount;
names = new IASTName[newSize];
for (int i = 0; i < newSize; ++i)
names[i] = old[i];
currentIndex = newSize;
}
private int currentIndex = 0;
private IASTName[] names = null;
private static final int DEFAULT_NAMES_LIST_SIZE = 4;
private boolean value;
private String signature;
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#getNames()
*/
public IASTName[] getNames() {
if (names == null)
return IASTName.EMPTY_NAME_ARRAY;
removeNullNames();
return names;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTName#toCharArray()
*/
public char[] toCharArray() {
if (names == null)
return "".toCharArray(); //$NON-NLS-1$
removeNullNames();
//count first
int len = 0;
for (int i = 0; i < names.length; ++i) {
char[] n = names[i].toCharArray();
if (n == null)
return null;
len += n.length;
if (i != names.length - 1)
len += 2;
}
char[] nameArray = new char[len];
int pos = 0;
for (int i = 0; i < names.length; i++) {
char[] n = names[i].toCharArray();
System.arraycopy(n, 0, nameArray, pos, n.length);
pos += n.length;
if (i != names.length - 1) {
nameArray[pos++] = ':';
nameArray[pos++] = ':';
}
}
return nameArray;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#isFullyQualified()
*/
public boolean isFullyQualified() {
return value;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#setFullyQualified(boolean)
*/
public void setFullyQualified(boolean value) {
this.value = value;
}
/**
* @param string
*/
public void setValue(String string) {
this.signature = string;
}
public boolean accept( ASTVisitor action ){
if( action.shouldVisitNames ){
switch( action.visit( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#addName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public void addName(IASTName name) {
if (names == null) {
names = new IASTName[DEFAULT_NAMES_LIST_SIZE];
currentIndex = 0;
}
IASTName [] ns = getNames();
for ( int i = 0; i < ns.length; i++ ) {
if( i == names.length - 1 ){
if( names[i].toCharArray().length > 0 && !names[i].accept( action ) ) return false;
} else if( !names[i].accept( action ) ) return false;
}
return true;
}
if (names.length == currentIndex) {
IASTName[] old = names;
names = new IASTName[old.length * 2];
for (int i = 0; i < old.length; ++i)
names[i] = old[i];
}
names[currentIndex++] = name;
}
/**
* @param decls2
*/
private void removeNullNames() {
int nullCount = 0;
for (int i = 0; i < names.length; ++i)
if (names[i] == null)
++nullCount;
if (nullCount == 0)
return;
IASTName[] old = names;
int newSize = old.length - nullCount;
names = new IASTName[newSize];
for (int i = 0; i < newSize; ++i)
names[i] = old[i];
currentIndex = newSize;
}
private int currentIndex = 0;
private IASTName[] names = null;
private static final int DEFAULT_NAMES_LIST_SIZE = 4;
private boolean value;
private String signature;
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#getNames()
*/
public IASTName[] getNames() {
if (names == null)
return IASTName.EMPTY_NAME_ARRAY;
removeNullNames();
return names;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IASTName#toCharArray()
*/
public char[] toCharArray() {
if (names == null)
return "".toCharArray(); //$NON-NLS-1$
removeNullNames();
// count first
int len = 0;
for (int i = 0; i < names.length; ++i) {
char[] n = names[i].toCharArray();
if (n == null)
return null;
len += n.length;
if (i != names.length - 1)
len += 2;
}
char[] nameArray = new char[len];
int pos = 0;
for (int i = 0; i < names.length; i++) {
char[] n = names[i].toCharArray();
System.arraycopy(n, 0, nameArray, pos, n.length);
pos += n.length;
if (i != names.length - 1) {
nameArray[pos++] = ':';
nameArray[pos++] = ':';
}
}
return nameArray;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#isFullyQualified()
*/
public boolean isFullyQualified() {
return value;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#setFullyQualified(boolean)
*/
public void setFullyQualified(boolean value) {
this.value = value;
}
/**
* @param string
*/
public void setValue(String string) {
this.signature = string;
}
public boolean accept(ASTVisitor action) {
if (action.shouldVisitNames) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT:
return false;
case ASTVisitor.PROCESS_SKIP:
return true;
default:
break;
}
}
IASTName[] ns = getNames();
for (int i = 0; i < ns.length; i++) {
if (i == names.length - 1) {
if (names[i].toCharArray().length > 0
&& !names[i].accept(action))
return false;
} else if (!names[i].accept(action))
return false;
}
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isDeclaration()
*/
public boolean isDeclaration() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if( role == IASTNameOwner.r_reference ) return false;
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isReference()
*/
public boolean isReference() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if( role == IASTNameOwner.r_reference ) return true;
return false;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
IASTName [] namez = getNames();
for( int i = 0; i < names.length; ++i )
if( namez[i] == n )
{
if( i < names.length - 1 )
return r_reference;
IASTNode p = getParent();
if( i == names.length - 1 && p instanceof IASTNameOwner )
return ((IASTNameOwner)p).getRoleForName(this);
return r_unclear;
}
return r_unclear;
}
}

View file

@ -81,4 +81,13 @@ public class CPPASTSimpleTypeTemplateParameter extends CPPASTNode implements
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name )
return r_declaration;
return r_unclear;
}
}

View file

@ -145,4 +145,27 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId {
}
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isDeclaration()
*/
public boolean isDeclaration() {
return false; //for now this seems to be true
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isReference()
*/
public boolean isReference() {
return true; //for now this seems to be true
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == templateName )
return r_reference;
return r_unclear;
}
}

View file

@ -110,4 +110,13 @@ public class CPPASTTemplatedTypeTemplateParameter extends CPPASTNode implements
if( defaultValue != null ) if( !defaultValue.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name )
return r_declaration;
return r_unclear;
}
}

View file

@ -80,4 +80,13 @@ public class CPPASTTypenameExpression extends CPPASTNode implements
if( init != null ) if( !init.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name )
return r_reference;
return r_unclear;
}
}

View file

@ -63,4 +63,13 @@ public class CPPASTUsingDeclaration extends CPPASTNode implements
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name )
return r_reference;
return r_unclear;
}
}

View file

@ -48,4 +48,13 @@ public class CPPASTUsingDirective extends CPPASTNode implements
if( name != null ) if( !name.accept( action ) ) return false;
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( n == name )
return r_reference;
return r_unclear;
}
}

View file

@ -495,6 +495,13 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
public void setExpansion(String exp) {
this.expansion = exp;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n ) return r_declaration;
return r_unclear;
}
}
@ -617,6 +624,22 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
public String toString() {
return new String(name);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isDeclaration()
*/
public boolean isDeclaration() {
if (getParent() instanceof IASTPreprocessorMacroDefinition && getPropertyInParent() == IASTPreprocessorMacroDefinition.MACRO_NAME )
return true;
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#isReference()
*/
public boolean isReference() {
return !isDeclaration();
}
}
/**
@ -626,6 +649,13 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
IASTPreprocessorObjectStyleMacroDefinition {
private IASTName name;
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public int getRoleForName(IASTName n) {
if( name == n ) return r_declaration;
return r_unclear;
}
private String expansion;