mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Change in the hierarchy of the core Model:
ICModel ICProject ISourceRoot IBinary IArchive ITranslatioUnit ICContainer The ISourceRoot been added to better separate the files. By default the entire project is the SourceRoot.
This commit is contained in:
parent
8ccea9c408
commit
24b55c3712
49 changed files with 2355 additions and 918 deletions
|
@ -1,3 +1,27 @@
|
||||||
|
2004-03-18 Alain Magloire
|
||||||
|
|
||||||
|
Change in the hierarchy of the core Model:
|
||||||
|
ICModel
|
||||||
|
ICProject
|
||||||
|
ISourceRoot
|
||||||
|
IBinary
|
||||||
|
IArchive
|
||||||
|
ITranslatioUnit
|
||||||
|
ICContainer
|
||||||
|
The ISourceRoot been added to better separate
|
||||||
|
the files. By default the entire project is the
|
||||||
|
SourceRoot.
|
||||||
|
|
||||||
|
* model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java
|
||||||
|
* model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java
|
||||||
|
* model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java
|
||||||
|
* model/org/eclipse/cdt/core/model/tests/IMacroTests.java
|
||||||
|
* model/org/eclipse/cdt/core/model/tests/IStructureTests.java
|
||||||
|
* model/org/eclipse/cdt/core/model/tests/ITemplateTests.java
|
||||||
|
* model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTests.java
|
||||||
|
|
||||||
|
* suite/org/eclipse/cdt/testplugin/CProjectHelper.java
|
||||||
|
|
||||||
2003-03-16 Andrew Niefer
|
2003-03-16 Andrew Niefer
|
||||||
added CompleteParseASTTest.testBug55163
|
added CompleteParseASTTest.testBug55163
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.eclipse.cdt.core.model.tests;
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
@ -97,7 +97,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
checkMacro(tu);
|
checkMacro(tu);
|
||||||
|
|
||||||
// tu ---> namespace: MyPackage
|
// tu ---> namespace: MyPackage
|
||||||
ArrayList tuPackages = tu.getChildrenOfType(ICElement.C_NAMESPACE);
|
List tuPackages = tu.getChildrenOfType(ICElement.C_NAMESPACE);
|
||||||
INamespace namespace = (INamespace) tuPackages.get(0);
|
INamespace namespace = (INamespace) tuPackages.get(0);
|
||||||
assertEquals(namespace.getElementName(), new String("MyPackage"));
|
assertEquals(namespace.getElementName(), new String("MyPackage"));
|
||||||
checkElementOffset((CElement)namespace);
|
checkElementOffset((CElement)namespace);
|
||||||
|
@ -120,7 +120,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkInclude(IParent tu){
|
private void checkInclude(IParent tu){
|
||||||
ArrayList tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
|
List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
|
||||||
IInclude inc1 = (IInclude) tuIncludes.get(0);
|
IInclude inc1 = (IInclude) tuIncludes.get(0);
|
||||||
assertEquals(inc1.getElementName(), new String("stdio.h"));
|
assertEquals(inc1.getElementName(), new String("stdio.h"));
|
||||||
checkElementOffset((CElement)inc1);
|
checkElementOffset((CElement)inc1);
|
||||||
|
@ -128,7 +128,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMacro(IParent tu){
|
private void checkMacro(IParent tu){
|
||||||
ArrayList tuMacros = tu.getChildrenOfType(ICElement.C_MACRO);
|
List tuMacros = tu.getChildrenOfType(ICElement.C_MACRO);
|
||||||
IMacro mac1 = (IMacro) tuMacros.get(0);
|
IMacro mac1 = (IMacro) tuMacros.get(0);
|
||||||
assertEquals(mac1.getElementName(), new String("PRINT"));
|
assertEquals(mac1.getElementName(), new String("PRINT"));
|
||||||
checkElementOffset((CElement)mac1);
|
checkElementOffset((CElement)mac1);
|
||||||
|
@ -137,14 +137,14 @@ public class CModelElementsTests extends TestCase {
|
||||||
|
|
||||||
private void checkClass(IParent namespace){
|
private void checkClass(IParent namespace){
|
||||||
// MyPackage ---> class: Hello
|
// MyPackage ---> class: Hello
|
||||||
ArrayList nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
|
List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
|
||||||
IStructure classHello = (IStructure) nsClasses.get(0);
|
IStructure classHello = (IStructure) nsClasses.get(0);
|
||||||
assertEquals(classHello.getElementName(), new String("Hello"));
|
assertEquals(classHello.getElementName(), new String("Hello"));
|
||||||
checkElementOffset((CElement)classHello);
|
checkElementOffset((CElement)classHello);
|
||||||
checkLineNumbers((CElement)classHello, 12, 53);
|
checkLineNumbers((CElement)classHello, 12, 53);
|
||||||
|
|
||||||
// Hello --> field: int x
|
// Hello --> field: int x
|
||||||
ArrayList helloFields = classHello.getChildrenOfType(ICElement.C_FIELD);
|
List helloFields = classHello.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField intX = (IField) helloFields.get(0);
|
IField intX = (IField) helloFields.get(0);
|
||||||
assertEquals(intX.getElementName(), new String("x"));
|
assertEquals(intX.getElementName(), new String("x"));
|
||||||
checkElementOffset((CElement)intX);
|
checkElementOffset((CElement)intX);
|
||||||
|
@ -156,7 +156,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
fail("visibility should be protected!");
|
fail("visibility should be protected!");
|
||||||
|
|
||||||
// Hello ---> method: void setX(int X)
|
// Hello ---> method: void setX(int X)
|
||||||
ArrayList helloMethods = classHello.getChildrenOfType(ICElement.C_METHOD);
|
List helloMethods = classHello.getChildrenOfType(ICElement.C_METHOD);
|
||||||
IMethod setX = (IMethod) helloMethods.get(0);
|
IMethod setX = (IMethod) helloMethods.get(0);
|
||||||
assertEquals(setX.getElementName(), new String("setX"));
|
assertEquals(setX.getElementName(), new String("setX"));
|
||||||
checkElementOffset((CElement)setX);
|
checkElementOffset((CElement)setX);
|
||||||
|
@ -174,7 +174,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
}
|
}
|
||||||
private void checkNestedNamespace(IParent classHello){
|
private void checkNestedNamespace(IParent classHello){
|
||||||
// Hello ---> namespace: MyNestedPackage
|
// Hello ---> namespace: MyNestedPackage
|
||||||
ArrayList helloNamespaces = classHello.getChildrenOfType(ICElement.C_NAMESPACE);
|
List helloNamespaces = classHello.getChildrenOfType(ICElement.C_NAMESPACE);
|
||||||
INamespace myNestedPackage = (INamespace) helloNamespaces.get(0);
|
INamespace myNestedPackage = (INamespace) helloNamespaces.get(0);
|
||||||
assertEquals(myNestedPackage.getElementName(), new String("MyNestedPackage"));
|
assertEquals(myNestedPackage.getElementName(), new String("MyNestedPackage"));
|
||||||
checkElementOffset((CElement)myNestedPackage);
|
checkElementOffset((CElement)myNestedPackage);
|
||||||
|
@ -185,14 +185,14 @@ public class CModelElementsTests extends TestCase {
|
||||||
}
|
}
|
||||||
private void checkParentNestedClass(IParent myNestedPackage){
|
private void checkParentNestedClass(IParent myNestedPackage){
|
||||||
// MyNestedPackage ---> class: Y
|
// MyNestedPackage ---> class: Y
|
||||||
ArrayList nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
||||||
IStructure classY = (IStructure) nestedClasses.get(0);
|
IStructure classY = (IStructure) nestedClasses.get(0);
|
||||||
assertEquals(classY.getElementName(), new String("Y"));
|
assertEquals(classY.getElementName(), new String("Y"));
|
||||||
checkElementOffset((CElement)classY);
|
checkElementOffset((CElement)classY);
|
||||||
checkLineNumbers((CElement)classY, 28, 35);
|
checkLineNumbers((CElement)classY, 28, 35);
|
||||||
|
|
||||||
// Y ---> constructor: Y
|
// Y ---> constructor: Y
|
||||||
ArrayList yMethods = classY.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
List yMethods = classY.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||||
IMethodDeclaration constructor = (IMethodDeclaration) yMethods.get(0);
|
IMethodDeclaration constructor = (IMethodDeclaration) yMethods.get(0);
|
||||||
assertEquals(constructor.getElementName(), new String("Y"));
|
assertEquals(constructor.getElementName(), new String("Y"));
|
||||||
checkElementOffset((CElement)constructor);
|
checkElementOffset((CElement)constructor);
|
||||||
|
@ -211,7 +211,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
|
|
||||||
private void checkDerivedNestedClass(IParent myNestedPackage){
|
private void checkDerivedNestedClass(IParent myNestedPackage){
|
||||||
// MyNestedPackage ---> class: X public Y
|
// MyNestedPackage ---> class: X public Y
|
||||||
ArrayList nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
||||||
IStructure classX = (IStructure) nestedClasses.get(1);
|
IStructure classX = (IStructure) nestedClasses.get(1);
|
||||||
assertEquals(classX.getElementName(), new String("X"));
|
assertEquals(classX.getElementName(), new String("X"));
|
||||||
checkElementOffset((CElement)classX);
|
checkElementOffset((CElement)classX);
|
||||||
|
@ -219,7 +219,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
// TODO : Check for base classes here
|
// TODO : Check for base classes here
|
||||||
|
|
||||||
// X --> field: B b
|
// X --> field: B b
|
||||||
ArrayList xFieldChildren = classX.getChildrenOfType(ICElement.C_FIELD);
|
List xFieldChildren = classX.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField bB = (IField) xFieldChildren.get(0);
|
IField bB = (IField) xFieldChildren.get(0);
|
||||||
assertEquals(bB.getElementName(), new String("b"));
|
assertEquals(bB.getElementName(), new String("b"));
|
||||||
checkElementOffset((CElement)bB);
|
checkElementOffset((CElement)bB);
|
||||||
|
@ -230,7 +230,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
fail("visibility should be private!");
|
fail("visibility should be private!");
|
||||||
|
|
||||||
// X ---> constructor chain: X
|
// X ---> constructor chain: X
|
||||||
ArrayList xMethodChildren = classX.getChildrenOfType(ICElement.C_METHOD);
|
List xMethodChildren = classX.getChildrenOfType(ICElement.C_METHOD);
|
||||||
IMethod xconstructor = (IMethod) xMethodChildren.get(0);
|
IMethod xconstructor = (IMethod) xMethodChildren.get(0);
|
||||||
assertEquals(xconstructor.getElementName(), new String("X"));
|
assertEquals(xconstructor.getElementName(), new String("X"));
|
||||||
checkElementOffset((CElement)xconstructor);
|
checkElementOffset((CElement)xconstructor);
|
||||||
|
@ -238,7 +238,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
checkLineNumbers((CElement)xconstructor, 46, 48);
|
checkLineNumbers((CElement)xconstructor, 46, 48);
|
||||||
|
|
||||||
// X ---> method declaration: doNothing
|
// X ---> method declaration: doNothing
|
||||||
ArrayList xMethodDeclarations = classX.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
List xMethodDeclarations = classX.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||||
IMethodDeclaration xDoNothing = (IMethodDeclaration) xMethodDeclarations.get(0);
|
IMethodDeclaration xDoNothing = (IMethodDeclaration) xMethodDeclarations.get(0);
|
||||||
assertEquals(xDoNothing.getElementName(), new String("doNothing"));
|
assertEquals(xDoNothing.getElementName(), new String("doNothing"));
|
||||||
checkElementOffset((CElement)xDoNothing);
|
checkElementOffset((CElement)xDoNothing);
|
||||||
|
@ -248,14 +248,14 @@ public class CModelElementsTests extends TestCase {
|
||||||
|
|
||||||
private void checkEnums(IParent namespace){
|
private void checkEnums(IParent namespace){
|
||||||
// MyPackage ---> enum: Noname
|
// MyPackage ---> enum: Noname
|
||||||
ArrayList nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
|
List nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
|
||||||
IEnumeration enum = (IEnumeration) nsEnums.get(0);
|
IEnumeration enum = (IEnumeration) nsEnums.get(0);
|
||||||
assertEquals(enum.getElementName(), new String(""));
|
assertEquals(enum.getElementName(), new String(""));
|
||||||
checkElementOffset((CElement)enum);
|
checkElementOffset((CElement)enum);
|
||||||
checkLineNumbers((CElement)enum, 57, 61);
|
checkLineNumbers((CElement)enum, 57, 61);
|
||||||
|
|
||||||
// enum ---> enumerator: first = 1
|
// enum ---> enumerator: first = 1
|
||||||
ArrayList enumEnumerators = enum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
List enumEnumerators = enum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
||||||
IEnumerator first = (IEnumerator) enumEnumerators.get(0);
|
IEnumerator first = (IEnumerator) enumEnumerators.get(0);
|
||||||
assertEquals(first.getElementName(), new String("first"));
|
assertEquals(first.getElementName(), new String("first"));
|
||||||
assertEquals("1", first.getConstantExpression());
|
assertEquals("1", first.getConstantExpression());
|
||||||
|
@ -277,7 +277,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
checkLineNumbers((CElement)myEnum, 64, 67);
|
checkLineNumbers((CElement)myEnum, 64, 67);
|
||||||
|
|
||||||
// enum ---> enumerator: first
|
// enum ---> enumerator: first
|
||||||
ArrayList myEnumEnumerators = myEnum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
List myEnumEnumerators = myEnum.getChildrenOfType(ICElement.C_ENUMERATOR);
|
||||||
IEnumerator f = (IEnumerator) myEnumEnumerators.get(0);
|
IEnumerator f = (IEnumerator) myEnumEnumerators.get(0);
|
||||||
assertEquals(f.getElementName(), new String("f"));
|
assertEquals(f.getElementName(), new String("f"));
|
||||||
checkElementOffset((CElement)f);
|
checkElementOffset((CElement)f);
|
||||||
|
@ -293,7 +293,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
|
|
||||||
private void checkVariables(IParent namespace){
|
private void checkVariables(IParent namespace){
|
||||||
// MyPackage ---> int v
|
// MyPackage ---> int v
|
||||||
ArrayList nsVars = namespace.getChildrenOfType(ICElement.C_VARIABLE);
|
List nsVars = namespace.getChildrenOfType(ICElement.C_VARIABLE);
|
||||||
IVariable var1 = (IVariable) nsVars.get(0);
|
IVariable var1 = (IVariable) nsVars.get(0);
|
||||||
assertEquals(var1.getElementName(), new String("v"));
|
assertEquals(var1.getElementName(), new String("v"));
|
||||||
checkElementOffset((CElement)var1);
|
checkElementOffset((CElement)var1);
|
||||||
|
@ -324,7 +324,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
|
|
||||||
private void checkVariableDeclarations(IParent namespace){
|
private void checkVariableDeclarations(IParent namespace){
|
||||||
// MyPackage ---> extern int evar
|
// MyPackage ---> extern int evar
|
||||||
ArrayList nsVarDecls = namespace.getChildrenOfType(ICElement.C_VARIABLE_DECLARATION);
|
List nsVarDecls = namespace.getChildrenOfType(ICElement.C_VARIABLE_DECLARATION);
|
||||||
IVariableDeclaration vDecl1 = (IVariableDeclaration) nsVarDecls.get(0);
|
IVariableDeclaration vDecl1 = (IVariableDeclaration) nsVarDecls.get(0);
|
||||||
assertEquals(vDecl1.getElementName(), new String("evar"));
|
assertEquals(vDecl1.getElementName(), new String("evar"));
|
||||||
checkElementOffset((CElement)vDecl1);
|
checkElementOffset((CElement)vDecl1);
|
||||||
|
@ -333,7 +333,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkFunctions(IParent namespace){
|
private void checkFunctions(IParent namespace){
|
||||||
ArrayList nsFunctionDeclarations = namespace.getChildrenOfType(ICElement.C_FUNCTION_DECLARATION);
|
List nsFunctionDeclarations = namespace.getChildrenOfType(ICElement.C_FUNCTION_DECLARATION);
|
||||||
|
|
||||||
// MyPackage ---> function: void foo()
|
// MyPackage ---> function: void foo()
|
||||||
IFunctionDeclaration f1 = (IFunctionDeclaration) nsFunctionDeclarations.get(0);
|
IFunctionDeclaration f1 = (IFunctionDeclaration) nsFunctionDeclarations.get(0);
|
||||||
|
@ -356,7 +356,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
assertEquals(paramTypes[1], new String("char**"));
|
assertEquals(paramTypes[1], new String("char**"));
|
||||||
|
|
||||||
// MyPackage ---> function: void boo() {}
|
// MyPackage ---> function: void boo() {}
|
||||||
ArrayList nsFunctions = namespace.getChildrenOfType(ICElement.C_FUNCTION);
|
List nsFunctions = namespace.getChildrenOfType(ICElement.C_FUNCTION);
|
||||||
IFunction f3 = (IFunction) nsFunctions.get(0);
|
IFunction f3 = (IFunction) nsFunctions.get(0);
|
||||||
assertEquals(f3.getElementName(), new String("boo"));
|
assertEquals(f3.getElementName(), new String("boo"));
|
||||||
checkElementOffset((CElement)f3);
|
checkElementOffset((CElement)f3);
|
||||||
|
@ -366,12 +366,12 @@ public class CModelElementsTests extends TestCase {
|
||||||
|
|
||||||
private void checkStructs(IParent namespace){
|
private void checkStructs(IParent namespace){
|
||||||
// struct with name
|
// struct with name
|
||||||
ArrayList nsStructs = namespace.getChildrenOfType(ICElement.C_STRUCT);
|
List nsStructs = namespace.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure struct1 = (IStructure) nsStructs.get(0);
|
IStructure struct1 = (IStructure) nsStructs.get(0);
|
||||||
assertEquals(struct1.getElementName(), new String ("MyStruct"));
|
assertEquals(struct1.getElementName(), new String ("MyStruct"));
|
||||||
checkElementOffset((CElement)struct1);
|
checkElementOffset((CElement)struct1);
|
||||||
checkLineNumbers((CElement)struct1, 95, 97);
|
checkLineNumbers((CElement)struct1, 95, 97);
|
||||||
ArrayList struct1Fields = struct1.getChildrenOfType(ICElement.C_FIELD);
|
List struct1Fields = struct1.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField field1 = (IField) struct1Fields.get(0);
|
IField field1 = (IField) struct1Fields.get(0);
|
||||||
assertEquals(field1.getElementName(), new String("sint"));
|
assertEquals(field1.getElementName(), new String("sint"));
|
||||||
checkElementOffset((CElement)field1);
|
checkElementOffset((CElement)field1);
|
||||||
|
@ -386,7 +386,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
assertEquals(struct2.getElementName(), new String (""));
|
assertEquals(struct2.getElementName(), new String (""));
|
||||||
checkElementOffset((CElement)struct2);
|
checkElementOffset((CElement)struct2);
|
||||||
checkLineNumbers((CElement)struct2, 101, 103);
|
checkLineNumbers((CElement)struct2, 101, 103);
|
||||||
ArrayList struct2Fields = struct2.getChildrenOfType(ICElement.C_FIELD);
|
List struct2Fields = struct2.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField field2 = (IField) struct2Fields.get(0);
|
IField field2 = (IField) struct2Fields.get(0);
|
||||||
assertEquals(field2.getElementName(), new String("ss"));
|
assertEquals(field2.getElementName(), new String("ss"));
|
||||||
checkElementOffset((CElement)field2);
|
checkElementOffset((CElement)field2);
|
||||||
|
@ -396,7 +396,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
fail("field visibility should be public!");
|
fail("field visibility should be public!");
|
||||||
|
|
||||||
// typedefs
|
// typedefs
|
||||||
ArrayList nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
|
List nsTypeDefs = namespace.getChildrenOfType(ICElement.C_TYPEDEF);
|
||||||
ITypeDef td1 = (ITypeDef) nsTypeDefs.get(0);
|
ITypeDef td1 = (ITypeDef) nsTypeDefs.get(0);
|
||||||
assertEquals(td1.getElementName(), new String ("myStruct"));
|
assertEquals(td1.getElementName(), new String ("myStruct"));
|
||||||
checkElementOffset((CElement)td1);
|
checkElementOffset((CElement)td1);
|
||||||
|
@ -409,12 +409,12 @@ public class CModelElementsTests extends TestCase {
|
||||||
checkLineNumbers((CElement)td2, 101, 103);
|
checkLineNumbers((CElement)td2, 101, 103);
|
||||||
|
|
||||||
// union
|
// union
|
||||||
ArrayList nsUnions = namespace.getChildrenOfType(ICElement.C_UNION);
|
List nsUnions = namespace.getChildrenOfType(ICElement.C_UNION);
|
||||||
IStructure u0 = (IStructure) nsUnions.get(0);
|
IStructure u0 = (IStructure) nsUnions.get(0);
|
||||||
assertEquals(u0.getElementName(), new String("U"));
|
assertEquals(u0.getElementName(), new String("U"));
|
||||||
checkElementOffset((CElement)u0);
|
checkElementOffset((CElement)u0);
|
||||||
checkLineNumbers((CElement)u0, 105, 107);
|
checkLineNumbers((CElement)u0, 105, 107);
|
||||||
ArrayList u0Fields = u0.getChildrenOfType(ICElement.C_FIELD);
|
List u0Fields = u0.getChildrenOfType(ICElement.C_FIELD);
|
||||||
IField field3 = (IField) u0Fields.get(0);
|
IField field3 = (IField) u0Fields.get(0);
|
||||||
assertEquals(field3.getElementName(), new String("U1"));
|
assertEquals(field3.getElementName(), new String("U1"));
|
||||||
checkElementOffset((CElement)field3);
|
checkElementOffset((CElement)field3);
|
||||||
|
@ -426,7 +426,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
|
|
||||||
private void checkTemplates(IParent namespace){
|
private void checkTemplates(IParent namespace){
|
||||||
// template function
|
// template function
|
||||||
ArrayList functionTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION);
|
List functionTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION);
|
||||||
FunctionTemplate ft = (FunctionTemplate)functionTemplates.get(0);
|
FunctionTemplate ft = (FunctionTemplate)functionTemplates.get(0);
|
||||||
assertEquals(ft.getElementName(), new String("aTemplatedFunction"));
|
assertEquals(ft.getElementName(), new String("aTemplatedFunction"));
|
||||||
checkElementOffset((CElement)ft);
|
checkElementOffset((CElement)ft);
|
||||||
|
@ -435,10 +435,10 @@ public class CModelElementsTests extends TestCase {
|
||||||
checkLineNumbers((CElement)ft, 112, 113);
|
checkLineNumbers((CElement)ft, 112, 113);
|
||||||
|
|
||||||
// template method
|
// template method
|
||||||
ArrayList nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
|
List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
|
||||||
IStructure enclosingClass = (IStructure) nsClasses.get(1);
|
IStructure enclosingClass = (IStructure) nsClasses.get(1);
|
||||||
checkLineNumbers((CElement)enclosingClass, 115, 120);
|
checkLineNumbers((CElement)enclosingClass, 115, 120);
|
||||||
ArrayList methodTemplates = enclosingClass.getChildrenOfType(ICElement.C_TEMPLATE_METHOD);
|
List methodTemplates = enclosingClass.getChildrenOfType(ICElement.C_TEMPLATE_METHOD);
|
||||||
MethodTemplate mt = (MethodTemplate)methodTemplates.get(0);
|
MethodTemplate mt = (MethodTemplate)methodTemplates.get(0);
|
||||||
assertEquals(mt.getElementName(), new String("aTemplatedMethod"));
|
assertEquals(mt.getElementName(), new String("aTemplatedMethod"));
|
||||||
checkElementOffset((CElement)mt);
|
checkElementOffset((CElement)mt);
|
||||||
|
@ -447,7 +447,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
assertEquals(mt.getVisibility(), ASTAccessVisibility.PUBLIC);
|
assertEquals(mt.getVisibility(), ASTAccessVisibility.PUBLIC);
|
||||||
|
|
||||||
// template class
|
// template class
|
||||||
ArrayList classTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
|
List classTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
|
||||||
StructureTemplate ct = (StructureTemplate)classTemplates.get(0);
|
StructureTemplate ct = (StructureTemplate)classTemplates.get(0);
|
||||||
assertEquals(ct.getElementName(), new String("myarray"));
|
assertEquals(ct.getElementName(), new String("myarray"));
|
||||||
checkElementOffset((CElement)ct);
|
checkElementOffset((CElement)ct);
|
||||||
|
@ -455,7 +455,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
checkLineNumbers((CElement)ct, 122, 123);
|
checkLineNumbers((CElement)ct, 122, 123);
|
||||||
|
|
||||||
// template struct
|
// template struct
|
||||||
ArrayList structTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
|
List structTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
|
||||||
StructureTemplate st = (StructureTemplate)structTemplates.get(0);
|
StructureTemplate st = (StructureTemplate)structTemplates.get(0);
|
||||||
assertEquals(st.getElementName(), new String("mystruct"));
|
assertEquals(st.getElementName(), new String("mystruct"));
|
||||||
checkElementOffset((CElement)st);
|
checkElementOffset((CElement)st);
|
||||||
|
@ -475,7 +475,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
|
|
||||||
private void checkArrays(IParent tu){
|
private void checkArrays(IParent tu){
|
||||||
// array variable
|
// array variable
|
||||||
ArrayList variables = tu.getChildrenOfType(ICElement.C_VARIABLE);
|
List variables = tu.getChildrenOfType(ICElement.C_VARIABLE);
|
||||||
IVariable arrayVar = (IVariable) variables.get(0);
|
IVariable arrayVar = (IVariable) variables.get(0);
|
||||||
assertEquals(arrayVar.getElementName(), new String("myArray"));
|
assertEquals(arrayVar.getElementName(), new String("myArray"));
|
||||||
checkElementOffset((CElement)arrayVar);
|
checkElementOffset((CElement)arrayVar);
|
||||||
|
@ -483,7 +483,7 @@ public class CModelElementsTests extends TestCase {
|
||||||
checkLineNumbers((CElement)arrayVar, 133, 133);
|
checkLineNumbers((CElement)arrayVar, 133, 133);
|
||||||
|
|
||||||
// array parameter in function main
|
// array parameter in function main
|
||||||
ArrayList functions = tu.getChildrenOfType(ICElement.C_FUNCTION);
|
List functions = tu.getChildrenOfType(ICElement.C_FUNCTION);
|
||||||
IFunction mainFunction = (IFunction) functions.get(0);
|
IFunction mainFunction = (IFunction) functions.get(0);
|
||||||
assertEquals(mainFunction.getElementName(), new String("main"));
|
assertEquals(mainFunction.getElementName(), new String("main"));
|
||||||
checkElementOffset((CElement)mainFunction);
|
checkElementOffset((CElement)mainFunction);
|
||||||
|
|
|
@ -139,14 +139,20 @@ public class CPathEntryTest extends TestCase {
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
}
|
}
|
||||||
IPathEntry[] entries = testProject.getResolvedPathEntries();
|
IPathEntry[] entries = testProject.getResolvedPathEntries();
|
||||||
assertTrue("No cpathentries", entries.length == 0);
|
// We always have at least two entries:
|
||||||
|
// 1) the default sourceEntry becomes the project
|
||||||
|
// 2) the default outputEntry becomes the project
|
||||||
|
assertTrue("No cpathentries", entries.length == 2);
|
||||||
entries = new IPathEntry[3];
|
entries = new IPathEntry[3];
|
||||||
entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true);
|
entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true);
|
||||||
entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), new Path("/usr/include"), true);
|
entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), new Path("/usr/include"), true);
|
||||||
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
|
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null);
|
||||||
testProject.setRawPathEntries(entries, new NullProgressMonitor());
|
testProject.setRawPathEntries(entries, new NullProgressMonitor());
|
||||||
entries = testProject.getResolvedPathEntries();
|
entries = testProject.getResolvedPathEntries();
|
||||||
assertTrue("Expecting 3 pathentries", entries.length == 3);
|
// We always have at least two entries:
|
||||||
|
// 1) the default sourceEntry becomes the project
|
||||||
|
// 2) the default outputEntry becomes the project
|
||||||
|
assertTrue("Expecting 3 pathentries", entries.length == (3 + 2));
|
||||||
testProject.setRawPathEntries(null, null);
|
testProject.setRawPathEntries(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +167,7 @@ public class CPathEntryTest extends TestCase {
|
||||||
if (testProject == null) {
|
if (testProject == null) {
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
}
|
}
|
||||||
CProjectHelper.addSourceContainer(testProject, "foo");
|
CProjectHelper.addCContainer(testProject, "foo");
|
||||||
IPathEntry[] entries = new IPathEntry[3];
|
IPathEntry[] entries = new IPathEntry[3];
|
||||||
entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true);
|
entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true);
|
||||||
entries[1] = CoreModel.newIncludeEntry(new Path("foo"), new Path("/usr/include"), true);
|
entries[1] = CoreModel.newIncludeEntry(new Path("foo"), new Path("/usr/include"), true);
|
||||||
|
@ -208,6 +214,9 @@ public class CPathEntryTest extends TestCase {
|
||||||
CoreModel.getDefault().setRawPathEntries(testProject, new IPathEntry[]{containerEntry}, new NullProgressMonitor());
|
CoreModel.getDefault().setRawPathEntries(testProject, new IPathEntry[]{containerEntry}, new NullProgressMonitor());
|
||||||
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{testProject}, container, new NullProgressMonitor());
|
CoreModel.getDefault().setPathEntryContainer(new ICProject[]{testProject}, container, new NullProgressMonitor());
|
||||||
IPathEntry[] entries = testProject.getResolvedPathEntries();
|
IPathEntry[] entries = testProject.getResolvedPathEntries();
|
||||||
assertTrue("Expecting 3 pathentries from container", entries.length == 3);
|
// We always have at least two entries:
|
||||||
|
// 1) the default sourceEntry becomes the project
|
||||||
|
// 2) the default outputEntry becomes the project
|
||||||
|
assertTrue("Expecting 3 pathentries from container", entries.length == (3 + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,6 +22,7 @@ import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.IBuffer;
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
@ -31,7 +32,6 @@ import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
|
||||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.testplugin.TestPluginLauncher;
|
import org.eclipse.cdt.testplugin.TestPluginLauncher;
|
||||||
|
@ -96,7 +96,12 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
||||||
|
|
||||||
|
|
||||||
public void testElementDeltas() throws Exception {
|
public void testElementDeltas() throws Exception {
|
||||||
ITranslationUnit tu = new TranslationUnit(fCProject, headerFile);
|
//ITranslationUnit tu = new TranslationUnit(fCProject, headerFile);
|
||||||
|
ICElement celement = CoreModel.getDefault().create(headerFile);
|
||||||
|
ITranslationUnit tu = null;
|
||||||
|
if (celement instanceof ITranslationUnit) {
|
||||||
|
tu = (ITranslationUnit)celement;
|
||||||
|
}
|
||||||
assertNotNull (tu);
|
assertNotNull (tu);
|
||||||
IWorkingCopy wc = tu.getWorkingCopy();
|
IWorkingCopy wc = tu.getWorkingCopy();
|
||||||
assertNotNull (wc);
|
assertNotNull (wc);
|
||||||
|
@ -110,6 +115,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
||||||
wc.commit(true, monitor);
|
wc.commit(true, monitor);
|
||||||
assertChangedElement(ICElement.C_MODEL, "");
|
assertChangedElement(ICElement.C_MODEL, "");
|
||||||
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
||||||
|
assertChangedElement(ICElement.C_CCONTAINER, "TestProject1");
|
||||||
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
||||||
assertAddedElement(ICElement.C_CLASS, "Hello");
|
assertAddedElement(ICElement.C_CLASS, "Hello");
|
||||||
assertRemovedElement(ICElement.C_INCLUDE, "stdio.h");
|
assertRemovedElement(ICElement.C_INCLUDE, "stdio.h");
|
||||||
|
@ -121,6 +127,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
||||||
wc.commit(true, monitor);
|
wc.commit(true, monitor);
|
||||||
assertChangedElement(ICElement.C_MODEL, "");
|
assertChangedElement(ICElement.C_MODEL, "");
|
||||||
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
||||||
|
assertChangedElement(ICElement.C_CCONTAINER, "TestProject1");
|
||||||
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
||||||
assertChangedElement(ICElement.C_CLASS, "Hello");
|
assertChangedElement(ICElement.C_CLASS, "Hello");
|
||||||
assertAddedElement(ICElement.C_FIELD, "x");
|
assertAddedElement(ICElement.C_FIELD, "x");
|
||||||
|
@ -132,6 +139,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
||||||
wc.commit(true, monitor);
|
wc.commit(true, monitor);
|
||||||
assertChangedElement(ICElement.C_MODEL, "");
|
assertChangedElement(ICElement.C_MODEL, "");
|
||||||
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
||||||
|
assertChangedElement(ICElement.C_CCONTAINER, "TestProject1");
|
||||||
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
||||||
assertChangedElement(ICElement.C_CLASS, "Hello");
|
assertChangedElement(ICElement.C_CLASS, "Hello");
|
||||||
assertAddedElement(ICElement.C_METHOD_DECLARATION, "setValue");
|
assertAddedElement(ICElement.C_METHOD_DECLARATION, "setValue");
|
||||||
|
@ -144,6 +152,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
||||||
wc.commit(true, monitor);
|
wc.commit(true, monitor);
|
||||||
assertChangedElement(ICElement.C_MODEL, "");
|
assertChangedElement(ICElement.C_MODEL, "");
|
||||||
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
||||||
|
assertChangedElement(ICElement.C_CCONTAINER, "TestProject1");
|
||||||
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
||||||
assertChangedElement(ICElement.C_CLASS, "Hello");
|
assertChangedElement(ICElement.C_CLASS, "Hello");
|
||||||
assertAddedElement(ICElement.C_FIELD, "y");
|
assertAddedElement(ICElement.C_FIELD, "y");
|
||||||
|
@ -156,6 +165,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
||||||
wc.commit(true, monitor);
|
wc.commit(true, monitor);
|
||||||
assertChangedElement(ICElement.C_MODEL, "");
|
assertChangedElement(ICElement.C_MODEL, "");
|
||||||
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
||||||
|
assertChangedElement(ICElement.C_CCONTAINER, "TestProject1");
|
||||||
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
||||||
assertChangedElement(ICElement.C_CLASS, "Hello");
|
assertChangedElement(ICElement.C_CLASS, "Hello");
|
||||||
assertChangedElement(ICElement.C_FIELD, "y");
|
assertChangedElement(ICElement.C_FIELD, "y");
|
||||||
|
@ -168,6 +178,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
||||||
wc.commit(true, monitor);
|
wc.commit(true, monitor);
|
||||||
assertChangedElement(ICElement.C_MODEL, "");
|
assertChangedElement(ICElement.C_MODEL, "");
|
||||||
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
||||||
|
assertChangedElement(ICElement.C_CCONTAINER, "TestProject1");
|
||||||
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
||||||
assertChangedElement(ICElement.C_CLASS, "Hello");
|
assertChangedElement(ICElement.C_CLASS, "Hello");
|
||||||
assertRemovedElement(ICElement.C_FIELD, "y");
|
assertRemovedElement(ICElement.C_FIELD, "y");
|
||||||
|
@ -179,6 +190,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
||||||
wc.commit(true, monitor);
|
wc.commit(true, monitor);
|
||||||
assertChangedElement(ICElement.C_MODEL, "");
|
assertChangedElement(ICElement.C_MODEL, "");
|
||||||
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
assertChangedElement(ICElement.C_PROJECT, "TestProject1");
|
||||||
|
assertChangedElement(ICElement.C_CCONTAINER, "TestProject1");
|
||||||
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
assertChangedElement(ICElement.C_UNIT, "WorkingCopyTest.h");
|
||||||
assertRemovedElement(ICElement.C_CLASS, "Hello");
|
assertRemovedElement(ICElement.C_CLASS, "Hello");
|
||||||
assertEmptyDelta();
|
assertEmptyDelta();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.eclipse.cdt.core.model.IMacro;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.tests.IntegratedCModelTest;
|
import org.eclipse.cdt.core.model.tests.IntegratedCModelTest;
|
||||||
|
@ -55,7 +55,7 @@ public class IMacroTests extends IntegratedCModelTest {
|
||||||
|
|
||||||
public void testGetElementName() {
|
public void testGetElementName() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
List arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
||||||
|
|
||||||
String expectedList[] = new String[] {
|
String expectedList[] = new String[] {
|
||||||
"SINGLETON",
|
"SINGLETON",
|
||||||
|
@ -72,7 +72,7 @@ public class IMacroTests extends IntegratedCModelTest {
|
||||||
|
|
||||||
public void testGetIdentifierList() {
|
public void testGetIdentifierList() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
List arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
||||||
|
|
||||||
String expectedList[] = new String[] {
|
String expectedList[] = new String[] {
|
||||||
"",
|
"",
|
||||||
|
@ -89,7 +89,7 @@ public class IMacroTests extends IntegratedCModelTest {
|
||||||
|
|
||||||
public void testGetTokenSequence() {
|
public void testGetTokenSequence() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
List arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
||||||
|
|
||||||
String expectedList[] = new String[] {
|
String expectedList[] = new String[] {
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bnicolle
|
* @author bnicolle
|
||||||
|
@ -71,7 +71,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
|
|
||||||
public void testGetChildrenOfTypeStruct() {
|
public void testGetChildrenOfTypeStruct() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList arrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
List arrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
String[] myExpectedStructs = {
|
String[] myExpectedStructs = {
|
||||||
"testStruct1", "testStruct2", "testStruct3",
|
"testStruct1", "testStruct2", "testStruct3",
|
||||||
/* 2 anonymous structs */ "", "", "testStruct7",
|
/* 2 anonymous structs */ "", "", "testStruct7",
|
||||||
|
@ -86,7 +86,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
public void testGetChildrenOfTypeClass() {
|
public void testGetChildrenOfTypeClass() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
|
List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
|
||||||
String[] myExpectedClasses = {
|
String[] myExpectedClasses = {
|
||||||
"testClass1", "testClass3", "testClass4Abstract",
|
"testClass1", "testClass3", "testClass4Abstract",
|
||||||
"testClass5", "testClass6" };
|
"testClass5", "testClass6" };
|
||||||
|
@ -100,7 +100,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
|
|
||||||
public void testGetFields() {
|
public void testGetFields() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||||
IField[] myArrayIField = myIStruct.getFields();
|
IField[] myArrayIField = myIStruct.getFields();
|
||||||
String[] myExpectedFields = {
|
String[] myExpectedFields = {
|
||||||
|
@ -118,13 +118,13 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
// TODO Bug# 38985: remove testGetFieldsHack()
|
// TODO Bug# 38985: remove testGetFieldsHack()
|
||||||
public void testGetFieldsHack() {
|
public void testGetFieldsHack() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||||
String[] myExpectedFields = {
|
String[] myExpectedFields = {
|
||||||
"m_field1","m_field2","m_field3",
|
"m_field1","m_field2","m_field3",
|
||||||
"m_field4","m_field5","m_field6",
|
"m_field4","m_field5","m_field6",
|
||||||
};
|
};
|
||||||
ArrayList myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD);
|
List myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD);
|
||||||
assertEquals(myExpectedFields.length, myArrayIField.size());
|
assertEquals(myExpectedFields.length, myArrayIField.size());
|
||||||
for(int i=0; i<myArrayIField.size(); i++) {
|
for(int i=0; i<myArrayIField.size(); i++) {
|
||||||
IField myIField = (IField) myArrayIField.get(i);
|
IField myIField = (IField) myArrayIField.get(i);
|
||||||
|
@ -135,7 +135,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
public void testGetField() {
|
public void testGetField() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||||
String[] myExpectedFields = {
|
String[] myExpectedFields = {
|
||||||
"m_field1","m_field2","m_field3",
|
"m_field1","m_field2","m_field3",
|
||||||
|
@ -156,7 +156,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
public void testGetMethods() {
|
public void testGetMethods() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||||
IMethodDeclaration[] myArrayIMethod = myIStruct.getMethods();
|
IMethodDeclaration[] myArrayIMethod = myIStruct.getMethods();
|
||||||
String[] myExpectedMethods = {
|
String[] myExpectedMethods = {
|
||||||
|
@ -172,9 +172,9 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
// TODO Bug# 38985: remove testGetMethodsHack()
|
// TODO Bug# 38985: remove testGetMethodsHack()
|
||||||
public void testGetMethodsHack() {
|
public void testGetMethodsHack() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||||
ArrayList myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
List myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||||
myArrayIMethod.addAll( myIStruct.getChildrenOfType(ICElement.C_METHOD) );
|
myArrayIMethod.addAll( myIStruct.getChildrenOfType(ICElement.C_METHOD) );
|
||||||
String[] myExpectedMethods = {
|
String[] myExpectedMethods = {
|
||||||
"method1","method2","testStruct1","~testStruct1"
|
"method1","method2","testStruct1","~testStruct1"
|
||||||
|
@ -189,7 +189,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
public void testGetMethod() {
|
public void testGetMethod() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||||
String[] myExpectedMethods = {
|
String[] myExpectedMethods = {
|
||||||
"method1","method2","testStruct1","~testStruct1"
|
"method1","method2","testStruct1","~testStruct1"
|
||||||
|
@ -411,7 +411,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
||||||
String[] myExpectedInnerStructs = {
|
String[] myExpectedInnerStructs = {
|
||||||
"testStruct9Inner", "testStruct10Inner"
|
"testStruct9Inner", "testStruct10Inner"
|
||||||
};
|
};
|
||||||
ArrayList myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT);
|
List myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT);
|
||||||
assertEquals( myExpectedInnerStructs.length, myInnerStructs.size() );
|
assertEquals( myExpectedInnerStructs.length, myInnerStructs.size() );
|
||||||
for(int i=0; i<myExpectedInnerStructs.length; i++) {
|
for(int i=0; i<myExpectedInnerStructs.length; i++) {
|
||||||
IStructure myInnerStruct = (IStructure) myInnerStructs.get(i);
|
IStructure myInnerStruct = (IStructure) myInnerStructs.get(i);
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.eclipse.cdt.core.model.tests;
|
||||||
import org.eclipse.cdt.core.model.*;
|
import org.eclipse.cdt.core.model.*;
|
||||||
import junit.framework.*;
|
import junit.framework.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList getTemplateMethods(ITranslationUnit tu)
|
public List getTemplateMethods(ITranslationUnit tu)
|
||||||
{
|
{
|
||||||
IStructure myElem = null;
|
IStructure myElem = null;
|
||||||
try {
|
try {
|
||||||
|
@ -71,7 +72,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
||||||
public void testGetChildrenOfTypeTemplate() {
|
public void testGetChildrenOfTypeTemplate() {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
{
|
{
|
||||||
ArrayList arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
|
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
|
||||||
String[] myExpectedValues = {
|
String[] myExpectedValues = {
|
||||||
"Map"
|
"Map"
|
||||||
};
|
};
|
||||||
|
@ -83,7 +84,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ArrayList arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
|
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
|
||||||
String[] myExpectedValues = {
|
String[] myExpectedValues = {
|
||||||
"nonVector"
|
"nonVector"
|
||||||
};
|
};
|
||||||
|
@ -95,7 +96,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ArrayList arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION);
|
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION);
|
||||||
String[] myExpectedValues = {
|
String[] myExpectedValues = {
|
||||||
"ArrayOverlay"
|
"ArrayOverlay"
|
||||||
};
|
};
|
||||||
|
@ -107,7 +108,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ArrayList arrayElements = getTemplateMethods(tu);
|
List arrayElements = getTemplateMethods(tu);
|
||||||
String[] myExpectedValues = {
|
String[] myExpectedValues = {
|
||||||
"fum",
|
"fum",
|
||||||
"scrum"
|
"scrum"
|
||||||
|
@ -120,7 +121,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ArrayList arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION);
|
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION);
|
||||||
String[] myExpectedValues = {
|
String[] myExpectedValues = {
|
||||||
"nonVector<T>::first",
|
"nonVector<T>::first",
|
||||||
"IsGreaterThan",
"Foo::fum"
|
"IsGreaterThan",
"Foo::fum"
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.core.model.tests;
|
package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -27,7 +26,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -7,6 +7,7 @@ import junit.framework.Assert;
|
||||||
import org.eclipse.cdt.core.CCProjectNature;
|
import org.eclipse.cdt.core.CCProjectNature;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IArchive;
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
@ -14,8 +15,8 @@ import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
|
@ -123,38 +124,41 @@ public class CProjectHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a source container to a ICProject.
|
* Adds a folder container to a ICProject.
|
||||||
*/
|
*/
|
||||||
public static ICContainer addSourceContainer(ICProject cproject, String containerName) throws CoreException {
|
public static ICContainer addCContainer(ICProject cproject, String containerName) throws CoreException {
|
||||||
IProject project = cproject.getProject();
|
IProject project = cproject.getProject();
|
||||||
ICContainer container = null;
|
ICContainer container = null;
|
||||||
if (containerName == null || containerName.length() == 0) {
|
if (containerName == null || containerName.length() == 0) {
|
||||||
container = CModelManager.getDefault().create(project);
|
ICContainer[] conts = cproject.getSourceRoots();
|
||||||
|
if (conts.length > 0) {
|
||||||
|
container = conts[0];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
IFolder folder = project.getFolder(containerName);
|
IFolder folder = project.getFolder(containerName);
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.create(false, true, null);
|
folder.create(false, true, null);
|
||||||
}
|
}
|
||||||
container = CModelManager.getDefault().create(folder);
|
container = CoreModel.getDefault().create(folder);
|
||||||
}
|
}
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a source container to a ICProject and imports all files contained
|
* Adds a folder container to a ICProject and imports all files contained
|
||||||
* in the given Zip file.
|
* in the given Zip file.
|
||||||
*/
|
*/
|
||||||
public static ICContainer addSourceContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile)
|
public static ICContainer addCContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile)
|
||||||
throws InvocationTargetException, CoreException {
|
throws InvocationTargetException, CoreException {
|
||||||
ICContainer root = addSourceContainer(cproject, containerName);
|
ICContainer root = addCContainer(cproject, containerName);
|
||||||
importFilesFromZip(zipFile, root.getPath(), null);
|
importFilesFromZip(zipFile, root.getPath(), null);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a source folder from a ICProject.
|
* Removes a folder from a ICProject.
|
||||||
*/
|
*/
|
||||||
public static void removeSourceContainer(ICProject cproject, String containerName) throws CoreException {
|
public static void removeCContainer(ICProject cproject, String containerName) throws CoreException {
|
||||||
IFolder folder = cproject.getProject().getFolder(containerName);
|
IFolder folder = cproject.getProject().getFolder(containerName);
|
||||||
folder.delete(true, null);
|
folder.delete(true, null);
|
||||||
}
|
}
|
||||||
|
@ -205,52 +209,55 @@ public class CProjectHelper {
|
||||||
* Attempts to find an object with the given name in the workspace
|
* Attempts to find an object with the given name in the workspace
|
||||||
*/
|
*/
|
||||||
public static IBinary findObject(ICProject testProject, String name) {
|
public static IBinary findObject(ICProject testProject, String name) {
|
||||||
int x;
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
ICElement[] myElements;
|
for (int i = 0; i < sourceRoots.length; i++) {
|
||||||
myElements = testProject.getChildren();
|
ISourceRoot root = (ISourceRoot)sourceRoots[i];
|
||||||
if (myElements.length < 1)
|
ICElement[] myElements = root.getChildren();
|
||||||
return (null);
|
for (int x = 0; x < myElements.length; x++) {
|
||||||
for (x = 0; x < myElements.length; x++) {
|
if (myElements[x].getElementName().equals(name)) {
|
||||||
if (myElements[x].getElementName().equals(name))
|
if (myElements[x] instanceof IBinary) {
|
||||||
if (myElements[x] instanceof IBinary) {
|
return ((IBinary)myElements[x]);
|
||||||
return ((IBinary)myElements[x]);
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (null);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to find a TranslationUnit with the given name in the workspace
|
* Attempts to find a TranslationUnit with the given name in the workspace
|
||||||
*/
|
*/
|
||||||
public static ITranslationUnit findTranslationUnit(ICProject testProject, String name) {
|
public static ITranslationUnit findTranslationUnit(ICProject testProject, String name) {
|
||||||
int x;
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
ICElement[] myElements;
|
for (int i = 0; i < sourceRoots.length; i++) {
|
||||||
myElements = testProject.getChildren();
|
ISourceRoot root = (ISourceRoot)sourceRoots[i];
|
||||||
if (myElements.length < 1)
|
ICElement[] myElements = root.getChildren();
|
||||||
return (null);
|
for (int x = 0; x < myElements.length; x++) {
|
||||||
for (x = 0; x < myElements.length; x++) {
|
if (myElements[x].getElementName().equals(name)) {
|
||||||
if (myElements[x].getElementName().equals(name))
|
if (myElements[x] instanceof ITranslationUnit) {
|
||||||
if (myElements[x] instanceof ITranslationUnit) {
|
return ((ITranslationUnit)myElements[x]);
|
||||||
return ((ITranslationUnit)myElements[x]);
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (null);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to find an element with the given name in the workspace
|
* Attempts to find an element with the given name in the workspace
|
||||||
*/
|
*/
|
||||||
public static ICElement findElement(ICProject testProject, String name) {
|
public static ICElement findElement(ICProject testProject, String name) {
|
||||||
int x;
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
ICElement[] myElements;
|
for (int i = 0; i < sourceRoots.length; i++) {
|
||||||
myElements = testProject.getChildren();
|
ISourceRoot root = (ISourceRoot)sourceRoots[i];
|
||||||
if (myElements.length < 1)
|
ICElement[] myElements = root.getChildren();
|
||||||
return (null);
|
for (int x = 0; x < myElements.length; x++) {
|
||||||
for (x = 0; x < myElements.length; x++) {
|
if (myElements[x].getElementName().equals(name)) {
|
||||||
if (myElements[x].getElementName().equals(name))
|
return myElements[x];
|
||||||
return myElements[x];
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (null);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
|
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
|
||||||
|
|
|
@ -1,3 +1,30 @@
|
||||||
|
2004-03-18 Alain Magloire
|
||||||
|
|
||||||
|
Change in the hierarchy of the core Model:
|
||||||
|
ICModel
|
||||||
|
ICProject
|
||||||
|
ISourceRoot
|
||||||
|
IBinary
|
||||||
|
IArchive
|
||||||
|
ITranslatioUnit
|
||||||
|
ICContainer
|
||||||
|
The ISourceRoot been added to better separate
|
||||||
|
the files. By default the entire project is the
|
||||||
|
SourceRoot.
|
||||||
|
|
||||||
|
* model/org/eclipse/cdt/core/model/CoreModel.java
|
||||||
|
* model/org/eclipse/cdt/core/model/ICContainer.java
|
||||||
|
* model/org/eclipse/cdt/core/model/ICElement.java
|
||||||
|
* model/org/eclipse/cdt/core/model/ICProject.java
|
||||||
|
* model/org/eclipse/cdt/core/model/IIncludeEnty.java
|
||||||
|
* model/org/eclipse/cdt/core/model/IOutputEntry.java
|
||||||
|
* model/org/eclipse/cdt/core/model/IMacroEntry.java
|
||||||
|
* model/org/eclipse/cdt/core/model/IParent.java
|
||||||
|
* model/org/eclipse/cdt/core/model/ISourceEntry.java
|
||||||
|
* model/org/eclipse/cdt/core/model/ISourceRoot.java
|
||||||
|
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/*
|
||||||
|
|
||||||
2004-03-17 Alain Magloire
|
2004-03-17 Alain Magloire
|
||||||
|
|
||||||
Put the framework in to take advantage of being a
|
Put the framework in to take advantage of being a
|
||||||
|
|
|
@ -3,16 +3,17 @@ package org.eclipse.cdt.core.model;
|
||||||
/*
|
/*
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CDescriptorEvent;
|
import org.eclipse.cdt.core.CDescriptorEvent;
|
||||||
import org.eclipse.cdt.core.ICDescriptorListener;
|
import org.eclipse.cdt.core.ICDescriptorListener;
|
||||||
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
||||||
|
import org.eclipse.cdt.internal.core.model.CModel;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||||
import org.eclipse.cdt.internal.core.model.ContainerEntry;
|
import org.eclipse.cdt.internal.core.model.ContainerEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.IncludeEntry;
|
import org.eclipse.cdt.internal.core.model.IncludeEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.LibraryEntry;
|
import org.eclipse.cdt.internal.core.model.LibraryEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.MacroEntry;
|
import org.eclipse.cdt.internal.core.model.MacroEntry;
|
||||||
|
import org.eclipse.cdt.internal.core.model.OutputEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.PathEntryManager;
|
import org.eclipse.cdt.internal.core.model.PathEntryManager;
|
||||||
import org.eclipse.cdt.internal.core.model.ProjectEntry;
|
import org.eclipse.cdt.internal.core.model.ProjectEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.SourceEntry;
|
import org.eclipse.cdt.internal.core.model.SourceEntry;
|
||||||
|
@ -22,6 +23,7 @@ import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -29,11 +31,9 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public class CoreModel implements ICDescriptorListener {
|
public class CoreModel implements ICDescriptorListener {
|
||||||
|
|
||||||
private static CoreModel cmodel = null;
|
private static CoreModel cmodel = null;
|
||||||
private static CModelManager manager = null;
|
private static CModelManager manager = null;
|
||||||
private static PathEntryManager pathEntryManager = null;
|
private static PathEntryManager pathEntryManager = null;
|
||||||
|
|
||||||
public final static String CORE_MODEL_ID = CCorePlugin.PLUGIN_ID + ".coremodel"; //$NON-NLS-1$
|
public final static String CORE_MODEL_ID = CCorePlugin.PLUGIN_ID + ".coremodel"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,30 +47,47 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
* Creates an ICElement form and IFile. Returns null if not found.
|
* Creates an ICElement form and IFile. Returns null if not found.
|
||||||
*/
|
*/
|
||||||
public ICElement create(IFile file) {
|
public ICElement create(IFile file) {
|
||||||
return manager.create(file);
|
return manager.create(file, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ICElement form and IFolder. Returns null if not found.
|
* Creates an ICElement form and IFolder. Returns null if not found.
|
||||||
*/
|
*/
|
||||||
public ICContainer create(IFolder folder) {
|
public ICContainer create(IFolder folder) {
|
||||||
return manager.create(folder);
|
return manager.create(folder, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ICElement form and IProject. Returns null if not found.
|
* Creates an ICElement form and IProject. Returns null if not found.
|
||||||
*/
|
*/
|
||||||
public ICProject create(IProject project) {
|
public ICProject create(IProject project) {
|
||||||
return manager.create(project);
|
if (project == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CModel cModel = manager.getCModel();
|
||||||
|
return cModel.getCProject(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ICElement form and IResource. Returns null if not found.
|
* Creates an ICElement form and IResource. Returns null if not found.
|
||||||
*/
|
*/
|
||||||
public ICElement create(IResource resource) {
|
public ICElement create(IResource resource) {
|
||||||
return manager.create(resource);
|
return manager.create(resource, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the C model.
|
||||||
|
*
|
||||||
|
* @param root the given root
|
||||||
|
* @return the C model, or <code>null</code> if the root is null
|
||||||
|
*/
|
||||||
|
public static ICModel create(IWorkspaceRoot root) {
|
||||||
|
if (root == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return manager.getCModel();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the default ICModel.
|
* Returns the default ICModel.
|
||||||
*/
|
*/
|
||||||
|
@ -295,6 +312,35 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
return new LibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported);
|
return new LibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns a new entry of kind <code>CDT_OUTPUT</code> for
|
||||||
|
* the project's output folder
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
* the project-relative path of a binary folder
|
||||||
|
* @return a new source entry with not exclusion patterns
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static IOutputEntry newOutputEntry(IPath path) {
|
||||||
|
return newOutputEntry(path, OutputEntry.NO_EXCLUSION_PATTERNS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns a new entry of kind <code>CDT_OUPUT</code> for
|
||||||
|
* the project
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
* the absolute project-relative path of a binary folder
|
||||||
|
* @param exclusionPatterns
|
||||||
|
* the possibly empty list of exclusion patterns represented as
|
||||||
|
* relative paths
|
||||||
|
* @return a new source entry with the given exclusion patterns
|
||||||
|
*/
|
||||||
|
public static IOutputEntry newOutputEntry(IPath path, IPath[] exclusionPatterns) {
|
||||||
|
return new OutputEntry(path, exclusionPatterns, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
||||||
* the project's source folder identified by the given absolute
|
* the project's source folder identified by the given absolute
|
||||||
|
@ -322,60 +368,6 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
return newSourceEntry(path, SourceEntry.NO_EXCLUSION_PATTERNS);
|
return newSourceEntry(path, SourceEntry.NO_EXCLUSION_PATTERNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
|
||||||
* the project's source folder identified by the given absolute
|
|
||||||
* workspace-relative path but excluding all source files with paths
|
|
||||||
* matching any of the given patterns. This specifies that all package
|
|
||||||
* fragments within the root will have children of type <code>ICompilationUnit</code>.
|
|
||||||
* <p>
|
|
||||||
* The source folder is referred to using an absolute path relative to the
|
|
||||||
* workspace root, e.g. <code>/Project/src</code>. A project's source
|
|
||||||
* folders are located with that project. That is, a source entry
|
|
||||||
* specifying the path <code>/P1/src</code> is only usable for project
|
|
||||||
* <code>P1</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
* the project-relative path of a source folder
|
|
||||||
* @param exclusionPatterns
|
|
||||||
* the possibly empty list of exclusion patterns represented as
|
|
||||||
* relative paths
|
|
||||||
* @return a new source entry with the given exclusion patterns
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static ISourceEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
|
|
||||||
return newSourceEntry(path, null, exclusionPatterns);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
|
||||||
* the project's source folder identified by the given absolute
|
|
||||||
* workspace-relative path but excluding all source files with paths
|
|
||||||
* matching any of the given patterns. This specifies that all package
|
|
||||||
* fragments within the root will have children of type <code>ICompilationUnit</code>.
|
|
||||||
* <p>
|
|
||||||
* The source folder is referred to using an absolute path relative to the
|
|
||||||
* workspace root, e.g. <code>/Project/src</code>. A project's source
|
|
||||||
* folders are located with that project. That is, a source entry
|
|
||||||
* specifying the path <code>/P1/src</code> is only usable for project
|
|
||||||
* <code>P1</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
* the project-relative path of a source folder
|
|
||||||
* @param exclusionPatterns
|
|
||||||
* the possibly empty list of exclusion patterns represented as
|
|
||||||
* relative paths
|
|
||||||
* @param specificOutputLocation
|
|
||||||
* the specific output location for this source entry (<code>null</code>
|
|
||||||
* if using project default ouput location)
|
|
||||||
* @return a new source entry with the given exclusion patterns
|
|
||||||
*/
|
|
||||||
public static ISourceEntry newSourceEntry(IPath path, IPath outputLocation, IPath[] exclusionPatterns) {
|
|
||||||
return newSourceEntry(path, outputLocation, true, exclusionPatterns);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
||||||
* the project's source folder identified by the given absolute
|
* the project's source folder identified by the given absolute
|
||||||
|
@ -395,13 +387,10 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
* @param exclusionPatterns
|
* @param exclusionPatterns
|
||||||
* the possibly empty list of exclusion patterns represented as
|
* the possibly empty list of exclusion patterns represented as
|
||||||
* relative paths
|
* relative paths
|
||||||
* @param specificOutputLocation
|
|
||||||
* the specific output location for this source entry (<code>null</code>
|
|
||||||
* if using project default ouput location)
|
|
||||||
* @return a new source entry with the given exclusion patterns
|
* @return a new source entry with the given exclusion patterns
|
||||||
*/
|
*/
|
||||||
public static ISourceEntry newSourceEntry(IPath path, IPath outputLocation, boolean isRecursive, IPath[] exclusionPatterns) {
|
public static ISourceEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
|
||||||
return new SourceEntry(path, outputLocation, isRecursive, exclusionPatterns);
|
return new SourceEntry(path, exclusionPatterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -429,8 +418,7 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
/**
|
* * Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
|
||||||
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
|
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the affected project-relative resource path
|
* the affected project-relative resource path
|
||||||
|
@ -442,7 +430,7 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
* @return IIncludeEntry
|
* @return IIncludeEntry
|
||||||
*/
|
*/
|
||||||
public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude) {
|
public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude) {
|
||||||
return newIncludeEntry(resourcePath, includePath, isSystemInclude, true, IncludeEntry.NO_EXCLUSION_PATTERNS);
|
return newIncludeEntry(resourcePath, includePath, isSystemInclude, IncludeEntry.NO_EXCLUSION_PATTERNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -462,9 +450,24 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
* exclusion patterns in the resource if a container
|
* exclusion patterns in the resource if a container
|
||||||
* @return IIincludeEntry
|
* @return IIincludeEntry
|
||||||
*/
|
*/
|
||||||
public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude, boolean isRecursive,
|
public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude,
|
||||||
IPath[] exclusionPatterns) {
|
IPath[] exclusionPatterns) {
|
||||||
return new IncludeEntry(resourcePath, includePath, isSystemInclude, isRecursive, exclusionPatterns);
|
return new IncludeEntry(resourcePath, includePath, isSystemInclude, exclusionPatterns);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns an entry kind <code>CDT_MACRO</code>
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
* the affected workspace-relative resource path
|
||||||
|
* @param macroName
|
||||||
|
* the name of the macro
|
||||||
|
* @param macroValue
|
||||||
|
* the value of the macro
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static IMacroEntry newMacroEntry(String macroName, String macroValue) {
|
||||||
|
return newMacroEntry(null, macroName, macroValue, MacroEntry.NO_EXCLUSION_PATTERNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -479,7 +482,7 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static IMacroEntry newMacroEntry(IPath path, String macroName, String macroValue) {
|
public static IMacroEntry newMacroEntry(IPath path, String macroName, String macroValue) {
|
||||||
return newMacroEntry(path, macroName, macroValue, true, MacroEntry.NO_EXCLUSION_PATTERNS, true);
|
return newMacroEntry(path, macroName, macroValue, MacroEntry.NO_EXCLUSION_PATTERNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -491,18 +494,12 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
* the name of the macro
|
* the name of the macro
|
||||||
* @param macroValue
|
* @param macroValue
|
||||||
* the value of the macro
|
* the value of the macro
|
||||||
* @param isRecursive
|
|
||||||
* if the resource is a folder the include applied to all
|
|
||||||
* recursively
|
|
||||||
* @param exclusionPatterns
|
* @param exclusionPatterns
|
||||||
* exclusion patterns in the resource if a container
|
* exclusion patterns in the resource if a container
|
||||||
* @param isExported
|
|
||||||
* whether this cpath is exported.
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static IMacroEntry newMacroEntry(IPath path, String macroName, String macroValue, boolean isRecursive,
|
public static IMacroEntry newMacroEntry(IPath path, String macroName, String macroValue, IPath[] exclusionPatterns) {
|
||||||
IPath[] exclusionPatterns, boolean isExported) {
|
return new MacroEntry(path, macroName, macroValue, exclusionPatterns);
|
||||||
return new MacroEntry(path, macroName, macroValue, isRecursive, exclusionPatterns, isExported);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -731,5 +728,4 @@ public class CoreModel implements ICDescriptorListener {
|
||||||
public IndexManager getIndexManager() {
|
public IndexManager getIndexManager() {
|
||||||
return manager.getIndexManager();
|
return manager.getIndexManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
||||||
|
@ -10,6 +11,7 @@ package org.eclipse.cdt.core.model;
|
||||||
* A C Folder Resource.
|
* A C Folder Resource.
|
||||||
*/
|
*/
|
||||||
public interface ICContainer extends ICElement, IParent, IOpenable {
|
public interface ICContainer extends ICElement, IParent, IOpenable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of non-C resources directly contained in this project.
|
* Returns an array of non-C resources directly contained in this project.
|
||||||
* It does not transitively answer non-C resources contained in folders;
|
* It does not transitively answer non-C resources contained in folders;
|
||||||
|
@ -24,4 +26,81 @@ public interface ICContainer extends ICElement, IParent, IOpenable {
|
||||||
*/
|
*/
|
||||||
Object[] getNonCResources() throws CModelException;
|
Object[] getNonCResources() throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all of the translation units in this ccontainer.
|
||||||
|
*
|
||||||
|
* @exception CModelException if this element does not exist or if an
|
||||||
|
* exception occurs while accessing its corresponding resource.
|
||||||
|
* @return all of the translation units in this ccontainer
|
||||||
|
*/
|
||||||
|
ITranslationUnit[] getTranslationUnits() throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tranlation unit with the specified name
|
||||||
|
* in this container (for example, <code>"foobar.c"</code>).
|
||||||
|
* The name has to be a valid translation unit name.
|
||||||
|
* This is a handle-only operation. The celement
|
||||||
|
* may or may not exist.
|
||||||
|
*
|
||||||
|
* @param name the given name
|
||||||
|
* @return the translation unit with the specified name in this container
|
||||||
|
*/
|
||||||
|
ITranslationUnit getTranslationUnit(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the all the binaries of this container.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
IBinary[] getBinaries() throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the binary for this name, it must be a
|
||||||
|
* valid binary
|
||||||
|
* This is a handle-only operation. The celement
|
||||||
|
* may or may not exist.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
IBinary getBinary(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the archive of this container
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
IArchive[] getArchives() throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a handle-only operation. The celement
|
||||||
|
* may or may not exist.
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
IArchive getArchive(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return al the child containers of this container.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
ICContainer[] getCContainers() throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the container with the given name.
|
||||||
|
* An empty string indicates the default package.
|
||||||
|
* This is a handle-only operation. The celement
|
||||||
|
* may or may not exist.
|
||||||
|
*
|
||||||
|
* @param name the given container
|
||||||
|
* @return the container with the given name
|
||||||
|
*/
|
||||||
|
ICContainer getCContainer(String name);
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ package org.eclipse.cdt.core.model;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
* @see CCore#create(org.eclipse.core.resources.IProject)
|
* @see CCore#create(org.eclipse.core.resources.IProject)
|
||||||
* @see IBuildEntry
|
* @see IBuildEntry
|
||||||
*/
|
*/
|
||||||
public interface ICProject extends ICContainer {
|
public interface ICProject extends IParent, IOpenable, ICElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the <code>ICElement</code> corresponding to the given
|
* Returns the <code>ICElement</code> corresponding to the given
|
||||||
|
@ -42,6 +43,36 @@ public interface ICProject extends ICContainer {
|
||||||
*/
|
*/
|
||||||
IBinaryContainer getBinaryContainer();
|
IBinaryContainer getBinaryContainer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the source root folders of the project.
|
||||||
|
* @return ISourceRoot - root folders
|
||||||
|
* @exception CModelException
|
||||||
|
*/
|
||||||
|
ISourceRoot[] getSourceRoots() throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param entry
|
||||||
|
* @return ISourceRoot
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
ISourceRoot getSourceRoot(ISourceEntry entry) throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the output entries.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
public IOutputEntry[] getOutputEntries() throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isOnOutputEntry(IResource resource);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the library references for this project.
|
* Return the library references for this project.
|
||||||
*
|
*
|
||||||
|
@ -157,4 +188,18 @@ public interface ICProject extends ICContainer {
|
||||||
*/
|
*/
|
||||||
void setRawPathEntries(IPathEntry[] entries, IProgressMonitor monitor) throws CModelException;
|
void setRawPathEntries(IPathEntry[] entries, IProgressMonitor monitor) throws CModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of non-C resources directly contained in this project.
|
||||||
|
* It does not transitively answer non-C resources contained in folders;
|
||||||
|
* these would have to be explicitly iterated over.
|
||||||
|
* <p>
|
||||||
|
* Non-C resources includes files, folders, projects not accounted for.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @return an array of non-C resources directly contained in this project
|
||||||
|
* @exception JavaModelException if this element does not exist or if an
|
||||||
|
* exception occurs while accessing its corresponding resource
|
||||||
|
*/
|
||||||
|
Object[] getNonCResources() throws CModelException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,6 @@ public interface IIncludeEntry extends IPathEntry {
|
||||||
*/
|
*/
|
||||||
boolean isSystemInclude();
|
boolean isSystemInclude();
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether or not the include affects the resource(if it is a folder)
|
|
||||||
* recursively
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
boolean isRecursive();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If isRecursive() is true, specify an exclude file patterns.
|
* If isRecursive() is true, specify an exclude file patterns.
|
||||||
* @return IPath
|
* @return IPath
|
||||||
|
|
|
@ -28,12 +28,6 @@ public interface IMacroEntry extends IPathEntry {
|
||||||
*/
|
*/
|
||||||
String getMacroValue();
|
String getMacroValue();
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether or not the macro is applied recursively.
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
boolean isRecursive();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of inclusion paths affecting the
|
* Returns an array of inclusion paths affecting the
|
||||||
* resource when looking for files recursively.
|
* resource when looking for files recursively.
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IOuputEntry
|
||||||
|
*/
|
||||||
|
public interface IOutputEntry extends IPathEntry {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of inclusion paths affecting the
|
||||||
|
* source folder when looking for files recursively.
|
||||||
|
* @return IPath
|
||||||
|
*/
|
||||||
|
IPath[] getExclusionPatterns();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a char based representation of the exclusions patterns full path.
|
||||||
|
*/
|
||||||
|
public char[][] fullExclusionPatternChars();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
@ -24,7 +24,7 @@ public interface IParent {
|
||||||
/**
|
/**
|
||||||
* returns the children of a certain type
|
* returns the children of a certain type
|
||||||
*/
|
*/
|
||||||
public ArrayList getChildrenOfType(int type);
|
public List getChildrenOfType(int type);
|
||||||
/**
|
/**
|
||||||
* Returns whether this element has one or more immediate children.
|
* Returns whether this element has one or more immediate children.
|
||||||
* This is a convenience method, and may be more efficient than
|
* This is a convenience method, and may be more efficient than
|
||||||
|
|
|
@ -16,24 +16,16 @@ import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public interface ISourceEntry extends IPathEntry {
|
public interface ISourceEntry extends IPathEntry {
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether or not to look recursively in the folder.
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
boolean isRecursive();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of inclusion paths affecting the
|
* Returns an array of inclusion paths affecting the
|
||||||
* source folder when looking for files recursively.
|
* source folder when looking for files recursively.
|
||||||
* @return IPath
|
* @return IPath[]
|
||||||
*/
|
*/
|
||||||
IPath[] getExclusionPatterns();
|
IPath[] getExclusionPatterns();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binary output location for this source folder.
|
* Returns a char based representation of the exclusions patterns full path.
|
||||||
* @return IPath, <code>null</code> means to use the
|
|
||||||
* default output location of the project.
|
|
||||||
*/
|
*/
|
||||||
IPath getOutputLocation();
|
public char[][] fullExclusionPatternChars();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ISourceRoot
|
||||||
|
*/
|
||||||
|
public interface ISourceRoot extends ICContainer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isOnSourceEntry(IResource resource);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param element
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isOnSourceEntry(ICElement element);
|
||||||
|
|
||||||
|
}
|
|
@ -18,12 +18,12 @@ public abstract class APathEntry extends PathEntry {
|
||||||
|
|
||||||
public static IPath[] NO_EXCLUSION_PATTERNS = {};
|
public static IPath[] NO_EXCLUSION_PATTERNS = {};
|
||||||
IPath[] exclusionPatterns;
|
IPath[] exclusionPatterns;
|
||||||
boolean isRecursive;
|
private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
|
||||||
|
char[][]fullCharExclusionPatterns = UNINIT_PATTERNS;
|
||||||
|
|
||||||
public APathEntry (int kind, IPath path, boolean isRecursive, IPath[] exclusionPatterns, boolean isExported) {
|
public APathEntry (int kind, IPath path, IPath[] exclusionPatterns, boolean isExported) {
|
||||||
super(kind, path, isExported);
|
super(kind, path, isExported);
|
||||||
this.exclusionPatterns = exclusionPatterns;
|
this.exclusionPatterns = exclusionPatterns;
|
||||||
this.isRecursive = isRecursive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,12 +34,20 @@ public abstract class APathEntry extends PathEntry {
|
||||||
return exclusionPatterns;
|
return exclusionPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Whether or not it is recursive
|
* Returns a char based representation of the exclusions patterns full path.
|
||||||
* @return boolean
|
|
||||||
*/
|
*/
|
||||||
public boolean isRecursive() {
|
public char[][] fullExclusionPatternChars() {
|
||||||
return isRecursive;
|
if (this.fullCharExclusionPatterns == UNINIT_PATTERNS) {
|
||||||
|
int length = this.exclusionPatterns.length;
|
||||||
|
this.fullCharExclusionPatterns = new char[length][];
|
||||||
|
IPath prefixPath = this.path.removeTrailingSeparator();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
this.fullCharExclusionPatterns[i] =
|
||||||
|
prefixPath.append(this.exclusionPatterns[i]).toString().toCharArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.fullCharExclusionPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
|
@ -48,9 +56,6 @@ public abstract class APathEntry extends PathEntry {
|
||||||
if (!super.equals(otherEntry)) {
|
if (!super.equals(otherEntry)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isRecursive != otherEntry.isRecursive()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
IPath[] otherExcludes = otherEntry.getExclusionPatterns();
|
IPath[] otherExcludes = otherEntry.getExclusionPatterns();
|
||||||
if (exclusionPatterns != otherExcludes) {
|
if (exclusionPatterns != otherExcludes) {
|
||||||
int excludeLength = (exclusionPatterns == null) ? 0 : exclusionPatterns.length;
|
int excludeLength = (exclusionPatterns == null) ? 0 : exclusionPatterns.length;
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
|
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
|
||||||
|
@ -39,16 +38,16 @@ public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
private long fLastModification;
|
private long fLastModification;
|
||||||
|
|
||||||
IBinaryFile binaryFile;
|
IBinaryObject binaryObject;
|
||||||
|
|
||||||
public Binary(ICElement parent, IFile file, IBinaryFile bin) {
|
public Binary(ICElement parent, IFile file, IBinaryObject bin) {
|
||||||
super(parent, file, ICElement.C_BINARY);
|
super(parent, file, ICElement.C_BINARY);
|
||||||
binaryFile = bin;
|
binaryObject = bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binary(ICElement parent, IPath path, IBinaryFile bin) {
|
public Binary(ICElement parent, IPath path, IBinaryObject bin) {
|
||||||
super (parent, path, ICElement.C_BINARY);
|
super (parent, path, ICElement.C_BINARY);
|
||||||
binaryFile = bin;
|
binaryObject = bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSharedLib() {
|
public boolean isSharedLib() {
|
||||||
|
@ -70,7 +69,10 @@ public class Binary extends Openable implements IBinary {
|
||||||
public boolean hasDebug() {
|
public boolean hasDebug() {
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
if (hasDebug == null || hasChanged()) {
|
if (hasDebug == null || hasChanged()) {
|
||||||
hasDebug = new Boolean(((IBinaryObject)getBinaryFile()).hasDebug()).toString();
|
IBinaryObject obj = getBinaryObject();
|
||||||
|
if (obj != null) {
|
||||||
|
hasDebug = new Boolean(obj.hasDebug()).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Boolean.valueOf(hasDebug).booleanValue();
|
return Boolean.valueOf(hasDebug).booleanValue();
|
||||||
|
@ -79,7 +81,8 @@ public class Binary extends Openable implements IBinary {
|
||||||
public String getCPU() {
|
public String getCPU() {
|
||||||
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
||||||
if (cpu == null || hasChanged()) {
|
if (cpu == null || hasChanged()) {
|
||||||
cpu = ((IBinaryObject)getBinaryFile()).getCPU();
|
IBinaryObject obj = getBinaryObject();
|
||||||
|
cpu = obj.getCPU();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (cpu == null ? "" : cpu); //$NON-NLS-1$
|
return (cpu == null ? "" : cpu); //$NON-NLS-1$
|
||||||
|
@ -88,7 +91,10 @@ public class Binary extends Openable implements IBinary {
|
||||||
public String[] getNeededSharedLibs() {
|
public String[] getNeededSharedLibs() {
|
||||||
if (isExecutable() || isSharedLib()) {
|
if (isExecutable() || isSharedLib()) {
|
||||||
if (needed == null || hasChanged()) {
|
if (needed == null || hasChanged()) {
|
||||||
needed = ((IBinaryExecutable)getBinaryFile()).getNeededSharedLibs();
|
IBinaryObject obj = getBinaryObject();
|
||||||
|
if (obj instanceof IBinaryExecutable) {
|
||||||
|
needed = ((IBinaryExecutable)obj).getNeededSharedLibs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (needed == null ? new String[0] : needed);
|
return (needed == null ? new String[0] : needed);
|
||||||
|
@ -97,7 +103,10 @@ public class Binary extends Openable implements IBinary {
|
||||||
public long getText() {
|
public long getText() {
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
if (longText == -1 || hasChanged()) {
|
if (longText == -1 || hasChanged()) {
|
||||||
longText = ((IBinaryObject)getBinaryFile()).getText();
|
IBinaryObject obj = getBinaryObject();
|
||||||
|
if (obj != null) {
|
||||||
|
longText = obj.getText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return longText;
|
return longText;
|
||||||
|
@ -106,7 +115,10 @@ public class Binary extends Openable implements IBinary {
|
||||||
public long getData() {
|
public long getData() {
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
if (longData == -1 || hasChanged()) {
|
if (longData == -1 || hasChanged()) {
|
||||||
longData = ((IBinaryObject)getBinaryFile()).getData();
|
IBinaryObject obj = getBinaryObject();
|
||||||
|
if (obj != null) {
|
||||||
|
longData = obj.getData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return longData;
|
return longData;
|
||||||
|
@ -115,7 +127,10 @@ public class Binary extends Openable implements IBinary {
|
||||||
public long getBSS() {
|
public long getBSS() {
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
if (longBSS == -1 || hasChanged()) {
|
if (longBSS == -1 || hasChanged()) {
|
||||||
longBSS = ((IBinaryObject)getBinaryFile()).getBSS();
|
IBinaryObject obj = getBinaryObject();
|
||||||
|
if (obj != null) {
|
||||||
|
longBSS = obj.getBSS();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return longBSS;
|
return longBSS;
|
||||||
|
@ -124,7 +139,10 @@ public class Binary extends Openable implements IBinary {
|
||||||
public String getSoname() {
|
public String getSoname() {
|
||||||
if (isSharedLib()) {
|
if (isSharedLib()) {
|
||||||
if (soname == null || hasChanged()) {
|
if (soname == null || hasChanged()) {
|
||||||
soname = ((IBinaryShared)getBinaryFile()).getSoName();
|
IBinaryObject obj = getBinaryObject();
|
||||||
|
if (obj instanceof IBinaryShared) {
|
||||||
|
soname = ((IBinaryShared)obj).getSoName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (soname == null ? "" : soname); //$NON-NLS-1$
|
return (soname == null ? "" : soname); //$NON-NLS-1$
|
||||||
|
@ -133,19 +151,23 @@ public class Binary extends Openable implements IBinary {
|
||||||
public boolean isLittleEndian() {
|
public boolean isLittleEndian() {
|
||||||
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
||||||
if (endian == null || hasChanged()) {
|
if (endian == null || hasChanged()) {
|
||||||
endian = new Boolean(((IBinaryObject)getBinaryFile()).isLittleEndian()).toString();
|
IBinaryObject obj = getBinaryObject();
|
||||||
|
if (obj != null) {
|
||||||
|
endian = new Boolean(obj.isLittleEndian()).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Boolean.valueOf(endian).booleanValue();
|
return Boolean.valueOf(endian).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IBinaryFile getBinaryFile() {
|
protected IBinaryObject getBinaryObject() {
|
||||||
return binaryFile;
|
return binaryObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getType() {
|
protected int getType() {
|
||||||
if (getBinaryFile() != null && (fBinType == 0 || hasChanged())) {
|
IBinaryObject obj = getBinaryObject();
|
||||||
fBinType = getBinaryFile().getType();
|
if (obj != null && (fBinType == 0 || hasChanged())) {
|
||||||
|
fBinType = obj.getType();
|
||||||
}
|
}
|
||||||
return fBinType;
|
return fBinType;
|
||||||
}
|
}
|
||||||
|
@ -197,24 +219,27 @@ public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
|
|
||||||
boolean computeChildren(OpenableInfo info, IResource res) {
|
boolean computeChildren(OpenableInfo info, IResource res) {
|
||||||
|
boolean ok = false;
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
Map hash = new HashMap();
|
Map hash = new HashMap();
|
||||||
ISymbol[] symbols = ((IBinaryObject)getBinaryFile()).getSymbols();
|
IBinaryObject obj = getBinaryObject();
|
||||||
for (int i = 0; i < symbols.length; i++) {
|
if (obj != null) {
|
||||||
switch (symbols[i].getType()) {
|
ISymbol[] symbols = obj.getSymbols();
|
||||||
case ISymbol.FUNCTION :
|
for (int i = 0; i < symbols.length; i++) {
|
||||||
addFunction(info, symbols[i], hash);
|
switch (symbols[i].getType()) {
|
||||||
break;
|
case ISymbol.FUNCTION :
|
||||||
|
addFunction(info, symbols[i], hash);
|
||||||
|
break;
|
||||||
|
|
||||||
case ISymbol.VARIABLE :
|
case ISymbol.VARIABLE :
|
||||||
addVariable(info, symbols[i], hash);
|
addVariable(info, symbols[i], hash);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ok = true;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFunction(OpenableInfo info, ISymbol symbol, Map hash) {
|
private void addFunction(OpenableInfo info, ISymbol symbol, Map hash) {
|
||||||
|
@ -288,7 +313,7 @@ public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
// set the buffer source
|
// set the buffer source
|
||||||
if (buffer.getCharacters() == null){
|
if (buffer.getCharacters() == null){
|
||||||
IBinaryFile bin = getBinaryFile();
|
IBinaryObject bin = getBinaryObject();
|
||||||
if (bin != null) {
|
if (bin != null) {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
||||||
if (path != null && path.isAbsolute()) {
|
if (path != null && path.isAbsolute()) {
|
||||||
IResource res = mgr.getCModel().getWorkspace().getRoot().getFileForLocation(path);
|
IResource res = mgr.getCModel().getWorkspace().getRoot().getFileForLocation(path);
|
||||||
if (res != null && res.exists() && res.getType() == IResource.FILE) {
|
if (res != null && res.exists() && res.getType() == IResource.FILE) {
|
||||||
ICElement e = CModelManager.getDefault().create(res);
|
ICElement e = CModelManager.getDefault().create(res, null);
|
||||||
if (e instanceof ITranslationUnit) {
|
if (e instanceof ITranslationUnit) {
|
||||||
tu = (ITranslationUnit)e;
|
tu = (ITranslationUnit)e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,20 +6,27 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.IOutputEntry;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceVisitor;
|
import org.eclipse.core.resources.IResourceVisitor;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class BinaryRunner {
|
public class BinaryRunner {
|
||||||
IProject project;
|
IProject project;
|
||||||
Thread runner;
|
Thread runner;
|
||||||
|
ArchiveContainer vlib;
|
||||||
|
BinaryContainer vbin;
|
||||||
|
|
||||||
public BinaryRunner(IProject prj) {
|
public BinaryRunner(IProject prj) {
|
||||||
project = prj;
|
project = prj;
|
||||||
|
@ -32,23 +39,48 @@ public class BinaryRunner {
|
||||||
if (cproject == null || Thread.currentThread().isInterrupted()) {
|
if (cproject == null || Thread.currentThread().isInterrupted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArchiveContainer clib;
|
IOutputEntry[] outs = null;
|
||||||
BinaryContainer cbin;
|
|
||||||
cbin = (BinaryContainer)cproject.getBinaryContainer();
|
|
||||||
clib = (ArchiveContainer)cproject.getArchiveContainer();
|
|
||||||
clib.removeChildren();
|
|
||||||
cbin.removeChildren();
|
|
||||||
try {
|
try {
|
||||||
cproject.getProject().accept(new Visitor(BinaryRunner.this));
|
outs = cproject.getOutputEntries();
|
||||||
} catch (CoreException e) {
|
} catch (CModelException e) {
|
||||||
//e.printStackTrace();
|
outs = new IOutputEntry[0];
|
||||||
} catch (Exception e) {
|
}
|
||||||
// What is wrong ?
|
|
||||||
e.printStackTrace();
|
vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||||
|
vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||||
|
vlib.removeChildren();
|
||||||
|
vbin.removeChildren();
|
||||||
|
IPath projectPath = project.getFullPath();
|
||||||
|
for (int i = 0; i < outs.length; i++) {
|
||||||
|
IPath path = outs[i].getPath();
|
||||||
|
if (projectPath.equals(path)) {
|
||||||
|
try {
|
||||||
|
project.accept(new Visitor(BinaryRunner.this));
|
||||||
|
} catch (CoreException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// What is wrong ?
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
break; // We are done.
|
||||||
|
} else if (projectPath.isPrefixOf(path)) {
|
||||||
|
path = path.removeFirstSegments(projectPath.segmentCount());
|
||||||
|
IResource res =project.findMember(path);
|
||||||
|
if (res != null) {
|
||||||
|
try {
|
||||||
|
res.accept(new Visitor(BinaryRunner.this));
|
||||||
|
} catch (CoreException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// What is wrong ?
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!Thread.currentThread().isInterrupted()) {
|
if (!Thread.currentThread().isInterrupted()) {
|
||||||
fireEvents(cproject, cbin);
|
fireEvents(cproject, vbin);
|
||||||
fireEvents(cproject, clib);
|
fireEvents(cproject, vlib);
|
||||||
}
|
}
|
||||||
// Tell the listeners we are done.
|
// Tell the listeners we are done.
|
||||||
synchronized(BinaryRunner.this) {
|
synchronized(BinaryRunner.this) {
|
||||||
|
@ -104,10 +136,20 @@ public class BinaryRunner {
|
||||||
if (!factory.isTranslationUnit(file)) {
|
if (!factory.isTranslationUnit(file)) {
|
||||||
IBinaryFile bin = factory.createBinaryFile(file);
|
IBinaryFile bin = factory.createBinaryFile(file);
|
||||||
if (bin != null) {
|
if (bin != null) {
|
||||||
IResource res = file.getParent();
|
ICElement parent = factory.create(file.getParent(), null);
|
||||||
ICElement parent = factory.create(res);
|
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||||
// By creating the element, it will be added to the correct (bin/archive)container.
|
if (parent == null) {
|
||||||
factory.create(parent, file, bin);
|
parent = vlib;
|
||||||
|
}
|
||||||
|
Archive ar = new Archive(parent, file, (IBinaryArchive)bin);
|
||||||
|
vlib.addChild(ar);
|
||||||
|
} else if (bin.getType() == IBinaryFile.EXECUTABLE || bin.getType() == IBinaryFile.SHARED) {
|
||||||
|
if (parent == null) {
|
||||||
|
parent = vbin;
|
||||||
|
}
|
||||||
|
Binary binary = new Binary(parent, file, (IBinaryObject)bin);
|
||||||
|
vbin.addChild(binary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,40 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.IArchive;
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class CContainer extends Openable implements ICContainer {
|
public class CContainer extends Openable implements ICContainer {
|
||||||
|
CModelManager factory = CModelManager.getDefault();
|
||||||
|
|
||||||
public CContainer (ICElement parent, IResource res) {
|
public CContainer(ICElement parent, IResource res) {
|
||||||
this (parent, res, ICElement.C_CCONTAINER);
|
this(parent, res, ICElement.C_CCONTAINER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CContainer (ICElement parent, IResource res, int type) {
|
public CContainer(ICElement parent, IResource res, int type) {
|
||||||
super (parent, res, type);
|
super(parent, res, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,35 +43,99 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
* @see ICContainer#getBinaries()
|
* @see ICContainer#getBinaries()
|
||||||
*/
|
*/
|
||||||
public IBinary[] getBinaries() throws CModelException {
|
public IBinary[] getBinaries() throws CModelException {
|
||||||
ArrayList list = getChildrenOfType(C_BINARY);
|
List list = getChildrenOfType(C_BINARY);
|
||||||
IBinary[] array = new IBinary[list.size()];
|
IBinary[] array = new IBinary[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ICContainer#getBinary(String)
|
||||||
|
*/
|
||||||
|
public IBinary getBinary(String name) {
|
||||||
|
IFile file = getContainer().getFile(new Path(name));
|
||||||
|
return getBinary(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinary getBinary(IFile file) {
|
||||||
|
IBinaryFile bin = factory.createBinaryFile(file);
|
||||||
|
if (bin instanceof IBinaryObject) {
|
||||||
|
return new Binary(this, file, (IBinaryObject) bin);
|
||||||
|
}
|
||||||
|
return new Binary(this, file, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a the collection of archive files in this ccontainer
|
* Returns a the collection of archive files in this ccontainer
|
||||||
*
|
*
|
||||||
* @see ICContainer#getArchives()
|
* @see ICContainer#getArchives()
|
||||||
*/
|
*/
|
||||||
public IArchive[] getArchives() throws CModelException {
|
public IArchive[] getArchives() throws CModelException {
|
||||||
ArrayList list = getChildrenOfType(C_ARCHIVE);
|
List list = getChildrenOfType(C_ARCHIVE);
|
||||||
IArchive[] array = new IArchive[list.size()];
|
IArchive[] array = new IArchive[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ICContainer#getArchive(String)
|
||||||
|
*/
|
||||||
|
public IArchive getArchive(String name) {
|
||||||
|
IFile file = getContainer().getFile(new Path(name));
|
||||||
|
return getArchive(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IArchive getArchive(IFile file) {
|
||||||
|
IBinaryFile ar = factory.createBinaryFile(file);
|
||||||
|
if (ar != null && ar.getType() == IBinaryFile.ARCHIVE) {
|
||||||
|
return new Archive(this, file, (IBinaryArchive) ar);
|
||||||
|
}
|
||||||
|
return new Archive(this, file, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ICContainer#getTranslationUnits()
|
* @see ICContainer#getTranslationUnits()
|
||||||
*/
|
*/
|
||||||
public ITranslationUnit[] getTranslationUnit() throws CModelException {
|
public ITranslationUnit[] getTranslationUnits() throws CModelException {
|
||||||
ArrayList list = getChildrenOfType(C_UNIT);
|
List list = getChildrenOfType(C_UNIT);
|
||||||
ITranslationUnit[] array = new ITranslationUnit[list.size()];
|
ITranslationUnit[] array = new ITranslationUnit[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CElementInfo createElementInfo () {
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.model.ICContainer#getTranslationUnit(java.lang.String)
|
||||||
|
*/
|
||||||
|
public ITranslationUnit getTranslationUnit(String name) {
|
||||||
|
IFile file = getContainer().getFile(new Path(name));
|
||||||
|
return getTranslationUnit(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITranslationUnit getTranslationUnit(IFile file) {
|
||||||
|
return new TranslationUnit(this, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.model.ICContainer#getCContainer(java.lang.String)
|
||||||
|
*/
|
||||||
|
public ICContainer getCContainer(String name) {
|
||||||
|
IFolder folder = getContainer().getFolder(new Path(name));
|
||||||
|
return getCContainer(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICContainer getCContainer(IFolder folder) {
|
||||||
|
return new CContainer(this, folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IContainer getContainer() {
|
||||||
|
return (IContainer) getResource();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CElementInfo createElementInfo() {
|
||||||
return new CContainerInfo(this);
|
return new CContainerInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,9 +147,8 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
/**
|
/**
|
||||||
* @see Openable
|
* @see Openable
|
||||||
*/
|
*/
|
||||||
protected boolean generateInfos(OpenableInfo info, IProgressMonitor pm,
|
protected boolean generateInfos(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
|
||||||
Map newElements, IResource underlyingResource) throws CModelException {
|
throws CModelException {
|
||||||
|
|
||||||
boolean validInfo = false;
|
boolean validInfo = false;
|
||||||
try {
|
try {
|
||||||
IResource res = getResource();
|
IResource res = getResource();
|
||||||
|
@ -95,39 +165,60 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
return validInfo;
|
return validInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* Returns an array of non-c resources contained in the receiver.
|
* (non-Javadoc) Returns an array of non-c resources contained in the
|
||||||
|
* receiver.
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.model.ICContainer#getNonCResources()
|
* @see org.eclipse.cdt.core.model.ICContainer#getNonCResources()
|
||||||
*/
|
*/
|
||||||
public Object[] getNonCResources() throws CModelException {
|
public Object[] getNonCResources() throws CModelException {
|
||||||
return ((CContainerInfo)getElementInfo()).getNonCResources(getResource());
|
return ((CContainerInfo) getElementInfo()).getNonCResources(getResource());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean computeChildren(OpenableInfo info, IResource res) {
|
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
||||||
ArrayList vChildren = new ArrayList();
|
ArrayList vChildren = new ArrayList();
|
||||||
ArrayList notChildren = new ArrayList();
|
ArrayList notChildren = new ArrayList();
|
||||||
try {
|
try {
|
||||||
IResource[] resources = null;
|
IResource[] resources = null;
|
||||||
if (res != null) {
|
if (res instanceof IContainer) {
|
||||||
//System.out.println (" Resource: " + res.getFullPath().toOSString());
|
//System.out.println (" Resource: " +
|
||||||
switch(res.getType()) {
|
// res.getFullPath().toOSString());
|
||||||
case IResource.ROOT:
|
IContainer container = (IContainer) res;
|
||||||
case IResource.PROJECT:
|
resources = container.members(false);
|
||||||
case IResource.FOLDER:
|
|
||||||
IContainer container = (IContainer)res;
|
|
||||||
resources = container.members(false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IResource.FILE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resources != null) {
|
if (resources != null) {
|
||||||
CModelManager factory = CModelManager.getDefault();
|
ICProject cproject = getCProject();
|
||||||
for (int i = 0; i < resources.length; i++) {
|
for (int i = 0; i < resources.length; i++) {
|
||||||
// Check for Valid C Element only.
|
// Check for Valid C Element only.
|
||||||
ICElement celement = factory.create(this, resources[i]);
|
ICElement celement = null;
|
||||||
|
switch (resources[i].getType()) {
|
||||||
|
case IResource.FILE :
|
||||||
|
{
|
||||||
|
IFile file = (IFile) resources[i];
|
||||||
|
if (factory.isTranslationUnit(file)) {
|
||||||
|
celement = new TranslationUnit(this, file);
|
||||||
|
} else if (cproject.isOnOutputEntry(file)) {
|
||||||
|
IBinaryParser.IBinaryFile bin = factory.createBinaryFile(file);
|
||||||
|
if (bin != null) {
|
||||||
|
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||||
|
celement = new Archive(this, file, (IBinaryArchive)bin);
|
||||||
|
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||||
|
vlib.addChild(celement);
|
||||||
|
} else {
|
||||||
|
celement = new Binary(this, file, (IBinaryObject)bin);
|
||||||
|
if (bin.getType() == IBinaryFile.EXECUTABLE || bin.getType() == IBinaryFile.SHARED) {
|
||||||
|
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||||
|
vbin.addChild(celement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IResource.FOLDER :
|
||||||
|
celement = new CContainer(this, (IFolder) resources[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (celement != null) {
|
if (celement != null) {
|
||||||
vChildren.add(celement);
|
vChildren.add(celement);
|
||||||
} else {
|
} else {
|
||||||
|
@ -139,11 +230,22 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
//System.out.println (e);
|
//System.out.println (e);
|
||||||
//CPlugin.log (e);
|
//CPlugin.log (e);
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
|
throw new CModelException(e);
|
||||||
}
|
}
|
||||||
ICElement[] children = new ICElement[vChildren.size()];
|
ICElement[] children = new ICElement[vChildren.size()];
|
||||||
vChildren.toArray(children);
|
vChildren.toArray(children);
|
||||||
info.setChildren(children);
|
info.setChildren(children);
|
||||||
((CContainerInfo)getElementInfo()).setNonCResources(notChildren.toArray());
|
((CContainerInfo) getElementInfo()).setNonCResources(notChildren.toArray());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
|
||||||
|
*/
|
||||||
|
public ICContainer[] getCContainers() throws CModelException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 QNX Software Systems Ltd. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -7,11 +17,6 @@ import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class CContainerInfo extends OpenableInfo {
|
public class CContainerInfo extends OpenableInfo {
|
||||||
|
@ -42,18 +47,9 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
ICElement parent = getElement();
|
ICElement parent = getElement();
|
||||||
try {
|
try {
|
||||||
IResource[] resources = null;
|
IResource[] resources = null;
|
||||||
if (res != null) {
|
if (res instanceof IContainer) {
|
||||||
switch(res.getType()) {
|
IContainer container = (IContainer)res;
|
||||||
case IResource.ROOT:
|
resources = container.members(false);
|
||||||
case IResource.PROJECT:
|
|
||||||
case IResource.FOLDER:
|
|
||||||
IContainer container = (IContainer)res;
|
|
||||||
resources = container.members(false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IResource.FILE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resources != null) {
|
if (resources != null) {
|
||||||
|
@ -63,7 +59,7 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int j = 0; j < children.length; j++) {
|
for (int j = 0; j < children.length; j++) {
|
||||||
IResource r = children[j].getResource();
|
IResource r = children[j].getResource();
|
||||||
if (r.equals(resources[i])){
|
if (r != null && r.equals(resources[i])){
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -71,11 +67,6 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
if (!found) {
|
if (!found) {
|
||||||
notChildren.add(resources[i]);
|
notChildren.add(resources[i]);
|
||||||
}
|
}
|
||||||
// Check for Valid C projects only.
|
|
||||||
//ICElement celement = factory.create(parent, resources[i]);
|
|
||||||
//if (celement == null) {
|
|
||||||
// notChildren.add(resources[i]);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
|
|
@ -364,7 +364,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IJavaElement
|
* @see ICElement
|
||||||
*/
|
*/
|
||||||
public ICElement getAncestor(int ancestorType) {
|
public ICElement getAncestor(int ancestorType) {
|
||||||
ICElement element = this;
|
ICElement element = this;
|
||||||
|
|
|
@ -5,19 +5,23 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public class CModel extends CContainer implements ICModel {
|
public class CModel extends Openable implements ICModel {
|
||||||
|
|
||||||
public CModel () {
|
public CModel () {
|
||||||
this(ResourcesPlugin.getWorkspace().getRoot());
|
this(ResourcesPlugin.getWorkspace().getRoot());
|
||||||
|
@ -33,12 +37,33 @@ public class CModel extends CContainer implements ICModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICProject[] getCProjects() {
|
public ICProject[] getCProjects() {
|
||||||
ArrayList list = getChildrenOfType(C_PROJECT);
|
List list = getChildrenOfType(C_PROJECT);
|
||||||
ICProject[] array= new ICProject[list.size()];
|
ICProject[] array= new ICProject[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the active C project associated with the specified
|
||||||
|
* resource, or <code>null</code> if no C project yet exists
|
||||||
|
* for the resource.
|
||||||
|
*
|
||||||
|
* @exception IllegalArgumentException if the given resource
|
||||||
|
* is not one of an IProject, IFolder, or IFile.
|
||||||
|
*/
|
||||||
|
public ICProject getCProject(IResource resource) {
|
||||||
|
switch(resource.getType()){
|
||||||
|
case IResource.FOLDER:
|
||||||
|
return new CProject(this, ((IFolder)resource).getProject());
|
||||||
|
case IResource.FILE:
|
||||||
|
return new CProject(this, ((IFile)resource).getProject());
|
||||||
|
case IResource.PROJECT:
|
||||||
|
return new CProject(this, (IProject)resource);
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("element.invalidResourceForProject"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IWorkspace getWorkspace() {
|
public IWorkspace getWorkspace() {
|
||||||
return getUnderlyingResource().getWorkspace();
|
return getUnderlyingResource().getWorkspace();
|
||||||
}
|
}
|
||||||
|
@ -106,4 +131,48 @@ public class CModel extends CContainer implements ICModel {
|
||||||
return resource.hashCode();
|
return resource.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.Openable#generateInfos(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.runtime.IProgressMonitor, java.util.Map, org.eclipse.core.resources.IResource)
|
||||||
|
*/
|
||||||
|
protected boolean generateInfos(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException {
|
||||||
|
boolean validInfo = false;
|
||||||
|
try {
|
||||||
|
IResource res = getResource();
|
||||||
|
if (res != null && (res instanceof IWorkspaceRoot || res.getProject().isOpen())) {
|
||||||
|
// put the info now, because computing the roots requires it
|
||||||
|
CModelManager.getDefault().putInfo(this, info);
|
||||||
|
validInfo = computeChildren(info, res);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (!validInfo) {
|
||||||
|
CModelManager.getDefault().removeInfo(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ICModel#getNonCResources()
|
||||||
|
*/
|
||||||
|
public Object[] getNonCResources() throws CModelException {
|
||||||
|
return ((CModelInfo)getElementInfo()).getNonCResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
||||||
|
CModelManager factory = CModelManager.getDefault();
|
||||||
|
|
||||||
|
// determine my children
|
||||||
|
IWorkspaceRoot root = (IWorkspaceRoot)getResource();
|
||||||
|
IProject[] projects = root.getProjects();
|
||||||
|
for (int i = 0, max = projects.length; i < max; i++) {
|
||||||
|
IProject project = projects[i];
|
||||||
|
if (factory.hasCNature(project) || factory.hasCCNature(project)) {
|
||||||
|
ICProject cproject = new CProject(this, project);
|
||||||
|
info.addChild(cproject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
((CModelInfo)getElementInfo()).setNonCResources(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,20 +24,23 @@ public class CModelInfo extends CContainerInfo {
|
||||||
* Compute the non-C resources contained in this C project.
|
* Compute the non-C resources contained in this C project.
|
||||||
*/
|
*/
|
||||||
private Object[] computeNonCResources() {
|
private Object[] computeNonCResources() {
|
||||||
|
CModelManager mgr = CModelManager.getDefault();
|
||||||
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
||||||
int length = projects.length;
|
int length = projects.length;
|
||||||
Object[] nonCProjects = null;
|
Object[] nonCProjects = null;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
IProject project = projects[i];
|
IProject project = projects[i];
|
||||||
if (!CProject.hasCNature(project)) {
|
if (!(mgr.hasCNature(project) || mgr.hasCCNature(project))) {
|
||||||
if (nonCProjects == null) {
|
if (nonCProjects == null) {
|
||||||
nonCProjects = new Object[length];
|
nonCProjects = new Object[length];
|
||||||
}
|
}
|
||||||
nonCProjects[index++] = project;
|
nonCProjects[index++] = project;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == 0) return NO_NON_C_RESOURCES;
|
if (index == 0) {
|
||||||
|
return NO_NON_C_RESOURCES;
|
||||||
|
}
|
||||||
if (index < length) {
|
if (index < length) {
|
||||||
System.arraycopy(nonCProjects, 0, nonCProjects = new Object[index], 0, index);
|
System.arraycopy(nonCProjects, 0, nonCProjects = new Object[index], 0, index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.ICDescriptorListener;
|
import org.eclipse.cdt.core.ICDescriptorListener;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.IArchive;
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
|
@ -34,8 +35,10 @@ import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -50,6 +53,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class CModelManager implements IResourceChangeListener, ICDescriptorListener {
|
public class CModelManager implements IResourceChangeListener, ICDescriptorListener {
|
||||||
|
|
||||||
|
@ -150,7 +154,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
//return create(root);
|
//return create(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICModel getCModel() {
|
public CModel getCModel() {
|
||||||
return cModel;
|
return cModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,30 +164,37 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
IResource res = root.findMember(path);
|
IResource res = root.findMember(path);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
IPath rootPath = root.getLocation();
|
IPath rootPath = root.getLocation();
|
||||||
if (path.equals(rootPath))
|
if (path.equals(rootPath)) {
|
||||||
return getCModel(root);
|
return getCModel(root);
|
||||||
|
}
|
||||||
res = root.getContainerForLocation(path);
|
res = root.getContainerForLocation(path);
|
||||||
if (res == null || !res.exists())
|
if (res == null || !res.exists()) {
|
||||||
res = root.getFileForLocation(path);
|
res = root.getFileForLocation(path);
|
||||||
if (res != null && !res.exists())
|
}
|
||||||
|
if (res != null && !res.exists()) {
|
||||||
res = null;
|
res = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: for extenal resources ??
|
// TODO: for extenal resources ??
|
||||||
return create(res);
|
return create(res, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICElement create (IResource resource) {
|
public ICElement create (IResource resource, ICProject cproject) {
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cproject == null) {
|
||||||
|
cproject = create(resource.getProject());
|
||||||
|
}
|
||||||
int type = resource.getType();
|
int type = resource.getType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case IResource.PROJECT :
|
case IResource.PROJECT :
|
||||||
return create((IProject)resource);
|
return create((IProject)resource);
|
||||||
case IResource.FILE :
|
case IResource.FILE :
|
||||||
return create((IFile)resource);
|
return create((IFile)resource, cproject);
|
||||||
case IResource.FOLDER :
|
case IResource.FOLDER :
|
||||||
return create((IFolder)resource);
|
return create((IFolder)resource, cproject);
|
||||||
case IResource.ROOT :
|
case IResource.ROOT :
|
||||||
return create((IWorkspaceRoot)resource);
|
return create((IWorkspaceRoot)resource);
|
||||||
default :
|
default :
|
||||||
|
@ -191,39 +202,137 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICElement create(ICElement parent, IResource resource) {
|
public ICProject create(IProject project) {
|
||||||
int type = resource.getType();
|
if (project == null) {
|
||||||
switch (type) {
|
return null;
|
||||||
case IResource.PROJECT :
|
|
||||||
return create(parent, (IProject)resource);
|
|
||||||
case IResource.FILE :
|
|
||||||
return create(parent, (IFile)resource);
|
|
||||||
case IResource.FOLDER :
|
|
||||||
return create(parent, (IFolder)resource);
|
|
||||||
case IResource.ROOT :
|
|
||||||
return create((IWorkspaceRoot)resource);
|
|
||||||
default :
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return cModel.getCProject(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICElement create(IFile file) {
|
public ICModel create(IWorkspaceRoot root) {
|
||||||
IResource parent = file.getParent();
|
return getCModel();
|
||||||
ICElement cparent = null;
|
}
|
||||||
if (parent instanceof IFolder) {
|
|
||||||
cparent = create((IFolder)parent);
|
public ICContainer create(IFolder folder, ICProject cproject) {
|
||||||
} else if (parent instanceof IProject) {
|
if (folder == null) {
|
||||||
cparent = create((IProject)parent);
|
return null;
|
||||||
}
|
}
|
||||||
if (cparent != null)
|
if (cproject == null) {
|
||||||
return create(cparent, file);
|
cproject = create(folder.getProject());
|
||||||
return null;
|
}
|
||||||
|
ICContainer celement = null;
|
||||||
|
IPath resourcePath = folder.getFullPath();
|
||||||
|
try {
|
||||||
|
ISourceRoot[] roots = cproject.getSourceRoots();
|
||||||
|
for (int i = 0; i < roots.length; ++i) {
|
||||||
|
ISourceRoot root = roots[i];
|
||||||
|
IPath rootPath = root.getPath();
|
||||||
|
if (rootPath.equals(resourcePath)) {
|
||||||
|
celement = root;
|
||||||
|
break; // We are done.
|
||||||
|
} else if (root.isOnSourceEntry(folder)) {
|
||||||
|
IPath path = resourcePath.removeFirstSegments(rootPath.segmentCount());
|
||||||
|
String[] segments = path.segments();
|
||||||
|
ICContainer cfolder = root;
|
||||||
|
for (int j = 0; j < segments.length; j++) {
|
||||||
|
IResource res = cfolder.getResource();
|
||||||
|
if (res instanceof IContainer) {
|
||||||
|
IContainer container = (IContainer)res;
|
||||||
|
res = container.findMember(new Path(segments[j]));
|
||||||
|
if (res instanceof IFolder) {
|
||||||
|
cfolder = cfolder.getCContainer(segments[j]);
|
||||||
|
} else {
|
||||||
|
cfolder = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cfolder != null) {
|
||||||
|
celement = cfolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
return celement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICElement create(ICElement parent, IFile file) {
|
public ICElement create(IFile file, ICProject cproject) {
|
||||||
return create(parent, file, null);
|
if (file == null) {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
if (cproject == null) {
|
||||||
|
cproject = create(file.getProject());
|
||||||
|
}
|
||||||
|
ICElement celement = null;
|
||||||
|
try {
|
||||||
|
ISourceRoot[] roots = cproject.getSourceRoots();
|
||||||
|
for (int i = 0; i < roots.length; ++i) {
|
||||||
|
ISourceRoot root = roots[i];
|
||||||
|
IPath rootPath = root.getPath();
|
||||||
|
if (root.isOnSourceEntry(file)) {
|
||||||
|
IPath resourcePath = file.getFullPath();
|
||||||
|
IPath path = resourcePath.removeFirstSegments(rootPath.segmentCount());
|
||||||
|
String[] segments = path.segments();
|
||||||
|
ICContainer cfolder = root;
|
||||||
|
for (int j = 0; j < segments.length; j++) {
|
||||||
|
IResource res = cfolder.getResource();
|
||||||
|
if (res instanceof IContainer) {
|
||||||
|
IContainer container = (IContainer)res;
|
||||||
|
res = container.findMember(new Path(segments[j]));
|
||||||
|
if (res instanceof IFolder) {
|
||||||
|
cfolder = cfolder.getCContainer(segments[j]);
|
||||||
|
} else if (res instanceof IFile) {
|
||||||
|
IFile f = (IFile)res;
|
||||||
|
if (isTranslationUnit(f)) {
|
||||||
|
celement = new TranslationUnit(cfolder, f);
|
||||||
|
} else if (cproject.isOnOutputEntry(f)) {
|
||||||
|
IBinaryFile bin = createBinaryFile(f);
|
||||||
|
if (bin != null) {
|
||||||
|
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||||
|
celement = new Archive(cfolder, f, (IBinaryArchive)bin);
|
||||||
|
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||||
|
vlib.addChild(celement);
|
||||||
|
} else {
|
||||||
|
celement = new Binary(cfolder, f, (IBinaryObject)bin);
|
||||||
|
if (bin.getType() == IBinaryFile.EXECUTABLE || bin.getType() == IBinaryFile.SHARED) {
|
||||||
|
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||||
|
vbin.addChild(celement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// try in the outputEntry
|
||||||
|
if (celement == null && cproject.isOnOutputEntry(file)) {
|
||||||
|
IBinaryFile bin = createBinaryFile(file);
|
||||||
|
if (bin != null) {
|
||||||
|
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||||
|
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||||
|
celement = new Archive(vlib, file, (IBinaryArchive)bin);
|
||||||
|
vlib.addChild(celement);
|
||||||
|
} else {
|
||||||
|
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||||
|
celement = new Binary(vbin, file, (IBinaryObject)bin);
|
||||||
|
if (bin.getType() == IBinaryFile.EXECUTABLE || bin.getType() == IBinaryFile.SHARED) {
|
||||||
|
vbin.addChild(celement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
return celement;
|
||||||
|
}
|
||||||
|
/*
|
||||||
public synchronized ICElement create(ICElement parent, IFile file, IBinaryFile bin) {
|
public synchronized ICElement create(ICElement parent, IFile file, IBinaryFile bin) {
|
||||||
ICElement cfile = null;
|
ICElement cfile = null;
|
||||||
|
|
||||||
|
@ -261,45 +370,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
return cfile;
|
return cfile;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public ICContainer create(IFolder folder) {
|
|
||||||
IResource parent = folder.getParent();
|
|
||||||
ICElement cparent = null;
|
|
||||||
if (parent instanceof IFolder) {
|
|
||||||
cparent = create ((IFolder)parent);
|
|
||||||
} else if (parent instanceof IProject) {
|
|
||||||
cparent = create ((IProject)parent);
|
|
||||||
}
|
|
||||||
if (cparent != null)
|
|
||||||
return (ICContainer) create (cparent, folder);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICContainer create(ICElement parent, IFolder folder) {
|
|
||||||
return new CContainer(parent, folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICProject create(IProject project) {
|
|
||||||
IResource parent = project.getParent();
|
|
||||||
ICElement celement = null;
|
|
||||||
if (parent instanceof IWorkspaceRoot) {
|
|
||||||
celement = create ((IWorkspaceRoot)parent);
|
|
||||||
}
|
|
||||||
return create(celement, project);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICProject create(ICElement parent, IProject project) {
|
|
||||||
if (hasCNature(project)){
|
|
||||||
return new CProject(parent, project);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICModel create(IWorkspaceRoot root) {
|
|
||||||
return getCModel();
|
|
||||||
//return new CModel(root);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void releaseCElement(ICElement celement) {
|
public void releaseCElement(ICElement celement) {
|
||||||
|
|
||||||
// Guard.
|
// Guard.
|
||||||
|
@ -391,7 +462,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
|
|
||||||
// Remove the child from the parent list.
|
// Remove the child from the parent list.
|
||||||
Parent parent = (Parent)celement.getParent();
|
Parent parent = (Parent)celement.getParent();
|
||||||
if (parent != null) {
|
if (parent != null && peekAtInfo(parent) != null) {
|
||||||
parent.removeChild(celement);
|
parent.removeChild(celement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,7 +557,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSharedLib(IFile file) {
|
public boolean isSharedLib(IFile file) {
|
||||||
ICElement celement = create(file);
|
ICElement celement = create(file, null);
|
||||||
if (celement instanceof IBinary) {
|
if (celement instanceof IBinary) {
|
||||||
return ((IBinary)celement).isSharedLib();
|
return ((IBinary)celement).isSharedLib();
|
||||||
}
|
}
|
||||||
|
@ -494,7 +565,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isObject(IFile file) {
|
public boolean isObject(IFile file) {
|
||||||
ICElement celement = create(file);
|
ICElement celement = create(file, null);
|
||||||
if (celement instanceof IBinary) {
|
if (celement instanceof IBinary) {
|
||||||
return ((IBinary)celement).isObject();
|
return ((IBinary)celement).isObject();
|
||||||
}
|
}
|
||||||
|
@ -502,7 +573,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExecutable(IFile file) {
|
public boolean isExecutable(IFile file) {
|
||||||
ICElement celement = create(file);
|
ICElement celement = create(file, null);
|
||||||
if (celement instanceof IBinary) {
|
if (celement instanceof IBinary) {
|
||||||
return ((IBinary)celement).isExecutable();
|
return ((IBinary)celement).isExecutable();
|
||||||
}
|
}
|
||||||
|
@ -510,12 +581,12 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBinary(IFile file) {
|
public boolean isBinary(IFile file) {
|
||||||
ICElement celement = create(file);
|
ICElement celement = create(file, null);
|
||||||
return (celement instanceof IBinary);
|
return (celement instanceof IBinary);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isArchive(IFile file) {
|
public boolean isArchive(IFile file) {
|
||||||
ICElement celement = create(file);
|
ICElement celement = create(file, null);
|
||||||
return(celement instanceof IArchive);
|
return(celement instanceof IArchive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.IBinaryParser;
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
|
@ -26,8 +27,13 @@ import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ILibraryEntry;
|
import org.eclipse.cdt.core.model.ILibraryEntry;
|
||||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||||
|
import org.eclipse.cdt.core.model.IOutputEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -36,6 +42,8 @@ import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
|
||||||
public class CProject extends CContainer implements ICProject {
|
public class CProject extends CContainer implements ICProject {
|
||||||
|
|
||||||
|
private static final String CUSTOM_DEFAULT_OPTION_VALUE = "#\r\n\r#custom-non-empty-default-value#\r\n\r#"; //$NON-NLS-1$
|
||||||
|
|
||||||
public CProject(ICElement parent, IProject project) {
|
public CProject(ICElement parent, IProject project) {
|
||||||
super(parent, project, CElement.C_PROJECT);
|
super(parent, project, CElement.C_PROJECT);
|
||||||
}
|
}
|
||||||
|
@ -52,8 +60,6 @@ public class CProject extends CContainer implements ICProject {
|
||||||
return getUnderlyingResource().getProject();
|
return getUnderlyingResource().getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String CUSTOM_DEFAULT_OPTION_VALUE = "#\r\n\r#custom-non-empty-default-value#\r\n\r#"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
public ICElement findElement(IPath path) throws CModelException {
|
public ICElement findElement(IPath path) throws CModelException {
|
||||||
ICElement celem = null;
|
ICElement celem = null;
|
||||||
if (path.isAbsolute()) {
|
if (path.isAbsolute()) {
|
||||||
|
@ -126,8 +132,8 @@ public class CProject extends CContainer implements ICProject {
|
||||||
if (bin != null) {
|
if (bin != null) {
|
||||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||||
lib = new LibraryReferenceArchive(cproject, entry, (IBinaryArchive)bin);
|
lib = new LibraryReferenceArchive(cproject, entry, (IBinaryArchive)bin);
|
||||||
} else {
|
} else if (bin instanceof IBinaryObject){
|
||||||
lib = new LibraryReferenceShared(cproject, entry, bin);
|
lib = new LibraryReferenceShared(cproject, entry, (IBinaryObject)bin);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -323,4 +329,159 @@ public class CProject extends CContainer implements ICProject {
|
||||||
CoreModel.getDefault().setRawPathEntries(this, newEntries, monitor);
|
CoreModel.getDefault().setRawPathEntries(this, newEntries, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ICProject#getSourceRoot(org.eclipse.cdt.core.model.ISourceEntry)
|
||||||
|
*/
|
||||||
|
public ISourceRoot getSourceRoot(ISourceEntry entry) throws CModelException {
|
||||||
|
IPath p = getPath();
|
||||||
|
IPath sp = entry.getPath();
|
||||||
|
if (p.isPrefixOf(sp)) {
|
||||||
|
int count = sp.matchingFirstSegments(p);
|
||||||
|
sp = sp.removeFirstSegments(count);
|
||||||
|
IResource res = null;
|
||||||
|
if (sp.isEmpty()) {
|
||||||
|
res = getProject();
|
||||||
|
} else {
|
||||||
|
res = getProject().findMember(sp);
|
||||||
|
}
|
||||||
|
if (res != null) {
|
||||||
|
return new SourceRoot(this, res, entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ICProject#getSourceRoots()
|
||||||
|
*/
|
||||||
|
public ISourceRoot[] getSourceRoots() throws CModelException {
|
||||||
|
return computeSourceRoots();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOutputEntry[] getOutputEntries() throws CModelException {
|
||||||
|
IPathEntry[] entries = getResolvedPathEntries();
|
||||||
|
ArrayList list = new ArrayList(entries.length);
|
||||||
|
for (int i = 0; i < entries.length; i++) {
|
||||||
|
if (entries[i].getEntryKind() == IPathEntry .CDT_OUTPUT) {
|
||||||
|
list.add(entries[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IOutputEntry[] outputs = new IOutputEntry[list.size()];
|
||||||
|
list.toArray(outputs);
|
||||||
|
return outputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOnOutputEntry(IResource resource) {
|
||||||
|
IPath path = resource.getFullPath();
|
||||||
|
|
||||||
|
// ensure that folders are only excluded if all of their children are excluded
|
||||||
|
if (resource.getType() == IResource.FOLDER) {
|
||||||
|
path = path.append("*"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
IOutputEntry[] entries = getOutputEntries();
|
||||||
|
for (int i = 0; i < entries.length; i++) {
|
||||||
|
boolean on = isOnOutputEntry(entries[i], path);
|
||||||
|
if (on) {
|
||||||
|
return on;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isOnOutputEntry(IOutputEntry entry, IPath path) {
|
||||||
|
if (entry.getPath().isPrefixOf(path)
|
||||||
|
&& !Util.isExcluded(path, entry.fullExclusionPatternChars())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.Openable#generateInfos(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.runtime.IProgressMonitor, java.util.Map, org.eclipse.core.resources.IResource)
|
||||||
|
*/
|
||||||
|
protected boolean generateInfos(OpenableInfo info, IProgressMonitor pm,
|
||||||
|
Map newElements, IResource underlyingResource)
|
||||||
|
throws CModelException {
|
||||||
|
boolean validInfo = false;
|
||||||
|
try {
|
||||||
|
IResource res = getResource();
|
||||||
|
if (res != null && (res instanceof IWorkspaceRoot || res.getProject().isOpen())) {
|
||||||
|
// put the info now, because computing the roots requires it
|
||||||
|
CModelManager.getDefault().putInfo(this, info);
|
||||||
|
validInfo = computeSourceRoots(info, res);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (!validInfo) {
|
||||||
|
CModelManager.getDefault().removeInfo(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ISourceRoot[] computeSourceRoots() throws CModelException {
|
||||||
|
IPathEntry[] entries = getResolvedPathEntries();
|
||||||
|
ArrayList list = new ArrayList(entries.length);
|
||||||
|
for (int i = 0; i < entries.length; i++) {
|
||||||
|
if (entries[i].getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||||
|
ISourceEntry sourceEntry = (ISourceEntry)entries[i];
|
||||||
|
ISourceRoot root = getSourceRoot(sourceEntry);
|
||||||
|
if (root != null) {
|
||||||
|
list.add(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ISourceRoot[] roots = new ISourceRoot[list.size()];
|
||||||
|
list.toArray(roots);
|
||||||
|
return roots;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean computeSourceRoots(OpenableInfo info, IResource res) throws CModelException {
|
||||||
|
info.setChildren(computeSourceRoots());
|
||||||
|
if (info instanceof CProjectInfo) {
|
||||||
|
CProjectInfo pinfo = (CProjectInfo)info;
|
||||||
|
pinfo.setNonCResources(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see ICProject
|
||||||
|
*/
|
||||||
|
public boolean isOnClasspath(ICElement element) {
|
||||||
|
try {
|
||||||
|
ISourceRoot[] roots = getSourceRoots();
|
||||||
|
for (int i = 0; i < roots.length; i++) {
|
||||||
|
if (roots[i].isOnSourceEntry(element)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
// ..
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see ICProject
|
||||||
|
*/
|
||||||
|
public boolean isOnClasspath(IResource resource) {
|
||||||
|
try {
|
||||||
|
ISourceRoot[] roots = getSourceRoots();
|
||||||
|
for (int i = 0; i < roots.length; i++) {
|
||||||
|
if (roots[i].isOnSourceEntry(resource)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,16 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Info for ICProject.
|
* Info for ICProject.
|
||||||
|
@ -39,4 +47,65 @@ class CProjectInfo extends CContainerInfo {
|
||||||
return vLib;
|
return vLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object[] getNonCResources(IResource res) {
|
||||||
|
if (nonCResources != null)
|
||||||
|
return nonCResources;
|
||||||
|
|
||||||
|
// determine if src == project and/or if bin == project
|
||||||
|
IPath projectPath = res.getProject().getFullPath();
|
||||||
|
ISourceRoot root = null;
|
||||||
|
ICElement[] elements = getChildren();
|
||||||
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
if (elements[i] instanceof ISourceRoot) {
|
||||||
|
ISourceRoot source = (ISourceRoot)elements[i];
|
||||||
|
if (getElement().getPath().equals(source.getPath())) {
|
||||||
|
root = source;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList notChildren = new ArrayList();
|
||||||
|
ICElement parent = getElement();
|
||||||
|
try {
|
||||||
|
IResource[] resources = null;
|
||||||
|
if (res instanceof IContainer) {
|
||||||
|
IContainer container = (IContainer)res;
|
||||||
|
resources = container.members(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resources != null) {
|
||||||
|
CModelManager factory = CModelManager.getDefault();
|
||||||
|
for (int i = 0; i < resources.length; i++) {
|
||||||
|
ICElement[] children;
|
||||||
|
if (root == null) {
|
||||||
|
children = getChildren();
|
||||||
|
} else {
|
||||||
|
children = root.getChildren();
|
||||||
|
}
|
||||||
|
boolean found = false;
|
||||||
|
for (int j = 0; j < children.length; j++) {
|
||||||
|
IResource r = children[j].getResource();
|
||||||
|
if (r != null && r.equals(resources[i])){
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
notChildren.add(resources[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
//System.out.println (e);
|
||||||
|
//CPlugin.log (e);
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
setNonCResources(notChildren.toArray());
|
||||||
|
return nonCResources;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class CopyResourceElementsOperation extends MultiOperation {
|
||||||
// update new resource content
|
// update new resource content
|
||||||
|
|
||||||
// register the correct change deltas
|
// register the correct change deltas
|
||||||
ICElement cdest = CModelManager.getDefault().create(destFile);
|
ICElement cdest = CModelManager.getDefault().create(destFile, null);
|
||||||
prepareDeltas(source, cdest);
|
prepareDeltas(source, cdest);
|
||||||
fCreatedElements.add(cdest);
|
fCreatedElements.add(cdest);
|
||||||
//if (newName != null) {
|
//if (newName != null) {
|
||||||
|
|
|
@ -9,13 +9,16 @@ import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
|
@ -53,16 +56,38 @@ public class DeltaProcessor {
|
||||||
* Returns null if none was found.
|
* Returns null if none was found.
|
||||||
*/
|
*/
|
||||||
protected ICElement createElement(IResource resource) {
|
protected ICElement createElement(IResource resource) {
|
||||||
CModelManager manager = CModelManager.getDefault();
|
if (resource == null) {
|
||||||
if (resource == null)
|
|
||||||
return null;
|
return null;
|
||||||
ICElement celement = manager.create(resource);
|
}
|
||||||
|
CModelManager manager = CModelManager.getDefault();
|
||||||
|
ICElement celement = manager.create(resource, null);
|
||||||
if (celement == null) {
|
if (celement == null) {
|
||||||
ICElement parent = manager.create(resource.getParent());
|
|
||||||
// Probably it was deleted, find it
|
// Probably it was deleted, find it
|
||||||
|
IResource resParent = resource.getParent();
|
||||||
|
ICElement parent = null;
|
||||||
|
// the sourceRoot == Project
|
||||||
|
if (resParent instanceof IProject) {
|
||||||
|
ICProject cpj = manager.create((IProject)resParent);
|
||||||
|
if (cpj != null) {
|
||||||
|
try {
|
||||||
|
ISourceRoot[] roots = cpj.getSourceRoots();
|
||||||
|
for (int i = 0; i < roots.length; i++) {
|
||||||
|
if (roots[i].isOnSourceEntry(resource)) {
|
||||||
|
parent = roots[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parent == null) {
|
||||||
|
parent = manager.create(resParent, null);
|
||||||
|
}
|
||||||
if (parent instanceof IParent) {
|
if (parent instanceof IParent) {
|
||||||
ICElement[] children;
|
ICElement[] children;
|
||||||
if ( CModelManager.getDefault().peekAtInfo(parent) != null ) {
|
if (manager.peekAtInfo(parent) != null ) {
|
||||||
children = ((CElement)parent).getElementInfo().getChildren();
|
children = ((CElement)parent).getElementInfo().getChildren();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (int i = 0; i < children.length; i++) {
|
||||||
IResource res = children[i].getResource();
|
IResource res = children[i].getResource();
|
||||||
|
@ -72,40 +97,64 @@ public class DeltaProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// BUG 36424:
|
}
|
||||||
// The Binary may only be visible in the BinaryContainers
|
}
|
||||||
if (celement == null) {
|
|
||||||
ICProject cproj = parent.getCProject();
|
// BUG 36424:
|
||||||
if (cproj != null) {
|
// The Binary may only be visible in the BinaryContainers
|
||||||
IBinaryContainer bin = cproj.getBinaryContainer();
|
if (celement == null) {
|
||||||
children = ((CElement)bin).getElementInfo().getChildren();
|
ICElement[] children;
|
||||||
for (int i = 0; i < children.length; i++) {
|
ICProject cproj = manager.create(resource.getProject());
|
||||||
IResource res = children[i].getResource();
|
if (cproj != null && manager.peekAtInfo(cproj) != null) {
|
||||||
if (res != null && res.equals(resource)) {
|
IBinaryContainer bin = cproj.getBinaryContainer();
|
||||||
celement = children[i];
|
if (manager.peekAtInfo(bin) != null) {
|
||||||
break;
|
children = ((CElement)bin).getElementInfo().getChildren();
|
||||||
}
|
for (int i = 0; i < children.length; i++) {
|
||||||
}
|
IResource res = children[i].getResource();
|
||||||
}
|
if (res != null && res.equals(resource)) {
|
||||||
}
|
celement = children[i];
|
||||||
// BUG 36424:
|
break;
|
||||||
// The Archive may only be visible in the ArchiveContainers
|
|
||||||
if (celement == null) {
|
|
||||||
ICProject cproj = parent.getCProject();
|
|
||||||
if (cproj != null) {
|
|
||||||
IArchiveContainer bin = cproj.getArchiveContainer();
|
|
||||||
children = ((CElement)bin).getElementInfo().getChildren();
|
|
||||||
for (int i = 0; i < children.length; i++) {
|
|
||||||
IResource res = children[i].getResource();
|
|
||||||
if (res != null && res.equals(resource)) {
|
|
||||||
celement = children[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// BUG 36424:
|
||||||
|
// The Archive may only be visible in the ArchiveContainers
|
||||||
|
if (celement == null) {
|
||||||
|
ICElement[] children;
|
||||||
|
ICProject cproj = manager.create(resource.getProject());
|
||||||
|
if (cproj != null && manager.peekAtInfo(cproj) != null) {
|
||||||
|
IArchiveContainer ar = cproj.getArchiveContainer();
|
||||||
|
if (manager.peekAtInfo(ar) != null) {
|
||||||
|
children = ((CElement)ar).getElementInfo().getChildren();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
IResource res = children[i].getResource();
|
||||||
|
if (res != null && res.equals(resource)) {
|
||||||
|
celement = children[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return an handler
|
||||||
|
if (celement == null) {
|
||||||
|
IResource resParent = resource.getParent();
|
||||||
|
ICElement parent = manager.create(resParent, null);
|
||||||
|
if (parent instanceof ICContainer) {
|
||||||
|
String name = resource.getName();
|
||||||
|
if (resource instanceof IFile) {
|
||||||
|
if (manager.isValidTranslationUnitName(name)) {
|
||||||
|
celement = ((ICContainer)parent).getTranslationUnit(name);
|
||||||
|
}
|
||||||
|
} else if (resource instanceof IFolder) {
|
||||||
|
celement = ((ICContainer)parent).getCContainer(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return celement;
|
return celement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +539,7 @@ public class DeltaProcessor {
|
||||||
|
|
||||||
switch (element.getElementType()) {
|
switch (element.getElementType()) {
|
||||||
case ICElement.C_PROJECT :
|
case ICElement.C_PROJECT :
|
||||||
this.indexManager.removeIndexFamily(element.getCProject().getProject().getFullPath());
|
indexManager.removeIndexFamily(element.getCProject().getProject().getFullPath());
|
||||||
// NB: Discarding index jobs belonging to this project was done during PRE_DELETE
|
// NB: Discarding index jobs belonging to this project was done during PRE_DELETE
|
||||||
break;
|
break;
|
||||||
// NB: Update of index if project is opened, closed, or its c nature is added or removed
|
// NB: Update of index if project is opened, closed, or its c nature is added or removed
|
||||||
|
@ -498,7 +547,7 @@ public class DeltaProcessor {
|
||||||
|
|
||||||
case ICElement.C_UNIT:
|
case ICElement.C_UNIT:
|
||||||
IFile file = (IFile) delta.getResource();
|
IFile file = (IFile) delta.getResource();
|
||||||
indexManager.remove(file.getFullPath().toString(), file.getProject().getProject().getFullPath());
|
indexManager.remove(file.getFullPath().toString(), file.getProject().getFullPath());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,11 @@ import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
||||||
|
|
||||||
IPath includePath;
|
IPath includePath;
|
||||||
boolean isSystemInclude;
|
boolean isSystemInclude;
|
||||||
|
|
||||||
public IncludeEntry(IPath path, IPath includePath, boolean isSystemInclude, boolean isRecursive,
|
public IncludeEntry(IPath path, IPath includePath, boolean isSystemInclude, IPath[] exclusionPatterns) {
|
||||||
IPath[] exclusionPatterns) {
|
super(IIncludeEntry.CDT_INCLUDE, path, exclusionPatterns, path == null);
|
||||||
super(IIncludeEntry.CDT_INCLUDE, path, isRecursive, exclusionPatterns, path == null);
|
|
||||||
this.includePath = includePath;
|
this.includePath = includePath;
|
||||||
this.isSystemInclude = isSystemInclude;
|
this.isSystemInclude = isSystemInclude;
|
||||||
}
|
}
|
||||||
|
@ -76,5 +74,4 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
||||||
}
|
}
|
||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ILibraryEntry;
|
import org.eclipse.cdt.core.model.ILibraryEntry;
|
||||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||||
|
@ -20,7 +20,7 @@ public class LibraryReferenceShared extends Binary implements ILibraryReference
|
||||||
|
|
||||||
ILibraryEntry entry;
|
ILibraryEntry entry;
|
||||||
|
|
||||||
public LibraryReferenceShared(ICElement parent, ILibraryEntry e, IBinaryFile bin) {
|
public LibraryReferenceShared(ICElement parent, ILibraryEntry e, IBinaryObject bin) {
|
||||||
super(parent, e.getPath(), bin);
|
super(parent, e.getPath(), bin);
|
||||||
setElementType(ICElement.C_VCONTAINER);
|
setElementType(ICElement.C_VCONTAINER);
|
||||||
entry = e;
|
entry = e;
|
||||||
|
|
|
@ -20,9 +20,8 @@ public class MacroEntry extends APathEntry implements IMacroEntry {
|
||||||
String macroName;
|
String macroName;
|
||||||
String macroValue;
|
String macroValue;
|
||||||
|
|
||||||
public MacroEntry (IPath path, String macroName, String macroValue,
|
public MacroEntry (IPath path, String macroName, String macroValue, IPath[] exclusionPatterns) {
|
||||||
boolean isRecursive, IPath[] exclusionPatterns, boolean isExported) {
|
super(IMacroEntry.CDT_MACRO, path, exclusionPatterns, path == null);
|
||||||
super(IMacroEntry.CDT_MACRO, path, isRecursive, exclusionPatterns, isExported);
|
|
||||||
this.macroName = macroName;
|
this.macroName = macroName;
|
||||||
this.macroValue = macroValue;
|
this.macroValue = macroValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.IOutputEntry;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OutputEntry
|
||||||
|
*/
|
||||||
|
public class OutputEntry extends APathEntry implements IOutputEntry {
|
||||||
|
/**
|
||||||
|
* @param kind
|
||||||
|
* @param path
|
||||||
|
* @param isRecursive
|
||||||
|
* @param exclusionPatterns
|
||||||
|
* @param isExported
|
||||||
|
*/
|
||||||
|
public OutputEntry(IPath path, IPath[] exclusionPatterns, boolean isExported) {
|
||||||
|
super(CDT_OUTPUT, path, exclusionPatterns, isExported);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof IOutputEntry) {
|
||||||
|
IOutputEntry otherEntry = (IOutputEntry) obj;
|
||||||
|
if (!super.equals(otherEntry)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (path == null) {
|
||||||
|
if (otherEntry.getPath() != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!path.toString().equals(otherEntry.getPath().toString())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.equals(obj);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
@ -56,7 +57,7 @@ public abstract class Parent extends CElement implements IParent {
|
||||||
* @param type
|
* @param type
|
||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
*/
|
*/
|
||||||
public ArrayList getChildrenOfType(int type){
|
public List getChildrenOfType(int type){
|
||||||
ICElement[] children = getChildren();
|
ICElement[] children = getChildren();
|
||||||
int size = children.length;
|
int size = children.length;
|
||||||
ArrayList list = new ArrayList(size);
|
ArrayList list = new ArrayList(size);
|
||||||
|
|
|
@ -81,6 +81,8 @@ public class PathEntry implements IPathEntry {
|
||||||
return IPathEntry.CDT_MACRO;
|
return IPathEntry.CDT_MACRO;
|
||||||
if (kindStr.equalsIgnoreCase("con")) //$NON-NLS-1$
|
if (kindStr.equalsIgnoreCase("con")) //$NON-NLS-1$
|
||||||
return IPathEntry.CDT_CONTAINER;
|
return IPathEntry.CDT_CONTAINER;
|
||||||
|
if (kindStr.equalsIgnoreCase("out")) //$NON-NLS-1$
|
||||||
|
return IPathEntry.CDT_OUTPUT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +106,8 @@ public class PathEntry implements IPathEntry {
|
||||||
return "mac"; //$NON-NLS-1$
|
return "mac"; //$NON-NLS-1$
|
||||||
case IPathEntry.CDT_CONTAINER :
|
case IPathEntry.CDT_CONTAINER :
|
||||||
return "con"; //$NON-NLS-1$
|
return "con"; //$NON-NLS-1$
|
||||||
|
case IPathEntry.CDT_OUTPUT:
|
||||||
|
return "out"; //$NON-NLS-1$
|
||||||
default :
|
default :
|
||||||
return "unknown"; //$NON-NLS-1$
|
return "unknown"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -125,9 +129,9 @@ public class PathEntry implements IPathEntry {
|
||||||
case IPathEntry.CDT_SOURCE :
|
case IPathEntry.CDT_SOURCE :
|
||||||
buffer.append("CDT_SOURCE"); //$NON-NLS-1$
|
buffer.append("CDT_SOURCE"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
//case IPathEntry.CDT_VARIABLE :
|
case IPathEntry.CDT_OUTPUT :
|
||||||
// buffer.append("CDT_VARIABLE"); //$NON-NLS-1$
|
buffer.append("CDT_OUTPUT"); //$NON-NLS-1$
|
||||||
// break;
|
break;
|
||||||
case IPathEntry.CDT_INCLUDE :
|
case IPathEntry.CDT_INCLUDE :
|
||||||
buffer.append("CDT_INCLUDE"); //$NON-NLS-1$
|
buffer.append("CDT_INCLUDE"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,14 +9,12 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
@ -30,6 +28,7 @@ import org.eclipse.cdt.core.model.IContainerEntry;
|
||||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||||
import org.eclipse.cdt.core.model.ILibraryEntry;
|
import org.eclipse.cdt.core.model.ILibraryEntry;
|
||||||
import org.eclipse.cdt.core.model.IMacroEntry;
|
import org.eclipse.cdt.core.model.IMacroEntry;
|
||||||
|
import org.eclipse.cdt.core.model.IOutputEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
import org.eclipse.cdt.core.model.IProjectEntry;
|
import org.eclipse.cdt.core.model.IProjectEntry;
|
||||||
|
@ -57,7 +56,6 @@ import org.w3c.dom.NodeList;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PathEntryManager {
|
public class PathEntryManager {
|
||||||
|
|
||||||
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "pathEntryContainerInitializer"; //$NON-NLS-1$
|
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "pathEntryContainerInitializer"; //$NON-NLS-1$
|
||||||
static String PATH_ENTRY = "pathentry"; //$NON-NLS-1$
|
static String PATH_ENTRY = "pathentry"; //$NON-NLS-1$
|
||||||
static String PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$
|
static String PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$
|
||||||
|
@ -68,28 +66,22 @@ public class PathEntryManager {
|
||||||
static String ATTRIBUTE_ROOTPATH = "roopath"; //$NON-NLS-1$
|
static String ATTRIBUTE_ROOTPATH = "roopath"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_PREFIXMAPPING = "prefixmapping"; //$NON-NLS-1$
|
static String ATTRIBUTE_PREFIXMAPPING = "prefixmapping"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_EXCLUDING = "excluding"; //$NON-NLS-1$
|
static String ATTRIBUTE_EXCLUDING = "excluding"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_RECUSIVE = "recusive"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_OUTPUT = "output"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_INCLUDE = "include"; //$NON-NLS-1$
|
static String ATTRIBUTE_INCLUDE = "include"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_SYSTEM = "system"; //$NON-NLS-1$
|
static String ATTRIBUTE_SYSTEM = "system"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
|
static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
|
static String ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
|
||||||
static String VALUE_TRUE = "true"; //$NON-NLS-1$
|
static String VALUE_TRUE = "true"; //$NON-NLS-1$
|
||||||
|
|
||||||
final static IPathEntry[] EMPTY = {};
|
final static IPathEntry[] EMPTY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An empty array of strings indicating that a project doesn't have any prerequesite projects.
|
* An empty array of strings indicating that a project doesn't have any
|
||||||
|
* prerequesite projects.
|
||||||
*/
|
*/
|
||||||
static final String[] NO_PREREQUISITES = new String[0];
|
static final String[] NO_PREREQUISITES = new String[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pathentry containers pool
|
* pathentry containers pool
|
||||||
*/
|
*/
|
||||||
public static HashMap Containers = new HashMap(5);
|
public static HashMap Containers = new HashMap(5);
|
||||||
|
|
||||||
HashMap resolvedMap = new HashMap();
|
HashMap resolvedMap = new HashMap();
|
||||||
|
|
||||||
private static PathEntryManager pathEntryManager;
|
private static PathEntryManager pathEntryManager;
|
||||||
|
|
||||||
private PathEntryManager() {
|
private PathEntryManager() {
|
||||||
|
@ -137,7 +129,7 @@ public class PathEntryManager {
|
||||||
|
|
||||||
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
||||||
try {
|
try {
|
||||||
IPathEntry[] oldResolvedEntries = (IPathEntry[])resolvedMap.get(cproject);
|
IPathEntry[] oldResolvedEntries = (IPathEntry[]) resolvedMap.get(cproject);
|
||||||
resolvedMap.put(cproject, null);
|
resolvedMap.put(cproject, null);
|
||||||
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, oldResolvedEntries, newEntries);
|
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, oldResolvedEntries, newEntries);
|
||||||
CModelManager.getDefault().runOperation(op, monitor);
|
CModelManager.getDefault().runOperation(op, monitor);
|
||||||
|
@ -163,31 +155,48 @@ public class PathEntryManager {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
throw new CModelException(e);
|
throw new CModelException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks/hacks for backward compatibility ..
|
||||||
|
// if no output is specified we return the project
|
||||||
|
// if no source is specified we return the project
|
||||||
|
boolean foundSource = false;
|
||||||
|
boolean foundOutput = false;
|
||||||
|
for (int i = 0; i < pathEntries.size(); i++) {
|
||||||
|
IPathEntry rawEntry = (IPathEntry)pathEntries.get(i);
|
||||||
|
if (rawEntry.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||||
|
foundSource = true;
|
||||||
|
}
|
||||||
|
if (rawEntry.getEntryKind() == IPathEntry.CDT_OUTPUT) {
|
||||||
|
foundOutput = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundSource) {
|
||||||
|
pathEntries.add(CoreModel.newSourceEntry(cproject.getPath()));
|
||||||
|
}
|
||||||
|
if (!foundOutput) {
|
||||||
|
pathEntries.add(CoreModel.newOutputEntry(cproject.getPath()));
|
||||||
|
}
|
||||||
return (IPathEntry[]) pathEntries.toArray(EMPTY);
|
return (IPathEntry[]) pathEntries.toArray(EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer newContainer, IProgressMonitor monitor) throws CModelException {
|
public void setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer newContainer, IProgressMonitor monitor)
|
||||||
|
throws CModelException {
|
||||||
if (monitor != null && monitor.isCanceled()) {
|
if (monitor != null && monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPath containerPath = (newContainer == null) ? new Path("") : newContainer.getPath(); //$NON-NLS-1$
|
IPath containerPath = (newContainer == null) ? new Path("") : newContainer.getPath(); //$NON-NLS-1$
|
||||||
final int projectLength = affectedProjects.length;
|
final int projectLength = affectedProjects.length;
|
||||||
final ICProject[] modifiedProjects = new ICProject[projectLength];
|
final ICProject[] modifiedProjects = new ICProject[projectLength];
|
||||||
System.arraycopy(affectedProjects, 0, modifiedProjects, 0, projectLength);
|
System.arraycopy(affectedProjects, 0, modifiedProjects, 0, projectLength);
|
||||||
final IPathEntry[][] oldResolvedEntries = new IPathEntry[projectLength][];
|
final IPathEntry[][] oldResolvedEntries = new IPathEntry[projectLength][];
|
||||||
|
|
||||||
// filter out unmodified project containers
|
// filter out unmodified project containers
|
||||||
int remaining = 0;
|
int remaining = 0;
|
||||||
for (int i = 0; i < projectLength; i++) {
|
for (int i = 0; i < projectLength; i++) {
|
||||||
|
|
||||||
if (monitor != null && monitor.isCanceled()) {
|
if (monitor != null && monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICProject affectedProject = affectedProjects[i];
|
ICProject affectedProject = affectedProjects[i];
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
IPathEntry[] rawPath = getRawPathEntries(affectedProject);
|
IPathEntry[] rawPath = getRawPathEntries(affectedProject);
|
||||||
for (int j = 0, cpLength = rawPath.length; j < cpLength; j++) {
|
for (int j = 0, cpLength = rawPath.length; j < cpLength; j++) {
|
||||||
|
@ -201,26 +210,26 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// filter out this project - does not reference the container path
|
// filter out this project - does not reference the container
|
||||||
|
// path
|
||||||
modifiedProjects[i] = null;
|
modifiedProjects[i] = null;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IPathEntryContainer oldContainer = containerGet(affectedProject, containerPath);
|
IPathEntryContainer oldContainer = containerGet(affectedProject, containerPath);
|
||||||
if (oldContainer != null && newContainer != null && oldContainer.equals(newContainer)) {
|
if (oldContainer != null && newContainer != null && oldContainer.equals(newContainer)) {
|
||||||
modifiedProjects[i] = null; // filter out this project - container did not change
|
modifiedProjects[i] = null; // filter out this project -
|
||||||
|
// container did not change
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
remaining++;
|
remaining++;
|
||||||
oldResolvedEntries[i] = (IPathEntry[])resolvedMap.get(affectedProject);
|
oldResolvedEntries[i] = (IPathEntry[]) resolvedMap.get(affectedProject);
|
||||||
resolvedMap.put(affectedProject, null);
|
resolvedMap.put(affectedProject, null);
|
||||||
containerPut(affectedProject, containerPath, newContainer);
|
containerPut(affectedProject, containerPath, newContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing change.
|
// Nothing change.
|
||||||
if (remaining == 0) {
|
if (remaining == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger model refresh
|
// trigger model refresh
|
||||||
try {
|
try {
|
||||||
CoreModel.run(new IWorkspaceRunnable() {
|
CoreModel.run(new IWorkspaceRunnable() {
|
||||||
|
@ -235,18 +244,16 @@ public class PathEntryManager {
|
||||||
if (affectedProject == null) {
|
if (affectedProject == null) {
|
||||||
continue; // was filtered out
|
continue; // was filtered out
|
||||||
}
|
}
|
||||||
|
|
||||||
IPathEntry[] newEntries = getResolvedPathEntries(affectedProject);
|
IPathEntry[] newEntries = getResolvedPathEntries(affectedProject);
|
||||||
ICElementDelta[] deltas = generatePathEntryDeltas(affectedProject,
|
ICElementDelta[] deltas = generatePathEntryDeltas(affectedProject, oldResolvedEntries[i], newEntries);
|
||||||
oldResolvedEntries[i], newEntries);
|
|
||||||
if (deltas.length > 0) {
|
if (deltas.length > 0) {
|
||||||
shouldFire = true;
|
shouldFire = true;
|
||||||
for (int j = 0; j < deltas.length; j++) {
|
for (int j = 0; j < deltas.length; j++) {
|
||||||
mgr.registerCModelDelta(deltas[j]);
|
mgr.registerCModelDelta(deltas[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//affectedProject.setRawPathEntries(affectedProject.getRawPathEntries(),
|
||||||
//affectedProject.setRawPathEntries(affectedProject.getRawPathEntries(), progressMonitor);
|
// progressMonitor);
|
||||||
}
|
}
|
||||||
if (shouldFire) {
|
if (shouldFire) {
|
||||||
mgr.fire(ElementChangedEvent.POST_CHANGE);
|
mgr.fire(ElementChangedEvent.POST_CHANGE);
|
||||||
|
@ -267,33 +274,35 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntryContainer getPathEntryContainer(final IPath containerPath, final ICProject project) throws CModelException {
|
public IPathEntryContainer getPathEntryContainer(final IPath containerPath, final ICProject project) throws CModelException {
|
||||||
|
|
||||||
// Try the cache.
|
// Try the cache.
|
||||||
IPathEntryContainer container = containerGet(project, containerPath);
|
IPathEntryContainer container = containerGet(project, containerPath);
|
||||||
|
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
final PathEntryContainerInitializer initializer = getPathEntryContainerInitializer(containerPath.segment(0));
|
final PathEntryContainerInitializer initializer = getPathEntryContainerInitializer(containerPath.segment(0));
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
containerPut(project, containerPath, container);
|
containerPut(project, containerPath, container);
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
try {
|
try {
|
||||||
// wrap initializer call with Safe runnable in case initializer would be
|
// wrap initializer call with Safe runnable in case
|
||||||
|
// initializer would be
|
||||||
// causing some grief
|
// causing some grief
|
||||||
Platform.run(new ISafeRunnable() {
|
Platform.run(new ISafeRunnable() {
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
//Util.log(exception, "Exception occurred in container initializer: "+initializer); //$NON-NLS-1$
|
//Util.log(exception, "Exception occurred in
|
||||||
|
// container initializer: "+initializer);
|
||||||
|
// //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
initializer.initialize(containerPath, project);
|
initializer.initialize(containerPath, project);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// retrieve value (if initialization was successful)
|
// retrieve value (if initialization was successful)
|
||||||
container = containerGet(project, containerPath);
|
container = containerGet(project, containerPath);
|
||||||
ok = true;
|
ok = true;
|
||||||
} finally {
|
} finally {
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
containerPut(project, containerPath, null); // flush cache
|
containerPut(project, containerPath, null); // flush
|
||||||
|
// cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,20 +311,21 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method finding the container initializer registered for a given container ID or <code>null</code>
|
* Helper method finding the container initializer registered for a given
|
||||||
* if none was found while iterating over the contributions to extension point to the extension point
|
* container ID or <code>null</code> if none was found while iterating
|
||||||
|
* over the contributions to extension point to the extension point
|
||||||
* "org.eclipse.cdt.core.PathEntryContainerInitializer".
|
* "org.eclipse.cdt.core.PathEntryContainerInitializer".
|
||||||
* <p>
|
* <p>
|
||||||
* A containerID is the first segment of any container path, used to identify the registered container initializer.
|
* A containerID is the first segment of any container path, used to
|
||||||
|
* identify the registered container initializer.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param containerID -
|
* @param containerID -
|
||||||
* a containerID identifying a registered initializer
|
* a containerID identifying a registered initializer
|
||||||
* @return PathEntryContainerInitializer - the registered container initializer or <code>null</code> if none was
|
* @return PathEntryContainerInitializer - the registered container
|
||||||
* found.
|
* initializer or <code>null</code> if none was found.
|
||||||
*/
|
*/
|
||||||
public PathEntryContainerInitializer getPathEntryContainerInitializer(String containerID) {
|
public PathEntryContainerInitializer getPathEntryContainerInitializer(String containerID) {
|
||||||
|
|
||||||
Plugin core = CCorePlugin.getDefault();
|
Plugin core = CCorePlugin.getDefault();
|
||||||
if (core == null) {
|
if (core == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -369,7 +379,7 @@ public class PathEntryManager {
|
||||||
ArrayList prerequisites = new ArrayList();
|
ArrayList prerequisites = new ArrayList();
|
||||||
for (int i = 0, length = entries.length; i < length; i++) {
|
for (int i = 0, length = entries.length; i < length; i++) {
|
||||||
if (entries[i].getEntryKind() == IPathEntry.CDT_PROJECT) {
|
if (entries[i].getEntryKind() == IPathEntry.CDT_PROJECT) {
|
||||||
IProjectEntry entry = (IProjectEntry)entries[i];
|
IProjectEntry entry = (IProjectEntry) entries[i];
|
||||||
prerequisites.add(entry.getPath().lastSegment());
|
prerequisites.add(entry.getPath().lastSegment());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,6 +392,7 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
return NO_PREREQUISITES;
|
return NO_PREREQUISITES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveRawPathEntries(ICProject cproject, IPathEntry[] newRawEntries) throws CModelException {
|
public void saveRawPathEntries(ICProject cproject, IPathEntry[] newRawEntries) throws CModelException {
|
||||||
try {
|
try {
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(cproject.getProject());
|
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(cproject.getProject());
|
||||||
|
@ -392,7 +403,6 @@ public class PathEntryManager {
|
||||||
rootElement.removeChild(child);
|
rootElement.removeChild(child);
|
||||||
child = rootElement.getFirstChild();
|
child = rootElement.getFirstChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the entries
|
// Save the entries
|
||||||
if (newRawEntries != null && newRawEntries.length > 0) {
|
if (newRawEntries != null && newRawEntries.length > 0) {
|
||||||
// Serialize the include paths
|
// Serialize the include paths
|
||||||
|
@ -410,7 +420,6 @@ public class PathEntryManager {
|
||||||
CModelManager manager = CModelManager.getDefault();
|
CModelManager manager = CModelManager.getDefault();
|
||||||
boolean needToUpdateDependents = false;
|
boolean needToUpdateDependents = false;
|
||||||
boolean hasDelta = false;
|
boolean hasDelta = false;
|
||||||
|
|
||||||
// Check the removed entries.
|
// Check the removed entries.
|
||||||
if (oldEntries != null) {
|
if (oldEntries != null) {
|
||||||
for (int i = 0; i < oldEntries.length; i++) {
|
for (int i = 0; i < oldEntries.length; i++) {
|
||||||
|
@ -425,8 +434,7 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
// Was it deleted.
|
// Was it deleted.
|
||||||
if (!found) {
|
if (!found) {
|
||||||
ICElementDelta delta =
|
ICElementDelta delta = makePathEntryDelta(cproject, oldEntries[i], true);
|
||||||
makePathEntryDelta(cproject, oldEntries[i], true);
|
|
||||||
if (delta != null) {
|
if (delta != null) {
|
||||||
list.add(delta);
|
list.add(delta);
|
||||||
}
|
}
|
||||||
|
@ -447,8 +455,7 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
// is it new?
|
// is it new?
|
||||||
if (!found) {
|
if (!found) {
|
||||||
ICElementDelta delta =
|
ICElementDelta delta = makePathEntryDelta(cproject, newEntries[i], false);
|
||||||
makePathEntryDelta(cproject, newEntries[i], false);
|
|
||||||
if (delta != null) {
|
if (delta != null) {
|
||||||
list.add(delta);
|
list.add(delta);
|
||||||
}
|
}
|
||||||
|
@ -474,8 +481,8 @@ public class PathEntryManager {
|
||||||
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_SOURCE : ICElementDelta.F_ADDED_PATHENTRY_SOURCE;
|
flag = (removed) ? ICElementDelta.F_REMOVED_PATHENTRY_SOURCE : ICElementDelta.F_ADDED_PATHENTRY_SOURCE;
|
||||||
} else if (kind == IPathEntry.CDT_LIBRARY) {
|
} else if (kind == IPathEntry.CDT_LIBRARY) {
|
||||||
ILibraryEntry lib = (ILibraryEntry) entry;
|
ILibraryEntry lib = (ILibraryEntry) entry;
|
||||||
celement = CProject.getLibraryReference(cproject, null,lib);
|
celement = CProject.getLibraryReference(cproject, null, lib);
|
||||||
flag = (removed) ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY : ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY;
|
flag = (removed) ? ICElementDelta.F_ADDED_PATHENTRY_LIBRARY : ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY;
|
||||||
} else if (kind == IPathEntry.CDT_PROJECT) {
|
} else if (kind == IPathEntry.CDT_PROJECT) {
|
||||||
//IProjectEntry pentry = (IProjectEntry) entry;
|
//IProjectEntry pentry = (IProjectEntry) entry;
|
||||||
celement = cproject;
|
celement = cproject;
|
||||||
|
@ -528,32 +535,28 @@ public class PathEntryManager {
|
||||||
|
|
||||||
static IPathEntry decodePathEntry(ICProject cProject, Element element) throws CModelException {
|
static IPathEntry decodePathEntry(ICProject cProject, Element element) throws CModelException {
|
||||||
IPath projectPath = cProject.getProject().getFullPath();
|
IPath projectPath = cProject.getProject().getFullPath();
|
||||||
|
|
||||||
// kind
|
// kind
|
||||||
String kindAttr = element.getAttribute(ATTRIBUTE_KIND);
|
String kindAttr = element.getAttribute(ATTRIBUTE_KIND);
|
||||||
int kind = PathEntry.kindFromString(kindAttr);
|
int kind = PathEntry.kindFromString(kindAttr);
|
||||||
|
|
||||||
// exported flag
|
// exported flag
|
||||||
boolean isExported = false;
|
boolean isExported = false;
|
||||||
if (element.hasAttribute(ATTRIBUTE_EXPORTED)) {
|
if (element.hasAttribute(ATTRIBUTE_EXPORTED)) {
|
||||||
isExported = element.getAttribute(ATTRIBUTE_EXPORTED).equals(VALUE_TRUE);
|
isExported = element.getAttribute(ATTRIBUTE_EXPORTED).equals(VALUE_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure path is absolute
|
// ensure path is absolute
|
||||||
|
boolean hasPath = element.hasAttribute(ATTRIBUTE_PATH);
|
||||||
String pathAttr = element.getAttribute(ATTRIBUTE_PATH);
|
String pathAttr = element.getAttribute(ATTRIBUTE_PATH);
|
||||||
IPath path = new Path(pathAttr);
|
IPath path = new Path(pathAttr);
|
||||||
if (kind != IPathEntry.CDT_VARIABLE && !path.isAbsolute()) {
|
if (kind != IPathEntry.CDT_VARIABLE && !path.isAbsolute()) {
|
||||||
path = projectPath.append(path);
|
path = projectPath.append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// source attachment info (optional)
|
// source attachment info (optional)
|
||||||
IPath sourceAttachmentPath =
|
IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path(element
|
||||||
element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path(element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null;
|
.getAttribute(ATTRIBUTE_SOURCEPATH)) : null;
|
||||||
IPath sourceAttachmentRootPath =
|
IPath sourceAttachmentRootPath = element.hasAttribute(ATTRIBUTE_ROOTPATH) ? new Path(element
|
||||||
element.hasAttribute(ATTRIBUTE_ROOTPATH) ? new Path(element.getAttribute(ATTRIBUTE_ROOTPATH)) : null;
|
.getAttribute(ATTRIBUTE_ROOTPATH)) : null;
|
||||||
IPath sourceAttachmentPrefixMapping =
|
IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(element
|
||||||
element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
|
.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
|
||||||
|
|
||||||
// exclusion patterns (optional)
|
// exclusion patterns (optional)
|
||||||
String exclusion = element.getAttribute(ATTRIBUTE_EXCLUDING);
|
String exclusion = element.getAttribute(ATTRIBUTE_EXCLUDING);
|
||||||
IPath[] exclusionPatterns = APathEntry.NO_EXCLUSION_PATTERNS;
|
IPath[] exclusionPatterns = APathEntry.NO_EXCLUSION_PATTERNS;
|
||||||
|
@ -567,72 +570,53 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isRecursive = false;
|
|
||||||
if (element.hasAttribute(ATTRIBUTE_RECUSIVE)) {
|
|
||||||
isRecursive = element.getAttribute(ATTRIBUTE_RECUSIVE).equals(VALUE_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// recreate the CP entry
|
// recreate the CP entry
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
|
||||||
case IPathEntry.CDT_PROJECT :
|
case IPathEntry.CDT_PROJECT :
|
||||||
return CoreModel.newProjectEntry(path, isExported);
|
return CoreModel.newProjectEntry(path, isExported);
|
||||||
|
|
||||||
case IPathEntry.CDT_LIBRARY :
|
case IPathEntry.CDT_LIBRARY :
|
||||||
return CoreModel.newLibraryEntry(
|
return CoreModel.newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath,
|
||||||
path,
|
sourceAttachmentPrefixMapping, isExported);
|
||||||
sourceAttachmentPath,
|
|
||||||
sourceAttachmentRootPath,
|
|
||||||
sourceAttachmentPrefixMapping,
|
|
||||||
isExported);
|
|
||||||
|
|
||||||
case IPathEntry.CDT_SOURCE :
|
case IPathEntry.CDT_SOURCE :
|
||||||
{
|
{
|
||||||
// custom output location
|
|
||||||
IPath outputLocation = element.hasAttribute(ATTRIBUTE_OUTPUT) ? projectPath.append(element.getAttribute(ATTRIBUTE_OUTPUT)) : null;
|
|
||||||
// must be an entry in this project or specify another
|
// must be an entry in this project or specify another
|
||||||
// project
|
// project
|
||||||
String projSegment = path.segment(0);
|
String projSegment = path.segment(0);
|
||||||
if (projSegment != null && projSegment.equals(cProject.getElementName())) { // this project
|
if (projSegment != null && projSegment.equals(cProject.getElementName())) { // this
|
||||||
return CoreModel.newSourceEntry(path, outputLocation, isRecursive, exclusionPatterns);
|
// project
|
||||||
|
return CoreModel.newSourceEntry(path, exclusionPatterns);
|
||||||
} else { // another project
|
} else { // another project
|
||||||
return CoreModel.newProjectEntry(path, isExported);
|
return CoreModel.newProjectEntry(path, isExported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case IPathEntry.CDT_OUTPUT :
|
||||||
|
{
|
||||||
|
return CoreModel.newOutputEntry(path, exclusionPatterns);
|
||||||
|
}
|
||||||
case IPathEntry.CDT_INCLUDE :
|
case IPathEntry.CDT_INCLUDE :
|
||||||
{
|
{
|
||||||
// include path info
|
// include path info
|
||||||
IPath includePath =
|
IPath includePath = element.hasAttribute(ATTRIBUTE_INCLUDE)
|
||||||
element.hasAttribute(ATTRIBUTE_INCLUDE) ? new Path(element.getAttribute(ATTRIBUTE_INCLUDE)) : null;
|
? new Path(element.getAttribute(ATTRIBUTE_INCLUDE))
|
||||||
|
: null;
|
||||||
// isSysteminclude
|
// isSysteminclude
|
||||||
boolean isSystemInclude = false;
|
boolean isSystemInclude = false;
|
||||||
if (element.hasAttribute(ATTRIBUTE_SYSTEM)) {
|
if (element.hasAttribute(ATTRIBUTE_SYSTEM)) {
|
||||||
isSystemInclude = element.getAttribute(ATTRIBUTE_SYSTEM).equals(VALUE_TRUE);
|
isSystemInclude = element.getAttribute(ATTRIBUTE_SYSTEM).equals(VALUE_TRUE);
|
||||||
}
|
}
|
||||||
return CoreModel.newIncludeEntry(
|
return CoreModel.newIncludeEntry(path, includePath, isSystemInclude, exclusionPatterns);
|
||||||
path,
|
|
||||||
includePath,
|
|
||||||
isSystemInclude,
|
|
||||||
isRecursive,
|
|
||||||
exclusionPatterns);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case IPathEntry.CDT_MACRO :
|
case IPathEntry.CDT_MACRO :
|
||||||
{
|
{
|
||||||
String macroName = element.getAttribute(ATTRIBUTE_NAME);
|
String macroName = element.getAttribute(ATTRIBUTE_NAME);
|
||||||
String macroValue = element.getAttribute(ATTRIBUTE_VALUE);
|
String macroValue = element.getAttribute(ATTRIBUTE_VALUE);
|
||||||
return CoreModel.newMacroEntry(path, macroName, macroValue, isRecursive, exclusionPatterns, isExported);
|
return CoreModel.newMacroEntry(path, macroName, macroValue, exclusionPatterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
case IPathEntry.CDT_CONTAINER :
|
case IPathEntry.CDT_CONTAINER :
|
||||||
{
|
{
|
||||||
IPath id = new Path(element.getAttribute(ATTRIBUTE_PATH));
|
IPath id = new Path(element.getAttribute(ATTRIBUTE_PATH));
|
||||||
return CoreModel.newContainerEntry(id, isExported);
|
return CoreModel.newContainerEntry(id, isExported);
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
{
|
{
|
||||||
ICModelStatus status = new CModelStatus(ICModelStatus.ERROR, "PathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
ICModelStatus status = new CModelStatus(ICModelStatus.ERROR, "PathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -647,10 +631,8 @@ public class PathEntryManager {
|
||||||
element = doc.createElement(PATH_ENTRY);
|
element = doc.createElement(PATH_ENTRY);
|
||||||
configRootElement.appendChild(element);
|
configRootElement.appendChild(element);
|
||||||
int kind = entries[i].getEntryKind();
|
int kind = entries[i].getEntryKind();
|
||||||
|
|
||||||
// Set the kind
|
// Set the kind
|
||||||
element.setAttribute(ATTRIBUTE_KIND, PathEntry.kindToString(kind));
|
element.setAttribute(ATTRIBUTE_KIND, PathEntry.kindToString(kind));
|
||||||
|
|
||||||
// Save the exclusions attributes
|
// Save the exclusions attributes
|
||||||
if (entries[i] instanceof APathEntry) {
|
if (entries[i] instanceof APathEntry) {
|
||||||
APathEntry entry = (APathEntry) entries[i];
|
APathEntry entry = (APathEntry) entries[i];
|
||||||
|
@ -665,19 +647,15 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
element.setAttribute(ATTRIBUTE_EXCLUDING, excludeRule.toString());
|
element.setAttribute(ATTRIBUTE_EXCLUDING, excludeRule.toString());
|
||||||
}
|
}
|
||||||
if (entry.isRecursive()) {
|
|
||||||
element.setAttribute(ATTRIBUTE_RECUSIVE, VALUE_TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == IPathEntry.CDT_SOURCE) {
|
if (kind == IPathEntry.CDT_SOURCE) {
|
||||||
ISourceEntry source = (ISourceEntry) entries[i];
|
ISourceEntry source = (ISourceEntry) entries[i];
|
||||||
IPath path = source.getPath();
|
IPath path = source.getPath();
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
IPath output = source.getOutputLocation();
|
} else if (kind == IPathEntry.CDT_OUTPUT) {
|
||||||
if (output != null && output.isEmpty()) {
|
IOutputEntry out = (IOutputEntry) entries[i];
|
||||||
element.setAttribute(ATTRIBUTE_OUTPUT, output.toString());
|
IPath path = out.getPath();
|
||||||
}
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
} else if (kind == IPathEntry.CDT_LIBRARY) {
|
} else if (kind == IPathEntry.CDT_LIBRARY) {
|
||||||
ILibraryEntry lib = (ILibraryEntry) entries[i];
|
ILibraryEntry lib = (ILibraryEntry) entries[i];
|
||||||
IPath path = lib.getPath();
|
IPath path = lib.getPath();
|
||||||
|
@ -698,7 +676,9 @@ public class PathEntryManager {
|
||||||
} else if (kind == IPathEntry.CDT_INCLUDE) {
|
} else if (kind == IPathEntry.CDT_INCLUDE) {
|
||||||
IIncludeEntry include = (IIncludeEntry) entries[i];
|
IIncludeEntry include = (IIncludeEntry) entries[i];
|
||||||
IPath path = include.getPath();
|
IPath path = include.getPath();
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
if (path != null) {
|
||||||
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
|
}
|
||||||
IPath includePath = include.getIncludePath();
|
IPath includePath = include.getIncludePath();
|
||||||
element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString());
|
element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString());
|
||||||
if (include.isSystemInclude()) {
|
if (include.isSystemInclude()) {
|
||||||
|
@ -707,7 +687,9 @@ public class PathEntryManager {
|
||||||
} else if (kind == IPathEntry.CDT_MACRO) {
|
} else if (kind == IPathEntry.CDT_MACRO) {
|
||||||
IMacroEntry macro = (IMacroEntry) entries[i];
|
IMacroEntry macro = (IMacroEntry) entries[i];
|
||||||
IPath path = macro.getPath();
|
IPath path = macro.getPath();
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
if (path != null) {
|
||||||
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
|
}
|
||||||
element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName());
|
element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName());
|
||||||
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
|
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
|
||||||
} else if (kind == IPathEntry.CDT_CONTAINER) {
|
} else if (kind == IPathEntry.CDT_CONTAINER) {
|
||||||
|
@ -719,5 +701,4 @@ public class PathEntryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,20 +17,8 @@ import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class SourceEntry extends APathEntry implements ISourceEntry {
|
public class SourceEntry extends APathEntry implements ISourceEntry {
|
||||||
|
|
||||||
IPath outputLocation;
|
public SourceEntry(IPath path, IPath[] exclusionPatterns) {
|
||||||
|
super(ISourceEntry.CDT_SOURCE, path, exclusionPatterns, false);
|
||||||
public SourceEntry(IPath path, IPath outputLocation, boolean isRecursive, IPath[] exclusionPatterns) {
|
|
||||||
super(ISourceEntry.CDT_SOURCE, path, isRecursive, exclusionPatterns, false);
|
|
||||||
this.outputLocation = outputLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Binary output location for this source folder.
|
|
||||||
* @return IPath, <code>null</code> means to use the
|
|
||||||
* default output location of the project.
|
|
||||||
*/
|
|
||||||
public IPath getOutputLocation() {
|
|
||||||
return outputLocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals (Object obj) {
|
public boolean equals (Object obj) {
|
||||||
|
@ -48,15 +36,6 @@ public class SourceEntry extends APathEntry implements ISourceEntry {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (outputLocation == null) {
|
|
||||||
if (otherEntry.getOutputLocation() != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!outputLocation.toString().equals(otherEntry.getOutputLocation().toString())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,8 +25,8 @@ public class SourceMapper {
|
||||||
return findTranslationUnit(cproject, filename);
|
return findTranslationUnit(cproject, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITranslationUnit findTranslationUnit(ICContainer container, String filename) {
|
public ITranslationUnit findTranslationUnit(IParent container, String filename) {
|
||||||
ArrayList list = container.getChildrenOfType(ICElement.C_UNIT);
|
List list = container.getChildrenOfType(ICElement.C_UNIT);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Object o = list.get(i);
|
Object o = list.get(i);
|
||||||
if (o instanceof ITranslationUnit) {
|
if (o instanceof ITranslationUnit) {
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SourceRoot
|
||||||
|
*/
|
||||||
|
public class SourceRoot extends CContainer implements ISourceRoot {
|
||||||
|
|
||||||
|
ISourceEntry sourceEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parent
|
||||||
|
* @param res
|
||||||
|
*/
|
||||||
|
public SourceRoot(ICElement parent, IResource res, ISourceEntry entry) {
|
||||||
|
super(parent, res);
|
||||||
|
sourceEntry = entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.CContainer#computeChildren(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.resources.IResource)
|
||||||
|
*/
|
||||||
|
protected boolean computeChildren(OpenableInfo info, IResource res)
|
||||||
|
throws CModelException {
|
||||||
|
return super.computeChildren(info, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISourceEntry getSourceEntry() {
|
||||||
|
return sourceEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnclasspath(org.eclipse.cdt.core.model.ICElement)
|
||||||
|
*/
|
||||||
|
public boolean isOnSourceEntry(ICElement element) {
|
||||||
|
IPath path = element.getPath();
|
||||||
|
if (element.getElementType() == ICElement.C_CCONTAINER) {
|
||||||
|
// ensure that folders are only excluded if all of their children are excluded
|
||||||
|
path = path.append("*"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return this.isOnSourceEntry(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnSourceEntry(org.eclipse.core.resources.IResource)
|
||||||
|
*/
|
||||||
|
public boolean isOnSourceEntry(IResource resource) {
|
||||||
|
IPath path = resource.getFullPath();
|
||||||
|
|
||||||
|
// ensure that folders are only excluded if all of their children are excluded
|
||||||
|
if (resource.getType() == IResource.FOLDER) {
|
||||||
|
path = path.append("*"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOnSourceEntry(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isOnSourceEntry(IPath path) {
|
||||||
|
if (sourceEntry.getPath().isPrefixOf(path)
|
||||||
|
&& !Util.isExcluded(path, sourceEntry.fullExclusionPatternChars())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,29 +1,27 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
* (c) Copyright IBM Corp. 2000, 2001. All Rights Reserved.
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICLogConstants;
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
||||||
import org.eclipse.cdt.internal.core.model.IDebugLogConstants.DebugLogConstant;
|
import org.eclipse.cdt.internal.core.model.IDebugLogConstants.DebugLogConstant;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
public class Util implements ICLogConstants {
|
public class Util implements ICLogConstants {
|
||||||
|
|
||||||
public static boolean VERBOSE_PARSER = false;
|
public static boolean VERBOSE_PARSER = false;
|
||||||
public static boolean VERBOSE_SCANNER = false;
|
public static boolean VERBOSE_SCANNER = false;
|
||||||
public static boolean VERBOSE_MODEL = false;
|
public static boolean VERBOSE_MODEL = false;
|
||||||
|
@ -31,7 +29,6 @@ public class Util implements ICLogConstants {
|
||||||
private Util() {
|
private Util() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static StringBuffer getContent(IFile file) throws IOException {
|
public static StringBuffer getContent(IFile file) throws IOException {
|
||||||
InputStream stream = null;
|
InputStream stream = null;
|
||||||
try {
|
try {
|
||||||
|
@ -40,7 +37,7 @@ public class Util implements ICLogConstants {
|
||||||
throw new IOException(e.getMessage());
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
char [] b = getInputStreamAsCharArray(stream, -1, null);
|
char[] b = getInputStreamAsCharArray(stream, -1, null);
|
||||||
return new StringBuffer(b.length).append(b);
|
return new StringBuffer(b.length).append(b);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
@ -52,18 +49,20 @@ public class Util implements ICLogConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the given input stream's contents as a character array.
|
* Returns the given input stream's contents as a character array. If a
|
||||||
* If a length is specified (ie. if length != -1), only length chars
|
* length is specified (ie. if length != -1), only length chars are
|
||||||
* are returned. Otherwise all chars in the stream are returned.
|
* returned. Otherwise all chars in the stream are returned. Note this
|
||||||
* Note this doesn't close the stream.
|
* doesn't close the stream.
|
||||||
* @throws IOException if a problem occured reading the stream.
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* if a problem occured reading the stream.
|
||||||
*/
|
*/
|
||||||
public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding)
|
public static char[] getInputStreamAsCharArray(InputStream stream,
|
||||||
throws IOException {
|
int length, String encoding) throws IOException {
|
||||||
InputStreamReader reader = null;
|
InputStreamReader reader = null;
|
||||||
reader = encoding == null
|
reader = encoding == null
|
||||||
? new InputStreamReader(stream)
|
? new InputStreamReader(stream)
|
||||||
: new InputStreamReader(stream, encoding);
|
: new InputStreamReader(stream, encoding);
|
||||||
char[] contents;
|
char[] contents;
|
||||||
if (length == -1) {
|
if (length == -1) {
|
||||||
contents = new char[0];
|
contents = new char[0];
|
||||||
|
@ -71,34 +70,23 @@ public class Util implements ICLogConstants {
|
||||||
int charsRead = -1;
|
int charsRead = -1;
|
||||||
do {
|
do {
|
||||||
int available = stream.available();
|
int available = stream.available();
|
||||||
|
|
||||||
// resize contents if needed
|
// resize contents if needed
|
||||||
if (contentsLength + available > contents.length) {
|
if (contentsLength + available > contents.length) {
|
||||||
System.arraycopy(
|
System.arraycopy(contents, 0,
|
||||||
contents,
|
contents = new char[contentsLength + available], 0,
|
||||||
0,
|
contentsLength);
|
||||||
contents = new char[contentsLength + available],
|
|
||||||
0,
|
|
||||||
contentsLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read as many chars as possible
|
// read as many chars as possible
|
||||||
charsRead = reader.read(contents, contentsLength, available);
|
charsRead = reader.read(contents, contentsLength, available);
|
||||||
|
|
||||||
if (charsRead > 0) {
|
if (charsRead > 0) {
|
||||||
// remember length of contents
|
// remember length of contents
|
||||||
contentsLength += charsRead;
|
contentsLength += charsRead;
|
||||||
}
|
}
|
||||||
} while (charsRead > 0);
|
} while (charsRead > 0);
|
||||||
|
|
||||||
// resize contents if necessary
|
// resize contents if necessary
|
||||||
if (contentsLength < contents.length) {
|
if (contentsLength < contents.length) {
|
||||||
System.arraycopy(
|
System.arraycopy(contents, 0,
|
||||||
contents,
|
contents = new char[contentsLength], 0, contentsLength);
|
||||||
0,
|
|
||||||
contents = new char[contentsLength],
|
|
||||||
0,
|
|
||||||
contentsLength);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contents = new char[length];
|
contents = new char[length];
|
||||||
|
@ -106,21 +94,24 @@ public class Util implements ICLogConstants {
|
||||||
int readSize = 0;
|
int readSize = 0;
|
||||||
while ((readSize != -1) && (len != length)) {
|
while ((readSize != -1) && (len != length)) {
|
||||||
// See PR 1FMS89U
|
// See PR 1FMS89U
|
||||||
// We record first the read size. In this case len is the actual read size.
|
// We record first the read size. In this case len is the
|
||||||
|
// actual read size.
|
||||||
len += readSize;
|
len += readSize;
|
||||||
readSize = reader.read(contents, len, length - len);
|
readSize = reader.read(contents, len, length - len);
|
||||||
}
|
}
|
||||||
// See PR 1FMS89U
|
// See PR 1FMS89U
|
||||||
// Now we need to resize in case the default encoding used more than one byte for each
|
// Now we need to resize in case the default encoding used more
|
||||||
// character
|
// than one byte for each
|
||||||
|
// character
|
||||||
if (len != length)
|
if (len != length)
|
||||||
System.arraycopy(contents, 0, (contents = new char[len]), 0, len);
|
System.arraycopy(contents, 0, (contents = new char[len]), 0,
|
||||||
|
len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save (StringBuffer buffer, IFile file) throws CoreException {
|
public static void save(StringBuffer buffer, IFile file)
|
||||||
|
throws CoreException {
|
||||||
byte[] bytes = buffer.toString().getBytes();
|
byte[] bytes = buffer.toString().getBytes();
|
||||||
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||||
// use a platform operation to update the resource contents
|
// use a platform operation to update the resource contents
|
||||||
|
@ -131,16 +122,19 @@ public class Util implements ICLogConstants {
|
||||||
/**
|
/**
|
||||||
* Returns the given file's contents as a character array.
|
* Returns the given file's contents as a character array.
|
||||||
*/
|
*/
|
||||||
public static char[] getResourceContentsAsCharArray(IFile file) throws CModelException {
|
public static char[] getResourceContentsAsCharArray(IFile file)
|
||||||
|
throws CModelException {
|
||||||
return getResourceContentsAsCharArray(file, null);
|
return getResourceContentsAsCharArray(file, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char[] getResourceContentsAsCharArray(IFile file, String encoding) throws CModelException {
|
public static char[] getResourceContentsAsCharArray(IFile file,
|
||||||
InputStream stream= null;
|
String encoding) throws CModelException {
|
||||||
|
InputStream stream = null;
|
||||||
try {
|
try {
|
||||||
stream = new BufferedInputStream(file.getContents(true));
|
stream = new BufferedInputStream(file.getContents(true));
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
throw new CModelException(e, ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST);
|
throw new CModelException(e,
|
||||||
|
ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return Util.getInputStreamAsCharArray(stream, -1, encoding);
|
return Util.getInputStreamAsCharArray(stream, -1, encoding);
|
||||||
|
@ -153,34 +147,29 @@ public class Util implements ICLogConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add a log entry
|
* Add a log entry
|
||||||
*/
|
*/
|
||||||
public static void log(Throwable e, String message, LogConst logType) {
|
public static void log(Throwable e, String message, LogConst logType) {
|
||||||
IStatus status= new Status(
|
IStatus status = new Status(IStatus.ERROR, CCorePlugin.getDefault()
|
||||||
IStatus.ERROR,
|
.getDescriptor().getUniqueIdentifier(), IStatus.ERROR, message,
|
||||||
CCorePlugin.getDefault().getDescriptor().getUniqueIdentifier(),
|
e);
|
||||||
IStatus.ERROR,
|
|
||||||
message,
|
|
||||||
e);
|
|
||||||
Util.log(status, logType);
|
Util.log(status, logType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(IStatus status, LogConst logType){
|
public static void log(IStatus status, LogConst logType) {
|
||||||
if (logType.equals(ICLogConstants.PDE)){
|
if (logType.equals(ICLogConstants.PDE)) {
|
||||||
CCorePlugin.getDefault().getLog().log(status);
|
CCorePlugin.getDefault().getLog().log(status);
|
||||||
}
|
} else if (logType.equals(ICLogConstants.CDT)) {
|
||||||
else if (logType.equals(ICLogConstants.CDT)){
|
|
||||||
CCorePlugin.getDefault().cdtLog.log(status);
|
CCorePlugin.getDefault().cdtLog.log(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String message, LogConst logType){
|
public static void log(String message, LogConst logType) {
|
||||||
IStatus status = new Status(IStatus.INFO,
|
IStatus status = new Status(IStatus.INFO, CCorePlugin.getDefault()
|
||||||
CCorePlugin.getDefault().getDescriptor().getUniqueIdentifier(),
|
.getDescriptor().getUniqueIdentifier(), IStatus.INFO, message,
|
||||||
IStatus.INFO,
|
null);
|
||||||
message,
|
|
||||||
null);
|
|
||||||
Util.log(status, logType);
|
Util.log(status, logType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,12 +177,15 @@ public class Util implements ICLogConstants {
|
||||||
Util.debugLog(message, client, true);
|
Util.debugLog(message, client, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debugLog(String message, DebugLogConstant client, boolean addTimeStamp) {
|
public static void debugLog(String message, DebugLogConstant client,
|
||||||
if( CCorePlugin.getDefault() == null ) return;
|
boolean addTimeStamp) {
|
||||||
if ( CCorePlugin.getDefault().isDebugging() && isActive(client)) {
|
if (CCorePlugin.getDefault() == null)
|
||||||
|
return;
|
||||||
|
if (CCorePlugin.getDefault().isDebugging() && isActive(client)) {
|
||||||
// Time stamp
|
// Time stamp
|
||||||
if(addTimeStamp)
|
if (addTimeStamp)
|
||||||
message = MessageFormat.format( "[{0}] {1}", new Object[] { new Long( System.currentTimeMillis() ), message } ); //$NON-NLS-1$
|
message = MessageFormat.format("[{0}] {1}", new Object[]{
|
||||||
|
new Long(System.currentTimeMillis()), message}); //$NON-NLS-1$
|
||||||
while (message.length() > 100) {
|
while (message.length() > 100) {
|
||||||
String partial = message.substring(0, 100);
|
String partial = message.substring(0, 100);
|
||||||
message = message.substring(100);
|
message = message.substring(100);
|
||||||
|
@ -212,18 +204,17 @@ public class Util implements ICLogConstants {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isActive(DebugLogConstant client) {
|
public static boolean isActive(DebugLogConstant client) {
|
||||||
if (client.equals(IDebugLogConstants.PARSER)){
|
if (client.equals(IDebugLogConstants.PARSER)) {
|
||||||
return VERBOSE_PARSER;
|
return VERBOSE_PARSER;
|
||||||
}
|
} else if (client.equals(IDebugLogConstants.SCANNER))
|
||||||
else if (client.equals(IDebugLogConstants.SCANNER ))
|
|
||||||
return VERBOSE_SCANNER;
|
return VERBOSE_SCANNER;
|
||||||
else if (client.equals(IDebugLogConstants.MODEL)){
|
else if (client.equals(IDebugLogConstants.MODEL)) {
|
||||||
return VERBOSE_MODEL;
|
return VERBOSE_MODEL;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDebugging(boolean value){
|
public static void setDebugging(boolean value) {
|
||||||
CCorePlugin.getDefault().setDebugging(value);
|
CCorePlugin.getDefault().setDebugging(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,67 +224,558 @@ public class Util implements ICLogConstants {
|
||||||
public static int combineHashCodes(int hashCode1, int hashCode2) {
|
public static int combineHashCodes(int hashCode1, int hashCode2) {
|
||||||
return hashCode1 * 17 + hashCode2;
|
return hashCode1 * 17 + hashCode2;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Compares two arrays using equals() on the elements.
|
|
||||||
* Either or both arrays may be null.
|
|
||||||
* Returns true if both are null.
|
|
||||||
* Returns false if only one is null.
|
|
||||||
* If both are arrays, returns true iff they have the same length and
|
|
||||||
* all elements compare true with equals.
|
|
||||||
*/
|
|
||||||
public static boolean equalArraysOrNull(Object[] a, Object[] b) {
|
|
||||||
if (a == b) return true;
|
|
||||||
if (a == null || b == null) return false;
|
|
||||||
|
|
||||||
int len = a.length;
|
/**
|
||||||
if (len != b.length) return false;
|
* Compares two arrays using equals() on the elements. Either or both
|
||||||
for (int i = 0; i < len; ++i) {
|
* arrays may be null. Returns true if both are null. Returns false if only
|
||||||
if (a[i] == null) {
|
* one is null. If both are arrays, returns true iff they have the same
|
||||||
if (b[i] != null) return false;
|
* length and all elements compare true with equals.
|
||||||
} else {
|
*/
|
||||||
if (!a[i].equals(b[i])) return false;
|
public static boolean equalArraysOrNull(Object[] a, Object[] b) {
|
||||||
}
|
if (a == b)
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
if (a == null || b == null)
|
||||||
/**
|
return false;
|
||||||
* Compares two arrays using equals() on the elements.
|
int len = a.length;
|
||||||
* Either or both arrays may be null.
|
if (len != b.length)
|
||||||
* Returns true if both are null.
|
return false;
|
||||||
* Returns false if only one is null.
|
for (int i = 0; i < len; ++i) {
|
||||||
* If both are arrays, returns true iff they have the same length and
|
if (a[i] == null) {
|
||||||
* all elements are equal.
|
if (b[i] != null)
|
||||||
*/
|
return false;
|
||||||
public static boolean equalArraysOrNull(int[] a, int[] b) {
|
} else {
|
||||||
if (a == b)
|
if (!a[i].equals(b[i]))
|
||||||
return true;
|
|
||||||
if (a == null || b == null)
|
|
||||||
return false;
|
|
||||||
int len = a.length;
|
|
||||||
if (len != b.length)
|
|
||||||
return false;
|
|
||||||
for (int i = 0; i < len; ++i) {
|
|
||||||
if (a[i] != b[i])
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares two arrays using equals() on the elements. Either or both
|
||||||
|
* arrays may be null. Returns true if both are null. Returns false if only
|
||||||
|
* one is null. If both are arrays, returns true iff they have the same
|
||||||
|
* length and all elements are equal.
|
||||||
|
*/
|
||||||
|
public static boolean equalArraysOrNull(int[] a, int[] b) {
|
||||||
|
if (a == b)
|
||||||
|
return true;
|
||||||
|
if (a == null || b == null)
|
||||||
|
return false;
|
||||||
|
int len = a.length;
|
||||||
|
if (len != b.length)
|
||||||
|
return false;
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
if (a[i] != b[i])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares two objects using equals(). Either or both array may be null.
|
||||||
|
* Returns true if both are null. Returns false if only one is null.
|
||||||
|
* Otherwise, return the result of comparing with equals().
|
||||||
|
*/
|
||||||
|
public static boolean equalOrNull(Object a, Object b) {
|
||||||
|
if (a == b) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (a == null || b == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return a.equals(b);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Compares two objects using equals().
|
* Returns whether the given resource path matches one of the exclusion
|
||||||
* Either or both array may be null.
|
* patterns.
|
||||||
* Returns true if both are null.
|
*
|
||||||
* Returns false if only one is null.
|
* @see IClasspathEntry#getExclusionPatterns
|
||||||
* Otherwise, return the result of comparing with equals().
|
*/
|
||||||
*/
|
public final static boolean isExcluded(IPath resourcePath,
|
||||||
public static boolean equalOrNull(Object a, Object b) {
|
char[][] exclusionPatterns) {
|
||||||
if (a == b) {
|
if (exclusionPatterns == null)
|
||||||
|
return false;
|
||||||
|
char[] path = resourcePath.toString().toCharArray();
|
||||||
|
for (int i = 0, length = exclusionPatterns.length; i < length; i++)
|
||||||
|
if (pathMatch(exclusionPatterns[i], path, true, '/'))
|
||||||
return true;
|
return true;
|
||||||
}
|
return false;
|
||||||
if (a == null || b == null) {
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns whether the given resource matches one of the exclusion
|
||||||
|
* patterns.
|
||||||
|
*
|
||||||
|
* @see IClasspathEntry#getExclusionPatterns
|
||||||
|
*/
|
||||||
|
public final static boolean isExcluded(IResource resource,
|
||||||
|
char[][] exclusionPatterns) {
|
||||||
|
IPath path = resource.getFullPath();
|
||||||
|
// ensure that folders are only excluded if all of their children are
|
||||||
|
// excluded
|
||||||
|
if (resource.getType() == IResource.FOLDER)
|
||||||
|
path = path.append("*"); //$NON-NLS-1$
|
||||||
|
return isExcluded(path, exclusionPatterns);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answers true if the pattern matches the given name, false otherwise.
|
||||||
|
* This char[] pattern matching accepts wild-cards '*' and '?'.
|
||||||
|
*
|
||||||
|
* When not case sensitive, the pattern is assumed to already be
|
||||||
|
* lowercased, the name will be lowercased character per character as
|
||||||
|
* comparing. If name is null, the answer is false. If pattern is null, the
|
||||||
|
* answer is true if name is not null. <br>
|
||||||
|
* <br>
|
||||||
|
* For example:
|
||||||
|
* <ol>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pattern = { '?', 'b', '*' }
|
||||||
|
* name = { 'a', 'b', 'c' , 'd' }
|
||||||
|
* isCaseSensitive = true
|
||||||
|
* result => true
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pattern = { '?', 'b', '?' }
|
||||||
|
* name = { 'a', 'b', 'c' , 'd' }
|
||||||
|
* isCaseSensitive = true
|
||||||
|
* result => false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pattern = { 'b', '*' }
|
||||||
|
* name = { 'a', 'b', 'c' , 'd' }
|
||||||
|
* isCaseSensitive = true
|
||||||
|
* result => false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* @param pattern
|
||||||
|
* the given pattern
|
||||||
|
* @param name
|
||||||
|
* the given name
|
||||||
|
* @param isCaseSensitive
|
||||||
|
* flag to know whether or not the matching should be case
|
||||||
|
* sensitive
|
||||||
|
* @return true if the pattern matches the given name, false otherwise
|
||||||
|
*/
|
||||||
|
public static final boolean match(char[] pattern, char[] name,
|
||||||
|
boolean isCaseSensitive) {
|
||||||
|
if (name == null)
|
||||||
|
return false; // null name cannot match
|
||||||
|
if (pattern == null)
|
||||||
|
return true; // null pattern is equivalent to '*'
|
||||||
|
return match(pattern, 0, pattern.length, name, 0, name.length,
|
||||||
|
isCaseSensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answers true if the a sub-pattern matches the subpart of the given name,
|
||||||
|
* false otherwise. char[] pattern matching, accepting wild-cards '*' and
|
||||||
|
* '?'. Can match only subset of name/pattern. end positions are
|
||||||
|
* non-inclusive. The subpattern is defined by the patternStart and
|
||||||
|
* pattternEnd positions. When not case sensitive, the pattern is assumed
|
||||||
|
* to already be lowercased, the name will be lowercased character per
|
||||||
|
* character as comparing. <br>
|
||||||
|
* <br>
|
||||||
|
* For example:
|
||||||
|
* <ol>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pattern = { '?', 'b', '*' }
|
||||||
|
* patternStart = 1
|
||||||
|
* patternEnd = 3
|
||||||
|
* name = { 'a', 'b', 'c' , 'd' }
|
||||||
|
* nameStart = 1
|
||||||
|
* nameEnd = 4
|
||||||
|
* isCaseSensitive = true
|
||||||
|
* result => true
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pattern = { '?', 'b', '*' }
|
||||||
|
* patternStart = 1
|
||||||
|
* patternEnd = 2
|
||||||
|
* name = { 'a', 'b', 'c' , 'd' }
|
||||||
|
* nameStart = 1
|
||||||
|
* nameEnd = 2
|
||||||
|
* isCaseSensitive = true
|
||||||
|
* result => false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* @param pattern
|
||||||
|
* the given pattern
|
||||||
|
* @param patternStart
|
||||||
|
* the given pattern start
|
||||||
|
* @param patternEnd
|
||||||
|
* the given pattern end
|
||||||
|
* @param name
|
||||||
|
* the given name
|
||||||
|
* @param nameStart
|
||||||
|
* the given name start
|
||||||
|
* @param nameEnd
|
||||||
|
* the given name end
|
||||||
|
* @param isCaseSensitive
|
||||||
|
* flag to know if the matching should be case sensitive
|
||||||
|
* @return true if the a sub-pattern matches the subpart of the given name,
|
||||||
|
* false otherwise
|
||||||
|
*/
|
||||||
|
public static final boolean match(char[] pattern, int patternStart,
|
||||||
|
int patternEnd, char[] name, int nameStart, int nameEnd,
|
||||||
|
boolean isCaseSensitive) {
|
||||||
|
if (name == null)
|
||||||
|
return false; // null name cannot match
|
||||||
|
if (pattern == null)
|
||||||
|
return true; // null pattern is equivalent to '*'
|
||||||
|
int iPattern = patternStart;
|
||||||
|
int iName = nameStart;
|
||||||
|
if (patternEnd < 0)
|
||||||
|
patternEnd = pattern.length;
|
||||||
|
if (nameEnd < 0)
|
||||||
|
nameEnd = name.length;
|
||||||
|
/* check first segment */
|
||||||
|
char patternChar = 0;
|
||||||
|
while ((iPattern < patternEnd)
|
||||||
|
&& (patternChar = pattern[iPattern]) != '*') {
|
||||||
|
if (iName == nameEnd)
|
||||||
|
return false;
|
||||||
|
if (patternChar != (isCaseSensitive ? name[iName] : Character
|
||||||
|
.toLowerCase(name[iName]))
|
||||||
|
&& patternChar != '?') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return a.equals(b);
|
iName++;
|
||||||
|
iPattern++;
|
||||||
}
|
}
|
||||||
|
/* check sequence of star+segment */
|
||||||
|
int segmentStart;
|
||||||
|
if (patternChar == '*') {
|
||||||
|
segmentStart = ++iPattern; // skip star
|
||||||
|
} else {
|
||||||
|
segmentStart = 0; // force iName check
|
||||||
|
}
|
||||||
|
int prefixStart = iName;
|
||||||
|
checkSegment : while (iName < nameEnd) {
|
||||||
|
if (iPattern == patternEnd) {
|
||||||
|
iPattern = segmentStart; // mismatch - restart current segment
|
||||||
|
iName = ++prefixStart;
|
||||||
|
continue checkSegment;
|
||||||
|
}
|
||||||
|
/* segment is ending */
|
||||||
|
if ((patternChar = pattern[iPattern]) == '*') {
|
||||||
|
segmentStart = ++iPattern; // skip start
|
||||||
|
if (segmentStart == patternEnd) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
prefixStart = iName;
|
||||||
|
continue checkSegment;
|
||||||
|
}
|
||||||
|
/* check current name character */
|
||||||
|
if ((isCaseSensitive ? name[iName] : Character
|
||||||
|
.toLowerCase(name[iName])) != patternChar
|
||||||
|
&& patternChar != '?') {
|
||||||
|
iPattern = segmentStart; // mismatch - restart current segment
|
||||||
|
iName = ++prefixStart;
|
||||||
|
continue checkSegment;
|
||||||
|
}
|
||||||
|
iName++;
|
||||||
|
iPattern++;
|
||||||
|
}
|
||||||
|
return (segmentStart == patternEnd)
|
||||||
|
|| (iName == nameEnd && iPattern == patternEnd)
|
||||||
|
|| (iPattern == patternEnd - 1 && pattern[iPattern] == '*');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answers true if the pattern matches the filepath using the
|
||||||
|
* pathSepatator, false otherwise.
|
||||||
|
*
|
||||||
|
* Path char[] pattern matching, accepting wild-cards '**', '*' and '?'
|
||||||
|
* (using Ant directory tasks conventions, also see
|
||||||
|
* "http://jakarta.apache.org/ant/manual/dirtasks.html#defaultexcludes").
|
||||||
|
* Path pattern matching is enhancing regular pattern matching in
|
||||||
|
* supporting extra rule where '**' represent any folder combination.
|
||||||
|
* Special rule: - foo\ is equivalent to foo\** When not case sensitive,
|
||||||
|
* the pattern is assumed to already be lowercased, the name will be
|
||||||
|
* lowercased character per character as comparing.
|
||||||
|
*
|
||||||
|
* @param pattern
|
||||||
|
* the given pattern
|
||||||
|
* @param filepath
|
||||||
|
* the given path
|
||||||
|
* @param isCaseSensitive
|
||||||
|
* to find out whether or not the matching should be case
|
||||||
|
* sensitive
|
||||||
|
* @param pathSeparator
|
||||||
|
* the given path separator
|
||||||
|
* @return true if the pattern matches the filepath using the
|
||||||
|
* pathSepatator, false otherwise
|
||||||
|
*/
|
||||||
|
public static final boolean pathMatch(char[] pattern, char[] filepath,
|
||||||
|
boolean isCaseSensitive, char pathSeparator) {
|
||||||
|
if (filepath == null)
|
||||||
|
return false; // null name cannot match
|
||||||
|
if (pattern == null)
|
||||||
|
return true; // null pattern is equivalent to '*'
|
||||||
|
// offsets inside pattern
|
||||||
|
int pSegmentStart = pattern[0] == pathSeparator ? 1 : 0;
|
||||||
|
int pLength = pattern.length;
|
||||||
|
int pSegmentEnd = indexOf(pathSeparator, pattern, pSegmentStart + 1);
|
||||||
|
if (pSegmentEnd < 0)
|
||||||
|
pSegmentEnd = pLength;
|
||||||
|
// special case: pattern foo\ is equivalent to foo\**
|
||||||
|
boolean freeTrailingDoubleStar = pattern[pLength - 1] == pathSeparator;
|
||||||
|
// offsets inside filepath
|
||||||
|
int fSegmentStart, fLength = filepath.length;
|
||||||
|
if (filepath[0] != pathSeparator) {
|
||||||
|
fSegmentStart = 0;
|
||||||
|
} else {
|
||||||
|
fSegmentStart = 1;
|
||||||
|
}
|
||||||
|
if (fSegmentStart != pSegmentStart) {
|
||||||
|
return false; // both must start with a separator or none.
|
||||||
|
}
|
||||||
|
int fSegmentEnd = indexOf(pathSeparator, filepath, fSegmentStart + 1);
|
||||||
|
if (fSegmentEnd < 0)
|
||||||
|
fSegmentEnd = fLength;
|
||||||
|
// first segments
|
||||||
|
while (pSegmentStart < pLength
|
||||||
|
&& !(pSegmentEnd == pLength && freeTrailingDoubleStar || (pSegmentEnd == pSegmentStart + 2
|
||||||
|
&& pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*'))) {
|
||||||
|
if (fSegmentStart >= fLength)
|
||||||
|
return false;
|
||||||
|
if (!match(pattern, pSegmentStart, pSegmentEnd, filepath,
|
||||||
|
fSegmentStart, fSegmentEnd, isCaseSensitive)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// jump to next segment
|
||||||
|
pSegmentEnd = indexOf(pathSeparator, pattern,
|
||||||
|
pSegmentStart = pSegmentEnd + 1);
|
||||||
|
// skip separator
|
||||||
|
if (pSegmentEnd < 0)
|
||||||
|
pSegmentEnd = pLength;
|
||||||
|
fSegmentEnd = indexOf(pathSeparator, filepath,
|
||||||
|
fSegmentStart = fSegmentEnd + 1);
|
||||||
|
// skip separator
|
||||||
|
if (fSegmentEnd < 0)
|
||||||
|
fSegmentEnd = fLength;
|
||||||
|
}
|
||||||
|
/* check sequence of doubleStar+segment */
|
||||||
|
int pSegmentRestart;
|
||||||
|
if ((pSegmentStart >= pLength && freeTrailingDoubleStar)
|
||||||
|
|| (pSegmentEnd == pSegmentStart + 2
|
||||||
|
&& pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*')) {
|
||||||
|
pSegmentEnd = indexOf(pathSeparator, pattern,
|
||||||
|
pSegmentStart = pSegmentEnd + 1);
|
||||||
|
// skip separator
|
||||||
|
if (pSegmentEnd < 0)
|
||||||
|
pSegmentEnd = pLength;
|
||||||
|
pSegmentRestart = pSegmentStart;
|
||||||
|
} else {
|
||||||
|
if (pSegmentStart >= pLength)
|
||||||
|
return fSegmentStart >= fLength; // true if filepath is done
|
||||||
|
// too.
|
||||||
|
pSegmentRestart = 0; // force fSegmentStart check
|
||||||
|
}
|
||||||
|
int fSegmentRestart = fSegmentStart;
|
||||||
|
checkSegment : while (fSegmentStart < fLength) {
|
||||||
|
if (pSegmentStart >= pLength) {
|
||||||
|
if (freeTrailingDoubleStar)
|
||||||
|
return true;
|
||||||
|
// mismatch - restart current path segment
|
||||||
|
pSegmentEnd = indexOf(pathSeparator, pattern,
|
||||||
|
pSegmentStart = pSegmentRestart);
|
||||||
|
if (pSegmentEnd < 0)
|
||||||
|
pSegmentEnd = pLength;
|
||||||
|
fSegmentRestart = indexOf(pathSeparator, filepath,
|
||||||
|
fSegmentRestart + 1);
|
||||||
|
// skip separator
|
||||||
|
if (fSegmentRestart < 0) {
|
||||||
|
fSegmentRestart = fLength;
|
||||||
|
} else {
|
||||||
|
fSegmentRestart++;
|
||||||
|
}
|
||||||
|
fSegmentEnd = indexOf(pathSeparator, filepath,
|
||||||
|
fSegmentStart = fSegmentRestart);
|
||||||
|
if (fSegmentEnd < 0)
|
||||||
|
fSegmentEnd = fLength;
|
||||||
|
continue checkSegment;
|
||||||
|
}
|
||||||
|
/* path segment is ending */
|
||||||
|
if (pSegmentEnd == pSegmentStart + 2
|
||||||
|
&& pattern[pSegmentStart] == '*'
|
||||||
|
&& pattern[pSegmentStart + 1] == '*') {
|
||||||
|
pSegmentEnd = indexOf(pathSeparator, pattern,
|
||||||
|
pSegmentStart = pSegmentEnd + 1);
|
||||||
|
// skip separator
|
||||||
|
if (pSegmentEnd < 0)
|
||||||
|
pSegmentEnd = pLength;
|
||||||
|
pSegmentRestart = pSegmentStart;
|
||||||
|
fSegmentRestart = fSegmentStart;
|
||||||
|
if (pSegmentStart >= pLength)
|
||||||
|
return true;
|
||||||
|
continue checkSegment;
|
||||||
|
}
|
||||||
|
/* chech current path segment */
|
||||||
|
if (!match(pattern, pSegmentStart, pSegmentEnd, filepath,
|
||||||
|
fSegmentStart, fSegmentEnd, isCaseSensitive)) {
|
||||||
|
// mismatch - restart current path segment
|
||||||
|
pSegmentEnd = indexOf(pathSeparator, pattern,
|
||||||
|
pSegmentStart = pSegmentRestart);
|
||||||
|
if (pSegmentEnd < 0)
|
||||||
|
pSegmentEnd = pLength;
|
||||||
|
fSegmentRestart = indexOf(pathSeparator, filepath,
|
||||||
|
fSegmentRestart + 1);
|
||||||
|
// skip separator
|
||||||
|
if (fSegmentRestart < 0) {
|
||||||
|
fSegmentRestart = fLength;
|
||||||
|
} else {
|
||||||
|
fSegmentRestart++;
|
||||||
|
}
|
||||||
|
fSegmentEnd = indexOf(pathSeparator, filepath,
|
||||||
|
fSegmentStart = fSegmentRestart);
|
||||||
|
if (fSegmentEnd < 0)
|
||||||
|
fSegmentEnd = fLength;
|
||||||
|
continue checkSegment;
|
||||||
|
}
|
||||||
|
// jump to next segment
|
||||||
|
pSegmentEnd = indexOf(pathSeparator, pattern,
|
||||||
|
pSegmentStart = pSegmentEnd + 1);
|
||||||
|
// skip separator
|
||||||
|
if (pSegmentEnd < 0)
|
||||||
|
pSegmentEnd = pLength;
|
||||||
|
fSegmentEnd = indexOf(pathSeparator, filepath,
|
||||||
|
fSegmentStart = fSegmentEnd + 1);
|
||||||
|
// skip separator
|
||||||
|
if (fSegmentEnd < 0)
|
||||||
|
fSegmentEnd = fLength;
|
||||||
|
}
|
||||||
|
return (pSegmentRestart >= pSegmentEnd)
|
||||||
|
|| (fSegmentStart >= fLength && pSegmentStart >= pLength)
|
||||||
|
|| (pSegmentStart == pLength - 2
|
||||||
|
&& pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*')
|
||||||
|
|| (pSegmentStart == pLength && freeTrailingDoubleStar);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answers the first index in the array for which the corresponding
|
||||||
|
* character is equal to toBeFound. Answers -1 if no occurrence of this
|
||||||
|
* character is found. <br>
|
||||||
|
* <br>
|
||||||
|
* For example:
|
||||||
|
* <ol>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* toBeFound = 'c'
|
||||||
|
* array = { ' a', 'b', 'c', 'd' }
|
||||||
|
* result => 2
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* toBeFound = 'e'
|
||||||
|
* array = { ' a', 'b', 'c', 'd' }
|
||||||
|
* result => -1
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* @param toBeFound
|
||||||
|
* the character to search
|
||||||
|
* @param array
|
||||||
|
* the array to be searched
|
||||||
|
* @return the first index in the array for which the corresponding
|
||||||
|
* character is equal to toBeFound, -1 otherwise
|
||||||
|
* @throws NullPointerException
|
||||||
|
* if array is null
|
||||||
|
*/
|
||||||
|
public static final int indexOf(char toBeFound, char[] array) {
|
||||||
|
for (int i = 0; i < array.length; i++)
|
||||||
|
if (toBeFound == array[i])
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answers the first index in the array for which the corresponding
|
||||||
|
* character is equal to toBeFound starting the search at index start.
|
||||||
|
* Answers -1 if no occurrence of this character is found. <br>
|
||||||
|
* <br>
|
||||||
|
* For example:
|
||||||
|
* <ol>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* toBeFound = 'c'
|
||||||
|
* array = { ' a', 'b', 'c', 'd' }
|
||||||
|
* start = 2
|
||||||
|
* result => 2
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* toBeFound = 'c'
|
||||||
|
* array = { ' a', 'b', 'c', 'd' }
|
||||||
|
* start = 3
|
||||||
|
* result => -1
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* toBeFound = 'e'
|
||||||
|
* array = { ' a', 'b', 'c', 'd' }
|
||||||
|
* start = 1
|
||||||
|
* result => -1
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* </li>
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
|
* @param toBeFound
|
||||||
|
* the character to search
|
||||||
|
* @param array
|
||||||
|
* the array to be searched
|
||||||
|
* @param start
|
||||||
|
* the starting index
|
||||||
|
* @return the first index in the array for which the corresponding
|
||||||
|
* character is equal to toBeFound, -1 otherwise
|
||||||
|
* @throws NullPointerException
|
||||||
|
* if array is null
|
||||||
|
* @throws ArrayIndexOutOfBoundsException
|
||||||
|
* if start is lower than 0
|
||||||
|
*/
|
||||||
|
public static final int indexOf(char toBeFound, char[] array, int start) {
|
||||||
|
for (int i = start; i < array.length; i++)
|
||||||
|
if (toBeFound == array[i])
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
2004-03-18 Alain Magloire
|
||||||
|
Change in the hierarchy of the core Model:
|
||||||
|
ICModel
|
||||||
|
ICProject
|
||||||
|
ISourceRoot
|
||||||
|
IBinary
|
||||||
|
IArchive
|
||||||
|
ITranslatioUnit
|
||||||
|
ICContainer
|
||||||
|
The ISourceRoot been added to better separate
|
||||||
|
the files. By default the entire project is the
|
||||||
|
SourceRoot.
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/CElementImageProvider.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/CPluginImages.java
|
||||||
|
* src/org/eclipse/cdt/ui/CElementContentProvider.java
|
||||||
|
|
||||||
2004-03-17 Tanya Wolff
|
2004-03-17 Tanya Wolff
|
||||||
Syntax errors in property files
|
Syntax errors in property files
|
||||||
* CBrowsingMessages.properties
|
* CBrowsingMessages.properties
|
||||||
|
|
|
@ -20,10 +20,13 @@ import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||||
|
@ -38,13 +41,14 @@ import org.eclipse.jface.viewers.Viewer;
|
||||||
* The following C element hierarchy is surfaced by this content provider:
|
* The following C element hierarchy is surfaced by this content provider:
|
||||||
* <p>
|
* <p>
|
||||||
* <pre>
|
* <pre>
|
||||||
C model (<code>ICModel</code>)
|
C model (<code>ICModel</code>)<br>
|
||||||
C project (<code>ICProject</code>)
|
C project (<code>ICProject</code>)<br>
|
||||||
C Container(folders) (<code>ICContainer</code>)
|
Source root (<code>ISourceRoot</code>)<br>
|
||||||
Translation unit (<code>ITranslationUnit</code>)
|
C Container(folders) (<code>ICContainer</code>)<br>
|
||||||
Binary file (<code>IBinary</code>)
|
Translation unit (<code>ITranslationUnit</code>)<br>
|
||||||
Archive file (<code>IArchive</code>)
|
Binary file (<code>IBinary</code>)<br>
|
||||||
Non C Resource file (<code>Object</code>)
|
Archive file (<code>IArchive</code>)<br>
|
||||||
|
Non C Resource file (<code>Object</code>)<br>
|
||||||
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@ -118,36 +122,38 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
* Method declared on ITreeContentProvider.
|
* Method declared on ITreeContentProvider.
|
||||||
*/
|
*/
|
||||||
public Object[] getChildren(Object element) {
|
public Object[] getChildren(Object element) {
|
||||||
if (element instanceof ICElement) {
|
if (!exists(element))
|
||||||
ICElement celement = (ICElement)element;
|
return NO_CHILDREN;
|
||||||
if (celement instanceof ICModel) {
|
|
||||||
return getCProjects((ICModel)celement);
|
if (element instanceof ICModel) {
|
||||||
} else if (celement instanceof ICProject ) {
|
return getCProjects((ICModel)element);
|
||||||
return getCProjectResources((ICProject)celement);
|
} else if (element instanceof ICProject ) {
|
||||||
} else if (celement instanceof ICContainer) {
|
return getSourceRoots((ICProject)element);
|
||||||
return getCResources((ICContainer)celement);
|
} else if (element instanceof ICContainer) {
|
||||||
} else if (celement instanceof ITranslationUnit) {
|
return getCResources((ICContainer)element);
|
||||||
// if we want to get the chidren of a translation unit
|
} else if (element instanceof ITranslationUnit) {
|
||||||
if (fProvideMembers) {
|
// if we want to get the chidren of a translation unit
|
||||||
// if we want to use the working copy of it
|
if (fProvideMembers) {
|
||||||
if(fProvideWorkingCopy){
|
// if we want to use the working copy of it
|
||||||
// if it is not already a working copy
|
if(fProvideWorkingCopy){
|
||||||
if(!(celement instanceof IWorkingCopy)){
|
// if it is not already a working copy
|
||||||
// if it has a valid working copy
|
if(!(element instanceof IWorkingCopy)){
|
||||||
ITranslationUnit tu = (ITranslationUnit)celement;
|
// if it has a valid working copy
|
||||||
IWorkingCopy copy = tu.findSharedWorkingCopy(CUIPlugin.getBufferFactory());
|
ITranslationUnit tu = (ITranslationUnit)element;
|
||||||
if(copy != null) {
|
IWorkingCopy copy = tu.findSharedWorkingCopy(CUIPlugin.getBufferFactory());
|
||||||
return ((IParent)copy).getChildren();
|
if(copy != null) {
|
||||||
}
|
return ((IParent)copy).getChildren();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ((IParent)celement).getChildren();
|
|
||||||
}
|
}
|
||||||
} else if (celement instanceof IParent) {
|
return ((IParent)element).getChildren();
|
||||||
return (Object[])((IParent)celement).getChildren();
|
|
||||||
}
|
}
|
||||||
|
} else if (element instanceof IParent) {
|
||||||
|
return (Object[])((IParent)element).getChildren();
|
||||||
|
} else if (element instanceof IFolder) {
|
||||||
|
return getResources((IFolder)element);
|
||||||
}
|
}
|
||||||
return getResources(element);
|
return NO_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Cdoc)
|
/* (non-Cdoc)
|
||||||
|
@ -162,7 +168,8 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// don't allow to drill down into a compilation unit or class file
|
// don't allow to drill down into a compilation unit or class file
|
||||||
if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive) {
|
if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive
|
||||||
|
|| element instanceof IFile) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,13 +183,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof ICContainer) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element instanceof IParent) {
|
if (element instanceof IParent) {
|
||||||
// when we have C children return true, else we fetch all the children
|
// when we have C children return true, else we fetch all the children
|
||||||
return ((IParent)element).hasChildren();
|
if (((IParent)element).hasChildren()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Object[] children= getChildren(element);
|
Object[] children= getChildren(element);
|
||||||
return (children != null) && children.length > 0;
|
return (children != null) && children.length > 0;
|
||||||
|
@ -199,9 +204,6 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object internalGetParent(Object element) {
|
public Object internalGetParent(Object element) {
|
||||||
if (element instanceof ICElement) {
|
|
||||||
return ((ICElement)element).getParent();
|
|
||||||
}
|
|
||||||
if (element instanceof IResource) {
|
if (element instanceof IResource) {
|
||||||
IResource parent= ((IResource)element).getParent();
|
IResource parent= ((IResource)element).getParent();
|
||||||
ICElement cParent= CoreModel.getDefault().create(parent);
|
ICElement cParent= CoreModel.getDefault().create(parent);
|
||||||
|
@ -210,15 +212,64 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
}
|
}
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
return null;
|
Object parent = null;
|
||||||
|
if (element instanceof ICElement) {
|
||||||
|
parent = ((ICElement)element).getParent();
|
||||||
|
}
|
||||||
|
// if the parent is the default ISourceRoot == ICProject return the project
|
||||||
|
if (parent instanceof ISourceRoot) {
|
||||||
|
if (isProjectSourceRoot((ISourceRoot)parent)) {
|
||||||
|
parent = ((ISourceRoot)parent).getCProject();
|
||||||
|
}
|
||||||
|
} else if (parent instanceof IBinaryContainer || parent instanceof IArchiveContainer) {
|
||||||
|
// If the virtual container is the parent we must find the legitimate parent.
|
||||||
|
if (element instanceof ICElement) {
|
||||||
|
IResource res = ((ICElement)element).getResource();
|
||||||
|
if (res != null) {
|
||||||
|
parent = internalGetParent(res.getParent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object[] getCProjects(ICModel cModel) {
|
protected Object[] getCProjects(ICModel cModel) {
|
||||||
return cModel.getCProjects();
|
return cModel.getCProjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object[] getCProjectResources(ICProject cproject) {
|
protected Object[] getSourceRoots(ICProject cproject) {
|
||||||
Object[] objects = getCResources((ICContainer)cproject);
|
if (!cproject.getProject().isOpen())
|
||||||
|
return NO_CHILDREN;
|
||||||
|
|
||||||
|
List list= new ArrayList();
|
||||||
|
try {
|
||||||
|
ISourceRoot[] roots = cproject.getSourceRoots();
|
||||||
|
// filter out source roots that correspond to projects and
|
||||||
|
// replace them with the package fragments directly
|
||||||
|
for (int i= 0; i < roots.length; i++) {
|
||||||
|
ISourceRoot root= roots[i];
|
||||||
|
if (isProjectSourceRoot(root)) {
|
||||||
|
Object[] children= root.getChildren();
|
||||||
|
for (int k= 0; k < children.length; k++) {
|
||||||
|
list.add(children[k]);
|
||||||
|
}
|
||||||
|
} else if (hasChildren(root)) {
|
||||||
|
list.add(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e1) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Object[] objects = list.toArray();
|
||||||
|
try {
|
||||||
|
Object[] nonC = cproject.getNonCResources();
|
||||||
|
if (nonC != null && nonC.length > 0) {
|
||||||
|
objects = concatenate(objects, cproject.getNonCResources());
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
//Object[] objects = getCResources((ICContainer)cproject);
|
||||||
IArchiveContainer archives = cproject.getArchiveContainer();
|
IArchiveContainer archives = cproject.getArchiveContainer();
|
||||||
if (archives.hasChildren()) {
|
if (archives.hasChildren()) {
|
||||||
objects = concatenate(objects, new Object[] {archives});
|
objects = concatenate(objects, new Object[] {archives});
|
||||||
|
@ -248,31 +299,40 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
return concatenate(children, objects);
|
return concatenate(children, objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] getResources(Object resource) {
|
private Object[] getResources(IFolder folder) {
|
||||||
try {
|
try {
|
||||||
if (resource instanceof IContainer) {
|
Object[] members= folder.members();
|
||||||
Object[] members= ((IContainer)resource).members();
|
List nonCResources= new ArrayList();
|
||||||
List nonCResources= new ArrayList();
|
for (int i= 0; i < members.length; i++) {
|
||||||
for (int i= 0; i < members.length; i++) {
|
Object o= members[i];
|
||||||
Object o= members[i];
|
// A folder can also be a source root in the following case
|
||||||
nonCResources.add(o);
|
// Project
|
||||||
|
// + src <- source folder
|
||||||
|
// + excluded <- excluded from class path
|
||||||
|
// + included <- a new source folder.
|
||||||
|
// Included is a member of excluded, but since it is rendered as a source
|
||||||
|
// folder we have to exclude it as a normal child.
|
||||||
|
if (o instanceof IFolder) {
|
||||||
|
ICElement element= CoreModel.getDefault().create((IFolder)o);
|
||||||
|
if (element instanceof ISourceRoot && element.exists()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nonCResources.toArray();
|
nonCResources.add(o);
|
||||||
}
|
}
|
||||||
|
return nonCResources.toArray();
|
||||||
} catch(CoreException e) {
|
} catch(CoreException e) {
|
||||||
}
|
}
|
||||||
return NO_CHILDREN;
|
return NO_CHILDREN;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
protected boolean isBuildPathChange(ICElementDelta delta) {
|
|
||||||
int flags= delta.getFlags();
|
|
||||||
return (delta.getKind() == ICElementDelta.CHANGED &&
|
|
||||||
((flags & ICElementDelta.F_ADDED_TO_CLASSPATH) != 0) ||
|
|
||||||
((flags & ICElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) ||
|
|
||||||
((flags & ICElementDelta.F_CLASSPATH_REORDER) != 0));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: This method is for internal use only. Clients should not call this method.
|
||||||
|
*/
|
||||||
|
protected boolean isProjectSourceRoot(ISourceRoot root) {
|
||||||
|
IResource resource= root.getResource();
|
||||||
|
return (resource instanceof IProject);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean exists(Object element) {
|
protected boolean exists(Object element) {
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
|
|
|
@ -283,16 +283,16 @@ public class CElementImageProvider {
|
||||||
case ICElement.C_PROJECT:
|
case ICElement.C_PROJECT:
|
||||||
ICProject cp= (ICProject)celement;
|
ICProject cp= (ICProject)celement;
|
||||||
if (cp.getProject().isOpen()) {
|
if (cp.getProject().isOpen()) {
|
||||||
IProject project= cp.getProject();
|
IProject project= cp.getProject();
|
||||||
IWorkbenchAdapter adapter= (IWorkbenchAdapter)project.getAdapter(IWorkbenchAdapter.class);
|
IWorkbenchAdapter adapter= (IWorkbenchAdapter)project.getAdapter(IWorkbenchAdapter.class);
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
ImageDescriptor result= adapter.getImageDescriptor(project);
|
ImageDescriptor result= adapter.getImageDescriptor(project);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
return DESC_OBJ_PROJECT;
|
|
||||||
}
|
}
|
||||||
return DESC_OBJ_PROJECT_CLOSED;
|
return DESC_OBJ_PROJECT;
|
||||||
|
}
|
||||||
|
return DESC_OBJ_PROJECT_CLOSED;
|
||||||
|
|
||||||
case ICElement.C_STRUCT:
|
case ICElement.C_STRUCT:
|
||||||
case ICElement.C_TEMPLATE_STRUCT:
|
case ICElement.C_TEMPLATE_STRUCT:
|
||||||
|
|
|
@ -66,7 +66,8 @@ public class CPluginImages {
|
||||||
public static final String IMG_OBJS_TUNIT= NAME_PREFIX + "c_file_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_TUNIT= NAME_PREFIX + "c_file_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_TUNIT_HEADER= NAME_PREFIX + "h_file_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_TUNIT_HEADER= NAME_PREFIX + "h_file_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_TUNIT_ASM= NAME_PREFIX + "s_file_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_TUNIT_ASM= NAME_PREFIX + "s_file_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_TUNIT_RESOURCE = NAME_PREFIX + "c_resource_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_TUNIT_RESOURCE= NAME_PREFIX + "c_resource_obj.gif"; //$NON-NLS-1$
|
||||||
|
public static final String IMG_OBJS_SOURCE_ROOT= NAME_PREFIX + "cfolder_obj.gif"; // $NON-NLS-1$
|
||||||
public static final String IMG_OBJS_ARCHIVE= NAME_PREFIX + "ar_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_ARCHIVE= NAME_PREFIX + "ar_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_BINARY= NAME_PREFIX + "bin_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_BINARY= NAME_PREFIX + "bin_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_SHLIB= NAME_PREFIX + "shlib_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_SHLIB= NAME_PREFIX + "shlib_obj.gif"; //$NON-NLS-1$
|
||||||
|
@ -109,6 +110,7 @@ public class CPluginImages {
|
||||||
public static final ImageDescriptor DESC_OBJS_TUNIT_HEADER= createManaged(T_OBJ, IMG_OBJS_TUNIT_HEADER);
|
public static final ImageDescriptor DESC_OBJS_TUNIT_HEADER= createManaged(T_OBJ, IMG_OBJS_TUNIT_HEADER);
|
||||||
public static final ImageDescriptor DESC_OBJS_TUNIT_ASM= createManaged(T_OBJ, IMG_OBJS_TUNIT_ASM);
|
public static final ImageDescriptor DESC_OBJS_TUNIT_ASM= createManaged(T_OBJ, IMG_OBJS_TUNIT_ASM);
|
||||||
public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE);
|
public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE);
|
||||||
|
public static final ImageDescriptor DESC_OBJS_SOURCE_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE_ROOT);
|
||||||
public static final ImageDescriptor DESC_OBJS_ARCHIVE= createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
|
public static final ImageDescriptor DESC_OBJS_ARCHIVE= createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
|
||||||
public static final ImageDescriptor DESC_OBJS_BINARY= createManaged(T_OBJ, IMG_OBJS_BINARY);
|
public static final ImageDescriptor DESC_OBJS_BINARY= createManaged(T_OBJ, IMG_OBJS_BINARY);
|
||||||
public static final ImageDescriptor DESC_OBJS_SHLIB= createManaged(T_OBJ, IMG_OBJS_SHLIB);
|
public static final ImageDescriptor DESC_OBJS_SHLIB= createManaged(T_OBJ, IMG_OBJS_SHLIB);
|
||||||
|
|
|
@ -23,12 +23,30 @@ import org.eclipse.cdt.internal.core.model.BinaryContainer;
|
||||||
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A content provider for C elements.
|
||||||
|
* <p>
|
||||||
|
* The following C element hierarchy is surfaced by this content provider:
|
||||||
|
* <p>
|
||||||
|
* <pre>
|
||||||
|
C model (<code>ICModel</code>)<br>
|
||||||
|
C project (<code>ICProject</code>)<br>
|
||||||
|
Virtual binaries container(<code>IBinaryContainery</code>)
|
||||||
|
Virtual archives container(<code>IArchiveContainery</code>)
|
||||||
|
Source root (<code>ISourceRoot</code>)<br>
|
||||||
|
C Container(folders) (<code>ICContainer</code>)<br>
|
||||||
|
Translation unit (<code>ITranslationUnit</code>)<br>
|
||||||
|
Binary file (<code>IBinary</code>)<br>
|
||||||
|
Archive file (<code>IArchive</code>)<br>
|
||||||
|
Non C Resource file (<code>Object</code>)<br>
|
||||||
|
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
public class CElementContentProvider extends BaseCElementContentProvider implements ITreeContentProvider, IElementChangedListener {
|
public class CElementContentProvider extends BaseCElementContentProvider implements ITreeContentProvider, IElementChangedListener {
|
||||||
|
|
||||||
protected StructuredViewer fViewer;
|
protected StructuredViewer fViewer;
|
||||||
|
@ -84,6 +102,16 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isPathEntryChange(ICElementDelta delta) {
|
||||||
|
int flags= delta.getFlags();
|
||||||
|
return (delta.getKind() == ICElementDelta.CHANGED &&
|
||||||
|
((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0 ||
|
||||||
|
(flags & ICElementDelta.F_ADDED_PATHENTRY_LIBRARY) != 0 ||
|
||||||
|
(flags & ICElementDelta.F_ADDED_PATHENTRY_SOURCE) != 0 ||
|
||||||
|
(flags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0 ||
|
||||||
|
(flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a delta recursively. When more than two children are affected the
|
* Processes a delta recursively. When more than two children are affected the
|
||||||
* tree is fully refreshed starting at this node. The delta is processed in the
|
* tree is fully refreshed starting at this node. The delta is processed in the
|
||||||
|
@ -95,9 +123,9 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
ICElement element= delta.getElement();
|
ICElement element= delta.getElement();
|
||||||
|
|
||||||
//System.out.println("Processing " + element);
|
//System.out.println("Processing " + element);
|
||||||
|
|
||||||
// handle open and closing of a solution or project
|
// handle open and closing of a solution or project
|
||||||
if (((flags & ICElementDelta.F_CLOSED) != 0)
|
if (((flags & ICElementDelta.F_CLOSED) != 0) || ((flags & ICElementDelta.F_OPENED) != 0)) {
|
||||||
|| ((flags & ICElementDelta.F_OPENED) != 0)) {
|
|
||||||
postRefresh(element);
|
postRefresh(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,12 +146,7 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == ICElementDelta.CHANGED) {
|
if (kind == ICElementDelta.CHANGED) {
|
||||||
if ((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0) {
|
if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive) {
|
||||||
// throw the towel and do a full refresh of the affected C project.
|
|
||||||
postRefresh(element.getCProject());
|
|
||||||
return;
|
|
||||||
} else if (element instanceof ITranslationUnit ||
|
|
||||||
element instanceof IBinary || element instanceof IArchive) {
|
|
||||||
postRefresh(element);
|
postRefresh(element);
|
||||||
return;
|
return;
|
||||||
} else if (element instanceof ArchiveContainer || element instanceof BinaryContainer) {
|
} else if (element instanceof ArchiveContainer || element instanceof BinaryContainer) {
|
||||||
|
@ -132,6 +155,11 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPathEntryChange(delta)) {
|
||||||
|
// throw the towel and do a full refresh of the affected C project.
|
||||||
|
postRefresh(element.getCProject());
|
||||||
|
}
|
||||||
|
|
||||||
if (delta.getResourceDeltas() != null) {
|
if (delta.getResourceDeltas() != null) {
|
||||||
IResourceDelta[] rd= delta.getResourceDeltas();
|
IResourceDelta[] rd= delta.getResourceDeltas();
|
||||||
for (int i= 0; i < rd.length; i++) {
|
for (int i= 0; i < rd.length; i++) {
|
||||||
|
@ -143,11 +171,6 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
for (int i= 0; i < affectedChildren.length; i++) {
|
for (int i= 0; i < affectedChildren.length; i++) {
|
||||||
processDelta(affectedChildren[i]);
|
processDelta(affectedChildren[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that containers are updated.
|
|
||||||
//if (element instanceof ICModel) {
|
|
||||||
// updateContainer((ICModel)element);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -163,21 +186,9 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
|
|
||||||
// this could be optimized by handling all the added children in the parent
|
// this could be optimized by handling all the added children in the parent
|
||||||
if ((status & IResourceDelta.REMOVED) != 0) {
|
if ((status & IResourceDelta.REMOVED) != 0) {
|
||||||
// if (!(parent instanceof ICContainer)) {
|
|
||||||
// // refresh one level above to deal with empty package filtering properly
|
|
||||||
// postRefresh(internalGetParent(parent));
|
|
||||||
// } else {
|
|
||||||
// postRemove(resource);
|
|
||||||
// }
|
|
||||||
postRemove(resource);
|
postRemove(resource);
|
||||||
}
|
}
|
||||||
if ((status & IResourceDelta.ADDED) != 0) {
|
if ((status & IResourceDelta.ADDED) != 0) {
|
||||||
// if (!(parent instanceof ICContainer)) {
|
|
||||||
// // refresh one level above to deal with empty package filtering properly
|
|
||||||
// postRefresh(internalGetParent(parent));
|
|
||||||
// } else {
|
|
||||||
// postAdd(parent, resource);
|
|
||||||
// }
|
|
||||||
postAdd(parent, resource);
|
postAdd(parent, resource);
|
||||||
}
|
}
|
||||||
IResourceDelta[] affectedChildren= delta.getAffectedChildren();
|
IResourceDelta[] affectedChildren= delta.getAffectedChildren();
|
||||||
|
@ -193,36 +204,6 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private void updateContainer(ICModel root) {
|
|
||||||
// postRunnable(new Runnable() {
|
|
||||||
// public void run () {
|
|
||||||
// Control ctrl= fViewer.getControl();
|
|
||||||
// if (ctrl != null && !ctrl.isDisposed()) {
|
|
||||||
// IStructuredSelection s = (IStructuredSelection)fViewer.getSelection();
|
|
||||||
// if (s.isEmpty())
|
|
||||||
// return;
|
|
||||||
// Object element = s.getFirstElement();
|
|
||||||
// if (element instanceof ICProject) {
|
|
||||||
// updateContainer((ICProject)element);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected boolean updateContainer(ICProject cproject) {
|
|
||||||
// IParent binContainer = cproject.getBinaryContainer();
|
|
||||||
// IParent libContainer = cproject.getArchiveContainer();
|
|
||||||
// if (binContainer != null) {
|
|
||||||
// postContainerRefresh(binContainer, cproject);
|
|
||||||
// }
|
|
||||||
// if (libContainer != null) {
|
|
||||||
// postContainerRefresh(libContainer, cproject);
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private boolean updateContainer(ICElement cfile) {
|
private boolean updateContainer(ICElement cfile) {
|
||||||
IParent container = null;
|
IParent container = null;
|
||||||
ICProject cproject = null;
|
ICProject cproject = null;
|
||||||
|
@ -288,7 +269,6 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl= fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()){
|
if (ctrl != null && !ctrl.isDisposed()){
|
||||||
// fViewer.add(parent, element);
|
|
||||||
fViewer.refresh(parent);
|
fViewer.refresh(parent);
|
||||||
if(parent instanceof IWorkingCopy){
|
if(parent instanceof IWorkingCopy){
|
||||||
fViewer.refresh(((IWorkingCopy)parent).getOriginalElement());
|
fViewer.refresh(((IWorkingCopy)parent).getOriginalElement());
|
||||||
|
@ -306,7 +286,6 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
|
||||||
Control ctrl= fViewer.getControl();
|
Control ctrl= fViewer.getControl();
|
||||||
if (ctrl != null && !ctrl.isDisposed()) {
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
// fViewer.remove(element);
|
|
||||||
Object parent = internalGetParent(element);
|
Object parent = internalGetParent(element);
|
||||||
fViewer.refresh(parent);
|
fViewer.refresh(parent);
|
||||||
if(parent instanceof IWorkingCopy){
|
if(parent instanceof IWorkingCopy){
|
||||||
|
@ -326,35 +305,4 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The workbench has changed. Process the delta and issue updates to the viewer,
|
|
||||||
* inside the UI thread.
|
|
||||||
*
|
|
||||||
* @see IResourceChangeListener#resourceChanged
|
|
||||||
*/
|
|
||||||
//public void resourceChanged(final IResourceChangeEvent event) {
|
|
||||||
// final IResourceDelta delta = event.getDelta();
|
|
||||||
// Control ctrl = viewer.getControl();
|
|
||||||
// if (ctrl != null && !ctrl.isDisposed()) {
|
|
||||||
// ctrl.getDisplay().syncExec(new Runnable() {
|
|
||||||
// public void run() {
|
|
||||||
// processDelta(delta);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the implementation of IWorkbenchAdapter for the given
|
|
||||||
* object. Returns null if the adapter is not defined or the
|
|
||||||
* object is not adaptable.
|
|
||||||
*/
|
|
||||||
protected ICElement getAdapter(Object o) {
|
|
||||||
if (!(o instanceof IAdaptable)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (ICElement)((IAdaptable)o).getAdapter(ICElement.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue