mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +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:
parent
cc174bfe8c
commit
eaab6a9736
22 changed files with 183 additions and 191 deletions
|
@ -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
|
2003-08-19 Sean Evoy
|
||||||
In order to properly support the indexing feature, the scanner has to
|
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.
|
function as well as the version that ships with the toolset if possible.
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package org.eclipse.cdt.core.model.tests;
|
package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.*;
|
import org.eclipse.cdt.core.model.*;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.*;
|
||||||
|
|
||||||
|
@ -48,18 +49,18 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
// Interface tests:
|
// Interface tests:
|
||||||
suite.addTest( new IStructureTests("testGetChildrenOfTypeStruct"));
|
suite.addTest( new IStructureTests("testGetChildrenOfTypeStruct"));
|
||||||
suite.addTest( new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
|
suite.addTest( new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
|
||||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetFields"));
|
suite.addTest( new IStructureTests("testGetFields"));
|
||||||
suite.addTest( new IStructureTests("testGetFieldsHack"));
|
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetFieldsHack"));
|
||||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetField"));
|
suite.addTest( new IStructureTests("testGetField"));
|
||||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetMethods")); // C++ only
|
suite.addTest( new IStructureTests("testGetMethods")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testGetMethodsHack")); // C++ only
|
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetMethodsHack")); // C++ only
|
||||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetMethod")); // C++ only
|
suite.addTest( new IStructureTests("testGetMethod")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testIsStruct"));
|
suite.addTest( new IStructureTests("testIsStruct"));
|
||||||
suite.addTest( new IStructureTests("testIsClass")); // C++ only
|
suite.addTest( new IStructureTests("testIsClass")); // C++ only
|
||||||
suite.addTest( new IStructureTests("testIsUnion"));
|
suite.addTest( new IStructureTests("testIsUnion"));
|
||||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testIsAbstract")); // C++ only
|
suite.addTest( new IStructureTests("testIsAbstract")); // C++ only
|
||||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetBaseTypes")); // C++ only
|
suite.addTest( new IStructureTests("testGetBaseTypes")); // C++ only
|
||||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetAccessControl")); // C++ only
|
suite.addTest( new IStructureTests("testGetAccessControl")); // C++ only
|
||||||
|
|
||||||
// Language Specification tests:
|
// Language Specification tests:
|
||||||
suite.addTest( new IStructureTests("testAnonymousStructObject"));
|
suite.addTest( new IStructureTests("testAnonymousStructObject"));
|
||||||
|
@ -157,7 +158,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||||
IMethod[] myArrayIMethod = myIStruct.getMethods();
|
IMethodDeclaration[] myArrayIMethod = myIStruct.getMethods();
|
||||||
String[] myExpectedMethods = {
|
String[] myExpectedMethods = {
|
||||||
"method1","method2","testStruct1","~testStruct1"
|
"method1","method2","testStruct1","~testStruct1"
|
||||||
};
|
};
|
||||||
|
@ -194,7 +195,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
"method1","method2","testStruct1","~testStruct1"
|
"method1","method2","testStruct1","~testStruct1"
|
||||||
};
|
};
|
||||||
for(int i=0; i<myExpectedMethods.length; i++) {
|
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);
|
assertNotNull( "Failed on "+i, myIMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +203,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
"method7","method8","method9",
|
"method7","method8","method9",
|
||||||
};
|
};
|
||||||
for(int i=0; i<myUnexpectedMethods.length; i++) {
|
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);
|
assertNull( "Failed on "+i, myIMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +301,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
assertTrue( myStructAbstract.isAbstract() );
|
assertTrue( myStructAbstract.isAbstract() );
|
||||||
|
|
||||||
assertNotNull( myElementNonAbstract );
|
assertNotNull( myElementNonAbstract );
|
||||||
assertTrue( myElementNonAbstract.getElementType()!=ICElement.C_CLASS );
|
assertTrue( myElementNonAbstract.getElementType() == ICElement.C_CLASS );
|
||||||
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
|
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
|
||||||
assertNotNull( myStructNonAbstract );
|
assertNotNull( myStructNonAbstract );
|
||||||
assertFalse( myStructNonAbstract.isAbstract() );
|
assertFalse( myStructNonAbstract.isAbstract() );
|
||||||
|
@ -310,14 +311,14 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
public void testGetBaseTypes() {
|
public void testGetBaseTypes() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ICElement myElementDerived = null;
|
ICElement myElementDerived = null;
|
||||||
IStructure[] myBaseTypes = null;
|
String[] myBaseTypes = null;
|
||||||
try {
|
try {
|
||||||
myElementDerived = tu.getElement("testClass5"); // throws
|
myElementDerived = tu.getElement("testClass5"); // throws
|
||||||
assertNotNull( myElementDerived );
|
assertNotNull( myElementDerived );
|
||||||
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
||||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||||
assertNotNull( myStructDerived );
|
assertNotNull( myStructDerived );
|
||||||
myBaseTypes = myStructDerived.getBaseTypes(); // throws
|
myBaseTypes = myStructDerived.getSuperClassesNames();
|
||||||
}
|
}
|
||||||
catch( CModelException c )
|
catch( CModelException c )
|
||||||
{
|
{
|
||||||
|
@ -325,37 +326,36 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] myExpectedBaseTypes = {
|
String[] myExpectedBaseTypes = {
|
||||||
"testClass1","testClass3","testClass4"
|
"testClass1","testClass3","testClass4Abstract"
|
||||||
};
|
};
|
||||||
assertEquals( myExpectedBaseTypes.length, myBaseTypes.length );
|
assertEquals( myExpectedBaseTypes.length, myBaseTypes.length );
|
||||||
for(int i=0; i<myBaseTypes.length; i++) {
|
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),
|
// IInheritance
|
||||||
// not IDeclaration.getAccessControl()
|
|
||||||
public void testGetAccessControl() {
|
public void testGetAccessControl() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ICElement myElementDerived = null;
|
ICElement myElementDerived = null;
|
||||||
IStructure[] myBaseTypes = null;
|
String[] myBaseTypes = null;
|
||||||
try {
|
try {
|
||||||
myElementDerived = tu.getElement("testClass5"); // throws
|
myElementDerived = tu.getElement("testClass5"); // throws
|
||||||
assertNotNull( myElementDerived );
|
assertNotNull( myElementDerived );
|
||||||
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
||||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||||
assertNotNull( myStructDerived );
|
assertNotNull( myStructDerived );
|
||||||
myBaseTypes = myStructDerived.getBaseTypes(); // throws
|
myBaseTypes = myStructDerived.getSuperClassesNames();
|
||||||
|
|
||||||
int[] myExpectedAccessControl = {
|
ASTAccessVisibility[] myExpectedAccessControl = {
|
||||||
// TODO #38986: expect appropriate access control tags
|
// TODO #38986: expect appropriate access control tags
|
||||||
ICElement.CPP_PUBLIC,
|
ASTAccessVisibility.PUBLIC,
|
||||||
org.eclipse.cdt.core.index.TagFlags.T_PROTECTED,
|
ASTAccessVisibility.PROTECTED,
|
||||||
ICElement.CPP_PRIVATE
|
ASTAccessVisibility.PRIVATE
|
||||||
};
|
};
|
||||||
assertEquals( myExpectedAccessControl.length, myBaseTypes.length );
|
assertEquals( myExpectedAccessControl.length, myBaseTypes.length );
|
||||||
for(int i=0; i<myBaseTypes.length; i++) {
|
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 );
|
assertEquals( "Failed on "+i, myExpectedAccessControl[i], myAccessControl );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
2003-08-20 Alain Magloire
|
||||||
|
|
||||||
When doing the IPlugin.shutdown(). We have to make
|
When doing the IPlugin.shutdown(). We have to make
|
||||||
|
|
|
@ -14,15 +14,5 @@ package org.eclipse.cdt.core.model;
|
||||||
public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference {
|
public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference {
|
||||||
boolean isStatic();
|
boolean isStatic();
|
||||||
boolean isConst();
|
boolean isConst();
|
||||||
boolean isVolatile();
|
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();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,4 +22,8 @@ public interface IInclude extends ICElement, ISourceReference, ISourceManipulati
|
||||||
* <code>"#include "foobar.h"</code> returns false.
|
* <code>"#include "foobar.h"</code> returns false.
|
||||||
*/
|
*/
|
||||||
boolean isStandard();
|
boolean isStandard();
|
||||||
|
|
||||||
|
public String getFullFileName();
|
||||||
|
|
||||||
|
public boolean isLocal();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
|
@ -10,12 +12,11 @@ package org.eclipse.cdt.core.model;
|
||||||
*/
|
*/
|
||||||
public interface IInheritance {
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
|
||||||
* @exception CModelException if this element does not exist or if an
|
* @exception CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* exception occurs while accessing its corresponding resource.
|
||||||
*/
|
*/
|
||||||
boolean isAbstract();
|
boolean isPureVirtual();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if this method is static or not
|
* Returns if this method is static or not
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
|
@ -9,13 +10,11 @@ package org.eclipse.cdt.core.model;
|
||||||
* Represent struct(ure), class or union.
|
* Represent struct(ure), class or union.
|
||||||
*/
|
*/
|
||||||
public interface IStructure extends IInheritance, IParent, IVariableDeclaration {
|
public interface IStructure extends IInheritance, IParent, IVariableDeclaration {
|
||||||
//public String instantiatesTemplate();
|
|
||||||
|
|
||||||
public IField getField(String name);
|
public IField getField(String name);
|
||||||
public IField[] getFields();
|
public IField[] getFields();
|
||||||
|
|
||||||
public IMethod getMethod(String name);
|
public IMethodDeclaration getMethod(String name);
|
||||||
public IMethod [] getMethods();
|
public IMethodDeclaration [] getMethods();
|
||||||
|
|
||||||
public boolean isUnion();
|
public boolean isUnion();
|
||||||
|
|
||||||
|
@ -24,4 +23,5 @@ public interface IStructure extends IInheritance, IParent, IVariableDeclaration
|
||||||
public boolean isStruct();
|
public boolean isStruct();
|
||||||
|
|
||||||
public boolean isAbstract();
|
public boolean isAbstract();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,12 +86,4 @@ public class BinaryFunction extends BinaryElement implements IFunction {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
|
|
||||||
*/
|
|
||||||
public int getAccessControl() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,5 @@ public class BinaryVariable extends BinaryElement implements IVariable {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
|
|
||||||
*/
|
|
||||||
public int getAccessControl() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
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.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
|
@ -265,6 +266,7 @@ public class CModelBuilder {
|
||||||
protected Include createInclusion(Parent parent, IASTInclusion inclusion){
|
protected Include createInclusion(Parent parent, IASTInclusion inclusion){
|
||||||
// create element
|
// create element
|
||||||
Include element = new Include((CElement)parent, inclusion.getName(), !inclusion.isLocal());
|
Include element = new Include((CElement)parent, inclusion.getName(), !inclusion.isLocal());
|
||||||
|
element.setFullPathName(inclusion.getFullFileName());
|
||||||
// add to parent
|
// add to parent
|
||||||
parent.addChild((CElement) element);
|
parent.addChild((CElement) element);
|
||||||
// set position
|
// set position
|
||||||
|
@ -387,6 +389,12 @@ public class CModelBuilder {
|
||||||
element = classTemplate;
|
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
|
// add to parent
|
||||||
parent.addChild((ICElement) element);
|
parent.addChild((ICElement) element);
|
||||||
|
@ -493,17 +501,16 @@ public class CModelBuilder {
|
||||||
if( functionDeclaration instanceof IASTMethod )
|
if( functionDeclaration instanceof IASTMethod )
|
||||||
{
|
{
|
||||||
IASTMethod methodDeclaration = (IASTMethod) functionDeclaration;
|
IASTMethod methodDeclaration = (IASTMethod) functionDeclaration;
|
||||||
|
MethodDeclaration methodElement = null;
|
||||||
if (methodDeclaration.hasFunctionBody())
|
if (methodDeclaration.hasFunctionBody())
|
||||||
{
|
{
|
||||||
// method
|
// method
|
||||||
if(!isTemplate){
|
if(!isTemplate){
|
||||||
Method newElement = new Method( parent, name );
|
Method newElement = new Method( parent, name );
|
||||||
newElement.setVisibility(methodDeclaration.getVisiblity());
|
methodElement = newElement;
|
||||||
element = newElement;
|
|
||||||
}else {
|
}else {
|
||||||
MethodTemplate newElement = new MethodTemplate(parent, name);
|
MethodTemplate newElement = new MethodTemplate(parent, name);
|
||||||
newElement.setVisibility(methodDeclaration.getVisiblity());
|
methodElement = newElement;
|
||||||
element = newElement;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -511,17 +518,24 @@ public class CModelBuilder {
|
||||||
// method declaration
|
// method declaration
|
||||||
if(!isTemplate){
|
if(!isTemplate){
|
||||||
MethodDeclaration newElement = new MethodDeclaration( parent, name );
|
MethodDeclaration newElement = new MethodDeclaration( parent, name );
|
||||||
newElement.setVisibility(methodDeclaration.getVisiblity());
|
methodElement = newElement;
|
||||||
element = newElement;
|
|
||||||
}else {
|
}else {
|
||||||
MethodTemplate newElement = new MethodTemplate(parent, name);
|
MethodTemplate newElement = new MethodTemplate(parent, name);
|
||||||
newElement.setVisibility(methodDeclaration.getVisiblity());
|
methodElement = newElement;
|
||||||
element = newElement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
element.setVolatile(methodDeclaration.isVolatile());
|
// Common settings for method declaration
|
||||||
element.setConst(methodDeclaration.isConst());
|
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
|
else // instance of IASTFunction
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,13 +48,6 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
|
||||||
getEnumerationInfo().setTypeName(type);
|
getEnumerationInfo().setTypeName(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
|
|
||||||
*/
|
|
||||||
public int getAccessControl() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,10 +15,6 @@ public class Field extends VariableDeclaration implements IField {
|
||||||
super(parent, name, CElement.C_FIELD);
|
super(parent, name, CElement.C_FIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAccessControl(){
|
|
||||||
return getFieldInfo().getAccessControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMutable(){
|
public boolean isMutable(){
|
||||||
return getFieldInfo().isMutable();
|
return getFieldInfo().isMutable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
public class FieldInfo extends SourceManipulationInfo {
|
public class FieldInfo extends SourceManipulationInfo {
|
||||||
|
|
||||||
int flags = 0;
|
|
||||||
String typeStr = "";
|
String typeStr = "";
|
||||||
boolean isConst = false;
|
boolean isConst = false;
|
||||||
boolean isVolatile = false;
|
boolean isVolatile = false;
|
||||||
|
@ -25,22 +24,13 @@ public class FieldInfo extends SourceManipulationInfo {
|
||||||
|
|
||||||
protected FieldInfo (CElement element) {
|
protected FieldInfo (CElement element) {
|
||||||
super(element);
|
super(element);
|
||||||
flags = 0;
|
|
||||||
visibility = ASTAccessVisibility.PRIVATE;
|
visibility = ASTAccessVisibility.PRIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getAccessControl() {
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getTypeName(){
|
protected String getTypeName(){
|
||||||
return typeStr;
|
return typeStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setAccessControl(int flags) {
|
|
||||||
this.flags = flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setTypeName(String type){
|
protected void setTypeName(String type){
|
||||||
typeStr = type;
|
typeStr = type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,11 +83,6 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAccessControl(){
|
|
||||||
return getFunctionInfo().getAccessControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String[] getExceptions(){
|
public String[] getExceptions(){
|
||||||
return new String[] {};
|
return new String[] {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
class FunctionInfo extends SourceManipulationInfo {
|
class FunctionInfo extends SourceManipulationInfo {
|
||||||
|
|
||||||
protected int flags;
|
|
||||||
protected boolean isStatic;
|
protected boolean isStatic;
|
||||||
protected boolean isVolatile;
|
protected boolean isVolatile;
|
||||||
protected boolean isConst;
|
protected boolean isConst;
|
||||||
|
@ -15,15 +14,6 @@ class FunctionInfo extends SourceManipulationInfo {
|
||||||
|
|
||||||
protected FunctionInfo (CElement element) {
|
protected FunctionInfo (CElement element) {
|
||||||
super(element);
|
super(element);
|
||||||
flags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getAccessControl() {
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setAccessControl(int flags) {
|
|
||||||
this.flags = flags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,8 @@ import org.eclipse.cdt.core.model.IInclude;
|
||||||
|
|
||||||
public class Include extends SourceManipulation implements 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) {
|
public Include(ICElement parent, String name, boolean isStandard) {
|
||||||
super(parent, name, CElement.C_INCLUDE);
|
super(parent, name, CElement.C_INCLUDE);
|
||||||
|
@ -28,4 +29,26 @@ public class Include extends SourceManipulation implements IInclude {
|
||||||
protected CElementInfo createElementInfo () {
|
protected CElementInfo createElementInfo () {
|
||||||
return new SourceManipulationInfo(this);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,45 +17,48 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{
|
public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{
|
||||||
|
|
||||||
boolean isConst;
|
boolean isConst = false;
|
||||||
;
|
boolean isConstructor = false;
|
||||||
|
boolean isDestructor = false;
|
||||||
|
|
||||||
public MethodDeclaration(ICElement parent, String name){
|
public MethodDeclaration(ICElement parent, String name){
|
||||||
super(parent, name, CElement.C_METHOD_DECLARATION);
|
super(parent, name, CElement.C_METHOD_DECLARATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MethodDeclaration(ICElement parent, String name, int type){
|
public MethodDeclaration(ICElement parent, String name, int type){
|
||||||
super(parent, name, type);
|
super(parent, name, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see IMethod
|
|
||||||
*/
|
|
||||||
public boolean isConstructor(){
|
public boolean isConstructor(){
|
||||||
|
// Still a problem with the parser
|
||||||
|
//return isConstructor;
|
||||||
return getElementName().equals(getParent().getElementName());
|
return getElementName().equals(getParent().getElementName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see IMethod
|
|
||||||
*/
|
|
||||||
public boolean isDestructor() {
|
public boolean isDestructor() {
|
||||||
|
// still a problem with the parser
|
||||||
|
//return isDestructor;
|
||||||
return getElementName().startsWith("~");
|
return getElementName().startsWith("~");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setConstructor(boolean isConstructor) {
|
||||||
* @see IMethod
|
this.isConstructor = isConstructor;
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
public void setDestructor(boolean isDestructor) {
|
||||||
|
this.isDestructor = isDestructor;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isOperator(){
|
public boolean isOperator(){
|
||||||
return getElementName().startsWith("operator");
|
return getElementName().startsWith("operator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAbstract(){
|
public boolean isPureVirtual(){
|
||||||
return getMethodInfo().isAbstract();
|
return getMethodInfo().isPureVirtual();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsAbstract(boolean isAbstract){
|
public void setPureVirtual(boolean isPureVirtual){
|
||||||
getMethodInfo().setAbstract(isAbstract);
|
getMethodInfo().setPureVirtual(isPureVirtual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInline(){
|
public boolean isInline(){
|
||||||
|
@ -119,4 +122,5 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
public class MethodInfo extends FunctionInfo {
|
public class MethodInfo extends FunctionInfo {
|
||||||
|
|
||||||
boolean isAbstract = false;
|
boolean isPureVirtual = false;
|
||||||
boolean isInline = false;
|
boolean isInline = false;
|
||||||
boolean isVirtual = false;
|
boolean isVirtual = false;
|
||||||
boolean isFriend = false;
|
boolean isFriend = false;
|
||||||
|
@ -27,12 +27,12 @@ public class MethodInfo extends FunctionInfo {
|
||||||
visibility = ASTAccessVisibility.PRIVATE;
|
visibility = ASTAccessVisibility.PRIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAbstract(){
|
public boolean isPureVirtual(){
|
||||||
return isAbstract;
|
return isPureVirtual;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbstract(boolean isAbstract){
|
public void setPureVirtual(boolean isPureVirtual){
|
||||||
this.isAbstract = isAbstract;
|
this.isPureVirtual = isPureVirtual;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInline(){
|
public boolean isInline(){
|
||||||
|
@ -89,7 +89,7 @@ public class MethodInfo extends FunctionInfo {
|
||||||
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
|
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
|
||||||
return (super.hasSameContentsAs(otherInfo)
|
return (super.hasSameContentsAs(otherInfo)
|
||||||
&& (isConst == ((MethodInfo)otherInfo).isConst())
|
&& (isConst == ((MethodInfo)otherInfo).isConst())
|
||||||
&& (isAbstract == ((MethodInfo)otherInfo).isAbstract())
|
&& (isPureVirtual == ((MethodInfo)otherInfo).isPureVirtual())
|
||||||
&& (isInline == ((MethodInfo)otherInfo).isInline())
|
&& (isInline == ((MethodInfo)otherInfo).isInline())
|
||||||
&& (isVirtual == ((MethodInfo)otherInfo).isVirtual())
|
&& (isVirtual == ((MethodInfo)otherInfo).isVirtual())
|
||||||
&& (isFriend == ((MethodInfo)otherInfo).isFriend())
|
&& (isFriend == ((MethodInfo)otherInfo).isFriend())
|
||||||
|
|
|
@ -5,34 +5,57 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import java.util.ArrayList;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import java.util.LinkedHashMap;
|
||||||
import org.eclipse.cdt.core.model.IStructure;
|
import java.util.List;
|
||||||
import org.eclipse.cdt.core.model.IMethod;
|
import java.util.Map;
|
||||||
import org.eclipse.cdt.core.model.IField;
|
|
||||||
|
|
||||||
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) {
|
public Structure(ICElement parent, int kind, String name) {
|
||||||
super(parent, name, kind);
|
super(parent, name, kind);
|
||||||
baseTypes = new String[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IField[] getFields() {
|
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) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMethod[] getMethods() {
|
public IMethodDeclaration[] getMethods() {
|
||||||
return new IMethod[0];
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,27 +72,23 @@ public class Structure extends SourceManipulation implements IStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAbstract() {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String[] getSuperClassesNames(){
|
||||||
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
|
return (String[])superClassesNames.keySet().toArray(new String[superClassesNames.keySet().size()]);
|
||||||
*/
|
|
||||||
public int getAccessControl(){
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public ASTAccessVisibility getSuperClassAccess(String name){
|
||||||
* Return the inherited structures.
|
return (ASTAccessVisibility)superClassesNames.get(name);
|
||||||
* @IInheritance
|
|
||||||
*/
|
|
||||||
public IStructure [] getBaseTypes() throws CModelException {
|
|
||||||
return new IStructure[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see IVariable
|
|
||||||
*/
|
|
||||||
public String getTypeName() {
|
public String getTypeName() {
|
||||||
return getStructureInfo().getTypeName();
|
return getStructureInfo().getTypeName();
|
||||||
}
|
}
|
||||||
|
@ -105,31 +124,17 @@ public class Structure extends SourceManipulation implements IStructure {
|
||||||
public StructureInfo getStructureInfo(){
|
public StructureInfo getStructureInfo(){
|
||||||
return (StructureInfo) getElementInfo();
|
return (StructureInfo) getElementInfo();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @see IVariable
|
|
||||||
*/
|
|
||||||
public String getInitializer() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSuperClass(String name) {
|
public void addSuperClass(String name) {
|
||||||
String[] newBase = new String[baseTypes.length + 1];
|
superClassesNames.put(name, ASTAccessVisibility.PUBLIC);
|
||||||
System.arraycopy(baseTypes, 0, newBase, 0, baseTypes.length);
|
|
||||||
newBase[baseTypes.length] = name;
|
|
||||||
baseTypes = newBase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSuperClass(String name, ASTAccessVisibility access) {
|
||||||
|
superClassesNames.put(name, access);
|
||||||
|
}
|
||||||
|
|
||||||
protected CElementInfo createElementInfo () {
|
protected CElementInfo createElementInfo () {
|
||||||
return new StructureInfo(this);
|
return new StructureInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the access control for each inherited structure.
|
|
||||||
* @IInheritance
|
|
||||||
*/
|
|
||||||
public int getAccessControl(int pos) throws CModelException {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,6 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
|
||||||
super(parent, name, type);
|
super(parent, name, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAccessControl() {
|
|
||||||
return getVariableInfo().getAccessControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTypeName() {
|
public String getTypeName() {
|
||||||
return getVariableInfo().getTypeName();
|
return getVariableInfo().getTypeName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
class VariableInfo extends SourceManipulationInfo {
|
class VariableInfo extends SourceManipulationInfo {
|
||||||
|
|
||||||
protected int flags;
|
|
||||||
String typeStr = "";
|
String typeStr = "";
|
||||||
boolean isConst = false;
|
boolean isConst = false;
|
||||||
boolean isVolatile = false;
|
boolean isVolatile = false;
|
||||||
|
@ -15,11 +14,6 @@ class VariableInfo extends SourceManipulationInfo {
|
||||||
|
|
||||||
protected VariableInfo (CElement element) {
|
protected VariableInfo (CElement element) {
|
||||||
super(element);
|
super(element);
|
||||||
flags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getAccessControl() {
|
|
||||||
return flags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getTypeName(){
|
protected String getTypeName(){
|
||||||
|
@ -30,10 +24,6 @@ class VariableInfo extends SourceManipulationInfo {
|
||||||
typeStr = type;
|
typeStr = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setAccessControl(int flags) {
|
|
||||||
this.flags = flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setTypeString(String type){
|
protected void setTypeString(String type){
|
||||||
typeStr = type;
|
typeStr = type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue