mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
da074afa86
commit
d3fcfea8f1
6 changed files with 110 additions and 98 deletions
|
@ -33,11 +33,11 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
*/
|
*/
|
||||||
public class CEnumerator extends PlatformObject implements IEnumerator {
|
public class CEnumerator extends PlatformObject implements IEnumerator {
|
||||||
public static class CEnumeratorProblem extends ProblemBinding implements IEnumerator {
|
public static class CEnumeratorProblem extends ProblemBinding implements IEnumerator {
|
||||||
public CEnumeratorProblem( IASTNode node, int id, char[] arg ) {
|
public CEnumeratorProblem(IASTNode node, int id, char[] arg) {
|
||||||
super( node, id, arg );
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
public IType getType() throws DOMException {
|
public IType getType() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public IValue getValue() {
|
public IValue getValue() {
|
||||||
return Value.UNKNOWN;
|
return Value.UNKNOWN;
|
||||||
|
@ -46,21 +46,23 @@ public class CEnumerator extends PlatformObject implements IEnumerator {
|
||||||
|
|
||||||
private final IASTName enumeratorName;
|
private final IASTName enumeratorName;
|
||||||
|
|
||||||
public CEnumerator( IASTEnumerator enumtor ){
|
public CEnumerator(IASTEnumerator enumtor) {
|
||||||
this.enumeratorName = enumtor.getName();
|
this.enumeratorName = enumtor.getName();
|
||||||
enumeratorName.setBinding( this );
|
enumeratorName.setBinding(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTNode getPhysicalNode(){
|
public IASTNode getPhysicalNode() {
|
||||||
return enumeratorName;
|
return enumeratorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return enumeratorName.toString();
|
return enumeratorName.toString();
|
||||||
}
|
}
|
||||||
public char[] getNameCharArray(){
|
|
||||||
|
public char[] getNameCharArray() {
|
||||||
return enumeratorName.toCharArray();
|
return enumeratorName.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +70,7 @@ public class CEnumerator extends PlatformObject implements IEnumerator {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||||
*/
|
*/
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CVisitor.getContainingScope( enumeratorName.getParent() );
|
return CVisitor.getContainingScope(enumeratorName.getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -24,14 +24,15 @@ import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
||||||
*/
|
*/
|
||||||
public class CField extends CVariable implements IField {
|
public class CField extends CVariable implements IField {
|
||||||
public static class CFieldProblem extends CVariable.CVariableProblem implements IField {
|
public static class CFieldProblem extends CVariable.CVariableProblem implements IField {
|
||||||
public CFieldProblem( IASTNode node, int id, char[] arg ) {
|
public CFieldProblem(IASTNode node, int id, char[] arg) {
|
||||||
super( node, id, arg );
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
throw new DOMException(this);
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
|
@ -43,5 +44,4 @@ public class CField extends CVariable implements IField {
|
||||||
ICCompositeTypeScope scope = (ICCompositeTypeScope) getScope();
|
ICCompositeTypeScope scope = (ICCompositeTypeScope) getScope();
|
||||||
return scope.getCompositeType();
|
return scope.getCompositeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,24 +29,26 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
public class CLabel extends PlatformObject implements ILabel {
|
public class CLabel extends PlatformObject implements ILabel {
|
||||||
|
|
||||||
public static class CLabelProblem extends ProblemBinding implements ILabel {
|
public static class CLabelProblem extends ProblemBinding implements ILabel {
|
||||||
public CLabelProblem( IASTNode node, int id, char[] arg ) {
|
public CLabelProblem(IASTNode node, int id, char[] arg) {
|
||||||
super( node, id, arg );
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTLabelStatement getLabelStatement() throws DOMException{
|
public IASTLabelStatement getLabelStatement() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final IASTName labelStatement;
|
private final IASTName labelStatement;
|
||||||
|
|
||||||
public CLabel( IASTName statement ){
|
public CLabel(IASTName statement) {
|
||||||
labelStatement = statement;
|
labelStatement = statement;
|
||||||
statement.setBinding( this );
|
statement.setBinding(this);
|
||||||
}
|
}
|
||||||
public IASTNode getPhysicalNode(){
|
|
||||||
|
public IASTNode getPhysicalNode() {
|
||||||
return labelStatement;
|
return labelStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ILabel#getLabelStatement()
|
* @see org.eclipse.cdt.core.dom.ast.ILabel#getLabelStatement()
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +62,8 @@ public class CLabel extends PlatformObject implements ILabel {
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return labelStatement.toString();
|
return labelStatement.toString();
|
||||||
}
|
}
|
||||||
public char[] getNameCharArray(){
|
|
||||||
|
public char[] getNameCharArray() {
|
||||||
return labelStatement.toCharArray();
|
return labelStatement.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +71,7 @@ public class CLabel extends PlatformObject implements ILabel {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||||
*/
|
*/
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CVisitor.getContainingScope( labelStatement.getParent() );
|
return CVisitor.getContainingScope(labelStatement.getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
|
|
|
@ -39,34 +39,34 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
*/
|
*/
|
||||||
public class CParameter extends PlatformObject implements IParameter {
|
public class CParameter extends PlatformObject implements IParameter {
|
||||||
public static class CParameterProblem extends ProblemBinding implements IParameter {
|
public static class CParameterProblem extends ProblemBinding implements IParameter {
|
||||||
public CParameterProblem( IASTNode node, int id, char[] arg ) {
|
public CParameterProblem(IASTNode node, int id, char[] arg) {
|
||||||
super( node, id, arg );
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
public IType getType() throws DOMException {
|
public IType getType() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isStatic() throws DOMException {
|
public boolean isStatic() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isExtern() throws DOMException {
|
public boolean isExtern() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isAuto() throws DOMException {
|
public boolean isAuto() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isRegister() throws DOMException {
|
public boolean isRegister() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public IValue getInitialValue() {
|
public IValue getInitialValue() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTName [] declarations;
|
private IASTName[] declarations;
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
public CParameter( IASTName parameterName ){
|
public CParameter(IASTName parameterName) {
|
||||||
this.declarations = new IASTName [] { parameterName };
|
this.declarations = new IASTName[] { parameterName };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -74,22 +74,21 @@ public class CParameter extends PlatformObject implements IParameter {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if ( type == null && declarations[0].getParent() instanceof IASTDeclarator)
|
if (type == null && declarations[0].getParent() instanceof IASTDeclarator)
|
||||||
type = CVisitor.createType( (IASTDeclarator)declarations[0].getParent() );
|
type = CVisitor.createType((IASTDeclarator)declarations[0].getParent());
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTName getPrimaryDeclaration(){
|
private IASTName getPrimaryDeclaration() {
|
||||||
if( declarations != null ){
|
if (declarations != null) {
|
||||||
for( int i = 0; i < declarations.length && declarations[i] != null; i++ ){
|
for (int i = 0; i < declarations.length && declarations[i] != null; i++) {
|
||||||
IASTNode node = declarations[i].getParent();
|
IASTNode node = declarations[i].getParent();
|
||||||
while( !(node instanceof IASTDeclaration) )
|
while (!(node instanceof IASTDeclaration))
|
||||||
node = node.getParent();
|
node = node.getParent();
|
||||||
|
|
||||||
if( node.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER ||
|
if (node.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER ||
|
||||||
node instanceof IASTFunctionDefinition )
|
node instanceof IASTFunctionDefinition) {
|
||||||
{
|
|
||||||
return declarations[i];
|
return declarations[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,13 +102,14 @@ public class CParameter extends PlatformObject implements IParameter {
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
IASTName name = getPrimaryDeclaration();
|
IASTName name = getPrimaryDeclaration();
|
||||||
if( name != null )
|
if (name != null)
|
||||||
return name.toString();
|
return name.toString();
|
||||||
return CVisitor.EMPTY_STRING;
|
return CVisitor.EMPTY_STRING;
|
||||||
}
|
}
|
||||||
public char[] getNameCharArray(){
|
|
||||||
|
public char[] getNameCharArray() {
|
||||||
IASTName name = getPrimaryDeclaration();
|
IASTName name = getPrimaryDeclaration();
|
||||||
if( name != null )
|
if (name != null)
|
||||||
return name.toCharArray();
|
return name.toCharArray();
|
||||||
return CVisitor.EMPTY_CHAR_ARRAY;
|
return CVisitor.EMPTY_CHAR_ARRAY;
|
||||||
}
|
}
|
||||||
|
@ -119,19 +119,19 @@ public class CParameter extends PlatformObject implements IParameter {
|
||||||
*/
|
*/
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
//IASTParameterDeclaration or IASTSimpleDeclaration
|
//IASTParameterDeclaration or IASTSimpleDeclaration
|
||||||
for( int i = 0; i < declarations.length; i++ ){
|
for (int i = 0; i < declarations.length; i++) {
|
||||||
IASTNode parent = declarations[i].getParent();
|
IASTNode parent = declarations[i].getParent();
|
||||||
if( parent instanceof ICASTKnRFunctionDeclarator ){
|
if (parent instanceof ICASTKnRFunctionDeclarator) {
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
return ((IASTCompoundStatement)((IASTFunctionDefinition)parent).getBody()).getScope();
|
return ((IASTCompoundStatement)((IASTFunctionDefinition) parent).getBody()).getScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTNode fdtorNode = parent.getParent().getParent();
|
IASTNode fdtorNode = parent.getParent().getParent();
|
||||||
if (fdtorNode instanceof IASTFunctionDeclarator) {
|
if (fdtorNode instanceof IASTFunctionDeclarator) {
|
||||||
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator)fdtorNode;
|
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) fdtorNode;
|
||||||
parent = fdtor.getParent();
|
parent = fdtor.getParent();
|
||||||
if( parent instanceof IASTFunctionDefinition ) {
|
if (parent instanceof IASTFunctionDefinition) {
|
||||||
return ((IASTCompoundStatement)((IASTFunctionDefinition)parent).getBody()).getScope();
|
return ((IASTCompoundStatement)((IASTFunctionDefinition) parent).getBody()).getScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ public class CParameter extends PlatformObject implements IParameter {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic()
|
* @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic()
|
||||||
*/
|
*/
|
||||||
public boolean isStatic(){
|
public boolean isStatic() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,14 +165,14 @@ public class CParameter extends PlatformObject implements IParameter {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
||||||
*/
|
*/
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return hasStorageClass( IASTDeclSpecifier.sc_auto );
|
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
||||||
*/
|
*/
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return hasStorageClass( IASTDeclSpecifier.sc_register );
|
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasStorageClass(int storage) {
|
public boolean hasStorageClass(int storage) {
|
||||||
|
|
|
@ -51,38 +51,38 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
super(node, id, arg);
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
public IField findField(String name) throws DOMException {
|
public IField findField(String name) throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public IScope getCompositeScope() throws DOMException {
|
public IScope getCompositeScope() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public IField[] getFields() throws DOMException {
|
public IField[] getFields() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public int getKey() throws DOMException {
|
public int getKey() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isAnonymous() throws DOMException {
|
public boolean isAnonymous() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTName [] declarations = null;
|
private IASTName[] declarations = null;
|
||||||
private IASTName definition;
|
private IASTName definition;
|
||||||
private boolean checked;
|
private boolean checked;
|
||||||
private ICompositeType typeInIndex;
|
private ICompositeType typeInIndex;
|
||||||
|
|
||||||
public CStructure( IASTName name ){
|
public CStructure(IASTName name) {
|
||||||
if( name.getPropertyInParent() == IASTCompositeTypeSpecifier.TYPE_NAME )
|
if (name.getPropertyInParent() == IASTCompositeTypeSpecifier.TYPE_NAME) {
|
||||||
definition = name;
|
definition = name;
|
||||||
else {
|
} else {
|
||||||
declarations = new IASTName[] { name };
|
declarations = new IASTName[] { name };
|
||||||
}
|
}
|
||||||
name.setBinding( this );
|
name.setBinding(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTNode getPhysicalNode(){
|
public IASTNode getPhysicalNode() {
|
||||||
return ( definition != null ) ? (IASTNode)definition : (IASTNode)declarations[0];
|
return (definition != null) ? (IASTNode)definition : (IASTNode)declarations[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForDefinition() {
|
private void checkForDefinition() {
|
||||||
|
@ -112,13 +112,13 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if( definition != null )
|
if (definition != null)
|
||||||
return definition.toString();
|
return definition.toString();
|
||||||
|
|
||||||
return declarations[0].toString();
|
return declarations[0].toString();
|
||||||
}
|
}
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
if( definition != null )
|
if (definition != null)
|
||||||
return definition.toCharArray();
|
return definition.toCharArray();
|
||||||
|
|
||||||
return declarations[0].toCharArray();
|
return declarations[0].toCharArray();
|
||||||
|
@ -128,9 +128,9 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||||
*/
|
*/
|
||||||
public IScope getScope() throws DOMException {
|
public IScope getScope() throws DOMException {
|
||||||
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ( ( definition != null ) ? (IASTNode)definition.getParent() : declarations[0].getParent() );
|
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ((definition != null) ? (IASTNode)definition.getParent() : declarations[0].getParent());
|
||||||
IScope scope = CVisitor.getContainingScope( declSpec );
|
IScope scope = CVisitor.getContainingScope(declSpec);
|
||||||
while( scope instanceof ICCompositeTypeScope ){
|
while(scope instanceof ICCompositeTypeScope) {
|
||||||
scope = scope.getParent();
|
scope = scope.getParent();
|
||||||
}
|
}
|
||||||
return scope;
|
return scope;
|
||||||
|
@ -148,7 +148,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
}
|
}
|
||||||
ICASTCompositeTypeSpecifier compSpec = (ICASTCompositeTypeSpecifier) definition.getParent();
|
ICASTCompositeTypeSpecifier compSpec = (ICASTCompositeTypeSpecifier) definition.getParent();
|
||||||
IField[] fields = collectFields(compSpec, null);
|
IField[] fields = collectFields(compSpec, null);
|
||||||
return (IField[]) ArrayUtil.trim( IField.class, fields );
|
return (IField[]) ArrayUtil.trim(IField.class, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IField[] collectFields(ICASTCompositeTypeSpecifier compSpec, IField[] fields) {
|
private IField[] collectFields(ICASTCompositeTypeSpecifier compSpec, IField[] fields) {
|
||||||
|
@ -197,7 +197,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
||||||
*/
|
*/
|
||||||
public int getKey() {
|
public int getKey() {
|
||||||
return ( definition != null ) ? ((IASTCompositeTypeSpecifier)definition.getParent()).getKey()
|
return (definition != null) ? ((IASTCompositeTypeSpecifier)definition.getParent()).getKey()
|
||||||
: ((IASTElaboratedTypeSpecifier)declarations[0].getParent()).getKind();
|
: ((IASTElaboratedTypeSpecifier)declarations[0].getParent()).getKind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +223,11 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone(){
|
public Object clone() {
|
||||||
IType t = null;
|
IType t = null;
|
||||||
try {
|
try {
|
||||||
t = (IType) super.clone();
|
t = (IType) super.clone();
|
||||||
} catch ( CloneNotSupportedException e ) {
|
} catch (CloneNotSupportedException e) {
|
||||||
//not going to happen
|
//not going to happen
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -41,36 +41,36 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
*/
|
*/
|
||||||
public class CVariable extends PlatformObject implements IInternalVariable, ICInternalBinding {
|
public class CVariable extends PlatformObject implements IInternalVariable, ICInternalBinding {
|
||||||
public static class CVariableProblem extends ProblemBinding implements IVariable {
|
public static class CVariableProblem extends ProblemBinding implements IVariable {
|
||||||
public CVariableProblem( IASTNode node, int id, char[] arg ) {
|
public CVariableProblem(IASTNode node, int id, char[] arg) {
|
||||||
super( node, id, arg );
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IType getType() throws DOMException {
|
public IType getType() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isStatic() throws DOMException {
|
public boolean isStatic() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isExtern() throws DOMException {
|
public boolean isExtern() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isAuto() throws DOMException {
|
public boolean isAuto() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public boolean isRegister() throws DOMException {
|
public boolean isRegister() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
public IValue getInitialValue() {
|
public IValue getInitialValue() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private IASTName [] declarations = null;
|
private IASTName[] declarations = null;
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
public CVariable( IASTName name ){
|
public CVariable(IASTName name) {
|
||||||
declarations = new IASTName [] { name };
|
declarations = new IASTName[] { name };
|
||||||
}
|
}
|
||||||
public IASTNode getPhysicalNode(){
|
public IASTNode getPhysicalNode() {
|
||||||
return declarations[0];
|
return declarations[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,8 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return declarations[0].toString();
|
return declarations[0].toString();
|
||||||
}
|
}
|
||||||
public char[]getNameCharArray(){
|
|
||||||
|
public char[] getNameCharArray() {
|
||||||
return declarations[0].toCharArray();
|
return declarations[0].toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,62 +105,68 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
|
||||||
*/
|
*/
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
IASTDeclarator declarator = (IASTDeclarator) declarations[0].getParent();
|
IASTDeclarator declarator = (IASTDeclarator) declarations[0].getParent();
|
||||||
return CVisitor.getContainingScope( declarator.getParent() );
|
return CVisitor.getContainingScope(declarator.getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_static);
|
return hasStorageClass(IASTDeclSpecifier.sc_static);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasStorageClass( int storage){
|
public boolean hasStorageClass(int storage) {
|
||||||
if( declarations == null )
|
if (declarations == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for( int i = 0; i < declarations.length && declarations[i] != null; i++ ){
|
for (int i = 0; i < declarations.length && declarations[i] != null; i++) {
|
||||||
final IASTName name = declarations[i];
|
final IASTName name = declarations[i];
|
||||||
|
|
||||||
IASTNode parent = name.getParent();
|
IASTNode parent = name.getParent();
|
||||||
while( !(parent instanceof IASTDeclaration) )
|
while (!(parent instanceof IASTDeclaration))
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
|
|
||||||
if( parent instanceof IASTSimpleDeclaration ){
|
if (parent instanceof IASTSimpleDeclaration) {
|
||||||
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier();
|
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
|
||||||
if( declSpec.getStorageClass() == storage ) {
|
if (declSpec.getStorageClass() == storage) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
|
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
|
||||||
*/
|
*/
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return hasStorageClass( IASTDeclSpecifier.sc_extern);
|
return hasStorageClass(IASTDeclSpecifier.sc_extern);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
||||||
*/
|
*/
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return hasStorageClass( IASTDeclSpecifier.sc_auto);
|
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
||||||
*/
|
*/
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return hasStorageClass( IASTDeclSpecifier.sc_register);
|
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.C_LINKAGE;
|
return Linkage.C_LINKAGE;
|
||||||
}
|
}
|
||||||
public IASTNode[] getDeclarations() {
|
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
return declarations;
|
return declarations;
|
||||||
}
|
}
|
||||||
public IASTNode getDefinition() {
|
|
||||||
|
public IASTNode getDefinition() {
|
||||||
return getPhysicalNode();
|
return getPhysicalNode();
|
||||||
}
|
}
|
||||||
public IBinding getOwner() throws DOMException {
|
|
||||||
|
public IBinding getOwner() throws DOMException {
|
||||||
if (declarations == null || declarations.length == 0)
|
if (declarations == null || declarations.length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue