mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Change The Core Model interfaces to throw CModelException when
the fail abnormally. This forces a lot of try{} catch(){} bloks and rethrow to be added in the code.
This commit is contained in:
parent
e2983ad1f8
commit
7ef1a6ed7e
50 changed files with 631 additions and 436 deletions
|
@ -1,3 +1,6 @@
|
|||
2004-04-19 Alain Magloire
|
||||
The CoreModel interfaces throw much more exception, we need to log them for errors.
|
||||
|
||||
2004-04-19 Andrew Niefer
|
||||
added parser/CompleteParseASTTest.testBug59149()
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import junit.framework.TestSuite;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -216,7 +217,7 @@ public class BinaryTests extends TestCase {
|
|||
/***
|
||||
* A quick check to make sure the getBSS function works as expected.
|
||||
*/
|
||||
public void testGetBss(){
|
||||
public void testGetBss() throws CModelException{
|
||||
IBinary bigBinary,littleBinary;
|
||||
bigBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
||||
littleBinary=CProjectHelper.findBinary(testProject, "test_g");
|
||||
|
@ -227,7 +228,7 @@ public class BinaryTests extends TestCase {
|
|||
/***
|
||||
* A quick check to make sure the getBSS function works as expected.
|
||||
*/
|
||||
public void testGetData(){
|
||||
public void testGetData() throws CModelException{
|
||||
IBinary bigBinary,littleBinary;
|
||||
bigBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
||||
littleBinary=CProjectHelper.findBinary(testProject, "test_g");
|
||||
|
@ -241,7 +242,7 @@ public class BinaryTests extends TestCase {
|
|||
* something sane for the most common exe type (x86) and one other (ppc)
|
||||
* This is not a in depth test at all.
|
||||
*/
|
||||
public void testGetCpu() {
|
||||
public void testGetCpu() throws CModelException {
|
||||
IBinary myBinary;
|
||||
myBinary=CProjectHelper.findBinary(testProject, "exebig_g");
|
||||
|
||||
|
@ -254,7 +255,7 @@ public class BinaryTests extends TestCase {
|
|||
/****
|
||||
* A set of simple tests to make sute getNeededSharedLibs seems to be sane
|
||||
*/
|
||||
public void testGetNeededSharedLibs() {
|
||||
public void testGetNeededSharedLibs() throws CModelException {
|
||||
IBinary myBinary;
|
||||
String[] exelibs={"libsocket.so.2", "libc.so.2"};
|
||||
String[] bigexelibs={"libc.so.2"};
|
||||
|
@ -294,7 +295,7 @@ public class BinaryTests extends TestCase {
|
|||
/****
|
||||
* Simple tests for the getSoname method;
|
||||
*/
|
||||
public void testGetSoname() {
|
||||
public void testGetSoname() throws CModelException {
|
||||
IBinary myBinary;
|
||||
String name;
|
||||
myBinary=CProjectHelper.findBinary(testProject, "test_g");
|
||||
|
@ -311,7 +312,7 @@ public class BinaryTests extends TestCase {
|
|||
/***
|
||||
* Simple tests for getText
|
||||
*/
|
||||
public void testGetText() {
|
||||
public void testGetText() throws CModelException {
|
||||
IBinary bigBinary,littleBinary;
|
||||
bigBinary=CProjectHelper.findBinary(testProject, bigexe.getLocation().lastSegment());
|
||||
littleBinary=CProjectHelper.findBinary(testProject, exefile.getLocation().lastSegment());
|
||||
|
@ -323,7 +324,7 @@ public class BinaryTests extends TestCase {
|
|||
/***
|
||||
* Simple tests for the hadDebug call
|
||||
*/
|
||||
public void testHasDebug() {
|
||||
public void testHasDebug() throws CModelException {
|
||||
IBinary myBinary;
|
||||
myBinary = CProjectHelper.findBinary(testProject, "test_g");
|
||||
assertTrue(myBinary.hasDebug());
|
||||
|
@ -336,7 +337,7 @@ public class BinaryTests extends TestCase {
|
|||
/***
|
||||
* Sanity - isBinary and isReadonly should always return true;
|
||||
*/
|
||||
public void testisBinRead() {
|
||||
public void testisBinRead() throws CModelException {
|
||||
IBinary myBinary;
|
||||
myBinary =CProjectHelper.findBinary(testProject, "test_g");
|
||||
assertTrue(myBinary != null);
|
||||
|
@ -347,7 +348,7 @@ public class BinaryTests extends TestCase {
|
|||
/***
|
||||
* Quick tests to make sure isObject works as expected.
|
||||
*/
|
||||
public void testIsObject() {
|
||||
public void testIsObject() throws CModelException {
|
||||
IBinary myBinary;
|
||||
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
||||
assertTrue(myBinary.isObject());
|
||||
|
@ -367,7 +368,7 @@ public class BinaryTests extends TestCase {
|
|||
/***
|
||||
* Quick tests to make sure isSharedLib works as expected.
|
||||
*/
|
||||
public void testIsSharedLib() {
|
||||
public void testIsSharedLib() throws CModelException {
|
||||
IBinary myBinary;
|
||||
|
||||
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
||||
|
@ -388,7 +389,7 @@ public class BinaryTests extends TestCase {
|
|||
/***
|
||||
* Quick tests to make sure isExecutable works as expected.
|
||||
*/
|
||||
public void testIsExecutable() throws InterruptedException {
|
||||
public void testIsExecutable() throws InterruptedException, CModelException {
|
||||
IBinary myBinary;
|
||||
myBinary=CProjectHelper.findObject(testProject, "exetest.o");
|
||||
assertTrue(!myBinary.isExecutable());
|
||||
|
|
|
@ -18,6 +18,7 @@ import junit.framework.Test;
|
|||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IEnumeration;
|
||||
|
@ -85,7 +86,7 @@ public class CModelElementsTests extends TestCase {
|
|||
CProjectHelper.delete(fCProject);
|
||||
}
|
||||
|
||||
public void testCModelElements(){
|
||||
public void testCModelElements() throws CModelException{
|
||||
TranslationUnit tu = new TranslationUnit(fCProject, headerFile);
|
||||
// parse the translation unit to get the elements tree
|
||||
tu.parse();
|
||||
|
@ -119,7 +120,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkArrays(tu);
|
||||
}
|
||||
|
||||
private void checkInclude(IParent tu){
|
||||
private void checkInclude(IParent tu) throws CModelException{
|
||||
List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
|
||||
IInclude inc1 = (IInclude) tuIncludes.get(0);
|
||||
assertEquals(inc1.getElementName(), new String("stdio.h"));
|
||||
|
@ -127,7 +128,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkLineNumbers((CElement)inc1, 2, 2);
|
||||
}
|
||||
|
||||
private void checkMacro(IParent tu){
|
||||
private void checkMacro(IParent tu) throws CModelException{
|
||||
List tuMacros = tu.getChildrenOfType(ICElement.C_MACRO);
|
||||
IMacro mac1 = (IMacro) tuMacros.get(0);
|
||||
assertEquals(mac1.getElementName(), new String("PRINT"));
|
||||
|
@ -135,7 +136,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkLineNumbers((CElement)mac1, 5, 5);
|
||||
}
|
||||
|
||||
private void checkClass(IParent namespace){
|
||||
private void checkClass(IParent namespace) throws CModelException{
|
||||
// MyPackage ---> class: Hello
|
||||
List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
|
||||
IStructure classHello = (IStructure) nsClasses.get(0);
|
||||
|
@ -172,7 +173,7 @@ public class CModelElementsTests extends TestCase {
|
|||
|
||||
checkNestedNamespace(classHello);
|
||||
}
|
||||
private void checkNestedNamespace(IParent classHello){
|
||||
private void checkNestedNamespace(IParent classHello) throws CModelException{
|
||||
// Hello ---> namespace: MyNestedPackage
|
||||
List helloNamespaces = classHello.getChildrenOfType(ICElement.C_NAMESPACE);
|
||||
INamespace myNestedPackage = (INamespace) helloNamespaces.get(0);
|
||||
|
@ -183,7 +184,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkParentNestedClass(myNestedPackage);
|
||||
checkDerivedNestedClass(myNestedPackage);
|
||||
}
|
||||
private void checkParentNestedClass(IParent myNestedPackage){
|
||||
private void checkParentNestedClass(IParent myNestedPackage) throws CModelException{
|
||||
// MyNestedPackage ---> class: Y
|
||||
List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
||||
IStructure classY = (IStructure) nestedClasses.get(0);
|
||||
|
@ -209,7 +210,7 @@ public class CModelElementsTests extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
private void checkDerivedNestedClass(IParent myNestedPackage){
|
||||
private void checkDerivedNestedClass(IParent myNestedPackage) throws CModelException{
|
||||
// MyNestedPackage ---> class: X public Y
|
||||
List nestedClasses = myNestedPackage.getChildrenOfType(ICElement.C_CLASS);
|
||||
IStructure classX = (IStructure) nestedClasses.get(1);
|
||||
|
@ -246,7 +247,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkLineNumbers((CElement)xDoNothing, 50, 50);
|
||||
}
|
||||
|
||||
private void checkEnums(IParent namespace){
|
||||
private void checkEnums(IParent namespace) throws CModelException{
|
||||
// MyPackage ---> enum: Noname
|
||||
List nsEnums = namespace.getChildrenOfType(ICElement.C_ENUMERATION);
|
||||
IEnumeration enum = (IEnumeration) nsEnums.get(0);
|
||||
|
@ -291,7 +292,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkElementOffset((CElement)t);
|
||||
}
|
||||
|
||||
private void checkVariables(IParent namespace){
|
||||
private void checkVariables(IParent namespace) throws CModelException{
|
||||
// MyPackage ---> int v
|
||||
List nsVars = namespace.getChildrenOfType(ICElement.C_VARIABLE);
|
||||
IVariable var1 = (IVariable) nsVars.get(0);
|
||||
|
@ -322,7 +323,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkLineNumbers((CElement)vDecl2, 81, 81);
|
||||
}
|
||||
|
||||
private void checkVariableDeclarations(IParent namespace){
|
||||
private void checkVariableDeclarations(IParent namespace) throws CModelException{
|
||||
// MyPackage ---> extern int evar
|
||||
List nsVarDecls = namespace.getChildrenOfType(ICElement.C_VARIABLE_DECLARATION);
|
||||
IVariableDeclaration vDecl1 = (IVariableDeclaration) nsVarDecls.get(0);
|
||||
|
@ -332,7 +333,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkLineNumbers((CElement)vDecl1, 79, 79);
|
||||
}
|
||||
|
||||
private void checkFunctions(IParent namespace){
|
||||
private void checkFunctions(IParent namespace) throws CModelException{
|
||||
List nsFunctionDeclarations = namespace.getChildrenOfType(ICElement.C_FUNCTION_DECLARATION);
|
||||
|
||||
// MyPackage ---> function: void foo()
|
||||
|
@ -364,7 +365,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkLineNumbers((CElement)f3, 90, 92);
|
||||
}
|
||||
|
||||
private void checkStructs(IParent namespace){
|
||||
private void checkStructs(IParent namespace) throws CModelException{
|
||||
// struct with name
|
||||
List nsStructs = namespace.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure struct1 = (IStructure) nsStructs.get(0);
|
||||
|
@ -424,15 +425,15 @@ public class CModelElementsTests extends TestCase {
|
|||
fail("field visibility should be public!");
|
||||
}
|
||||
|
||||
private void checkTemplates(IParent namespace){
|
||||
private void checkTemplates(IParent namespace) throws CModelException{
|
||||
// template function
|
||||
List functionTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION);
|
||||
FunctionTemplate ft = (FunctionTemplate)functionTemplates.get(0);
|
||||
assertEquals(ft.getElementName(), new String("aTemplatedFunction"));
|
||||
checkElementOffset((CElement)ft);
|
||||
String sig = ft.getTemplateSignature();
|
||||
checkElementOffset(ft);
|
||||
ft.getTemplateSignature();
|
||||
assertEquals(ft.getTemplateSignature(), new String("aTemplatedFunction<A, B>(B) : A"));
|
||||
checkLineNumbers((CElement)ft, 112, 113);
|
||||
checkLineNumbers(ft, 112, 113);
|
||||
|
||||
// template method
|
||||
List nsClasses = namespace.getChildrenOfType(ICElement.C_CLASS);
|
||||
|
@ -441,26 +442,26 @@ public class CModelElementsTests extends TestCase {
|
|||
List methodTemplates = enclosingClass.getChildrenOfType(ICElement.C_TEMPLATE_METHOD);
|
||||
MethodTemplate mt = (MethodTemplate)methodTemplates.get(0);
|
||||
assertEquals(mt.getElementName(), new String("aTemplatedMethod"));
|
||||
checkElementOffset((CElement)mt);
|
||||
checkElementOffset(mt);
|
||||
assertEquals(mt.getTemplateSignature(), new String("aTemplatedMethod<A, B>(B) : A"));
|
||||
checkLineNumbers((CElement)mt, 118, 119 );
|
||||
checkLineNumbers(mt, 118, 119 );
|
||||
assertEquals(mt.getVisibility(), ASTAccessVisibility.PUBLIC);
|
||||
|
||||
// template class
|
||||
List classTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_CLASS);
|
||||
StructureTemplate ct = (StructureTemplate)classTemplates.get(0);
|
||||
assertEquals(ct.getElementName(), new String("myarray"));
|
||||
checkElementOffset((CElement)ct);
|
||||
checkElementOffset(ct);
|
||||
assertEquals(ct.getTemplateSignature(), new String("myarray<T, Tibor>"));
|
||||
checkLineNumbers((CElement)ct, 122, 123);
|
||||
checkLineNumbers(ct, 122, 123);
|
||||
|
||||
// template struct
|
||||
List structTemplates = namespace.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
|
||||
StructureTemplate st = (StructureTemplate)structTemplates.get(0);
|
||||
assertEquals(st.getElementName(), new String("mystruct"));
|
||||
checkElementOffset((CElement)st);
|
||||
checkElementOffset(st);
|
||||
assertEquals(st.getTemplateSignature(), new String("mystruct<T, Tibor>"));
|
||||
checkLineNumbers((CElement)st, 125, 126);
|
||||
checkLineNumbers(st, 125, 126);
|
||||
|
||||
// moved to failed tests
|
||||
// also commented in the source file
|
||||
|
@ -473,7 +474,7 @@ public class CModelElementsTests extends TestCase {
|
|||
// checkLineNumbers((CElement)vt, 128, 129);
|
||||
}
|
||||
|
||||
private void checkArrays(IParent tu){
|
||||
private void checkArrays(IParent tu) throws CModelException{
|
||||
// array variable
|
||||
List variables = tu.getChildrenOfType(ICElement.C_VARIABLE);
|
||||
IVariable arrayVar = (IVariable) variables.get(0);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.model.tests;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.IMacro;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
@ -53,7 +54,7 @@ public class IMacroTests extends IntegratedCModelTest {
|
|||
return "IMacroTest.h";
|
||||
}
|
||||
|
||||
public void testGetElementName() {
|
||||
public void testGetElementName() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
||||
|
||||
|
@ -70,7 +71,7 @@ public class IMacroTests extends IntegratedCModelTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void testGetIdentifierList() {
|
||||
public void testGetIdentifierList() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
||||
|
||||
|
@ -87,7 +88,7 @@ public class IMacroTests extends IntegratedCModelTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void testGetTokenSequence() {
|
||||
public void testGetTokenSequence() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List arrayElements = tu.getChildrenOfType( ITranslationUnit.C_MACRO );
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
return suite;
|
||||
}
|
||||
|
||||
public void testGetChildrenOfTypeStruct() {
|
||||
public void testGetChildrenOfTypeStruct() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List arrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
String[] myExpectedStructs = {
|
||||
|
@ -84,7 +84,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
assertEquals(myExpectedStructs[i], myIStruct.getElementName());
|
||||
}
|
||||
}
|
||||
public void testGetChildrenOfTypeClass() {
|
||||
public void testGetChildrenOfTypeClass() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
|
||||
String[] myExpectedClasses = {
|
||||
|
@ -98,7 +98,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void testGetFields() {
|
||||
public void testGetFields() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
|
@ -116,7 +116,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
}
|
||||
|
||||
// TODO Bug# 38985: remove testGetFieldsHack()
|
||||
public void testGetFieldsHack() {
|
||||
public void testGetFieldsHack() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
|
@ -133,7 +133,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
myExpectedFields[i], myIField.getElementName());
|
||||
}
|
||||
}
|
||||
public void testGetField() {
|
||||
public void testGetField() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
|
@ -154,7 +154,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
assertNull( "Failed on "+i, myIField);
|
||||
}
|
||||
}
|
||||
public void testGetMethods() {
|
||||
public void testGetMethods() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
|
@ -170,7 +170,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
}
|
||||
}
|
||||
// TODO Bug# 38985: remove testGetMethodsHack()
|
||||
public void testGetMethodsHack() {
|
||||
public void testGetMethodsHack() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
|
@ -187,7 +187,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
myExpectedMethods[i], myIMethod.getElementName());
|
||||
}
|
||||
}
|
||||
public void testGetMethod() {
|
||||
public void testGetMethod() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
|
@ -282,7 +282,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
assertFalse( myStructNonClass.isClass() );
|
||||
}
|
||||
|
||||
public void testIsAbstract() {
|
||||
public void testIsAbstract() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElementAbstract = null;
|
||||
ICElement myElementNonAbstract = null;
|
||||
|
@ -394,7 +394,7 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
assertEquals( ICElement.C_VARIABLE, myElement.getElementType() );
|
||||
}
|
||||
|
||||
public void testInnerStruct() {
|
||||
public void testInnerStruct() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElement = null;
|
||||
try {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package org.eclipse.cdt.core.model.tests;
|
||||
|
||||
import org.eclipse.cdt.core.model.*;
|
||||
|
||||
import junit.framework.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -56,7 +57,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
|||
return suite;
|
||||
}
|
||||
|
||||
public List getTemplateMethods(ITranslationUnit tu)
|
||||
public List getTemplateMethods(ITranslationUnit tu) throws CModelException
|
||||
{
|
||||
IStructure myElem = null;
|
||||
try {
|
||||
|
@ -69,7 +70,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
|||
return myElem.getChildrenOfType(ICElement.C_TEMPLATE_METHOD);
|
||||
}
|
||||
|
||||
public void testGetChildrenOfTypeTemplate() {
|
||||
public void testGetChildrenOfTypeTemplate() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
{
|
||||
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT);
|
||||
|
@ -150,7 +151,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
|||
*/ }
|
||||
|
||||
|
||||
public void testGetNumberOfTemplateParameters()
|
||||
public void testGetNumberOfTemplateParameters() throws CModelException
|
||||
{
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList arrayElements = new ArrayList();
|
||||
|
@ -174,7 +175,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
|||
myTemplate.getNumberOfTemplateParameters());
|
||||
}
|
||||
}
|
||||
public void testGetTemplateParameterTypes()
|
||||
public void testGetTemplateParameterTypes() throws CModelException
|
||||
{
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList arrayElements = new ArrayList();
|
||||
|
@ -219,7 +220,7 @@ public class ITemplateTests extends IntegratedCModelTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
public void testGetTemplateSignature()
|
||||
public void testGetTemplateSignature() throws CModelException
|
||||
{
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList arrayElements = new ArrayList();
|
||||
|
|
|
@ -89,7 +89,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
|||
* Simple sanity tests to make sure TranslationUnit.getChildren seems to
|
||||
* basicly work
|
||||
*/
|
||||
public void testGetChildren() {
|
||||
public void testGetChildren() throws CModelException {
|
||||
ITranslationUnit myTranslationUnit;
|
||||
ICElement[] elements;
|
||||
int x;
|
||||
|
@ -142,7 +142,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
|||
/***
|
||||
* Simple sanity tests for the getInclude call
|
||||
*/
|
||||
public void testBug23478A() {
|
||||
public void testBug23478A() throws CModelException {
|
||||
IInclude myInclude;
|
||||
int x;
|
||||
String includes[]={"stdio.h", "unistd.h"};
|
||||
|
|
|
@ -7,6 +7,7 @@ import junit.framework.Assert;
|
|||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IArchive;
|
||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||
|
@ -159,7 +160,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* Attempts to find an archive with the given name in the workspace
|
||||
*/
|
||||
public static IArchive findArchive(ICProject testProject, String name) {
|
||||
public static IArchive findArchive(ICProject testProject, String name) throws CModelException {
|
||||
int x;
|
||||
IArchive[] myArchives;
|
||||
IArchiveContainer archCont;
|
||||
|
@ -181,7 +182,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* Attempts to find a binary with the given name in the workspace
|
||||
*/
|
||||
public static IBinary findBinary(ICProject testProject, String name) {
|
||||
public static IBinary findBinary(ICProject testProject, String name) throws CModelException {
|
||||
IBinaryContainer binCont;
|
||||
int x;
|
||||
IBinary[] myBinaries;
|
||||
|
@ -199,7 +200,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* 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) throws CModelException {
|
||||
ICElement[] sourceRoots = testProject.getChildren();
|
||||
for (int i = 0; i < sourceRoots.length; i++) {
|
||||
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
||||
|
@ -218,7 +219,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* 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) throws CModelException {
|
||||
ICElement[] sourceRoots = testProject.getChildren();
|
||||
for (int i = 0; i < sourceRoots.length; i++) {
|
||||
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
||||
|
@ -237,7 +238,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* 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) throws CModelException {
|
||||
ICElement[] sourceRoots = testProject.getChildren();
|
||||
for (int i = 0; i < sourceRoots.length; i++) {
|
||||
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
||||
|
|
|
@ -1,3 +1,29 @@
|
|||
2004-04-19 Alain Magloire
|
||||
|
||||
It has become necessary to add exception in the interface
|
||||
IParent.getChildren()
|
||||
IParent.getChildrenOfType()
|
||||
IArchive.getBinaries()
|
||||
IBinary.getBinaries()
|
||||
...
|
||||
Now they throw CModelException.
|
||||
Lots of files changed, will not bother enumerated them
|
||||
all in the log.
|
||||
|
||||
* model/org/eclipse/cdt/core/IArchive.java
|
||||
* model/org/eclipse/cdt/core/IArchiveContainer.java
|
||||
* model/org/eclipse/cdt/core/IBinaryContainer.java
|
||||
* model/org/eclipse/cdt/core/IBinaryModule.java
|
||||
* model/org/eclipse/cdt/core/ICModel.java
|
||||
* model/org/eclipse/cdt/core/IParent.java
|
||||
* model/org/eclipse/cdt/core/IStructure.java
|
||||
|
||||
* model/org/eclipse/cdt/internal/core/model/*
|
||||
* browser/org/eclipse/cdt/core/model/TypeInfo.java
|
||||
* search/org/eclipse/cdt/internal/core/search/CSearchScope.java
|
||||
* search/org/eclipse/cdt/internal/core/search/CWorkspaceScope.java
|
||||
|
||||
|
||||
2004-04-19 David Inglis
|
||||
|
||||
Fixed dead lock - don't fire descriptor events with descriptor lock
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Arrays;
|
|||
import java.util.Comparator;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -226,14 +227,17 @@ public class TypeInfo implements ITypeInfo, Comparable
|
|||
private ICElement findCElement(ICElement celement, String name) {
|
||||
if (isValidType(celement.getElementType()) && celement.getElementName().equals(name))
|
||||
return celement;
|
||||
|
||||
if (celement instanceof IParent) {
|
||||
ICElement[] children = ((IParent)celement).getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
ICElement child= children[i];
|
||||
if (isValidType(child.getElementType()) && child.getElementName().equals(name))
|
||||
return child;
|
||||
try {
|
||||
if (celement instanceof IParent) {
|
||||
ICElement[] children = ((IParent)celement).getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
ICElement child= children[i];
|
||||
if (isValidType(child.getElementType()) && child.getElementName().equals(name))
|
||||
return child;
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -14,5 +14,5 @@ public interface IArchive extends ICElement, IParent, IOpenable {
|
|||
* Return the binaries contain in the archive.
|
||||
* It does not actually extract the files.
|
||||
*/
|
||||
public IBinary[] getBinaries();
|
||||
public IBinary[] getBinaries() throws CModelException;
|
||||
}
|
||||
|
|
|
@ -10,5 +10,10 @@ package org.eclipse.cdt.core.model;
|
|||
* while inspecting the project.
|
||||
*/
|
||||
public interface IArchiveContainer extends ICElement, IParent, IOpenable {
|
||||
public IArchive[] getArchives();
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CModelException
|
||||
*/
|
||||
public IArchive[] getArchives() throws CModelException;
|
||||
}
|
||||
|
|
|
@ -11,5 +11,10 @@ package org.eclipse.cdt.core.model;
|
|||
*/
|
||||
public interface IBinaryContainer extends ICElement, IParent, IOpenable {
|
||||
|
||||
public IBinary[] getBinaries();
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CModelException
|
||||
*/
|
||||
public IBinary[] getBinaries() throws CModelException;
|
||||
}
|
||||
|
|
|
@ -9,5 +9,10 @@ package org.eclipse.cdt.core.model;
|
|||
*/
|
||||
public interface IBinaryModule extends IParent, IBinaryElement {
|
||||
|
||||
IBinaryElement[] getBinaryElements();
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CModelException
|
||||
*/
|
||||
IBinaryElement[] getBinaryElements() throws CModelException;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ public interface ICModel extends ICElement, IParent, IOpenable {
|
|||
* Returns the C projects.
|
||||
*
|
||||
*/
|
||||
ICProject[] getCProjects();
|
||||
ICProject[] getCProjects() throws CModelException;
|
||||
|
||||
/**
|
||||
* Returns an array of non-C resources (i.e. non-C projects) in
|
||||
|
|
|
@ -19,12 +19,12 @@ public interface IParent {
|
|||
* @exception CModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
ICElement[] getChildren();
|
||||
ICElement[] getChildren() throws CModelException;
|
||||
|
||||
/**
|
||||
* returns the children of a certain type
|
||||
*/
|
||||
public List getChildrenOfType(int type);
|
||||
public List getChildrenOfType(int type) throws CModelException;
|
||||
/**
|
||||
* Returns whether this element has one or more immediate children.
|
||||
* This is a convenience method, and may be more efficient than
|
||||
|
|
|
@ -11,10 +11,22 @@ package org.eclipse.cdt.core.model;
|
|||
*/
|
||||
public interface IStructure extends IInheritance, IParent, IVariableDeclaration {
|
||||
public IField getField(String name);
|
||||
public IField[] getFields();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CModelException
|
||||
*/
|
||||
public IField[] getFields() throws CModelException;
|
||||
|
||||
public IMethodDeclaration getMethod(String name);
|
||||
public IMethodDeclaration [] getMethods();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CModelException
|
||||
*/
|
||||
public IMethodDeclaration [] getMethods() throws CModelException;
|
||||
|
||||
public boolean isUnion();
|
||||
|
||||
|
@ -22,6 +34,11 @@ public interface IStructure extends IInheritance, IParent, IVariableDeclaration
|
|||
|
||||
public boolean isStruct();
|
||||
|
||||
public boolean isAbstract();
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws CModelException
|
||||
*/
|
||||
public boolean isAbstract() throws CModelException;
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class Archive extends Openable implements IArchive {
|
|||
binaryArchive = ar;
|
||||
}
|
||||
|
||||
public IBinary[] getBinaries() {
|
||||
public IBinary[] getBinaries() throws CModelException {
|
||||
ICElement[] e = getChildren();
|
||||
IBinary[] b = new IBinary[e.length];
|
||||
System.arraycopy(e, 0, b, 0, e.length);
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ArchiveContainer extends Openable implements IArchiveContainer {
|
|||
super (cProject, null, CCorePlugin.getResourceString("CoreModel.ArchiveContainer.Archives"), CElement.C_VCONTAINER); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public IArchive[] getArchives() {
|
||||
public IArchive[] getArchives() throws CModelException {
|
||||
((ArchiveContainerInfo)getElementInfo()).sync();
|
||||
ICElement[] e = getChildren();
|
||||
IArchive[] a = new IArchive[e.length];
|
||||
|
|
|
@ -21,7 +21,7 @@ public class BinaryContainer extends Openable implements IBinaryContainer {
|
|||
super (cProject, null, CCorePlugin.getResourceString("CoreModel.BinaryContainer.Binaries"), CElement.C_VCONTAINER); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public IBinary[] getBinaries() {
|
||||
public IBinary[] getBinaries() throws CModelException {
|
||||
((BinaryContainerInfo)getElementInfo()).sync();
|
||||
ICElement[] e = getChildren();
|
||||
ArrayList list = new ArrayList(e.length);
|
||||
|
|
|
@ -98,7 +98,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceReference#getTranslationUnit()
|
||||
*/
|
||||
public ITranslationUnit getTranslationUnit() {
|
||||
public ITranslationUnit getTranslationUnit() {
|
||||
ITranslationUnit tu = null;
|
||||
CModelManager mgr = CModelManager.getDefault();
|
||||
ICElement parent = getParent();
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BinaryModule extends Parent implements IBinaryModule {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IBinaryModule#getBinaryElements()
|
||||
*/
|
||||
public IBinaryElement[] getBinaryElements() {
|
||||
public IBinaryElement[] getBinaryElements() throws CModelException {
|
||||
ICElement[] e = getChildren();
|
||||
IBinaryElement[] b = new IBinaryElement[e.length];
|
||||
System.arraycopy(e, 0, b, 0, e.length);
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.eclipse.cdt.internal.core.model;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICModel;
|
||||
|
@ -80,18 +81,22 @@ public class BinaryRunner {
|
|||
|
||||
void fireEvents(ICProject cproject, Parent container) {
|
||||
// Fired the event.
|
||||
ICElement[] children = container.getChildren();
|
||||
if (children.length > 0) {
|
||||
CModelManager factory = CModelManager.getDefault();
|
||||
ICElement root = (ICModel) factory.getCModel();
|
||||
CElementDelta cdelta = new CElementDelta(root);
|
||||
cdelta.added(cproject);
|
||||
cdelta.added(container);
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
cdelta.added(children[i]);
|
||||
try {
|
||||
ICElement[] children = container.getChildren();
|
||||
if (children.length > 0) {
|
||||
CModelManager factory = CModelManager.getDefault();
|
||||
ICElement root = (ICModel) factory.getCModel();
|
||||
CElementDelta cdelta = new CElementDelta(root);
|
||||
cdelta.added(cproject);
|
||||
cdelta.added(container);
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
cdelta.added(children[i]);
|
||||
}
|
||||
factory.registerCModelDelta(cdelta);
|
||||
factory.fire(ElementChangedEvent.POST_CHANGE);
|
||||
}
|
||||
factory.registerCModelDelta(cdelta);
|
||||
factory.fire(ElementChangedEvent.POST_CHANGE);
|
||||
} catch (CModelException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class CModel extends Openable implements ICModel {
|
|||
return super.equals(o);
|
||||
}
|
||||
|
||||
public ICProject[] getCProjects() {
|
||||
public ICProject[] getCProjects() throws CModelException {
|
||||
List list = getChildrenOfType(C_PROJECT);
|
||||
ICProject[] array= new ICProject[list.size()];
|
||||
list.toArray(array);
|
||||
|
|
|
@ -331,7 +331,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
IPath rootPath = root.getPath();
|
||||
IPath resourcePath = file.getFullPath();
|
||||
IPath path = resourcePath.removeFirstSegments(rootPath.segmentCount());
|
||||
String fileName = path.lastSegment();
|
||||
path = path.removeLastSegments(1);
|
||||
String[] segments = path.segments();
|
||||
ICContainer cfolder = root;
|
||||
|
@ -427,23 +426,31 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
ArrayList list = new ArrayList(5);
|
||||
if (pinfo != null && pinfo.vBin != null) {
|
||||
if (peekAtInfo(pinfo.vBin) != null) {
|
||||
ICElement[] bins = pinfo.vBin.getChildren();
|
||||
for (int i = 0; i < bins.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(bins[i].getPath())) {
|
||||
//pinfo.vBin.removeChild(bins[i]);
|
||||
list.add(bins[i]);
|
||||
try {
|
||||
ICElement[] bins = pinfo.vBin.getChildren();
|
||||
for (int i = 0; i < bins.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(bins[i].getPath())) {
|
||||
//pinfo.vBin.removeChild(bins[i]);
|
||||
list.add(bins[i]);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
// ..
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pinfo != null && pinfo.vLib != null) {
|
||||
if (peekAtInfo(pinfo.vLib) != null) {
|
||||
ICElement[] ars = pinfo.vLib.getChildren();
|
||||
for (int i = 0; i < ars.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(ars[i].getPath())) {
|
||||
//pinfo.vLib.removeChild(ars[i]);
|
||||
list.add(ars[i]);
|
||||
try {
|
||||
ICElement[] ars = pinfo.vLib.getChildren();
|
||||
for (int i = 0; i < ars.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(ars[i].getPath())) {
|
||||
//pinfo.vLib.removeChild(ars[i]);
|
||||
list.add(ars[i]);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
// ..
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -979,7 +986,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
switch (resource.getType()) {
|
||||
case IResource.ROOT :
|
||||
if (this.cProjectsCache == null) {
|
||||
this.cProjectsCache = this.getCModel().getCProjects();
|
||||
try {
|
||||
this.cProjectsCache = this.getCModel().getCProjects();
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
|
||||
IResourceDelta[] children = delta.getAffectedChildren();
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.eclipse.cdt.internal.core.model;
|
|||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IStructure;
|
||||
import org.eclipse.cdt.core.model.ICModelStatus;
|
||||
|
@ -44,7 +45,7 @@ public class CreateFieldOperation extends CreateMemberOperation {
|
|||
*/
|
||||
protected void initializeDefaultPosition() {
|
||||
IStructure parentElement = getStructure();
|
||||
//try {
|
||||
try {
|
||||
ICElement[] elements = parentElement.getFields();
|
||||
if (elements != null && elements.length > 0) {
|
||||
createAfter(elements[elements.length - 1]);
|
||||
|
@ -54,8 +55,8 @@ public class CreateFieldOperation extends CreateMemberOperation {
|
|||
createBefore(elements[0]);
|
||||
}
|
||||
}
|
||||
//} catch (CModelException e) {
|
||||
//}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -184,21 +184,27 @@ public class DeltaProcessor {
|
|||
CProjectInfo pinfo = (CProjectInfo)factory.peekAtInfo(cproject);
|
||||
if (pinfo != null && pinfo.vBin != null) {
|
||||
if (factory.peekAtInfo(pinfo.vBin) != null) {
|
||||
ICElement[] bins = pinfo.vBin.getChildren();
|
||||
for (int i = 0; i < bins.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(bins[i].getPath())) {
|
||||
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
|
||||
try {
|
||||
ICElement[] bins = pinfo.vBin.getChildren();
|
||||
for (int i = 0; i < bins.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(bins[i].getPath())) {
|
||||
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pinfo != null && pinfo.vLib != null) {
|
||||
if (factory.peekAtInfo(pinfo.vLib) != null) {
|
||||
ICElement[] ars = pinfo.vLib.getChildren();
|
||||
for (int i = 0; i < ars.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(ars[i].getPath())) {
|
||||
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
|
||||
try {
|
||||
ICElement[] ars = pinfo.vLib.getChildren();
|
||||
for (int i = 0; i < ars.length; i++) {
|
||||
if (celement.getPath().isPrefixOf(ars[i].getPath())) {
|
||||
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.eclipse.cdt.internal.core.model;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
public abstract class Parent extends CElement {
|
||||
|
@ -43,7 +44,7 @@ public abstract class Parent extends CElement {
|
|||
* Returns null if the element does not support children
|
||||
* Implementations override this method to support children
|
||||
*/
|
||||
public ICElement[] getChildren() {
|
||||
public ICElement[] getChildren() throws CModelException {
|
||||
CElementInfo info = getElementInfo();
|
||||
if (info != null)
|
||||
return info.getChildren();
|
||||
|
@ -56,7 +57,7 @@ public abstract class Parent extends CElement {
|
|||
* @param type
|
||||
* @return ArrayList
|
||||
*/
|
||||
public List getChildrenOfType(int type){
|
||||
public List getChildrenOfType(int type) throws CModelException {
|
||||
ICElement[] children = getChildren();
|
||||
int size = children.length;
|
||||
ArrayList list = new ArrayList(size);
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.eclipse.cdt.internal.core.model;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -26,29 +27,32 @@ public class SourceMapper {
|
|||
}
|
||||
|
||||
public ITranslationUnit findTranslationUnit(IParent container, String filename) {
|
||||
List list = container.getChildrenOfType(ICElement.C_UNIT);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object o = list.get(i);
|
||||
if (o instanceof ITranslationUnit) {
|
||||
ITranslationUnit tu = (ITranslationUnit)o;
|
||||
// TODO: What about non case sensitive filesystems.
|
||||
if (filename.equals(tu.getElementName())) {
|
||||
return tu;
|
||||
try {
|
||||
List list = container.getChildrenOfType(ICElement.C_UNIT);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object o = list.get(i);
|
||||
if (o instanceof ITranslationUnit) {
|
||||
ITranslationUnit tu = (ITranslationUnit)o;
|
||||
// TODO: What about non case sensitive filesystems.
|
||||
if (filename.equals(tu.getElementName())) {
|
||||
return tu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This to simple, we are not protected against
|
||||
// loop in the file system symbolic links etc ..
|
||||
list = container.getChildrenOfType(ICElement.C_CCONTAINER);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object o = list.get(i);
|
||||
if (o instanceof ICContainer) {
|
||||
ITranslationUnit tu = findTranslationUnit((ICContainer)o, filename);
|
||||
if (tu != null) {
|
||||
return tu;
|
||||
|
||||
// TODO: This to simple, we are not protected against
|
||||
// loop in the file system symbolic links etc ..
|
||||
list = container.getChildrenOfType(ICElement.C_CCONTAINER);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object o = list.get(i);
|
||||
if (o instanceof ICContainer) {
|
||||
ITranslationUnit tu = findTranslationUnit((ICContainer)o, filename);
|
||||
if (tu != null) {
|
||||
return tu;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IField;
|
||||
import org.eclipse.cdt.core.model.IMethodDeclaration;
|
||||
|
@ -24,24 +25,27 @@ public class Structure extends SourceManipulation implements IStructure {
|
|||
super(parent, name, kind);
|
||||
}
|
||||
|
||||
public IField[] getFields() {
|
||||
public IField[] getFields() throws CModelException {
|
||||
List fields = new ArrayList();
|
||||
fields.addAll(getChildrenOfType(ICElement.C_FIELD));
|
||||
return (IField[]) fields.toArray(new IField[fields.size()]);
|
||||
}
|
||||
|
||||
public IField getField(String name) {
|
||||
IField[] fields = getFields();
|
||||
for (int i = 0; i<fields.length; i++){
|
||||
IField field = fields[i];
|
||||
if(field.getElementName().equals(name)){
|
||||
return field;
|
||||
try {
|
||||
IField[] fields = getFields();
|
||||
for (int i = 0; i<fields.length; i++){
|
||||
IField field = fields[i];
|
||||
if(field.getElementName().equals(name)){
|
||||
return field;
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IMethodDeclaration[] getMethods() {
|
||||
public IMethodDeclaration[] getMethods() throws CModelException {
|
||||
List methods = new ArrayList();
|
||||
methods.addAll(getChildrenOfType(ICElement.C_METHOD_DECLARATION));
|
||||
methods.addAll(getChildrenOfType(ICElement.C_METHOD));
|
||||
|
@ -49,12 +53,15 @@ public class Structure extends SourceManipulation implements IStructure {
|
|||
}
|
||||
|
||||
public IMethodDeclaration getMethod(String name) {
|
||||
IMethodDeclaration[] methods = getMethods();
|
||||
for (int i = 0; i<methods.length; i++){
|
||||
IMethodDeclaration method = methods[i];
|
||||
if(method.getElementName().equals(name)){
|
||||
return method;
|
||||
try {
|
||||
IMethodDeclaration[] methods = getMethods();
|
||||
for (int i = 0; i<methods.length; i++){
|
||||
IMethodDeclaration method = methods[i];
|
||||
if(method.getElementName().equals(name)){
|
||||
return method;
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -71,7 +78,7 @@ public class Structure extends SourceManipulation implements IStructure {
|
|||
return getStructureInfo().isStruct();
|
||||
}
|
||||
|
||||
public boolean isAbstract() {
|
||||
public boolean isAbstract() throws CModelException {
|
||||
IMethodDeclaration[] methods = getMethods();
|
||||
for(int i=0; i<methods.length; i++){
|
||||
IMethodDeclaration method = methods[i];
|
||||
|
|
|
@ -79,23 +79,29 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
|
||||
public ICElement getElement(String name ) {
|
||||
ICElement[] celements = getChildren();
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
if (name.equals(celements[i].getElementName())) {
|
||||
return celements[i];
|
||||
try {
|
||||
ICElement[] celements = getChildren();
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
if (name.equals(celements[i].getElementName())) {
|
||||
return celements[i];
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IInclude getInclude(String name) {
|
||||
ICElement[] celements = getChildren();
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
|
||||
if (name.equals(celements[i].getElementName())) {
|
||||
return (IInclude)celements[i];
|
||||
try {
|
||||
ICElement[] celements = getChildren();
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
|
||||
if (name.equals(celements[i].getElementName())) {
|
||||
return (IInclude)celements[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -112,14 +118,17 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
|
||||
public IUsing getUsing(String name) {
|
||||
ICElement[] celements = getChildren();
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
if (celements[i].getElementType() == ICElement.C_USING) {
|
||||
if (name.equals(celements[i].getElementName())) {
|
||||
return (IUsing)celements[i];
|
||||
try {
|
||||
ICElement[] celements = getChildren();
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
if (celements[i].getElementType() == ICElement.C_USING) {
|
||||
if (name.equals(celements[i].getElementName())) {
|
||||
return (IUsing)celements[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -474,10 +483,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
* Parse the buffer contents of this element.
|
||||
*/
|
||||
public Map parse(){
|
||||
removeChildren(this);
|
||||
CModelBuilder modelBuilder = new CModelBuilder(this);
|
||||
boolean quickParseMode = ! (CCorePlugin.getDefault().useStructuralParseMode());
|
||||
try {
|
||||
removeChildren(this);
|
||||
CModelBuilder modelBuilder = new CModelBuilder(this);
|
||||
boolean quickParseMode = ! (CCorePlugin.getDefault().useStructuralParseMode());
|
||||
return modelBuilder.parse(quickParseMode);
|
||||
} catch (Exception e) {
|
||||
// use the debug log for this exception.
|
||||
|
@ -486,7 +495,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
}
|
||||
|
||||
public void removeChildren(ICElement element){
|
||||
public void removeChildren(ICElement element) throws CModelException{
|
||||
if (element instanceof Parent){
|
||||
Parent parent = (Parent) element;
|
||||
ICElement[] children = parent.getChildren();
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IMember;
|
||||
|
@ -61,7 +62,7 @@ public class CSearchScope implements ICSearchScope {
|
|||
this.enclosingProjects[length] = path;
|
||||
}
|
||||
|
||||
public void add(ICProject cProject, boolean includesPrereqProjects, HashSet visitedProjects) {
|
||||
public void add(ICProject cProject, boolean includesPrereqProjects, HashSet visitedProjects) throws CModelException {
|
||||
IProject project = cProject.getProject();
|
||||
if (!project.isAccessible() || !visitedProjects.add(project)) return;
|
||||
|
||||
|
@ -90,7 +91,7 @@ public class CSearchScope implements ICSearchScope {
|
|||
* @param b
|
||||
* @param set
|
||||
*/
|
||||
public void add(IProject project, boolean includesPrereqProjects, HashSet visitedProjects) {
|
||||
public void add(IProject project, boolean includesPrereqProjects, HashSet visitedProjects) throws CModelException {
|
||||
|
||||
if (!project.isAccessible() || !visitedProjects.add(project)) return;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.search;
|
|||
import java.util.HashSet;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -46,9 +47,13 @@ public class CWorkspaceScope extends CSearchScope {
|
|||
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
try {
|
||||
IProject[] projects = CCorePlugin.getWorkspace().getRoot().getProjects();
|
||||
for (int i = 0, length = projects.length; i < length; i++)
|
||||
this.add(projects[i], false, new HashSet(2));
|
||||
} catch (CModelException e) {
|
||||
// ignore
|
||||
}
|
||||
this.needsInitialize = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
2004-04-19 Alain Magloire
|
||||
|
||||
The Core Model interfaces now is throwing CModelException
|
||||
we have to catch them and take appropriate actions.
|
||||
|
||||
* refactor/org/eclipse/cdt/internal/corext/refactorin/rename/RenameElementProcessor.java
|
||||
* src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
|
||||
* src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExtendedCPathBasePage.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsTabBlock.java
|
||||
* src/org/eclipse/cdt/internal/ui/search/CSearchResult.java
|
||||
* src/org/eclipse/cdt/ui/wizards/NewClasWizardPage.java
|
||||
|
||||
2004-04-18 Alain Magloire
|
||||
|
||||
First part to move to Eclipse-3.0 new DocumentProvider scheme
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IEnumeration;
|
||||
|
@ -249,7 +250,7 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
* @see org.eclipse.cdt.internal.corext.refactoring.IRefactoringProcessor#checkActivation()
|
||||
*/
|
||||
public RefactoringStatus checkActivation() throws CoreException {
|
||||
RefactoringStatus result= null;
|
||||
//RefactoringStatus result= null;
|
||||
if (!eligibleForRefactoring(fCElement)) {
|
||||
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.getString("RenameTypeRefactoring.wrong_element")); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -366,9 +367,9 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
|
||||
ITranslationUnit tu = CModelUtil.toWorkingCopy(cu);
|
||||
|
||||
if((tu == null) || (!( tu instanceof ITranslationUnit)))
|
||||
if(tu == null)
|
||||
return;
|
||||
ITranslationUnit wc = (ITranslationUnit)tu;
|
||||
ITranslationUnit wc = tu;
|
||||
String name= RefactoringCoreMessages.getString("RenameTypeRefactoring.update_reference"); //$NON-NLS-1$
|
||||
BasicSearchMatch[] results= fReferences[i].getSearchResults();
|
||||
|
||||
|
@ -513,16 +514,20 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
|||
}
|
||||
private RefactoringStatus checkSiblingsCollision() {
|
||||
RefactoringStatus result= new RefactoringStatus();
|
||||
// get the siblings of the CElement and check if it has the same name
|
||||
ICElement[] siblings= ((IParent)fCElement.getParent()).getChildren();
|
||||
for (int i = 0; i <siblings.length; ++i ){
|
||||
ICElement sibling = (ICElement)siblings[i];
|
||||
if ((sibling.getElementName().equals(fNewElementName))
|
||||
&& (sibling.getElementType() == fCElement.getElementType()) ) {
|
||||
String msg= RefactoringCoreMessages.getFormattedString("RenameTypeRefactoring.member_type_exists", //$NON-NLS-1$
|
||||
new String[]{fNewElementName, fCElement.getParent().getElementName()});
|
||||
result.addError(msg);
|
||||
try {
|
||||
// get the siblings of the CElement and check if it has the same name
|
||||
ICElement[] siblings= ((IParent)fCElement.getParent()).getChildren();
|
||||
for (int i = 0; i <siblings.length; ++i ){
|
||||
ICElement sibling = siblings[i];
|
||||
if ((sibling.getElementName().equals(fNewElementName))
|
||||
&& (sibling.getElementType() == fCElement.getElementType()) ) {
|
||||
String msg= RefactoringCoreMessages.getFormattedString("RenameTypeRefactoring.member_type_exists", //$NON-NLS-1$
|
||||
new String[]{fNewElementName, fCElement.getParent().getElementName()});
|
||||
result.addError(msg);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
result.addFatalError(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,8 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
public Object[] getChildren(Object element) {
|
||||
if (!exists(element))
|
||||
return NO_CHILDREN;
|
||||
|
||||
|
||||
try {
|
||||
if (element instanceof ICModel) {
|
||||
return getCProjects((ICModel)element);
|
||||
} else if (element instanceof ICProject ) {
|
||||
|
@ -158,6 +159,10 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
} else if (element instanceof IFolder) {
|
||||
return getResources((IFolder)element);
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
return NO_CHILDREN;
|
||||
}
|
||||
return NO_CHILDREN;
|
||||
}
|
||||
|
||||
|
@ -189,9 +194,13 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
}
|
||||
|
||||
if (element instanceof IBinaryContainer) {
|
||||
IBinaryContainer cont = (IBinaryContainer)element;
|
||||
IBinary[] bins = getExecutables(cont);
|
||||
return (bins != null) && bins.length > 0;
|
||||
try {
|
||||
IBinaryContainer cont = (IBinaryContainer)element;
|
||||
IBinary[] bins = getExecutables(cont);
|
||||
return (bins != null) && bins.length > 0;
|
||||
} catch (CModelException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (element instanceof IParent) {
|
||||
|
@ -244,7 +253,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
return parent;
|
||||
}
|
||||
|
||||
protected Object[] getCProjects(ICModel cModel) {
|
||||
protected Object[] getCProjects(ICModel cModel) throws CModelException {
|
||||
Object[] objects = cModel.getCProjects();
|
||||
try {
|
||||
Object[] nonC = cModel.getNonCResources();
|
||||
|
@ -257,44 +266,37 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
return objects;
|
||||
}
|
||||
|
||||
protected Object[] getSourceRoots(ICProject cproject) {
|
||||
protected Object[] getSourceRoots(ICProject cproject) throws CModelException {
|
||||
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 {
|
||||
list.add(root);
|
||||
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 {
|
||||
list.add(root);
|
||||
}
|
||||
} catch (CModelException e1) {
|
||||
}
|
||||
|
||||
Object[] objects = list.toArray();
|
||||
try {
|
||||
Object[] nonC = cproject.getNonCResources();
|
||||
if (nonC != null && nonC.length > 0) {
|
||||
nonC = filterNonCResources(nonC, cproject);
|
||||
objects = concatenate(objects, nonC);
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
//
|
||||
Object[] nonC = cproject.getNonCResources();
|
||||
if (nonC != null && nonC.length > 0) {
|
||||
nonC = filterNonCResources(nonC, cproject);
|
||||
objects = concatenate(objects, nonC);
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
protected Object[] getCResources(ICContainer container) {
|
||||
protected Object[] getCResources(ICContainer container) throws CModelException {
|
||||
Object[] objects = null;
|
||||
Object[] children = container.getChildren();
|
||||
try {
|
||||
|
@ -318,7 +320,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
return NO_CHILDREN;
|
||||
}
|
||||
|
||||
private Object[] getResources(IFolder folder) {
|
||||
private Object[] getResources(IFolder folder) throws CModelException {
|
||||
ICProject cproject = CoreModel.getDefault().create(folder.getProject());
|
||||
Object[] members = null;
|
||||
try {
|
||||
|
@ -332,7 +334,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
return filterNonCResources(members, cproject);
|
||||
}
|
||||
|
||||
private Object[] filterNonCResources(Object[] objects, ICProject cproject) {
|
||||
private Object[] filterNonCResources(Object[] objects, ICProject cproject) throws CModelException {
|
||||
ICElement[] binaries = getBinaries(cproject);
|
||||
ICElement[] archives = getArchives(cproject);
|
||||
ISourceRoot[] roots = null;
|
||||
|
@ -410,12 +412,12 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected IBinary[] getExecutables(ICProject cproject) {
|
||||
protected IBinary[] getExecutables(ICProject cproject) throws CModelException {
|
||||
IBinaryContainer container = cproject.getBinaryContainer();
|
||||
return getExecutables(container);
|
||||
}
|
||||
|
||||
protected IBinary[] getExecutables(IBinaryContainer container) {
|
||||
protected IBinary[] getExecutables(IBinaryContainer container) throws CModelException {
|
||||
ICElement[] celements = container.getChildren();
|
||||
ArrayList list = new ArrayList(celements.length);
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
|
@ -431,12 +433,12 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
return bins;
|
||||
}
|
||||
|
||||
protected IBinary[] getBinaries(ICProject cproject) {
|
||||
protected IBinary[] getBinaries(ICProject cproject) throws CModelException {
|
||||
IBinaryContainer container = cproject.getBinaryContainer();
|
||||
return getBinaries(container);
|
||||
}
|
||||
|
||||
protected IBinary[] getBinaries(IBinaryContainer container) {
|
||||
protected IBinary[] getBinaries(IBinaryContainer container) throws CModelException {
|
||||
ICElement[] celements = container.getChildren();
|
||||
ArrayList list = new ArrayList(celements.length);
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
|
@ -450,12 +452,12 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
return bins;
|
||||
}
|
||||
|
||||
protected IArchive[] getArchives(ICProject cproject) {
|
||||
protected IArchive[] getArchives(ICProject cproject) throws CModelException {
|
||||
IArchiveContainer container = cproject.getArchiveContainer();
|
||||
return getArchives(container);
|
||||
}
|
||||
|
||||
protected IArchive[] getArchives(IArchiveContainer container) {
|
||||
protected IArchive[] getArchives(IArchiveContainer container) throws CModelException {
|
||||
ICElement[] celements = container.getChildren();
|
||||
ArrayList list = new ArrayList(celements.length);
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
|
|
|
@ -8,9 +8,11 @@ package org.eclipse.cdt.internal.ui;
|
|||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
/**
|
||||
* An imlementation of the IWorkbenchAdapter for CElements.
|
||||
|
@ -31,9 +33,13 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
*/
|
||||
public Object[] getChildren(Object o) {
|
||||
if (o instanceof IParent) {
|
||||
Object[] members = ((IParent) o).getChildren();
|
||||
if (members != null) {
|
||||
return members;
|
||||
try {
|
||||
Object[] members = ((IParent) o).getChildren();
|
||||
if (members != null) {
|
||||
return members;
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
return fgEmptyArray;
|
||||
|
|
|
@ -45,18 +45,21 @@ public class CViewContentProvider extends CElementContentProvider {
|
|||
public Object[] getChildren(Object element) {
|
||||
Object[] objs = super.getChildren(element);
|
||||
Object[] extras = null;
|
||||
if (element instanceof ICProject) {
|
||||
extras = getProjectChildren((ICProject)element);
|
||||
} else if (element instanceof IBinaryContainer) {
|
||||
extras = getExecutables((IBinaryContainer)element);
|
||||
} else if (element instanceof IArchiveContainer) {
|
||||
extras = getArchives((IArchiveContainer)element);
|
||||
} else if (element instanceof LibraryRefContainer) {
|
||||
extras = ((LibraryRefContainer)element).getChildren(element);
|
||||
} else if (element instanceof IncludeRefContainer) {
|
||||
extras = ((IncludeRefContainer)element).getChildren(element);
|
||||
try {
|
||||
if (element instanceof ICProject) {
|
||||
extras = getProjectChildren((ICProject)element);
|
||||
} else if (element instanceof IBinaryContainer) {
|
||||
extras = getExecutables((IBinaryContainer)element);
|
||||
} else if (element instanceof IArchiveContainer) {
|
||||
extras = getArchives((IArchiveContainer)element);
|
||||
} else if (element instanceof LibraryRefContainer) {
|
||||
extras = ((LibraryRefContainer)element).getChildren(element);
|
||||
} else if (element instanceof IncludeRefContainer) {
|
||||
extras = ((IncludeRefContainer)element).getChildren(element);
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
extras = null;
|
||||
}
|
||||
|
||||
if (extras != null && extras.length > 0) {
|
||||
objs = concatenate(objs, extras);
|
||||
}
|
||||
|
@ -66,7 +69,7 @@ public class CViewContentProvider extends CElementContentProvider {
|
|||
/**
|
||||
* @return
|
||||
*/
|
||||
private Object[] getProjectChildren(ICProject cproject) {
|
||||
private Object[] getProjectChildren(ICProject cproject) throws CModelException {
|
||||
Object[] extras = null;
|
||||
IArchiveContainer archive = cproject.getArchiveContainer();
|
||||
if (getArchives(archive).length > 0) {
|
||||
|
|
|
@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
|
@ -20,6 +21,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
|||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
@ -111,33 +113,36 @@ public class CPathProjectsEntryPage extends CPathBasePage {
|
|||
|
||||
void updateProjectsList(ICProject currCProject) {
|
||||
ICModel cmodel = currCProject.getCModel();
|
||||
ICProject[] cprojects = cmodel.getCProjects();
|
||||
|
||||
List projects = new ArrayList(cprojects.length);
|
||||
|
||||
// a vector remembering all projects that dont have to be added anymore
|
||||
List existingProjects = new ArrayList(cprojects.length);
|
||||
existingProjects.add(currCProject.getProject());
|
||||
|
||||
final List checkedProjects = new ArrayList(cprojects.length);
|
||||
// add the projects-cpentries that are already on the C Path
|
||||
List cpelements = fCPathList.getElements();
|
||||
for (int i = cpelements.size() - 1; i >= 0; i--) {
|
||||
CPListElement cpelem = (CPListElement) cpelements.get(i);
|
||||
if (isEntryKind(cpelem.getEntryKind())) {
|
||||
existingProjects.add(cpelem.getResource());
|
||||
projects.add(cpelem);
|
||||
checkedProjects.add(cpelem);
|
||||
List projects = new ArrayList();
|
||||
final List checkedProjects = new ArrayList();
|
||||
try {
|
||||
ICProject[] cprojects = cmodel.getCProjects();
|
||||
|
||||
// a vector remembering all projects that dont have to be added anymore
|
||||
List existingProjects = new ArrayList(cprojects.length);
|
||||
existingProjects.add(currCProject.getProject());
|
||||
|
||||
// add the projects-cpentries that are already on the C Path
|
||||
List cpelements = fCPathList.getElements();
|
||||
for (int i = cpelements.size() - 1; i >= 0; i--) {
|
||||
CPListElement cpelem = (CPListElement) cpelements.get(i);
|
||||
if (isEntryKind(cpelem.getEntryKind())) {
|
||||
existingProjects.add(cpelem.getResource());
|
||||
projects.add(cpelem);
|
||||
checkedProjects.add(cpelem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < cprojects.length; i++) {
|
||||
IProject proj = cprojects[i].getProject();
|
||||
if (!existingProjects.contains(proj)) {
|
||||
projects.add(new CPListElement(fCurrCProject, IPathEntry.CDT_PROJECT, proj.getFullPath(), proj));
|
||||
|
||||
for (int i = 0; i < cprojects.length; i++) {
|
||||
IProject proj = cprojects[i].getProject();
|
||||
if (!existingProjects.contains(proj)) {
|
||||
projects.add(new CPListElement(fCurrCProject, IPathEntry.CDT_PROJECT, proj.getFullPath(), proj));
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
|
||||
fProjectsList.setElements(projects);
|
||||
fProjectsList.setCheckedElements(checkedProjects);
|
||||
fCurrCProject = currCProject;
|
||||
|
|
|
@ -196,7 +196,14 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
|||
|
||||
public void init(ICProject project, List cPaths) {
|
||||
fCurrCProject = project;
|
||||
List list = new ArrayList(project.getChildrenOfType(ICElement.C_CCONTAINER));
|
||||
List list = new ArrayList();
|
||||
try {
|
||||
List clist = project.getChildrenOfType(ICElement.C_CCONTAINER);
|
||||
list.addAll(clist);
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < list.size(); i++) {
|
||||
if (((ISourceRoot) list.get(i)).getResource() == project.getProject()) {
|
||||
|
|
|
@ -12,12 +12,14 @@ package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
|
@ -52,8 +54,12 @@ public class IncludesSymbolsTabBlock extends AbstractPathOptionBlock {
|
|||
public Object[] getChildren(TreeListDialogField field, Object element) {
|
||||
List children = new ArrayList();
|
||||
if (element instanceof ICContainer) {
|
||||
children.addAll(((ICContainer) element).getChildrenOfType(ICElement.C_CCONTAINER));
|
||||
children.addAll(((ICContainer) element).getChildrenOfType(ICElement.C_UNIT));
|
||||
try {
|
||||
children.addAll(((ICContainer) element).getChildrenOfType(ICElement.C_CCONTAINER));
|
||||
children.addAll(((ICContainer) element).getChildrenOfType(ICElement.C_UNIT));
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
return children.toArray();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IParent;
|
||||
|
@ -61,10 +62,13 @@ public class CSearchResult extends AbstractTextSearchResult {
|
|||
}
|
||||
if (element instanceof IParent) {
|
||||
IParent parent= (IParent) element;
|
||||
|
||||
ICElement[] children= parent.getChildren();
|
||||
for (int i= 0; i < children.length; i++) {
|
||||
collectMatches(matches, children[i]);
|
||||
try {
|
||||
ICElement[] children= parent.getChildren();
|
||||
for (int i= 0; i < children.length; i++) {
|
||||
collectMatches(matches, children[i]);
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
// we will not be tracking these results
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -415,9 +415,12 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
}
|
||||
|
||||
if (elem == null || elem.getElementType() == ICElement.C_MODEL) {
|
||||
ICProject[] projects= CoreModel.create(CUIPlugin.getWorkspace().getRoot()).getCProjects();
|
||||
if (projects.length == 1) {
|
||||
elem= projects[0];
|
||||
try {
|
||||
ICProject[] projects = CoreModel.create(CUIPlugin.getWorkspace().getRoot()).getCProjects();
|
||||
if (projects.length == 1) {
|
||||
elem= projects[0];
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
return elem;
|
||||
|
@ -438,7 +441,6 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
}
|
||||
|
||||
private IProject getSelectionProject(IStructuredSelection selection) {
|
||||
IProject project= null;
|
||||
if (selection != null && !selection.isEmpty()) {
|
||||
Object selectedElement= selection.getFirstElement();
|
||||
if (selectedElement instanceof IAdaptable) {
|
||||
|
@ -452,74 +454,74 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
return null;
|
||||
}
|
||||
|
||||
private ITypeInfo[] findClassElementsInProject(){
|
||||
private ITypeInfo[] findClassElementsInProject(){
|
||||
if(eSelection == null){
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if( elementsOfTypeClassInProject != null ){
|
||||
return elementsOfTypeClassInProject;
|
||||
}
|
||||
|
||||
ICProject cProject= eSelection.getCProject();
|
||||
ICElement[] elements= new ICElement[] { cProject };
|
||||
final ICSearchScope scope= SearchEngine.createCSearchScope(elements, true);
|
||||
final int[] kinds= { ICElement.C_CLASS, ICElement.C_STRUCT };
|
||||
final Collection typeList= new ArrayList();
|
||||
|
||||
if (AllTypesCache.isCacheUpToDate()) {
|
||||
// run without progress monitor
|
||||
AllTypesCache.getTypes(scope, kinds, null, typeList);
|
||||
} else {
|
||||
IRunnableWithProgress runnable= new IRunnableWithProgress() {
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
AllTypesCache.getTypes(scope, kinds, monitor, typeList);
|
||||
if (monitor.isCanceled()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
getContainer().run(true, true, runnable);
|
||||
} catch (InvocationTargetException e) {
|
||||
String title= NewWizardMessages.getString("NewClassWizardPage.getProjectClasses.exception.title"); //$NON-NLS-1$
|
||||
String message= NewWizardMessages.getString("NewClassWizardPage.getProjectClasses.exception.message"); //$NON-NLS-1$
|
||||
ExceptionHandler.handle(e, title, message);
|
||||
return null;
|
||||
} catch (InterruptedException e) {
|
||||
// cancelled by user
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeList.isEmpty()) {
|
||||
elementsOfTypeClassInProject= new ITypeInfo[0];
|
||||
} else {
|
||||
elementsOfTypeClassInProject= (ITypeInfo[]) typeList.toArray(new ITypeInfo[typeList.size()]);
|
||||
Arrays.sort(elementsOfTypeClassInProject, TYPE_NAME_COMPARATOR);
|
||||
ICProject cProject= eSelection.getCProject();
|
||||
ICElement[] elements= new ICElement[] { cProject };
|
||||
final ICSearchScope scope= SearchEngine.createCSearchScope(elements, true);
|
||||
final int[] kinds= { ICElement.C_CLASS, ICElement.C_STRUCT };
|
||||
final Collection typeList= new ArrayList();
|
||||
|
||||
if (AllTypesCache.isCacheUpToDate()) {
|
||||
// run without progress monitor
|
||||
AllTypesCache.getTypes(scope, kinds, null, typeList);
|
||||
} else {
|
||||
IRunnableWithProgress runnable= new IRunnableWithProgress() {
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
AllTypesCache.getTypes(scope, kinds, monitor, typeList);
|
||||
if (monitor.isCanceled()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
getContainer().run(true, true, runnable);
|
||||
} catch (InvocationTargetException e) {
|
||||
String title= NewWizardMessages.getString("NewClassWizardPage.getProjectClasses.exception.title"); //$NON-NLS-1$
|
||||
String message= NewWizardMessages.getString("NewClassWizardPage.getProjectClasses.exception.message"); //$NON-NLS-1$
|
||||
ExceptionHandler.handle(e, title, message);
|
||||
return null;
|
||||
} catch (InterruptedException e) {
|
||||
// cancelled by user
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (typeList.isEmpty()) {
|
||||
elementsOfTypeClassInProject= new ITypeInfo[0];
|
||||
} else {
|
||||
elementsOfTypeClassInProject= (ITypeInfo[]) typeList.toArray(new ITypeInfo[typeList.size()]);
|
||||
Arrays.sort(elementsOfTypeClassInProject, TYPE_NAME_COMPARATOR);
|
||||
}
|
||||
|
||||
return elementsOfTypeClassInProject;
|
||||
}
|
||||
|
||||
protected ITypeInfo chooseBaseClass(){
|
||||
ITypeInfo[] elementsFound= findClassElementsInProject();
|
||||
if (elementsFound == null || elementsFound.length == 0) {
|
||||
String title= NewWizardMessages.getString("NewClassWizardPage.getProjectClasses.noclasses.title"); //$NON-NLS-1$
|
||||
String message= NewWizardMessages.getString("NewClassWizardPage.getProjectClasses.noclasses.message"); //$NON-NLS-1$
|
||||
MessageDialog.openInformation(getShell(), title, message);
|
||||
return null;
|
||||
}
|
||||
|
||||
BaseClassSelectionDialog dialog= new BaseClassSelectionDialog(getShell());
|
||||
dialog.setElements(elementsFound);
|
||||
|
||||
int result= dialog.open();
|
||||
if (result != IDialogConstants.OK_ID)
|
||||
return null;
|
||||
|
||||
return (ITypeInfo)dialog.getFirstResult();
|
||||
protected ITypeInfo chooseBaseClass(){
|
||||
ITypeInfo[] elementsFound= findClassElementsInProject();
|
||||
if (elementsFound == null || elementsFound.length == 0) {
|
||||
String title= NewWizardMessages.getString("NewClassWizardPage.getProjectClasses.noclasses.title"); //$NON-NLS-1$
|
||||
String message= NewWizardMessages.getString("NewClassWizardPage.getProjectClasses.noclasses.message"); //$NON-NLS-1$
|
||||
MessageDialog.openInformation(getShell(), title, message);
|
||||
return null;
|
||||
}
|
||||
|
||||
BaseClassSelectionDialog dialog= new BaseClassSelectionDialog(getShell());
|
||||
dialog.setElements(elementsFound);
|
||||
|
||||
int result= dialog.open();
|
||||
if (result != IDialogConstants.OK_ID)
|
||||
return null;
|
||||
|
||||
return (ITypeInfo)dialog.getFirstResult();
|
||||
}
|
||||
|
||||
// ------------- getter methods for dialog controls -------------
|
||||
|
@ -703,7 +705,6 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
}
|
||||
catch (CoreException e) {
|
||||
// If the file already existed locally, just refresh to get contents
|
||||
int code = e.getStatus().getCode();
|
||||
if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED)
|
||||
fileHandle.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||
else
|
||||
|
@ -778,43 +779,43 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// ------------ Constructing File Contents -----------------
|
||||
protected String constructHeaderFileContent(ITranslationUnit header, String lineDelimiter){
|
||||
protected String constructHeaderFileContent(ITranslationUnit header, String lineDelimiter){
|
||||
StringBuffer text = new StringBuffer();
|
||||
boolean extendingBase = false;
|
||||
String baseClassName = getBaseClassName();
|
||||
String baseClassFileName = ""; //$NON-NLS-1$
|
||||
boolean systemIncludePath= false;
|
||||
|
||||
boolean systemIncludePath= false;
|
||||
|
||||
if((baseClassName != null) && (baseClassName.length() > 0))
|
||||
{
|
||||
extendingBase = true;
|
||||
|
||||
ITypeInfo[] classElements = findClassElementsInProject();
|
||||
ITypeInfo baseClass = findInList(baseClassName, null, classElements);
|
||||
|
||||
if (baseClass != null) {
|
||||
IPath projectPath= null;
|
||||
IPath baseClassPath= null;
|
||||
ICProject cProject= eSelection.getCProject();
|
||||
if (cProject != null) {
|
||||
projectPath= cProject.getPath();
|
||||
baseClassPath= baseClass.resolveIncludePath(cProject);
|
||||
if (baseClassPath != null && projectPath != null && !projectPath.isPrefixOf(baseClassPath)) {
|
||||
systemIncludePath= true;
|
||||
}
|
||||
}
|
||||
if (baseClassPath == null)
|
||||
baseClassPath= resolveRelativePath(baseClass.getPath(), header.getPath(), projectPath);
|
||||
|
||||
if (baseClassPath != null)
|
||||
baseClassFileName= baseClassPath.toString();
|
||||
else
|
||||
baseClassFileName= baseClass.getFileName();
|
||||
} else {
|
||||
|
||||
ITypeInfo[] classElements = findClassElementsInProject();
|
||||
ITypeInfo baseClass = findInList(baseClassName, null, classElements);
|
||||
|
||||
if (baseClass != null) {
|
||||
IPath projectPath= null;
|
||||
IPath baseClassPath= null;
|
||||
ICProject cProject= eSelection.getCProject();
|
||||
if (cProject != null) {
|
||||
projectPath= cProject.getPath();
|
||||
baseClassPath= baseClass.resolveIncludePath(cProject);
|
||||
if (baseClassPath != null && projectPath != null && !projectPath.isPrefixOf(baseClassPath)) {
|
||||
systemIncludePath= true;
|
||||
}
|
||||
}
|
||||
if (baseClassPath == null)
|
||||
baseClassPath= resolveRelativePath(baseClass.getPath(), header.getPath(), projectPath);
|
||||
|
||||
if (baseClassPath != null)
|
||||
baseClassFileName= baseClassPath.toString();
|
||||
else
|
||||
baseClassFileName= baseClass.getFileName();
|
||||
} else {
|
||||
baseClassFileName = baseClassName + HEADER_EXT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isIncludeGuard()){
|
||||
|
@ -830,16 +831,16 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
}
|
||||
|
||||
if(extendingBase){
|
||||
text.append("#include "); //$NON-NLS-1$
|
||||
if (systemIncludePath)
|
||||
text.append('<'); //$NON-NLS-1$
|
||||
else
|
||||
text.append('\"'); //$NON-NLS-1$
|
||||
text.append("#include "); //$NON-NLS-1$
|
||||
if (systemIncludePath)
|
||||
text.append('<'); //$NON-NLS-1$
|
||||
else
|
||||
text.append('\"'); //$NON-NLS-1$
|
||||
text.append(baseClassFileName);
|
||||
if (systemIncludePath)
|
||||
text.append('>'); //$NON-NLS-1$
|
||||
else
|
||||
text.append('\"'); //$NON-NLS-1$
|
||||
if (systemIncludePath)
|
||||
text.append('>'); //$NON-NLS-1$
|
||||
else
|
||||
text.append('\"'); //$NON-NLS-1$
|
||||
text.append(lineDelimiter);
|
||||
text.append(lineDelimiter);
|
||||
}
|
||||
|
@ -895,29 +896,29 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
text.append("_H"); //$NON-NLS-1$
|
||||
text.append(lineDelimiter);
|
||||
}
|
||||
|
||||
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
private IPath resolveRelativePath(IPath baseClassPath, IPath headerPath, IPath projectPath) {
|
||||
if (baseClassPath == null || headerPath == null || projectPath == null)
|
||||
return baseClassPath;
|
||||
|
||||
private IPath resolveRelativePath(IPath baseClassPath, IPath headerPath, IPath projectPath) {
|
||||
if (baseClassPath == null || headerPath == null || projectPath == null)
|
||||
return baseClassPath;
|
||||
|
||||
if (projectPath.isPrefixOf(baseClassPath) && projectPath.isPrefixOf(headerPath)) {
|
||||
int segments= headerPath.matchingFirstSegments(baseClassPath);
|
||||
if (segments > 0) {
|
||||
IPath headerPrefix= headerPath.removeFirstSegments(segments).removeLastSegments(1);
|
||||
IPath baseClassSuffix= baseClassPath.removeFirstSegments(segments);
|
||||
IPath relativeBaseClassPath= new Path(""); //$NON-NLS-1$
|
||||
for (int i= 0; i < headerPrefix.segmentCount(); ++i) {
|
||||
relativeBaseClassPath= relativeBaseClassPath.append(".." + IPath.SEPARATOR); //$NON-NLS-1$
|
||||
}
|
||||
return relativeBaseClassPath.append(baseClassSuffix);
|
||||
}
|
||||
}
|
||||
return baseClassPath;
|
||||
}
|
||||
|
||||
if (projectPath.isPrefixOf(baseClassPath) && projectPath.isPrefixOf(headerPath)) {
|
||||
int segments= headerPath.matchingFirstSegments(baseClassPath);
|
||||
if (segments > 0) {
|
||||
IPath headerPrefix= headerPath.removeFirstSegments(segments).removeLastSegments(1);
|
||||
IPath baseClassSuffix= baseClassPath.removeFirstSegments(segments);
|
||||
IPath relativeBaseClassPath= new Path(""); //$NON-NLS-1$
|
||||
for (int i= 0; i < headerPrefix.segmentCount(); ++i) {
|
||||
relativeBaseClassPath= relativeBaseClassPath.append(".." + IPath.SEPARATOR); //$NON-NLS-1$
|
||||
}
|
||||
return relativeBaseClassPath.append(baseClassSuffix);
|
||||
}
|
||||
}
|
||||
return baseClassPath;
|
||||
}
|
||||
|
||||
protected String constructBodyFileContent(String lineDelimiter){
|
||||
StringBuffer text = new StringBuffer();
|
||||
text.append("#include \""); //$NON-NLS-1$
|
||||
|
@ -928,7 +929,7 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
|
||||
if(isInline())
|
||||
return text.toString();
|
||||
|
||||
|
||||
// constructor
|
||||
text.append(getNewClassName());
|
||||
text.append("::"); //$NON-NLS-1$
|
||||
|
@ -948,7 +949,7 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
text.append(lineDelimiter);
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
|
||||
// ------ validation --------
|
||||
protected void doStatusUpdate() {
|
||||
// status of all used components
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2004-04-19 Alain Magloire
|
||||
|
||||
CoreModel throws Exception.
|
||||
|
||||
* src/org/eclipse/cdt/debug/core/CDebugTarget.java
|
||||
|
||||
2004-04-15 Mikhail Khodjaiants
|
||||
Fix for bug 58711: Breakpoint race condition.
|
||||
To avoid race condition all breakpoint marker updates (like increment/decrement the install count,
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
|||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.core.model.IBinaryModule;
|
||||
|
@ -2027,17 +2028,20 @@ public class CDebugTarget extends CDebugElement
|
|||
private List getCFileGlobals( IParent file )
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
ICElement[] elements = file.getChildren();
|
||||
for ( int i = 0; i < elements.length; ++i )
|
||||
{
|
||||
if ( elements[i] instanceof org.eclipse.cdt.core.model.IVariable )
|
||||
try {
|
||||
ICElement[] elements = file.getChildren();
|
||||
for ( int i = 0; i < elements.length; ++i )
|
||||
{
|
||||
list.add( createGlobalVariable( (org.eclipse.cdt.core.model.IVariable)elements[i] ) );
|
||||
}
|
||||
else if ( elements[i] instanceof org.eclipse.cdt.core.model.IParent )
|
||||
{
|
||||
list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.IParent)elements[i] ) );
|
||||
if ( elements[i] instanceof org.eclipse.cdt.core.model.IVariable )
|
||||
{
|
||||
list.add( createGlobalVariable( (org.eclipse.cdt.core.model.IVariable)elements[i] ) );
|
||||
}
|
||||
else if ( elements[i] instanceof org.eclipse.cdt.core.model.IParent )
|
||||
{
|
||||
list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.IParent)elements[i] ) );
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.eclipse.cdt.debug.testplugin;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||
|
@ -50,7 +51,7 @@ public class CDebugHelper {
|
|||
/**
|
||||
* Creates a ICDISession.
|
||||
*/
|
||||
public static ICDISession createSession(String exe, ICProject project) throws IOException, MIException {
|
||||
public static ICDISession createSession(String exe, ICProject project) throws IOException, MIException, CModelException {
|
||||
MIPlugin mi;
|
||||
String workspacePath= Platform.getLocation().toOSString();
|
||||
ICDISession session;
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.IArchive;
|
||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
|
@ -105,7 +106,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* Attempts to find an archive with the given name in the workspace
|
||||
*/
|
||||
public static IArchive findArchive(ICProject testProject,String name) {
|
||||
public static IArchive findArchive(ICProject testProject,String name) throws CModelException {
|
||||
int x;
|
||||
IArchive[] myArchives;
|
||||
IArchiveContainer archCont;
|
||||
|
@ -122,7 +123,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* Attempts to find a binary with the given name in the workspace
|
||||
*/
|
||||
public static IBinary findBinary(ICProject testProject,String name) {
|
||||
public static IBinary findBinary(ICProject testProject,String name) throws CModelException {
|
||||
IBinaryContainer binCont;
|
||||
int x;
|
||||
IBinary[] myBinaries;
|
||||
|
@ -141,7 +142,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* 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) throws CModelException {
|
||||
int x;
|
||||
ICElement[] myElements;
|
||||
myElements=testProject.getChildren();
|
||||
|
@ -149,18 +150,16 @@ public class CProjectHelper {
|
|||
return(null);
|
||||
for (x=0;x<myElements.length;x++) {
|
||||
if (myElements[x].getElementName().equals(name))
|
||||
if (myElements[x] instanceof ICElement) {
|
||||
if (myElements[x] instanceof IBinary) {
|
||||
return((IBinary) myElements[x]);
|
||||
}
|
||||
}
|
||||
if (myElements[x] instanceof IBinary) {
|
||||
return((IBinary) myElements[x]);
|
||||
}
|
||||
}
|
||||
return(null);
|
||||
}
|
||||
/**
|
||||
* 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) throws CModelException {
|
||||
int x;
|
||||
ICElement[] myElements;
|
||||
myElements=testProject.getChildren();
|
||||
|
@ -168,11 +167,9 @@ public class CProjectHelper {
|
|||
return(null);
|
||||
for (x=0;x<myElements.length;x++) {
|
||||
if (myElements[x].getElementName().equals(name))
|
||||
if (myElements[x] instanceof ICElement) {
|
||||
if (myElements[x] instanceof ITranslationUnit) {
|
||||
return((ITranslationUnit) myElements[x]);
|
||||
}
|
||||
}
|
||||
if (myElements[x] instanceof ITranslationUnit) {
|
||||
return((ITranslationUnit) myElements[x]);
|
||||
}
|
||||
}
|
||||
return(null);
|
||||
}
|
||||
|
@ -182,7 +179,7 @@ public class CProjectHelper {
|
|||
/**
|
||||
* 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) throws CModelException {
|
||||
int x;
|
||||
ICElement[] myElements;
|
||||
myElements=testProject.getChildren();
|
||||
|
@ -190,11 +187,7 @@ public class CProjectHelper {
|
|||
return(null);
|
||||
for (x=0;x<myElements.length;x++) {
|
||||
if (myElements[x].getElementName().equals(name))
|
||||
if (myElements[x] instanceof ICElement) {
|
||||
return((ICElement) myElements[x]);
|
||||
}
|
||||
|
||||
|
||||
return myElements[x];
|
||||
}
|
||||
return(null);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2004-04-19 Alain Magloire
|
||||
Core Model interface throws Exception
|
||||
|
||||
* src/org/eclipse/cdt/launch/internal/CApplicationLaunchShortcut.java
|
||||
* sr/org/eclipse/cdt/launch/ui/CMaintab.java
|
||||
|
||||
2004-04-06 Mikhail Khodjaiants
|
||||
|
||||
Do not remove debugger process from launch.
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
@ -351,12 +352,15 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut, ILaunchFilte
|
|||
if (r != null) {
|
||||
ICProject cproject = CoreModel.getDefault().create(r.getProject());
|
||||
if (cproject != null) {
|
||||
IBinary[] bins = cproject.getBinaryContainer().getBinaries();
|
||||
try {
|
||||
IBinary[] bins = cproject.getBinaryContainer().getBinaries();
|
||||
|
||||
for (int j = 0; j < bins.length; j++) {
|
||||
if (bins[j].isExecutable()) {
|
||||
results.add(bins[j]);
|
||||
for (int j = 0; j < bins.length; j++) {
|
||||
if (bins[j].isExecutable()) {
|
||||
results.add(bins[j]);
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.ArrayList;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
@ -360,7 +361,11 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
final Object[] ret = new Object[1];
|
||||
BusyIndicator.showWhile(display, new Runnable() {
|
||||
public void run() {
|
||||
ret[0] = cproject.getBinaryContainer().getBinaries();
|
||||
try {
|
||||
ret[0] = cproject.getBinaryContainer().getBinaries();
|
||||
} catch (CModelException e) {
|
||||
LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -387,21 +392,24 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
* or null if there was none.
|
||||
*/
|
||||
protected ICProject chooseCProject() {
|
||||
ICProject[] projects;
|
||||
projects = getCProjects();
|
||||
try {
|
||||
ICProject[] projects = getCProjects();
|
||||
|
||||
ILabelProvider labelProvider = new CElementLabelProvider();
|
||||
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
|
||||
dialog.setTitle(LaunchUIPlugin.getResourceString("CMainTab.Project_Selection")); //$NON-NLS-1$
|
||||
dialog.setMessage(LaunchUIPlugin.getResourceString("CMainTab.Choose_project_to_constrain_search_for_program")); //$NON-NLS-1$
|
||||
dialog.setElements(projects);
|
||||
ILabelProvider labelProvider = new CElementLabelProvider();
|
||||
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
|
||||
dialog.setTitle(LaunchUIPlugin.getResourceString("CMainTab.Project_Selection")); //$NON-NLS-1$
|
||||
dialog.setMessage(LaunchUIPlugin.getResourceString("CMainTab.Choose_project_to_constrain_search_for_program")); //$NON-NLS-1$
|
||||
dialog.setElements(projects);
|
||||
|
||||
ICProject cProject = getCProject();
|
||||
if (cProject != null) {
|
||||
dialog.setInitialSelections(new Object[] { cProject });
|
||||
}
|
||||
if (dialog.open() == ElementListSelectionDialog.OK) {
|
||||
return (ICProject) dialog.getFirstResult();
|
||||
ICProject cProject = getCProject();
|
||||
if (cProject != null) {
|
||||
dialog.setInitialSelections(new Object[] { cProject });
|
||||
}
|
||||
if (dialog.open() == ElementListSelectionDialog.OK) {
|
||||
return (ICProject) dialog.getFirstResult();
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -410,7 +418,7 @@ public class CMainTab extends CLaunchConfigurationTab {
|
|||
* Return an array a ICProject whose platform match that of the runtime env.
|
||||
**/
|
||||
|
||||
protected ICProject[] getCProjects() {
|
||||
protected ICProject[] getCProjects() throws CModelException {
|
||||
ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
|
||||
ArrayList list = new ArrayList(cproject.length);
|
||||
boolean isNative = filterPlatform.equals(BootLoader.getOS());
|
||||
|
|
Loading…
Add table
Reference in a new issue