mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed Bug 93123 - No way to determine if an IASTName is a definition
This commit is contained in:
parent
8468711bac
commit
d2e2b4f4b1
17 changed files with 314 additions and 132 deletions
|
@ -69,7 +69,14 @@ public interface IASTName extends IASTNode {
|
|||
|
||||
/**
|
||||
* Is this name being used in the AST as a reference rather than a declaration?
|
||||
* @return
|
||||
* @return boolean
|
||||
*/
|
||||
|
||||
public boolean isReference();
|
||||
|
||||
/**
|
||||
* Is this name being used in the AST as a reference rather than a declaration?
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isDefinition();
|
||||
}
|
||||
|
|
|
@ -16,10 +16,15 @@ public interface IASTNameOwner {
|
|||
* Role of name in this construct is a reference.
|
||||
*/
|
||||
public static final int r_reference = 1;
|
||||
|
||||
/**
|
||||
* Role of name in this construct is a definition.
|
||||
*/
|
||||
public static final int r_definition = 2;
|
||||
/**
|
||||
* Role is unclear.
|
||||
*/
|
||||
public static final int r_unclear = 2;
|
||||
public static final int r_unclear = 3;
|
||||
|
||||
/**
|
||||
* Get the role for the name.
|
||||
|
|
|
@ -113,7 +113,7 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
|
|||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( n == this.name )
|
||||
return r_declaration;
|
||||
return r_definition;
|
||||
return r_unclear;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,15 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
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.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
|
@ -125,7 +128,19 @@ public class CASTDeclarator extends CASTNode implements IASTDeclarator {
|
|||
{
|
||||
IASTNode getParent = getParent();
|
||||
if( getParent instanceof IASTDeclaration )
|
||||
return r_declaration;
|
||||
{
|
||||
if( getParent instanceof IASTFunctionDefinition )
|
||||
return r_definition;
|
||||
if( getParent instanceof IASTSimpleDeclaration )
|
||||
{
|
||||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
||||
if( sd.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_extern )
|
||||
return r_declaration;
|
||||
if( getInitializer() == null )
|
||||
return r_declaration;
|
||||
}
|
||||
return r_definition;
|
||||
}
|
||||
if( getParent instanceof IASTTypeId )
|
||||
return r_reference;
|
||||
if( getParent instanceof IASTDeclarator )
|
||||
|
@ -134,7 +149,19 @@ public class CASTDeclarator extends CASTNode implements IASTDeclarator {
|
|||
while ( t instanceof IASTDeclarator )
|
||||
t = t.getParent();
|
||||
if( t instanceof IASTDeclaration )
|
||||
return r_declaration;
|
||||
{
|
||||
if( getParent instanceof IASTFunctionDefinition )
|
||||
return r_definition;
|
||||
if( getParent instanceof IASTSimpleDeclaration )
|
||||
{
|
||||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
||||
if( sd.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_extern )
|
||||
return r_declaration;
|
||||
if( getInitializer() != null )
|
||||
return r_definition;
|
||||
}
|
||||
return r_definition;
|
||||
}
|
||||
if( t instanceof IASTTypeId )
|
||||
return r_reference;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class CASTEnumerationSpecifier extends CASTBaseDeclSpecifier implements
|
|||
*/
|
||||
public int getRoleForName(IASTName n ) {
|
||||
if( this.name == n )
|
||||
return r_declaration;
|
||||
return r_definition;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class CASTEnumerator extends CASTNode implements IASTEnumerator, IASTAmbi
|
|||
* @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;
|
||||
if( n == name )return r_definition;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,13 +21,15 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
public class CASTName extends CASTNode implements IASTName {
|
||||
|
||||
private final char[] name;
|
||||
private static final char[] EMPTY_CHAR_ARRAY = { };
|
||||
|
||||
private static final char[] EMPTY_CHAR_ARRAY = {};
|
||||
|
||||
private IBinding binding = null;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param name
|
||||
*/
|
||||
public CASTName(char [] name ) {
|
||||
public CASTName(char[] name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -38,74 +40,110 @@ public class CASTName extends CASTNode implements IASTName {
|
|||
name = EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
|
||||
*/
|
||||
public IBinding resolveBinding() {
|
||||
if( binding == null )
|
||||
CVisitor.createBinding( this );
|
||||
|
||||
if (binding == null)
|
||||
CVisitor.createBinding(this);
|
||||
|
||||
return binding;
|
||||
}
|
||||
public IBinding getBinding(){
|
||||
return binding;
|
||||
}
|
||||
|
||||
public IBinding[] resolvePrefix() {
|
||||
return CVisitor.prefixLookup(this);
|
||||
}
|
||||
|
||||
public void setBinding( IBinding binding ){
|
||||
this.binding = binding;
|
||||
|
||||
public IBinding getBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
public IBinding[] resolvePrefix() {
|
||||
return CVisitor.prefixLookup(this);
|
||||
}
|
||||
|
||||
public void setBinding(IBinding binding) {
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
if( name == EMPTY_CHAR_ARRAY ) return null;
|
||||
return new String( name );
|
||||
if (name == EMPTY_CHAR_ARRAY)
|
||||
return null;
|
||||
return new String(name);
|
||||
}
|
||||
|
||||
|
||||
public char[] toCharArray() {
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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#isDeclaration()
|
||||
*/
|
||||
public boolean isDeclaration() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
int role = ((IASTNameOwner) parent).getRoleForName(this);
|
||||
switch (role) {
|
||||
case IASTNameOwner.r_reference:
|
||||
case IASTNameOwner.r_unclear:
|
||||
return false;
|
||||
default:
|
||||
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.IASTName#isReference()
|
||||
*/
|
||||
public boolean isReference() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
int role = ((IASTNameOwner) parent).getRoleForName(this);
|
||||
switch (role) {
|
||||
case IASTNameOwner.r_reference:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDefinition() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
int role = ((IASTNameOwner) parent).getRoleForName(this);
|
||||
switch (role) {
|
||||
case IASTNameOwner.r_definition:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
|
|||
*/
|
||||
public int getRoleForName(IASTName name) {
|
||||
if( name == this.n )
|
||||
return r_declaration;
|
||||
return r_definition;
|
||||
return r_unclear;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,15 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
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.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
|
@ -121,10 +126,45 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
|
|||
* @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;
|
||||
IASTNode getParent = getParent();
|
||||
if( getParent instanceof IASTDeclaration )
|
||||
{
|
||||
if( getParent instanceof IASTFunctionDefinition )
|
||||
return r_definition;
|
||||
if( getParent instanceof IASTSimpleDeclaration )
|
||||
{
|
||||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
||||
if( sd.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_extern )
|
||||
return r_declaration;
|
||||
if( getInitializer() == null )
|
||||
return r_declaration;
|
||||
}
|
||||
return r_definition;
|
||||
}
|
||||
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 )
|
||||
{
|
||||
if( getParent instanceof IASTFunctionDefinition )
|
||||
return r_definition;
|
||||
if( getParent instanceof IASTSimpleDeclaration )
|
||||
{
|
||||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
||||
if( sd.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_extern )
|
||||
return r_declaration;
|
||||
if( getInitializer() != null )
|
||||
return r_definition;
|
||||
}
|
||||
return r_definition;
|
||||
}
|
||||
if( t instanceof IASTTypeId )
|
||||
return r_reference;
|
||||
}
|
||||
return r_unclear;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
|
|||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if (name == n)
|
||||
return r_declaration;
|
||||
return r_definition;
|
||||
return r_unclear;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class CPPASTEnumerator extends CPPASTNode implements IASTEnumerator, IAST
|
|||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( name == n )
|
||||
return r_declaration;
|
||||
return r_definition;
|
||||
return r_reference;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,15 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
public class CPPASTName extends CPPASTNode implements IASTName {
|
||||
|
||||
private char[] name;
|
||||
private static final char[] EMPTY_CHAR_ARRAY = { };
|
||||
|
||||
private static final char[] EMPTY_CHAR_ARRAY = {};
|
||||
|
||||
private IBinding binding = null;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param name
|
||||
*/
|
||||
public CPPASTName(char [] name ) {
|
||||
public CPPASTName(char[] name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -39,78 +41,114 @@ public class CPPASTName extends CPPASTNode implements IASTName {
|
|||
name = EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
|
||||
*/
|
||||
public IBinding resolveBinding() {
|
||||
if( binding == null )
|
||||
binding = CPPVisitor.createBinding( this );
|
||||
|
||||
if (binding == null)
|
||||
binding = CPPVisitor.createBinding(this);
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
public IBinding[] resolvePrefix() {
|
||||
return CPPSemantics.prefixLookup(this);
|
||||
}
|
||||
|
||||
public void setBinding( IBinding binding ){
|
||||
this.binding = binding;
|
||||
}
|
||||
public IBinding getBinding(){
|
||||
return binding;
|
||||
|
||||
public IBinding[] resolvePrefix() {
|
||||
return CPPSemantics.prefixLookup(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
public void setBinding(IBinding binding) {
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public IBinding getBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
if( name == EMPTY_CHAR_ARRAY ) return null;
|
||||
return new String( name );
|
||||
if (name == EMPTY_CHAR_ARRAY)
|
||||
return null;
|
||||
return new String(name);
|
||||
}
|
||||
|
||||
|
||||
public char[] toCharArray() {
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName( char [] name )
|
||||
{
|
||||
|
||||
public void setName(char[] name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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.IASTName#isDeclaration()
|
||||
*/
|
||||
public boolean isDeclaration() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
int role = ((IASTNameOwner) parent).getRoleForName(this);
|
||||
switch (role) {
|
||||
case IASTNameOwner.r_reference:
|
||||
case IASTNameOwner.r_unclear:
|
||||
return false;
|
||||
default:
|
||||
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);
|
||||
switch (role) {
|
||||
case IASTNameOwner.r_reference:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDefinition() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
int role = ((IASTNameOwner) parent).getRoleForName(this);
|
||||
switch (role) {
|
||||
case IASTNameOwner.r_definition:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements
|
|||
* @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;
|
||||
if( name == n ) return r_definition;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class CPPASTPointerToMember extends CPPASTPointer implements
|
|||
*/
|
||||
public int getRoleForName(IASTName name ) {
|
||||
if( name == this.n )
|
||||
return r_declaration;
|
||||
return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,5 +254,16 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDefinition() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
int role = ((IASTNameOwner) parent).getRoleForName(this);
|
||||
if( role == IASTNameOwner.r_definition ) return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
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;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -154,4 +155,15 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDefinition() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
int role = ((IASTNameOwner) parent).getRoleForName(this);
|
||||
if( role == IASTNameOwner.r_definition ) return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -575,7 +575,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
|||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if (name == n)
|
||||
return r_declaration;
|
||||
return r_definition;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
|
@ -740,6 +740,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDefinition() {
|
||||
return isDeclaration();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -784,7 +788,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
|||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if (name == n)
|
||||
return r_declaration;
|
||||
return r_definition;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue