1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 00:36:16 +02:00

Patch for Hoda Amer:

Core: 
        -Solutions to bug#38985 & bug#38986 
        In IStructure: 
                getField(String)                Implemented 
                getFields()                        Implemented 
                getMethod(String)                Implemented 
                getMethods()                Implemented 
                isAbstract()                Implemented 
                getBaseTypes()                Has been replaced by getSuperClassesNames() 
                getAccessControl(int)        Has been replaced by getSuperClassAccess(String name) 

        - Added some methods to IMethodDeclaration, namely: 
        isFriend(), isInline(), isVirtual(), and isPureVirtual(). 

Core Tests: 
        Enabled some tests in the IStructureTests, namely: 
        testGetFields(), testGetField(), testGetMethods(), testGetMethod(), 
        testIsAbstract(), testGetBaseTypes(), and testGetAccessControl().
This commit is contained in:
Doug Schaefer 2003-08-25 04:20:47 +00:00
parent cc174bfe8c
commit eaab6a9736
22 changed files with 183 additions and 191 deletions

View file

@ -1,3 +1,8 @@
2003-08-21 Hoda Amer
Enabled some tests in the IStructureTests, namely:
testGetFields(), testGetField(), testGetMethods(), testGetMethod(),
testIsAbstract(), testGetBaseTypes(), and testGetAccessControl().
2003-08-19 Sean Evoy
In order to properly support the indexing feature, the scanner has to
function as well as the version that ships with the toolset if possible.

View file

@ -5,6 +5,7 @@
package org.eclipse.cdt.core.model.tests;
import org.eclipse.cdt.core.model.*;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import junit.framework.*;
@ -48,18 +49,18 @@ public class IStructureTests extends IntegratedCModelTest {
// Interface tests:
suite.addTest( new IStructureTests("testGetChildrenOfTypeStruct"));
suite.addTest( new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetFields"));
suite.addTest( new IStructureTests("testGetFieldsHack"));
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetField"));
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetMethods")); // C++ only
suite.addTest( new IStructureTests("testGetMethodsHack")); // C++ only
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetMethod")); // C++ only
suite.addTest( new IStructureTests("testGetFields"));
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetFieldsHack"));
suite.addTest( new IStructureTests("testGetField"));
suite.addTest( new IStructureTests("testGetMethods")); // C++ only
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetMethodsHack")); // C++ only
suite.addTest( new IStructureTests("testGetMethod")); // C++ only
suite.addTest( new IStructureTests("testIsStruct"));
suite.addTest( new IStructureTests("testIsClass")); // C++ only
suite.addTest( new IStructureTests("testIsUnion"));
// TODO Bug# 38985: suite.addTest( new IStructureTests("testIsAbstract")); // C++ only
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetBaseTypes")); // C++ only
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetAccessControl")); // C++ only
suite.addTest( new IStructureTests("testIsAbstract")); // C++ only
suite.addTest( new IStructureTests("testGetBaseTypes")); // C++ only
suite.addTest( new IStructureTests("testGetAccessControl")); // C++ only
// Language Specification tests:
suite.addTest( new IStructureTests("testAnonymousStructObject"));
@ -157,7 +158,7 @@ public class IStructureTests extends IntegratedCModelTest {
ITranslationUnit tu = getTU();
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
IMethod[] myArrayIMethod = myIStruct.getMethods();
IMethodDeclaration[] myArrayIMethod = myIStruct.getMethods();
String[] myExpectedMethods = {
"method1","method2","testStruct1","~testStruct1"
};
@ -194,7 +195,7 @@ public class IStructureTests extends IntegratedCModelTest {
"method1","method2","testStruct1","~testStruct1"
};
for(int i=0; i<myExpectedMethods.length; i++) {
IMethod myIMethod = myIStruct.getMethod( myExpectedMethods[i] );
IMethodDeclaration myIMethod = myIStruct.getMethod( myExpectedMethods[i] );
assertNotNull( "Failed on "+i, myIMethod);
}
@ -202,7 +203,7 @@ public class IStructureTests extends IntegratedCModelTest {
"method7","method8","method9",
};
for(int i=0; i<myUnexpectedMethods.length; i++) {
IMethod myIMethod = myIStruct.getMethod( myUnexpectedMethods[i] );
IMethodDeclaration myIMethod = myIStruct.getMethod( myUnexpectedMethods[i] );
assertNull( "Failed on "+i, myIMethod);
}
}
@ -300,7 +301,7 @@ public class IStructureTests extends IntegratedCModelTest {
assertTrue( myStructAbstract.isAbstract() );
assertNotNull( myElementNonAbstract );
assertTrue( myElementNonAbstract.getElementType()!=ICElement.C_CLASS );
assertTrue( myElementNonAbstract.getElementType() == ICElement.C_CLASS );
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
assertNotNull( myStructNonAbstract );
assertFalse( myStructNonAbstract.isAbstract() );
@ -310,14 +311,14 @@ public class IStructureTests extends IntegratedCModelTest {
public void testGetBaseTypes() {
ITranslationUnit tu = getTU();
ICElement myElementDerived = null;
IStructure[] myBaseTypes = null;
String[] myBaseTypes = null;
try {
myElementDerived = tu.getElement("testClass5"); // throws
assertNotNull( myElementDerived );
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
IStructure myStructDerived = (IStructure) myElementDerived;
assertNotNull( myStructDerived );
myBaseTypes = myStructDerived.getBaseTypes(); // throws
myBaseTypes = myStructDerived.getSuperClassesNames();
}
catch( CModelException c )
{
@ -325,37 +326,36 @@ public class IStructureTests extends IntegratedCModelTest {
}
String[] myExpectedBaseTypes = {
"testClass1","testClass3","testClass4"
"testClass1","testClass3","testClass4Abstract"
};
assertEquals( myExpectedBaseTypes.length, myBaseTypes.length );
for(int i=0; i<myBaseTypes.length; i++) {
assertEquals( "Failed on "+i, myExpectedBaseTypes[i], myBaseTypes[i].getElementName() );
assertEquals( "Failed on "+i, myExpectedBaseTypes[i], myBaseTypes[i] );
}
}
// tests IInheritance.getAccessControl(int),
// not IDeclaration.getAccessControl()
// IInheritance
public void testGetAccessControl() {
ITranslationUnit tu = getTU();
ICElement myElementDerived = null;
IStructure[] myBaseTypes = null;
String[] myBaseTypes = null;
try {
myElementDerived = tu.getElement("testClass5"); // throws
assertNotNull( myElementDerived );
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
IStructure myStructDerived = (IStructure) myElementDerived;
assertNotNull( myStructDerived );
myBaseTypes = myStructDerived.getBaseTypes(); // throws
myBaseTypes = myStructDerived.getSuperClassesNames();
int[] myExpectedAccessControl = {
ASTAccessVisibility[] myExpectedAccessControl = {
// TODO #38986: expect appropriate access control tags
ICElement.CPP_PUBLIC,
org.eclipse.cdt.core.index.TagFlags.T_PROTECTED,
ICElement.CPP_PRIVATE
ASTAccessVisibility.PUBLIC,
ASTAccessVisibility.PROTECTED,
ASTAccessVisibility.PRIVATE
};
assertEquals( myExpectedAccessControl.length, myBaseTypes.length );
for(int i=0; i<myBaseTypes.length; i++) {
int myAccessControl = myStructDerived.getAccessControl(i); // throws
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
assertEquals( "Failed on "+i, myExpectedAccessControl[i], myAccessControl );
}
}

View file

@ -1,3 +1,15 @@
2003-08-21 Hoda Amer
- C Model cleanups + solutions to bug#38985 & bug#38986
getField(String) Implemented
getFields() Implemented
getMethod(String) Implemented
getMethods() Implemented
isAbstract() Implemented
getBaseTypes() Has been replaced by getSuperClassesNames()
getAccessControl(int) Has been replaced by getSuperClassAccess(String name)
- Added some methods to IMethodDeclaration, namely:
isFriend(), isInline(), isVirtual(), and isPureVirtual().
2003-08-20 Alain Magloire
When doing the IPlugin.shutdown(). We have to make

View file

@ -14,15 +14,5 @@ package org.eclipse.cdt.core.model;
public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference {
boolean isStatic();
boolean isConst();
boolean isVolatile();
/**
* Returns the access Control of the member. The access qualifier
* can be examine using the AccessControl class.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
* @see IAccessControl
*/
int getAccessControl();
boolean isVolatile();
}

View file

@ -22,4 +22,8 @@ public interface IInclude extends ICElement, ISourceReference, ISourceManipulati
* <code>"#include "foobar.h"</code> returns false.
*/
boolean isStandard();
public String getFullFileName();
public boolean isLocal();
}

View file

@ -1,5 +1,7 @@
package org.eclipse.cdt.core.model;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
@ -10,12 +12,11 @@ package org.eclipse.cdt.core.model;
*/
public interface IInheritance {
/**
* Return the inherited structures.
* Return the inherited structures names.
*/
public IStructure [] getBaseTypes() throws CModelException;
public String[] getSuperClassesNames();
/**
* Return the access control for each inherited structure.
* Returns the super class access : ASTAccessVisibility
*/
public int getAccessControl(int pos) throws CModelException;
public ASTAccessVisibility getSuperClassAccess(String name);
}

View file

@ -42,7 +42,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
boolean isAbstract();
boolean isPureVirtual();
/**
* Returns if this method is static or not

View file

@ -1,5 +1,6 @@
package org.eclipse.cdt.core.model;
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
@ -9,13 +10,11 @@ package org.eclipse.cdt.core.model;
* Represent struct(ure), class or union.
*/
public interface IStructure extends IInheritance, IParent, IVariableDeclaration {
//public String instantiatesTemplate();
public IField getField(String name);
public IField[] getFields();
public IMethod getMethod(String name);
public IMethod [] getMethods();
public IMethodDeclaration getMethod(String name);
public IMethodDeclaration [] getMethods();
public boolean isUnion();
@ -24,4 +23,5 @@ public interface IStructure extends IInheritance, IParent, IVariableDeclaration
public boolean isStruct();
public boolean isAbstract();
}

View file

@ -86,12 +86,4 @@ public class BinaryFunction extends BinaryElement implements IFunction {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
*/
public int getAccessControl() {
// TODO Auto-generated method stub
return 0;
}
}

View file

@ -62,13 +62,5 @@ public class BinaryVariable extends BinaryElement implements IVariable {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
*/
public int getAccessControl() {
// TODO Auto-generated method stub
return 0;
}
}

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
@ -265,6 +266,7 @@ public class CModelBuilder {
protected Include createInclusion(Parent parent, IASTInclusion inclusion){
// create element
Include element = new Include((CElement)parent, inclusion.getName(), !inclusion.isLocal());
element.setFullPathName(inclusion.getFullFileName());
// add to parent
parent.addChild((CElement) element);
// set position
@ -387,6 +389,12 @@ public class CModelBuilder {
element = classTemplate;
}
// store super classes names
Iterator baseClauses = classSpecifier.getBaseClauses();
while (baseClauses.hasNext()){
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier)baseClauses.next();
element.addSuperClass(baseSpec.getParentClassName(), baseSpec.getAccess());
}
// add to parent
parent.addChild((ICElement) element);
@ -493,17 +501,16 @@ public class CModelBuilder {
if( functionDeclaration instanceof IASTMethod )
{
IASTMethod methodDeclaration = (IASTMethod) functionDeclaration;
MethodDeclaration methodElement = null;
if (methodDeclaration.hasFunctionBody())
{
// method
if(!isTemplate){
Method newElement = new Method( parent, name );
newElement.setVisibility(methodDeclaration.getVisiblity());
element = newElement;
methodElement = newElement;
}else {
MethodTemplate newElement = new MethodTemplate(parent, name);
newElement.setVisibility(methodDeclaration.getVisiblity());
element = newElement;
methodElement = newElement;
}
}
else
@ -511,17 +518,24 @@ public class CModelBuilder {
// method declaration
if(!isTemplate){
MethodDeclaration newElement = new MethodDeclaration( parent, name );
newElement.setVisibility(methodDeclaration.getVisiblity());
element = newElement;
methodElement = newElement;
}else {
MethodTemplate newElement = new MethodTemplate(parent, name);
newElement.setVisibility(methodDeclaration.getVisiblity());
element = newElement;
methodElement = newElement;
}
}
element.setVolatile(methodDeclaration.isVolatile());
element.setConst(methodDeclaration.isConst());
// Common settings for method declaration
methodElement.setVisibility(methodDeclaration.getVisiblity());
methodElement.setVolatile(methodDeclaration.isVolatile());
methodElement.setConst(methodDeclaration.isConst());
methodElement.setVirtual(methodDeclaration.isVirtual());
methodElement.setPureVirtual(methodDeclaration.isPureVirtual());
methodElement.setInline(methodDeclaration.isInline());
methodElement.setFriend(methodDeclaration.isFriend());
methodElement.setConstructor(methodDeclaration.isConstructor());
methodElement.setDestructor(methodDeclaration.isDestructor());
element = methodElement;
}
else // instance of IASTFunction
{

View file

@ -48,13 +48,6 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
getEnumerationInfo().setTypeName(type);
}
/**
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
*/
public int getAccessControl() {
return 0;
}
/**
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/

View file

@ -15,10 +15,6 @@ public class Field extends VariableDeclaration implements IField {
super(parent, name, CElement.C_FIELD);
}
public int getAccessControl(){
return getFieldInfo().getAccessControl();
}
public boolean isMutable(){
return getFieldInfo().isMutable();
}

View file

@ -15,7 +15,6 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class FieldInfo extends SourceManipulationInfo {
int flags = 0;
String typeStr = "";
boolean isConst = false;
boolean isVolatile = false;
@ -25,22 +24,13 @@ public class FieldInfo extends SourceManipulationInfo {
protected FieldInfo (CElement element) {
super(element);
flags = 0;
visibility = ASTAccessVisibility.PRIVATE;
}
protected int getAccessControl() {
return flags;
}
protected String getTypeName(){
return typeStr;
}
protected void setAccessControl(int flags) {
this.flags = flags;
}
protected void setTypeName(String type){
typeStr = type;
}

View file

@ -83,11 +83,6 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
return "";
}
public int getAccessControl(){
return getFunctionInfo().getAccessControl();
}
public String[] getExceptions(){
return new String[] {};
}

View file

@ -7,7 +7,6 @@ package org.eclipse.cdt.internal.core.model;
class FunctionInfo extends SourceManipulationInfo {
protected int flags;
protected boolean isStatic;
protected boolean isVolatile;
protected boolean isConst;
@ -15,15 +14,6 @@ class FunctionInfo extends SourceManipulationInfo {
protected FunctionInfo (CElement element) {
super(element);
flags = 0;
}
protected int getAccessControl() {
return flags;
}
protected void setAccessControl(int flags) {
this.flags = flags;
}
/**

View file

@ -10,7 +10,8 @@ import org.eclipse.cdt.core.model.IInclude;
public class Include extends SourceManipulation implements IInclude {
private final boolean standard;
private final boolean standard;
private String fullPath;
public Include(ICElement parent, String name, boolean isStandard) {
super(parent, name, CElement.C_INCLUDE);
@ -28,4 +29,26 @@ public class Include extends SourceManipulation implements IInclude {
protected CElementInfo createElementInfo () {
return new SourceManipulationInfo(this);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IInclude#getFullFileName()
*/
public String getFullFileName() {
return fullPath;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IInclude#isLocal()
*/
public boolean isLocal() {
return !isStandard();
}
/*
* This is not yet populated properly by the parse;
* however, it might be in the near future.
*/
public void setFullPathName(String fullPath) {
this.fullPath = fullPath;
}
}

View file

@ -17,45 +17,48 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{
boolean isConst;
;
boolean isConst = false;
boolean isConstructor = false;
boolean isDestructor = false;
public MethodDeclaration(ICElement parent, String name){
super(parent, name, CElement.C_METHOD_DECLARATION);
}
public MethodDeclaration(ICElement parent, String name, int type){
super(parent, name, type);
}
/**
* @see IMethod
*/
public boolean isConstructor(){
// Still a problem with the parser
//return isConstructor;
return getElementName().equals(getParent().getElementName());
}
/**
* @see IMethod
*/
public boolean isDestructor() {
// still a problem with the parser
//return isDestructor;
return getElementName().startsWith("~");
}
/**
* @see IMethod
*/
public void setConstructor(boolean isConstructor) {
this.isConstructor = isConstructor;
}
public void setDestructor(boolean isDestructor) {
this.isDestructor = isDestructor;
}
public boolean isOperator(){
return getElementName().startsWith("operator");
}
public boolean isAbstract(){
return getMethodInfo().isAbstract();
public boolean isPureVirtual(){
return getMethodInfo().isPureVirtual();
}
public void setIsAbstract(boolean isAbstract){
getMethodInfo().setAbstract(isAbstract);
public void setPureVirtual(boolean isPureVirtual){
getMethodInfo().setPureVirtual(isPureVirtual);
}
public boolean isInline(){
@ -119,4 +122,5 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
);
}
}

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class MethodInfo extends FunctionInfo {
boolean isAbstract = false;
boolean isPureVirtual = false;
boolean isInline = false;
boolean isVirtual = false;
boolean isFriend = false;
@ -27,12 +27,12 @@ public class MethodInfo extends FunctionInfo {
visibility = ASTAccessVisibility.PRIVATE;
}
public boolean isAbstract(){
return isAbstract;
public boolean isPureVirtual(){
return isPureVirtual;
}
public void setAbstract(boolean isAbstract){
this.isAbstract = isAbstract;
public void setPureVirtual(boolean isPureVirtual){
this.isPureVirtual = isPureVirtual;
}
public boolean isInline(){
@ -89,7 +89,7 @@ public class MethodInfo extends FunctionInfo {
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
return (super.hasSameContentsAs(otherInfo)
&& (isConst == ((MethodInfo)otherInfo).isConst())
&& (isAbstract == ((MethodInfo)otherInfo).isAbstract())
&& (isPureVirtual == ((MethodInfo)otherInfo).isPureVirtual())
&& (isInline == ((MethodInfo)otherInfo).isInline())
&& (isVirtual == ((MethodInfo)otherInfo).isVirtual())
&& (isFriend == ((MethodInfo)otherInfo).isFriend())

View file

@ -5,34 +5,57 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.IField;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Structure extends SourceManipulation implements IStructure {
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IField;
import org.eclipse.cdt.core.model.IMethodDeclaration;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class Structure extends SourceManipulation implements IStructure {
String [] baseTypes;
Map superClassesNames = new LinkedHashMap();
public Structure(ICElement parent, int kind, String name) {
super(parent, name, kind);
baseTypes = new String[0];
}
public IField[] getFields() {
return new IField[0];
List fields = new ArrayList();
fields.addAll(getChildrenOfType(ICElement.C_FIELD));
return (IField[]) fields.toArray(new IField[fields.size()]);
}
public IField getField(String name) {
IField[] fields = getFields();
for (int i = 0; i<fields.length; i++){
IField field = fields[i];
if(field.getElementName().equals(name)){
return field;
}
}
return null;
}
public IMethod[] getMethods() {
return new IMethod[0];
public IMethodDeclaration[] getMethods() {
List methods = new ArrayList();
methods.addAll(getChildrenOfType(ICElement.C_METHOD_DECLARATION));
methods.addAll(getChildrenOfType(ICElement.C_METHOD));
return (IMethodDeclaration[])methods.toArray(new IMethodDeclaration[methods.size()]);
}
public IMethod getMethod(String name) {
public IMethodDeclaration getMethod(String name) {
IMethodDeclaration[] methods = getMethods();
for (int i = 0; i<methods.length; i++){
IMethodDeclaration method = methods[i];
if(method.getElementName().equals(name)){
return method;
}
}
return null;
}
@ -49,27 +72,23 @@ public class Structure extends SourceManipulation implements IStructure {
}
public boolean isAbstract() {
IMethodDeclaration[] methods = getMethods();
for(int i=0; i<methods.length; i++){
IMethodDeclaration method = methods[i];
if(method.isPureVirtual())
return true;
}
return false;
}
/**
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
*/
public int getAccessControl(){
return 0;
public String[] getSuperClassesNames(){
return (String[])superClassesNames.keySet().toArray(new String[superClassesNames.keySet().size()]);
}
/**
* Return the inherited structures.
* @IInheritance
*/
public IStructure [] getBaseTypes() throws CModelException {
return new IStructure[0];
public ASTAccessVisibility getSuperClassAccess(String name){
return (ASTAccessVisibility)superClassesNames.get(name);
}
/**
* @see IVariable
*/
public String getTypeName() {
return getStructureInfo().getTypeName();
}
@ -105,31 +124,17 @@ public class Structure extends SourceManipulation implements IStructure {
public StructureInfo getStructureInfo(){
return (StructureInfo) getElementInfo();
}
/**
* @see IVariable
*/
public String getInitializer() {
return "";
}
public void addSuperClass(String name) {
String[] newBase = new String[baseTypes.length + 1];
System.arraycopy(baseTypes, 0, newBase, 0, baseTypes.length);
newBase[baseTypes.length] = name;
baseTypes = newBase;
superClassesNames.put(name, ASTAccessVisibility.PUBLIC);
}
public void addSuperClass(String name, ASTAccessVisibility access) {
superClassesNames.put(name, access);
}
protected CElementInfo createElementInfo () {
return new StructureInfo(this);
}
/**
* Return the access control for each inherited structure.
* @IInheritance
*/
public int getAccessControl(int pos) throws CModelException {
return 0;
}
}

View file

@ -18,10 +18,6 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
super(parent, name, type);
}
public int getAccessControl() {
return getVariableInfo().getAccessControl();
}
public String getTypeName() {
return getVariableInfo().getTypeName();
}

View file

@ -7,7 +7,6 @@ package org.eclipse.cdt.internal.core.model;
class VariableInfo extends SourceManipulationInfo {
protected int flags;
String typeStr = "";
boolean isConst = false;
boolean isVolatile = false;
@ -15,11 +14,6 @@ class VariableInfo extends SourceManipulationInfo {
protected VariableInfo (CElement element) {
super(element);
flags = 0;
}
protected int getAccessControl() {
return flags;
}
protected String getTypeName(){
@ -30,10 +24,6 @@ class VariableInfo extends SourceManipulationInfo {
typeStr = type;
}
protected void setAccessControl(int flags) {
this.flags = flags;
}
protected void setTypeString(String type){
typeStr = type;
}