# HG changeset patch # User timkelly # Date 1249511739 18000 # Node ID 49c226a8748eb78c9e75d80adf60e1edab345aab # Parent fcb77f9783d2c410f5e70d8859fd004c67d10b0c CDT 6.0 from cdt_6_0 branch (eclipse.org cvs repository). This overwrites previous CDT 6.0 merges. diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt-feature/feature.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt-feature/feature.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt-feature/feature.xml Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/CdtVariableResolverTest.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,186 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 Andrew Gvozdev (Quoin Inc.) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - *******************************************************************************/ -package org.eclipse.cdt.utils; - -import org.eclipse.cdt.core.cdtvariables.CdtVariableException; -import org.eclipse.cdt.core.cdtvariables.ICdtVariableStatus; -import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; -import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class CdtVariableResolverTest extends TestCase { - - public static Test suite() { - return new TestSuite(CdtVariableResolverTest.class); - } - - private class MockSubstitutor implements IVariableSubstitutor { - - public String resolveToString(String macroName) - throws CdtVariableException { - if (macroName.equals("null")) { - return null; - } - if (macroName.equals("loop")) { - return "${LOOP}"; - } - if (macroName.equals("LOOP")) { - return "${loop}"; - } - if (macroName.equals("throw")) { - throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED,null,null,null); - } - return "#"+macroName+"#"; - } - - public String[] resolveToStringList(String macroName) - throws CdtVariableException { - - if (macroName.equals("null-to-list")) { - return null; - } - - if (macroName.equals("PATH")) { - return new String[] { - "path0", - "path1", - "path2", - }; - } - return new String[] {"@"+macroName+"@"}; - } - - } - private MockSubstitutor mockSubstitutor = new MockSubstitutor(); - - public void testResolveToString() throws CdtVariableException { - - assertEquals("",CdtVariableResolver.resolveToString(null, mockSubstitutor)); - assertEquals("",CdtVariableResolver.resolveToString("", mockSubstitutor)); - assertEquals("Text",CdtVariableResolver.resolveToString("Text", mockSubstitutor)); - assertEquals("#Macro#",CdtVariableResolver.resolveToString("${Macro}", mockSubstitutor)); - assertEquals("",CdtVariableResolver.resolveToString("${}", mockSubstitutor)); - assertEquals("${Nomacro",CdtVariableResolver.resolveToString("${Nomacro", mockSubstitutor)); - assertEquals("Nomacro}",CdtVariableResolver.resolveToString("Nomacro}", mockSubstitutor)); - assertEquals("Text/#Macro#",CdtVariableResolver.resolveToString("Text/${Macro}", mockSubstitutor)); - assertEquals("#Macro#/Text",CdtVariableResolver.resolveToString("${Macro}/Text", mockSubstitutor)); - assertEquals("#Macro1#/#Macro2#",CdtVariableResolver.resolveToString("${Macro1}/${Macro2}", mockSubstitutor)); - assertEquals("${Macro}",CdtVariableResolver.resolveToString("\\${Macro}", mockSubstitutor)); - assertEquals("${Macro}:#Macro#",CdtVariableResolver.resolveToString("\\${Macro}:${Macro}", mockSubstitutor)); - assertEquals("\\#Macro#",CdtVariableResolver.resolveToString("\\\\${Macro}", mockSubstitutor)); - assertEquals("\\${Macro}",CdtVariableResolver.resolveToString("\\\\\\${Macro}", mockSubstitutor)); - assertEquals("C:\\tmp\\",CdtVariableResolver.resolveToString("C:\\tmp\\", mockSubstitutor)); - - assertEquals("#workspace_loc:#Macro##",CdtVariableResolver.resolveToString("${workspace_loc:${Macro}}", mockSubstitutor)); - assertEquals("#workspace_loc:#Macro1#/#Macro2##",CdtVariableResolver.resolveToString("${workspace_loc:${Macro1}/${Macro2}}", mockSubstitutor)); - assertEquals("#workspace_loc:#project_loc:/#Macro###",CdtVariableResolver.resolveToString("${workspace_loc:${project_loc:/${Macro}}}", mockSubstitutor)); - - } - - public void testExceptions() throws CdtVariableException { - // test exceptions - try { - assertEquals("Unreacheable",CdtVariableResolver.resolveToString("${null}", mockSubstitutor)); - fail("Exception expected"); - } catch (CdtVariableException e) { - // expected behavior - } - try { - assertEquals("Unreacheable",CdtVariableResolver.resolveToString("${throw}", mockSubstitutor)); - fail("Exception expected"); - } catch (CdtVariableException e) { - // expected behavior - } - - // make sure there is no infinite loop - assertEquals("${LOOP}",CdtVariableResolver.resolveToString("${loop}", mockSubstitutor)); - } - - public void testAsList() throws CdtVariableException { - // Syntax ${var} implies using substitutor.resolveToStringList(...) - { - String[] list = CdtVariableResolver.resolveToStringList("${PATH}", mockSubstitutor); - - assertNotNull(list); - assertEquals(3,list.length); - assertEquals("path0",list[0]); - assertEquals("path1",list[1]); - assertEquals("path2",list[2]); - } - - // uses substitutor.resolveToString(...) - { - String[] list = CdtVariableResolver.resolveToStringList("Text", mockSubstitutor); - - assertNotNull(list); - assertEquals(1,list.length); - assertEquals("Text",list[0]); - } - - // uses substitutor.resolveToString(...) - { - String[] list = CdtVariableResolver.resolveToStringList("Text${PATH}", mockSubstitutor); - - assertNotNull(list); - assertEquals(1,list.length); - assertEquals("Text#PATH#",list[0]); - } - - // uses substitutor.resolveToString(...) - { - String[] list = CdtVariableResolver.resolveToStringList("${PATH}${PATH}", mockSubstitutor); - - assertNotNull(list); - assertEquals(1,list.length); - assertEquals("#PATH##PATH#",list[0]); - } - - // empty var delivers zero-length array - { - String[] list = CdtVariableResolver.resolveToStringList("${}", mockSubstitutor); - - assertNotNull(list); - assertEquals(0,list.length); - } - - // test exceptions - try { - CdtVariableResolver.resolveToStringList("${null-to-list}", mockSubstitutor); - fail("Exception expected"); - } catch (CdtVariableException e) { - // expected behavior - } - } - - // These tests are very basic not intended to be comprehensive - public void testOtherBasic() throws CdtVariableException { - assertEquals("${Macro}",CdtVariableResolver.createVariableReference("Macro")); - - { - String[] list = { "1","2","3" }; - assertEquals("1;2;3",CdtVariableResolver.convertStringListToString(list,";")); - } - - { - String[] list = { "${PATH}", "${Macro}" }; - String[] result = CdtVariableResolver.resolveStringListValues(list, mockSubstitutor, true); - assertEquals(4,result.length); - assertEquals("path0",result[0]); - assertEquals("path1",result[1]); - assertEquals("path2",result[2]); - assertEquals("@Macro@",result[3]); - } - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -669,28 +669,28 @@ parse(getAboveComment(), ParserLanguage.CPP, false, 0); } - // class X; // X is an incomplete type - // extern X* xp; // xp is a pointer to an incomplete type - // extern int arr[]; // the type of arr is incomplete - // typedef int UNKA[]; // UNKA is an incomplete type - // UNKA* arrp; // arrp is a pointer to an incomplete type - // UNKA** arrpp; - // void foo() { - // xp++; //ill-formed: X is incomplete - // arrp++; //ill-formed: incomplete type - // arrpp++; //OK: sizeof UNKA* is known - // } - // struct X { - // int i; - // }; // now X is a complete type - // int arr[10]; // now the type of arr is complete - // X x; - // void bar() { - // xp = &x; // OK; type is ''pointer to X'' - // arrp = &arr; // ill-formed: different types - // xp++; //OK: X is complete - // arrp++; //ill-formed: UNKA can't be completed - // } + // class X; // X is an incomplete type + // extern X* xp; // xp is a pointer to an incomplete type + // extern int arr[]; // the type of arr is incomplete + // typedef int UNKA[]; // UNKA is an incomplete type + // UNKA* arrp; // arrp is a pointer to an incomplete type + // UNKA** arrpp; + // void foo() + // { + // xp++; //illformed: X is incomplete + // arrp++; //illformed: incomplete type + // arrpp++; //OK: sizeof UNKA* is known + // } + // struct X { int i; }; // now X is a complete type + // int arr[10]; // now the type of arr is complete + // X x; + // void bar() + // { + // xp = &x; // OK; type is ''pointer to X'' + // arrp = &arr; // illformed: different types + // xp++; //OK: X is complete + // arrp++; //illformed: UNKA can't be completed + // } public void test3_9s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -797,7 +797,7 @@ assertNull(newExpr.getNewPlacement()); assertNull(newExpr.getNewInitializer()); IASTTypeId typeid= newExpr.getTypeId(); - isTypeEqual(CPPVisitor.createType(typeid), "int (* [10])()"); + isTypeEqual(CPPVisitor.createType(typeid), "int () * []"); } // typedef int T; @@ -835,7 +835,7 @@ newExpr= (ICPPASTNewExpression) expr; assertNull(newExpr.getNewPlacement()); assertNull(newExpr.getNewInitializer()); - isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int [5]"); + isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int []"); // new (2,f) T[5]; expr= getExpressionOfStatement(fdef, 3); @@ -843,7 +843,7 @@ newExpr= (ICPPASTNewExpression) expr; assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class); assertNull(newExpr.getNewInitializer()); - isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int [5]"); + isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int []"); } // int n=2; @@ -1858,7 +1858,7 @@ BindingAssertionHelper ba= new BindingAssertionHelper(code, true); IFunction f= ba.assertNonProblem("f", 1, IFunction.class); - isTypeEqual(f.getType(), "void (int (*)(C))"); + isTypeEqual(f.getType(), "void (int (C) *)"); } // class C { }; @@ -1869,7 +1869,7 @@ parse(code, ParserLanguage.CPP, true, 0); BindingAssertionHelper ba= new BindingAssertionHelper(code, true); IFunction f= ba.assertNonProblem("h", 1, IFunction.class); - isTypeEqual(f.getType(), "void (int * (*)(C *))"); + isTypeEqual(f.getType(), "void (int * (C *) *)"); } // namespace A { @@ -2054,7 +2054,7 @@ // *pi, // f(), // *fpi(int), - // (*pif)(const char*, const char*), + // (*pif)(const char*, const char*); // (*fpif(int))(int); public void test8_3_5s9a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java Wed Aug 05 17:35:39 2009 -0500 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM Corporation) - initial API and implementation + * IBM Corporation - initial API and implementation * Ed Swartz (Nokia) * Markus Schorn (Wind River Systems) * Andrew Ferguson (Symbian) @@ -121,6 +121,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.parser.ParserException; +/** + * @author aniefer + */ public class AST2CPPTests extends AST2BaseTest { public AST2CPPTests() { @@ -1086,7 +1089,7 @@ IFunction g = (IFunction) collector.getName(8).resolveBinding(); isTypeEqual(g.getType(), "void (char *)"); IFunction h = (IFunction) collector.getName(12).resolveBinding(); - isTypeEqual(h.getType(), "void (int (*)())"); + isTypeEqual(h.getType(), "void (int () *)"); assertInstances(collector, f, 3); assertInstances(collector, g, 2); @@ -5743,10 +5746,10 @@ checkNewExpression(fdef, 10, IASTIdExpression.class, "int", IASTExpressionList.class); checkNewExpression(fdef, 11, IASTIdExpression.class, "int", IASTIdExpression.class); - checkNewExpression(fdef, 12, null, "int [][]", null); - checkNewExpression(fdef, 13, IASTIdExpression.class, "int [][]", null); - checkNewExpression(fdef, 14, null, "int [][]", null); - checkNewExpression(fdef, 15, IASTIdExpression.class, "int [][]", null); + checkNewExpression(fdef, 12, null, "int [] []", null); + checkNewExpression(fdef, 13, IASTIdExpression.class, "int [] []", null); + checkNewExpression(fdef, 14, null, "int [] []", null); + checkNewExpression(fdef, 15, IASTIdExpression.class, "int [] []", null); } private void checkNewExpression(IASTFunctionDefinition fdef, int i_expr, Class placement, String type, Class init) { @@ -7052,6 +7055,25 @@ parseAndCheckBindings(code, ParserLanguage.CPP); } + // class C { + // C& operator()() {return *this;} + // }; + // void test() { + // C c; + // c()()()()()()()()()()()()()(); + // } + public void testNestedOverloadedFunctionCalls_Bug283324() throws Exception { + final String code = getAboveComment(); + IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.CPP); + IASTFunctionDefinition test= getDeclaration(tu, 1); + IASTExpressionStatement stmt= getStatement(test, 1); + long now= System.currentTimeMillis(); + IType t= stmt.getExpression().getExpressionType(); + assertInstance(t, ICPPReferenceType.class); + final long time = System.currentTimeMillis() - now; + assertTrue("Lasted " + time + "ms", time < 5000); + } + // struct A { int a; }; // struct B { int b; }; @@ -7122,7 +7144,7 @@ // foo(L'a'); // } public void testWideCharacterLiteralTypes_Bug270892() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); @@ -7180,122 +7202,53 @@ parseAndCheckBindings(code, ParserLanguage.CPP); } - // int foo(int x); - // int bar(int x); + // typedef enum enum_name enum_name; + public void testTypedefRecursion_285457() throws Exception { + BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); + ba.assertProblem("enum_name", 9); + } + + // class A { + // friend inline void m(A p) {} + // }; // - // typedef int (*fp)(int); - // struct A { - // operator fp() { return foo; } - // } a; - // - // int i = bar(a(1)); // problem on bar - public void testCallToObjectOfClassType_267389() throws Exception { + // void test(A a) { + // m(a); + // } + public void _testInlineFriendFunction_284690() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, ParserLanguage.CPP); } - - // typedef int T; - // class C { - // C(T); // ctor - // C(s); // instance s; - // }; - public void testDeclarationAmbiguity_Bug269953() throws Exception { - final String code = getAboveComment(); - IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.CPP); - ICPPASTCompositeTypeSpecifier ct= getCompositeType(tu, 1); - ICPPClassType c= (ICPPClassType) ct.getName().resolveBinding(); - - ICPPMethod[] methods= c.getDeclaredMethods(); - assertEquals(1, methods.length); - assertEquals("C", methods[0].getName()); - - ICPPField[] fields= c.getDeclaredFields(); - assertEquals(1, fields.length); - assertEquals("s", fields[0].getName()); - } - - // class C3 { - // C3(int); - // }; - // typedef C3 T3; - // T3::C3(int) { - // } - public void testCTorWithTypedef_Bug269953() throws Exception { - final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.CPP); - } - - // template class Compare { - // Compare(); - // ~Compare(); - // bool check; - // }; - // typedef Compare MY_COMPARE; - // template<> MY_COMPARE::Compare() {} - public void testTemplateCTorWithTypedef_Bug269953() throws Exception { - final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.CPP); - } - - // class IBase { - // public: - // virtual void base() = 0; - // }; + // void f(int t); + // void f(unsigned int t); + // void f(long t); + // + // enum IntEnum { i1 }; + // enum UnsignedEnum { u1 = 0x7FFFFFFF, u2 }; + // enum LongEnum { l1 = -1, l2 = 0x7FFFFFFF, l3 }; // - // class IDerived : virtual public IBase { - // public: - // virtual void derived() = 0; - // }; - // - // class BaseImplHelper : virtual public IBase { - // public: - // virtual void base() {} - // }; - // - // class Derived : virtual public IDerived, public BaseImplHelper { - // public: - // virtual void derived() {} - // }; - // - // int main() { - // Derived d; - // d.base(); // Parser log reports ambiguity on 'base' - // return 0; + // void test() { + // f(i1); + // f(u1); + // f(l1); // } - public void testHiddenVirtualBase_Bug282993() throws Exception { - final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.CPP); - } - - // class C { - // C& operator()() {return *this;} - // }; - // void test() { - // C c; - // c()()()()()()()()()()()()()(); - // } - public void testNestedOverloadedFunctionCalls_Bug283324() throws Exception { - final String code = getAboveComment(); - IASTTranslationUnit tu= parseAndCheckBindings(code, ParserLanguage.CPP); - IASTFunctionDefinition test= getDeclaration(tu, 1); - IASTExpressionStatement stmt= getStatement(test, 1); - long now= System.currentTimeMillis(); - IType t= stmt.getExpression().getExpressionType(); - assertInstance(t, ICPPReferenceType.class); - final long time = System.currentTimeMillis() - now; - assertTrue("Lasted " + time + "ms", time < 5000); - } - - // class A { - // friend inline void m(A p1, A p2) {} - // }; - // - // void test(A a1, A a2) { - // m(a1, a2); - // } - public void _testInlineFriendFunction_284690() throws Exception { - final String code = getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.CPP); + public void testEnumToIntConversion_285368() throws Exception { + BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); + ICPPFunction f1 = ba.assertNonProblem("f(i1)", 1, ICPPFunction.class); + IType t1 = f1.getType().getParameterTypes()[0]; + assertTrue(t1 instanceof ICPPBasicType); + assertEquals(IBasicType.t_int, ((ICPPBasicType) t1).getType()); + assertEquals(0, ((ICPPBasicType) t1).getQualifierBits()); + ICPPFunction f2 = ba.assertNonProblem("f(u1)", 1, ICPPFunction.class); + IType t2 = f2.getType().getParameterTypes()[0]; + assertTrue(t2 instanceof ICPPBasicType); + assertEquals(IBasicType.t_int, ((ICPPBasicType) t2).getType()); + assertEquals(ICPPBasicType.IS_UNSIGNED, ((ICPPBasicType) t2).getQualifierBits()); + ICPPFunction f3 = ba.assertNonProblem("f(l1)", 1, ICPPFunction.class); + IType t3 = f3.getType().getParameterTypes()[0]; + assertTrue(t3 instanceof ICPPBasicType); + assertEquals(IBasicType.t_int, ((ICPPBasicType) t3).getType()); + assertEquals(ICPPBasicType.IS_LONG, ((ICPPBasicType) t3).getQualifierBits()); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1203,10 +1203,8 @@ buffer.append("for (int j = 0, k = n*m+300; j < k; j++)\n"); //$NON-NLS-1$ buffer.append("// a is a pointer to a VLA with n*m+300 elements\n"); //$NON-NLS-1$ buffer.append("a[i][j] += x;\n"); //$NON-NLS-1$ - buffer.append("}\n"); - String code = buffer.toString(); //$NON-NLS-1$ - // no valid c++ code - parse(code, ParserLanguage.C, true, 0); + buffer.append("}\n"); //$NON-NLS-1$ + parseCandCPP(buffer.toString(), true, 0); } /** diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java Wed Aug 05 17:35:39 2009 -0500 @@ -1971,7 +1971,8 @@ ICPPSpecialization spec = (ICPPSpecialization) col.getName(9).resolveBinding(); assertSame(spec.getSpecializedBinding(), ctor); - ICPPParameter c = (ICPPParameter) col.getName(10).resolveBinding(); + ICPPSpecialization c = (ICPPSpecialization) col.getName(10).resolveBinding(); + assertSame(c.getSpecializedBinding(), g); assertSame(blah, col.getName(11).resolveBinding()); assertSame(c, col.getName(12).resolveBinding()); @@ -1979,7 +1980,8 @@ ICPPSpecialization spec2 = (ICPPSpecialization) col.getName(13).resolveBinding(); assertSame(spec.getSpecializedBinding(), ctor); - ICPPParameter c2 = (ICPPParameter) col.getName(14).resolveBinding(); + ICPPSpecialization c2 = (ICPPSpecialization) col.getName(14).resolveBinding(); + assertSame(c2.getSpecializedBinding(), g); assertSame(blah, col.getName(15).resolveBinding()); assertSame(c2, col.getName(16).resolveBinding()); @@ -2202,6 +2204,7 @@ bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class); } + // template // struct A {}; // @@ -4054,7 +4057,7 @@ // void test() { // S(a); // } - public void testFunctionTemplateWithArrayReferenceParameter_269926() throws Exception { + public void _testFunctionTemplateWithArrayReferenceParameter_269926() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, ParserLanguage.CPP); } @@ -4104,14 +4107,4 @@ final String code = getAboveComment(); parseAndCheckBindings(code, ParserLanguage.CPP); } - - // template void T(int (&array)[N]) {}; - // void test() { - // int a[2]; - // T<2>(a); - // } - public void testInstantiationOfArraySize_269926() throws Exception { - final String code= getAboveComment(); - parseAndCheckBindings(code, ParserLanguage.CPP); - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java Wed Aug 05 17:35:39 2009 -0500 @@ -4008,7 +4008,7 @@ // for plain C this is actually not a problem, the second J has to be interpreted as a (useless) // parameter name. assertInstance(typedef, ITypedef.class); - isTypeEqual(((ITypedef) typedef).getType(), "int (*)(int)"); + isTypeEqual(((ITypedef) typedef).getType(), "int (int) *"); } } } @@ -5123,19 +5123,19 @@ BindingAssertionHelper ba= new BindingAssertionHelper(comment, isCpp); IFunction f= ba.assertNonProblem("f1", 2, IFunction.class); - isTypeEqual(f.getType(), "int (int (*)(int))"); + isTypeEqual(f.getType(), "int (int (int) *)"); f= ba.assertNonProblem("f2", 2, IFunction.class); - isTypeEqual(f.getType(), "int (int (*)(int))"); + isTypeEqual(f.getType(), "int (int (int) *)"); f= ba.assertNonProblem("f3", 2, IFunction.class); - isTypeEqual(f.getType(), "int (int (*)(int))"); + isTypeEqual(f.getType(), "int (int (int) *)"); f= ba.assertNonProblem("f4", 2, IFunction.class); isTypeEqual(f.getType(), "int (int)"); f= ba.assertNonProblem("f5", 2, IFunction.class); - isTypeEqual(f.getType(), "int (int * (*)(int *))"); + isTypeEqual(f.getType(), "int (int * (int *) *)"); } } @@ -5145,7 +5145,7 @@ BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); IFunction f= ba.assertNonProblem("f1", 2, IFunction.class); - isTypeEqual(f.getType(), "void (int (*)(C))"); + isTypeEqual(f.getType(), "void (int (C) *)"); } // int (*f1(int par))[5] {}; @@ -5157,10 +5157,10 @@ BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp); IFunction f= ba.assertNonProblem("f1", 2, IFunction.class); - isTypeEqual(f.getType(), "int (* (int))[5]"); + isTypeEqual(f.getType(), "int [] * (int)"); f= ba.assertNonProblem("f1 ", 2, IFunction.class); - isTypeEqual(f.getType(), "int (* (int))[5]"); + isTypeEqual(f.getType(), "int [] * (int)"); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/InclusionTests.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,7 +49,6 @@ super(name); } - @Override protected void tearDown() throws Exception { if (fProject != null) { CProjectHelper.delete(fProject); @@ -78,36 +77,6 @@ return folder; } - // #include "one.h" - // #include "f1/two.h" - // #include "f1/f2/three.h" - public void testIncludeVariables_69529() throws Exception { - String content= getAboveComment(); - - IFolder f0 = importFolder(".framework"); - importFolder("f1.framework"); - importFolder("f1"); - importFolder("f1.framework/f2"); - importFolder("f3"); - IFile base = importFile("base.cpp", content); - - importFile(".framework/one.h", "1"); - importFile("f1.framework/two.h", "2"); - importFile("f1.framework/f2/three.h", "3"); - - String[] path = { - f0.getLocation().removeLastSegments(1) + "/__framework__.framework/__header__" - }; - IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[]{}, null); - CodeReader reader= new CodeReader(base.getLocation().toString()); - initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo); - - // first file is not picked up (no framework) - validateInteger("2"); - validateInteger("3"); - validateEOF(); - } - public void testIncludeNext() throws Exception { String baseFile = "int zero; \n#include \"foo.h\""; //$NON-NLS-1$ String i1Next = "int one; \n#include_next "; //$NON-NLS-1$ @@ -210,8 +179,8 @@ CodeReader reader= new CodeReader(base.getLocation().toString()); ParserLanguage lang[]= {ParserLanguage.C, ParserLanguage.CPP}; - for (ParserLanguage element : lang) { - initializeScanner(reader, element, ParserMode.COMPLETE_PARSE, new ScannerInfo()); + for (int i = 0; i < lang.length; i++) { + initializeScanner(reader, lang[i], ParserMode.COMPLETE_PARSE, new ScannerInfo()); validateToken(IToken.t_int); validateIdentifier("var"); validateToken(IToken.tASSIGN); @@ -232,22 +201,4 @@ validateEOF(); } - // #include - public void testRelativeIncludes_243170() throws Exception { - String content= getAboveComment(); - - IFolder f0 = importFolder("f1"); - importFolder("f1/f2"); - importFolder("f1/f2/inc"); - importFile("f1/f2/inc/test.h", "1"); - IFile base = importFile("f1/base.cpp", getAboveComment()); - - String[] path = {"f2"}; // relative include - IScannerInfo scannerInfo = new ExtendedScannerInfo(Collections.EMPTY_MAP, path, new String[]{}, null); - CodeReader reader= new CodeReader(base.getLocation().toString()); - initializeScanner(reader, ParserLanguage.C, ParserMode.COMPLETE_PARSE, scannerInfo); - - validateInteger("1"); - validateEOF(); - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -88,17 +88,9 @@ } protected void initializeScanner() throws Exception { - initializeScanner(getAboveComment()); - } - - protected StringBuffer[] getTestContent(int sections) throws IOException { StringBuffer[] input= TestSourceReader.getContentsForTest( - CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections); - return input; - } - - protected String getAboveComment() throws IOException { - return getTestContent(1)[0].toString(); + CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), 1); + initializeScanner(input[0].toString()); } protected void fullyTokenize() throws Exception { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java Wed Aug 05 17:35:39 2009 -0500 @@ -224,13 +224,17 @@ } protected static void assertTypeContainer(IType conType, String expQN, Class containerType, Class expContainedType, String expContainedTypeQN) { - assertInstance(conType, ITypeContainer.class); - assertInstance(conType, containerType); - IType containedType= ((ITypeContainer)conType).getType(); - assertInstance(containedType, expContainedType); - if (expContainedTypeQN != null) { - assertInstance(containedType, IBinding.class); - assertQNEquals(expContainedTypeQN, (IBinding) containedType); + try { + assertInstance(conType, ITypeContainer.class); + assertInstance(conType, containerType); + IType containedType= ((ITypeContainer)conType).getType(); + assertInstance(containedType, expContainedType); + if (expContainedTypeQN != null) { + assertInstance(containedType, IBinding.class); + assertQNEquals(expContainedTypeQN, (IBinding) containedType); + } + } catch (DOMException de) { + fail(de.getMessage()); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2008 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; -import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; @@ -1364,19 +1363,6 @@ assertNotNull(numericalValue); assertEquals(i, numericalValue.intValue()); } - - // void f(int (&v)[1]); - // void f(int (&v)[2]); - - // void test() { - // int a[1], b[2]; - // f(a); f(b); - // } - public void testArrayTypeWithSize_269926() throws Exception { - IFunction f1= getBindingFromASTName("f(a)", 1, IFunction.class); - IFunction f2= getBindingFromASTName("f(b)", 1, IFunction.class); - assertFalse(f1.equals(f2)); - } /* CPP assertion helpers */ /* ##################################################################### */ @@ -1470,14 +1456,18 @@ * @param qn may be null */ static protected void assertPTM(IType type, String cqn, String qn) { - assertTrue(type instanceof ICPPPointerToMemberType); - ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type; - ICPPClassType classType = (ICPPClassType) ptmt.getMemberOfClass(); - assertQNEquals(cqn, classType); - if(qn!=null) { - assert(ptmt.getType() instanceof ICPPBinding); - ICPPBinding tyBinding = (ICPPBinding) ptmt.getType(); - assertQNEquals(qn, tyBinding); + try { + assertTrue(type instanceof ICPPPointerToMemberType); + ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type; + ICPPClassType classType = (ICPPClassType) ptmt.getMemberOfClass(); + assertQNEquals(cqn, classType); + if(qn!=null) { + assert(ptmt.getType() instanceof ICPPBinding); + ICPPBinding tyBinding = (ICPPBinding) ptmt.getType(); + assertQNEquals(qn, tyBinding); + } + } catch(DOMException de) { + fail(de.getMessage()); } } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1597,7 +1597,7 @@ public void testDefaultTemplateArgInHeader_264988() throws Exception { ICPPTemplateInstance ti= getBindingFromASTName("XT<>", 4, ICPPTemplateInstance.class); } - + // typedef int TInt; // template class XT { // void m(); @@ -1609,76 +1609,6 @@ public void testParentScopeOfSpecialization_267013() throws Exception { ITypedef ti= getBindingFromASTName("TInt", 4, ITypedef.class); } - - // struct __true_type {}; - // struct __false_type {}; - // - // template - // struct __are_same { - // enum { __value = 0 }; - // typedef __false_type __type; - // }; - // - // template - // struct __are_same<_Tp, _Tp> { - // enum { __value = 1 }; - // typedef __true_type __type; - // }; - // - // template - // struct __enable_if {}; - // - // template - // struct __enable_if { - // typedef _Tp __type; - // }; - // - // template - // struct __normal_iterator { - // template - // __normal_iterator( - // const __normal_iterator< - // _Iter, - // typename __enable_if< - // __are_same<_Iter, typename _Container::pointer>::__value, - // _Container - // >::__type - // >& __i); - // }; - // - // template - // struct allocator { - // typedef _Tp* pointer; - // typedef const _Tp* const_pointer; - // - // template - // struct rebind - // { typedef allocator<_Tp1> other; }; - // }; - // - // template > - // struct vector { - // typedef vector<_Tp, _Alloc> vector_type; - // typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; - // - // typedef typename _Tp_alloc_type::pointer pointer; - // typedef typename _Tp_alloc_type::const_pointer const_pointer; - // typedef __normal_iterator iterator; - // typedef __normal_iterator const_iterator; - // - // iterator begin(); - // const_iterator begin() const; - // }; - - // void f(vector::const_iterator p); - // - // void test() { - // vector v; - // f(v.begin()); - // } - public void testTemplateMetaprogramming_284686() throws Exception { - getBindingFromASTName("f(v.begin())", 1, ICPPFunction.class); - } // template class op { // public: diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 QNX Software Systems + * Copyright (c) 2005, 2008 QNX Software Systems * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,7 +33,6 @@ public class DBTest extends BaseTestCase { protected Database db; - @Override protected void setUp() throws Exception { super.setUp(); db = new Database(getTestDir().append(getName()+System.currentTimeMillis()+".dat").toFile(), @@ -53,7 +52,6 @@ return path; } - @Override protected void tearDown() throws Exception { db.close(); if(!db.getLocation().delete()) { @@ -74,8 +72,8 @@ assertEquals(-blocksize, db.getShort(mem - Database.BLOCK_HEADER_SIZE)); db.free(mem); assertEquals(blocksize, db.getShort(mem - Database.BLOCK_HEADER_SIZE)); - assertEquals(mem, db.getRecPtr((deltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE)); - assertEquals(mem + blocksize, db.getRecPtr((freeDeltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE)); + assertEquals(mem - Database.BLOCK_HEADER_SIZE, db.getRecPtr((deltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE)); + assertEquals(mem - Database.BLOCK_HEADER_SIZE + blocksize, db.getRecPtr((freeDeltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE)); } public void testBug192437() throws IOException { @@ -112,10 +110,10 @@ long mem2 = db.malloc(realsize); db.free(mem1); db.free(mem2); - assertEquals(mem2, db.getRecPtr((deltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE)); + assertEquals(mem2 - Database.BLOCK_HEADER_SIZE, db.getRecPtr((deltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE)); assertEquals(0, db.getRecPtr(mem2)); - assertEquals(mem1, db.getRecPtr(mem2 + Database.INT_SIZE)); - assertEquals(mem2, db.getRecPtr(mem1)); + assertEquals(mem1 - Database.BLOCK_HEADER_SIZE, db.getRecPtr(mem2 + Database.INT_SIZE)); + assertEquals(mem2 - Database.BLOCK_HEADER_SIZE, db.getRecPtr(mem1)); assertEquals(0, db.getRecPtr(mem1 + Database.INT_SIZE)); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c Wed Aug 05 17:35:39 2009 -0500 @@ -39,11 +39,10 @@ int uid; // quasi-unique process ID; we have to create it to avoid duplicated pid // (actually this impossible from OS point of view but it is still possible // a clash of new created and already finished process with one and the same PID. - // 4 events connected to this process (see starter) - HANDLE eventBreak; // signaled when Spawner.interrupt() is called; mildest of the terminate requests (SIGINT signal in UNIX world) + // 3 events connected to this process (see starter) + HANDLE eventBreak; HANDLE eventWait; - HANDLE eventTerminate; // signaled when Spawner.terminate() is called; more forceful terminate request (SIGTERM signal in UNIX world) - HANDLE eventKill; // signaled when Spawner.kill() is called; most forceful terminate request (SIGKILL signal in UNIX world) + HANDLE eventTerminate; } procInfo_t, * pProcInfo_t; static int procCounter = 0; // Number of running processes @@ -147,7 +146,6 @@ wchar_t eventBreakName[20]; wchar_t eventWaitName[20]; wchar_t eventTerminateName[20]; - wchar_t eventKillName[20]; #ifdef DEBUG_MONITOR wchar_t buffer[1000]; #endif @@ -219,14 +217,14 @@ swprintf(eventBreakName, L"SABreak%p", pCurProcInfo); swprintf(eventWaitName, L"SAWait%p", pCurProcInfo); swprintf(eventTerminateName, L"SATerm%p", pCurProcInfo); - swprintf(eventKillName, L"SAKill%p", pCurProcInfo); + pCurProcInfo -> eventBreak = CreateEventW(NULL, TRUE, FALSE, eventBreakName); + ResetEvent(pCurProcInfo -> eventBreak); + pCurProcInfo -> eventWait = CreateEventW(NULL, TRUE, FALSE, eventWaitName); + ResetEvent(pCurProcInfo -> eventWait); + pCurProcInfo -> eventTerminate = CreateEventW(NULL, TRUE, FALSE, eventTerminateName); + ResetEvent(pCurProcInfo -> eventTerminate); - pCurProcInfo->eventBreak = CreateEventW(NULL, FALSE, FALSE, eventBreakName); - pCurProcInfo->eventWait = CreateEventW(NULL, TRUE, FALSE, eventWaitName); - pCurProcInfo->eventTerminate = CreateEventW(NULL, FALSE, FALSE, eventTerminateName); - pCurProcInfo->eventKill = CreateEventW(NULL, FALSE, FALSE, eventKillName); - - swprintf(szCmdLine, L"\"%sstarter.exe\" %i %i %s %s %s %s ", path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName, eventKillName); + swprintf(szCmdLine, L"\"%sstarter.exe\" %i %i %s %s %s ", path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName); nPos = wcslen(szCmdLine); // Prepare command line @@ -669,34 +667,22 @@ // Temporary do nothing ret = 0; break; + case SIG_KILL: case SIG_TERM: #ifdef DEBUG_MONITOR - swprintf(buffer, _T("Spawner received TERM signal for process %i\n"), + swprintf(buffer, _T("Spawner received KILL or TERM signal for process %i\n"), pCurProcInfo -> pid); OutputDebugStringW(buffer); #endif SetEvent(pCurProcInfo -> eventTerminate); #ifdef DEBUG_MONITOR - OutputDebugStringW(_T("Spawner signalled TERM event\n")); -#endif - ret = 0; - break; - - case SIG_KILL: -#ifdef DEBUG_MONITOR - swprintf(buffer, _T("Spawner received KILL signal for process %i\n"), - pCurProcInfo -> pid); - OutputDebugStringW(buffer); -#endif - SetEvent(pCurProcInfo -> eventKill); -#ifdef DEBUG_MONITOR OutputDebugStringW(_T("Spawner signalled KILL event\n")); #endif ret = 0; break; case SIG_INT: ResetEvent(pCurProcInfo -> eventWait); - SetEvent(pCurProcInfo -> eventBreak); + PulseEvent(pCurProcInfo -> eventBreak); ret = (WaitForSingleObject(pCurProcInfo -> eventWait, 100) == WAIT_OBJECT_0); break; default: @@ -855,12 +841,6 @@ pCurProcInfo -> eventTerminate = 0; } - if(0 != pCurProcInfo -> eventKill) - { - CloseHandle(pCurProcInfo -> eventKill); - pCurProcInfo -> eventKill = 0; - } - pCurProcInfo -> pid = 0; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/library/starter/starter.cpp --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/library/starter/starter.cpp Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/library/starter/starter.cpp Wed Aug 05 17:35:39 2009 -0500 @@ -139,8 +139,8 @@ wchar_t ** argv = CommandLineToArgvW(GetCommandLine(), &argc); // Make sure that we've been passed the right number of arguments - if (argc < 8) { - _tprintf(_T("Usage: %s (four inheritable event handles) (CommandLineToSpawn)\n"), + if (argc < 7) { + _tprintf(_T("Usage: %s (Three InheritableEventHandles) (CommandLineToSpawn)\n"), argv[0]); return(0); } @@ -151,7 +151,7 @@ szCmdLine[0]= 0; int nPos = 0; - for(int i = 7; i < argc; ++i) + for(int i = 6; i < argc; ++i) { int nCpyLen; int len= wcslen(argv[i]); @@ -192,11 +192,9 @@ BOOL exitProc = FALSE; HANDLE waitEvent = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[4]); - HANDLE h[4]; - h[0] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[3]); // simulated SIGINT -// h[1] we reserve for the process handle - h[2] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[5]); // simulated SIGTERM - h[3] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[6]); // simulated SIGKILL + HANDLE h[3]; + h[0] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[3]); + h[2] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[5]); // This is a terminate event SetConsoleCtrlHandler(HandlerRoutine, TRUE); int parentPid = wcstol(argv[1], NULL, 10); @@ -308,10 +306,9 @@ { // Wait for the spawned-process to die or for the event // indicating that the processes should be forcibly killed. - DWORD event = WaitForMultipleObjects(4, h, FALSE, INFINITE); - switch (event) + switch (WaitForMultipleObjects(3, h, FALSE, INFINITE)) { - case WAIT_OBJECT_0 + 0: // SIGINT + case WAIT_OBJECT_0 + 0: // Send Ctrl-C #ifdef DEBUG_MONITOR swprintf(buffer, _T("starter (PID %i) received CTRL-C event\n"), currentPID); OutputDebugStringW(buffer); @@ -341,23 +338,16 @@ GetExitCodeProcess(pi.hProcess, &dwExitCode); exitProc = TRUE; break; - - // Terminate and Kill behavior differ only for cygwin processes, where - // we use the cygwin 'kill' command. We send a SIGKILL in one case, - // SIGTERM in the other. For non-cygwin processes, both requests - // are treated exactly the same - case WAIT_OBJECT_0 + 2: // TERM - case WAIT_OBJECT_0 + 3: // KILL - { - const wchar_t* signal = (event == WAIT_OBJECT_0 + 2) ? L"TERM" : L"KILL"; + + case WAIT_OBJECT_0 + 2: // Kill #ifdef DEBUG_MONITOR - swprintf(buffer, _T("starter received %s event (PID %i)\n"), signal, currentPID); + swprintf(buffer, _T("starter received KILL event (PID %i)\n"), currentPID); OutputDebugStringW(buffer); #endif if (isCygwin(h[1])) { // Need to issue a kill command wchar_t kill[1024]; - swprintf(kill, L"kill -%s %d", signal, pi.dwProcessId); + swprintf(kill, L"kill -SIGTERM %d", pi.dwProcessId); if (!runCygwinCommand(kill)) { // fall back to console event GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); @@ -375,13 +365,10 @@ DisplayErrorMessage(); #endif } - } - - // Note that we keep trucking until the child process terminates (case WAIT_OBJECT_0 + 1) + } else + exitProc = TRUE; break; - } - - default: + default: // Unexpected code #ifdef DEBUG_MONITOR DisplayErrorMessage(); @@ -391,6 +378,7 @@ } } + CloseHandle(pi.hProcess); } else { #ifdef DEBUG_MONITOR swprintf(buffer, _T("Cannot start: %s\n"), szCmdLine); @@ -409,7 +397,6 @@ CloseHandle(h[0]); CloseHandle(h[1]); CloseHandle(h[2]); - CloseHandle(h[3]); return(dwExitCode); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/os/win32/x86/spawner.dll Binary file cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/os/win32/x86/spawner.dll has changed diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/os/win32/x86/starter.exe Binary file cdt/cdt_6_0_x/org.eclipse.cdt.core.win32/os/win32/x86/starter.exe has changed diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/META-INF/MANIFEST.MF --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/META-INF/MANIFEST.MF Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/META-INF/MANIFEST.MF Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true -Bundle-Version: 5.2.0.qualifier +Bundle-Version: 5.1.1.qualifier Bundle-Activator: org.eclipse.cdt.core.CCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java Wed Aug 05 17:35:39 2009 -0500 @@ -33,7 +33,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** * Creates labels for ICElement objects. @@ -759,14 +758,7 @@ if (rootQualified) { buf.append(container.getPath().makeRelative().toString()); } else { - if (CCorePlugin.showSourceRootsAtTopOfProject()) { - buf.append(container.getElementName()); - } - else { - String elementName = container.getElementName(); - IPath path = new Path(elementName); - buf.append(path.lastSegment()); - } + buf.append(container.getElementName()); if (getFlag(flags, ROOT_QUALIFIED)) { if (resource != null && container instanceof ISourceRoot && isReferenced((ISourceRoot)container)) { buf.append(CONCAT_STRING); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java Wed Aug 05 17:35:39 2009 -0500 @@ -93,18 +93,6 @@ } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((fSourceAttachmentPath == null) ? 0 : fSourceAttachmentPath.hashCode()); - result = prime * result - + ((fSourceAttachmentPrefixMapping == null) ? 0 : fSourceAttachmentPrefixMapping.hashCode()); - result = prime * result - + ((fSourceAttachmentRootPath == null) ? 0 : fSourceAttachmentRootPath.hashCode()); - return result; - } - - @Override public boolean equals(Object other) { if(other == this) return true; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java Wed Aug 05 17:35:39 2009 -0500 @@ -81,16 +81,6 @@ } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((basePath == null) ? 0 : basePath.hashCode()); - result = prime * result + ((baseRef == null) ? 0 : baseRef.hashCode()); - result = prime * result + Arrays.hashCode(exclusionPatterns); - return result; - } - - @Override public boolean equals(Object obj) { if (obj instanceof APathEntry) { APathEntry otherEntry = (APathEntry)obj; @@ -135,6 +125,16 @@ return super.equals(obj); } + @Override + public int hashCode() { + int hashCode = Arrays.hashCode(exclusionPatterns); + if (basePath != null) + hashCode += basePath.hashCode(); + if (baseRef != null) + hashCode += baseRef.hashCode(); + return hashCode + super.hashCode(); + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -150,5 +150,4 @@ } return sb.toString(); } - } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDeltaBuilder.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDeltaBuilder.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementDeltaBuilder.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java Wed Aug 05 17:35:39 2009 -0500 @@ -49,16 +49,6 @@ return isSystemInclude; } -@Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result - + ((includePath == null) ? 0 : includePath.hashCode()); - result = prime * result + (isSystemInclude ? 1231 : 1237); - return result; - } - @Override public boolean equals(Object obj) { if (obj instanceof IIncludeEntry) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java Wed Aug 05 17:35:39 2009 -0500 @@ -41,16 +41,6 @@ } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result - + ((includeFilePath == null) ? 0 : includeFilePath.hashCode()); - return result; - } - - - @Override public boolean equals(Object obj) { if (obj instanceof IIncludeFileEntry) { IIncludeFileEntry otherEntry = (IIncludeFileEntry) obj; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java Wed Aug 05 17:35:39 2009 -0500 @@ -133,17 +133,6 @@ return super.equals(obj); } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((libraryPath == null) ? 0 : libraryPath.hashCode()); - result = prime * result + ((sourceAttachmentPath == null) ? 0 : sourceAttachmentPath.hashCode()); - result = prime * result - + ((sourceAttachmentRootPath == null) ? 0 : sourceAttachmentRootPath.hashCode()); - return result; - } - public IPath getFullLibraryPath() { IPath p; IPath lib = getLibraryPath(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java Wed Aug 05 17:35:39 2009 -0500 @@ -45,17 +45,6 @@ } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result - + ((macroName == null) ? 0 : macroName.hashCode()); - result = prime * result - + ((macroValue == null) ? 0 : macroValue.hashCode()); - return result; - } - - @Override public boolean equals(Object obj) { if (obj instanceof IMacroEntry) { IMacroEntry otherEntry = (IMacroEntry)obj; @@ -85,6 +74,11 @@ return super.equals(obj); } + @Override + public int hashCode() { + return macroName.hashCode() + macroValue.hashCode() + super.hashCode(); + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java Wed Aug 05 17:35:39 2009 -0500 @@ -40,15 +40,6 @@ } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result - + ((macroFilePath == null) ? 0 : macroFilePath.hashCode()); - return result; - } - - @Override public boolean equals(Object obj) { if (obj instanceof IMacroFileEntry) { IMacroFileEntry otherEntry = (IMacroFileEntry) obj; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java Wed Aug 05 17:35:39 2009 -0500 @@ -73,12 +73,7 @@ @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + entryKind; - result = prime * result + (isExported ? 1231 : 1237); - result = prime * result + ((path == null) ? 0 : path.hashCode()); - return result; + return path.hashCode() + entryKind * 17 + (isExported ? 3 : 2); } /** diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,12 +12,9 @@ package org.eclipse.cdt.internal.core.model; import java.io.File; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.List; -import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CModelException; @@ -338,17 +335,17 @@ public static ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) { // Check duplication. - Set entrySet = new HashSet(entries.length); for (IPathEntry entry : entries) { - if (entry != null) { - if (entrySet.contains(entry)) { - return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, - MessageFormat.format("{0}{1}", //$NON-NLS-1$ - CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry"), //$NON-NLS-1$ - entry.getPath().toString())); + if (entry == null) { + continue; + } + for (IPathEntry otherEntry : entries) { + if (otherEntry == null) { + continue; } - else { - entrySet.add(entry); + if (entry != otherEntry && otherEntry.equals(entry)) { + StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$ + return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); } } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java Wed Aug 05 17:35:39 2009 -0500 @@ -1793,15 +1793,14 @@ newEntries = EMPTY_LANGUAGE_SETTINGS_ENTRIES_ARRAY; } - Set newEntrySet = new HashSet(Arrays.asList(newEntries)); - Set oldEntrySet = new HashSet(Arrays.asList(oldEntries)); - // Check the removed entries. - for (ICLanguageSettingEntry oldEntry : oldEntries) { + for (int i = 0; i < oldEntries.length; i++) { boolean found = false; - if (newEntrySet.contains(oldEntry)) { - found = true; - break; + for (int j = 0; j < newEntries.length; j++) { + if (oldEntries[i].equals(newEntries[j])) { + found = true; + break; + } } if(!found){ result[1] = true; @@ -1810,11 +1809,13 @@ } // Check the new entries. - for (ICLanguageSettingEntry newEntry : newEntries) { + for (int i = 0; i < newEntries.length; i++) { boolean found = false; - if (oldEntrySet.contains(newEntry)) { - found = true; - break; + for (int j = 0; j < oldEntries.length; j++) { + if (newEntries[i].equals(oldEntries[j])) { + found = true; + break; + } } if(!found){ result[0] = true; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Intel Corporation and others. + * Copyright (c) 2007 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,7 +33,6 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingBase; -import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; @@ -45,7 +44,7 @@ private IProject fProject; private ICProjectDescription fProjDes; private ICConfigurationDescription fCfgDes; - private Map fIdToLanguageSettingsMap = Collections.synchronizedMap(new HashMap()); + private Map fIdToLanguageSettingsMap = Collections.synchronizedMap(new HashMap()); private String fCurrentFileDescriptionId; private IScannerInfo fCurrentFileScannerInfo; private static final ScannerInfo INEXISTENT_SCANNER_INFO = new ScannerInfo(); @@ -110,9 +109,9 @@ IScannerInfo info; if(useMap) - info = fIdToLanguageSettingsMap.get(mapKey); + info = (IScannerInfo)fIdToLanguageSettingsMap.get(mapKey); else { - if(fCurrentFileScannerInfo != null && rcDes != null){ + if(fCurrentFileScannerInfo != null){ if(rcDes.getId().equals(fCurrentFileDescriptionId)) info = fCurrentFileScannerInfo; else { @@ -128,7 +127,7 @@ info = createScannerInfo(ls); if(useMap) fIdToLanguageSettingsMap.put(mapKey, info); - else if (rcDes != null){ + else { fCurrentFileScannerInfo = info; fCurrentFileDescriptionId = rcDes.getId(); } @@ -145,7 +144,7 @@ } private static ICMacroEntry[] getMacroEntries(ICLanguageSetting ls){ - ICLanguageSettingEntry entries[] = ls.getResolvedSettingEntries(ICSettingEntry.MACRO); + ICLanguageSettingEntry entries[] = ls.getResolvedSettingEntries(ICLanguageSettingEntry.MACRO); ICMacroEntry macroEntries[] = new ICMacroEntry[entries.length]; System.arraycopy(entries, 0, macroEntries, 0, entries.length); @@ -155,37 +154,37 @@ private IScannerInfo createProjectScannerInfo(){ ICFolderDescription foDes = fCfgDes.getRootFolderDescription(); ICLanguageSetting[] lSettings = foDes.getLanguageSettings(); - ICLanguageSettingPathEntry pathEntries[] = getPathEntries(lSettings, ICSettingEntry.INCLUDE_PATH); + ICLanguageSettingPathEntry pathEntries[] = getPathEntries(lSettings, ICLanguageSettingEntry.INCLUDE_PATH); String incs[] = getValues(pathEntries); - pathEntries = getPathEntries(lSettings, ICSettingEntry.INCLUDE_FILE); + pathEntries = getPathEntries(lSettings, ICLanguageSettingEntry.INCLUDE_FILE); String incFiles[] = getValues(pathEntries); - pathEntries = getPathEntries(lSettings, ICSettingEntry.MACRO_FILE); + pathEntries = getPathEntries(lSettings, ICLanguageSettingEntry.MACRO_FILE); String macroFiles[] = getValues(pathEntries); ICMacroEntry macroEntries[] = getMacroEntries(lSettings); - Map macrosMap = getValues(macroEntries); + Map macrosMap = getValues(macroEntries); return new ExtendedScannerInfo(macrosMap, incs, macroFiles, incFiles); } private ICMacroEntry[] getMacroEntries(ICLanguageSetting[] settings){ - LinkedHashSet set = getEntriesSet(ICSettingEntry.MACRO, settings); - return set.toArray(new ICMacroEntry[set.size()]); + LinkedHashSet set = getEntriesSet(ICLanguageSettingEntry.MACRO, settings); + return (ICMacroEntry[])set.toArray(new ICMacroEntry[set.size()]); } private ICLanguageSettingPathEntry[] getPathEntries(ICLanguageSetting[] settings, int kind){ - LinkedHashSet set = getEntriesSet(kind, settings); - return set.toArray(new ICLanguageSettingPathEntry[set.size()]); + LinkedHashSet set = getEntriesSet(kind, settings); + return (ICLanguageSettingPathEntry[])set.toArray(new ICLanguageSettingPathEntry[set.size()]); } - private LinkedHashSet getEntriesSet(int kind, ICLanguageSetting[] settings){ - LinkedHashSet set = new LinkedHashSet(); + private LinkedHashSet getEntriesSet(int kind, ICLanguageSetting[] settings){ + LinkedHashSet set = new LinkedHashSet(); ICLanguageSettingEntry[] langEntries; - for (ICLanguageSetting setting : settings) { - langEntries = setting.getResolvedSettingEntries(kind); + for(int i = 0; i < settings.length; i++){ + langEntries = settings[i].getResolvedSettingEntries(kind); if(langEntries.length != 0){ set.addAll(Arrays.asList(langEntries)); } @@ -197,29 +196,29 @@ if(ls == null) return createProjectScannerInfo(); - ICLanguageSettingPathEntry pathEntries[] = getPathEntries(ls, ICSettingEntry.INCLUDE_PATH); + ICLanguageSettingPathEntry pathEntries[] = getPathEntries(ls, ICLanguageSettingEntry.INCLUDE_PATH); String incs[] = getValues(pathEntries); - pathEntries = getPathEntries(ls, ICSettingEntry.INCLUDE_FILE); + pathEntries = getPathEntries(ls, ICLanguageSettingEntry.INCLUDE_FILE); String incFiles[] = getValues(pathEntries); - pathEntries = getPathEntries(ls, ICSettingEntry.MACRO_FILE); + pathEntries = getPathEntries(ls, ICLanguageSettingEntry.MACRO_FILE); String macroFiles[] = getValues(pathEntries); ICMacroEntry macroEntries[] = getMacroEntries(ls); - Map macrosMap = getValues(macroEntries); + Map macrosMap = getValues(macroEntries); return new ExtendedScannerInfo(macrosMap, incs, macroFiles, incFiles); } - private Map getValues(ICMacroEntry macroEntries[]){ - Map macrosMap = new HashMap(macroEntries.length); + private Map getValues(ICMacroEntry macroEntries[]){ + Map macrosMap = new HashMap(macroEntries.length); String name; String value; - for (ICMacroEntry macroEntry : macroEntries) { - name = macroEntry.getName(); - value = macroEntry.getValue(); + for(int i = 0; i < macroEntries.length; i++){ + name = macroEntries[i].getName(); + value = macroEntries[i].getValue(); macrosMap.put(name, value); } return macrosMap; @@ -229,13 +228,13 @@ String values[] = new String[pathEntries.length]; IPath path; int num = 0; - for (ICLanguageSettingPathEntry pathEntry : pathEntries) { - String p = pathEntry.getValue(); + for(int i = 0; i < pathEntries.length; i++){ + String p = pathEntries[i].getValue(); if(p == null) continue; //TODO: obtain location from pathEntries when entries are resolved - path = new Path(p);//p.getLocation(); - if(pathEntry.isValueWorkspacePath()){ + path = new Path(p);//pathEntries[i].getLocation(); + if(pathEntries[i].isValueWorkspacePath()){ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource rc = root.findMember(path); if(rc != null){ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTNodeFactoryFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTNodeFactoryFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.dom.ast; - -import org.eclipse.cdt.core.dom.ast.c.ICNodeFactory; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory; -import org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory; - -/** - * Provides access to the node factories. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @since 5.2 - */ -public class ASTNodeFactoryFactory { - - ASTNodeFactoryFactory() {} - - public static ICNodeFactory getDefaultCNodeFactory() { - return CNodeFactory.getDefault(); - } - - public static ICPPNodeFactory getDefaultCPPNodeFactory() { - return CPPNodeFactory.getDefault(); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java Wed Aug 05 17:35:39 2009 -0500 @@ -13,10 +13,7 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; -import java.util.ArrayList; -import java.util.BitSet; import java.util.LinkedList; -import java.util.List; import org.eclipse.cdt.core.dom.ast.c.ICArrayType; import org.eclipse.cdt.core.dom.ast.c.ICBasicType; @@ -39,7 +36,6 @@ import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.c.CASTTypeId; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding; @@ -59,6 +55,7 @@ private static final String COMMA_SPACE = ", "; //$NON-NLS-1$ private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String SPACE = " "; //$NON-NLS-1$ + private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final int DEAULT_ITYPE_SIZE = 2; /** @@ -183,7 +180,13 @@ * @see #getType(IType, boolean) */ public static String[] getParameterTypeStringArray(IFunctionType type) { - IType[] parms = type.getParameterTypes(); + IType[] parms = null; + try { + parms = type.getParameterTypes(); + } catch (DOMException e) { + return EMPTY_STRING_ARRAY; + } + String[] result = new String[parms.length]; for (int i = 0; i < parms.length; i++) { @@ -203,23 +206,22 @@ result.append(Keywords.cpLBRACKET); if (type instanceof ICArrayType) { try { - final ICArrayType catype = (ICArrayType) type; - if (catype.isConst()) { + if (((ICArrayType) type).isConst()) { result.append(Keywords.CONST); needSpace = true; } - if (catype.isRestrict()) { + if (((ICArrayType) type).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace = false; } result.append(Keywords.RESTRICT); needSpace = true; } - if (catype.isStatic()) { + if (((ICArrayType) type).isStatic()) { if (needSpace) { result.append(SPACE); needSpace = false; } result.append(Keywords.STATIC); needSpace = true; } - if (catype.isVolatile()) { + if (((ICArrayType) type).isVolatile()) { if (needSpace) { result.append(SPACE); needSpace = false; } @@ -227,23 +229,6 @@ } } catch (DOMException e) { } - } - IValue val= ((IArrayType) type).getSize(); - if (val != null && val != Value.UNKNOWN) { - if (normalize) { - if (needSpace) { - result.append(SPACE); needSpace = false; - } - result.append(val.getSignature()); - } else { - Long v= val.numericalValue(); - if (v != null) { - if (needSpace) { - result.append(SPACE); needSpace = false; - } - result.append(v.longValue()); - } - } } result.append(Keywords.cpRBRACKET); } else if (type instanceof IBasicType) { @@ -394,13 +379,23 @@ result.append(SPACE); result.append(getNameForAnonymous((IEnumeration) type)); } else if (type instanceof IFunctionType) { - String temp = getParameterTypeString((IFunctionType) type); - if (temp != null && !temp.equals(EMPTY_STRING)) { - result.append(temp); needSpace = false; - } - if (type instanceof ICPPFunctionType) { - ICPPFunctionType ft= (ICPPFunctionType) type; - needSpace= appendCVQ(result, needSpace, ft.isConst(), ft.isVolatile()); + try { + String temp = getType(((IFunctionType) type).getReturnType(), normalize); + if (temp != null && !temp.equals(EMPTY_STRING)) { + result.append(temp); needSpace = true; + } + if (needSpace) { + result.append(SPACE); needSpace = false; + } + temp = getParameterTypeString((IFunctionType) type); + if (temp != null && !temp.equals(EMPTY_STRING)) { + result.append(temp); needSpace = false; + } + if (type instanceof ICPPFunctionType) { + ICPPFunctionType ft= (ICPPFunctionType) type; + needSpace= appendCVQ(result, needSpace, ft.isConst(), ft.isVolatile()); + } + } catch (DOMException e) { } } else if (type instanceof IPointerType) { if (type instanceof ICPPPointerToMemberType) { @@ -515,67 +510,31 @@ } } if (type instanceof ITypeContainer) { - type = ((ITypeContainer) type).getType(); - } else if (type instanceof IFunctionType) { - type= ((IFunctionType) type).getReturnType(); + try { + type = ((ITypeContainer) type).getType(); + } catch (DOMException e) { + type= null; + } } else { type= null; } } // pop all of the types off of the stack, and build the string representation while doing so - List postfix= null; - BitSet parenthesis= null; - boolean needParenthesis= false; for (int j = types.length - 1; j >= 0; j--) { - IType tj = types[j]; - if (tj != null) { - if (j > 0 && types[j - 1] instanceof IQualifierType) { - if (result.length() > 0) - result.append(SPACE); // only add a space if this is not the first type being added - result.append(getTypeString(types[j - 1], normalize)); - result.append(SPACE); - result.append(getTypeString(tj, normalize)); - --j; - } else { - // handle post-fix - if (tj instanceof IFunctionType || tj instanceof IArrayType) { - if (j == 0) { - if (result.length() > 0) - result.append(SPACE); // only add a space if this is not the first type being added - result.append(getTypeString(tj, normalize)); - } else { - if (postfix == null) { - postfix= new ArrayList(); - } - postfix.add(tj); - needParenthesis= true; - } - } else { - if (result.length() > 0) - result.append(SPACE); // only add a space if this is not the first type being added - if (needParenthesis && postfix != null) { - result.append('('); - if (parenthesis == null) { - parenthesis= new BitSet(); - } - parenthesis.set(postfix.size()-1); - } - result.append(getTypeString(tj, normalize)); - needParenthesis= false; - } - } - } - } + if (types[j] != null && result.length() > 0) + result.append(SPACE); // only add a space if this is not the first type being added - if (postfix != null) { - for (int j = postfix.size() - 1; j >= 0; j--) { - if (parenthesis != null && parenthesis.get(j)) { - result.append(')'); - } - IType tj = postfix.get(j); - result.append(getTypeString(tj, normalize)); - } + if (types[j] != null) { + if (j > 0 && types[j - 1] instanceof IQualifierType) { + result.append(getTypeString(types[j - 1], normalize)); + result.append(SPACE); + result.append(getTypeString(types[j], normalize)); + --j; + } else { + result.append(getTypeString(types[j], normalize)); + } + } } return result.toString(); @@ -667,24 +626,54 @@ } /** - * @deprecated don't use it does something strange + * This can be used to invoke the IType's isConst() if it has an isConst() method. + * This returns the result of that invoked isConst() method. + * It is a convenience function so that the structure of IType does not need + * to be known to determine if the IType is const or not. + * + * Note: false is returned if no isConst() method is found + * + * @param type */ - @Deprecated public static boolean isConst(IType type) { if (type instanceof IQualifierType) { return ((IQualifierType) type).isConst(); } else if (type instanceof ITypeContainer) { - return isConst(((ITypeContainer) type).getType()); + try { + return isConst(((ITypeContainer) type).getType()); + } catch (DOMException e) { + return false; + } } else if (type instanceof IArrayType) { - return isConst(((IArrayType) type).getType()); + try { + return isConst(((IArrayType) type).getType()); + } catch (DOMException e) { + return false; + } } else if (type instanceof ICPPReferenceType) { - return isConst(((ICPPReferenceType) type).getType()); + try { + return isConst(((ICPPReferenceType) type).getType()); + } catch (DOMException e) { + return false; + } } else if (type instanceof IFunctionType) { - return isConst(((IFunctionType) type).getReturnType()); + try { + return isConst(((IFunctionType) type).getReturnType()); + } catch (DOMException e) { + return false; + } } else if (type instanceof IPointerType) { - return isConst(((IPointerType) type).getType()); + try { + return isConst(((IPointerType) type).getType()); + } catch (DOMException e) { + return false; + } } else if (type instanceof ITypedef) { - return isConst(((ITypedef) type).getType()); + try { + return isConst(((ITypedef) type).getType()); + } catch (DOMException e) { + return false; + } } else { return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java Wed Aug 05 17:35:39 2009 -0500 @@ -271,7 +271,9 @@ /** * Returns the node factory that was used to build the AST. - * @since 5.2 + * + * @noreference This method is not intended to be referenced by clients. + * @since 5.1 */ public INodeFactory getASTNodeFactory(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IArrayType.java Wed Aug 05 17:35:39 2009 -0500 @@ -7,7 +7,6 @@ * * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation - * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -18,14 +17,9 @@ public interface IArrayType extends IType { /** * get the type that this is an array of + * @throws DOMException */ - IType getType(); - - /** - * Returns the value for the size of the array type, or null if it is unspecified. - * @since 5.2 - */ - IValue getSize(); + IType getType() throws DOMException; /** * get the expression that represents the size of this array diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunctionType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunctionType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunctionType.java Wed Aug 05 17:35:39 2009 -0500 @@ -18,12 +18,14 @@ /** * get the return type of this function type + * @throws DOMException */ - public IType getReturnType(); + public IType getReturnType() throws DOMException; /** * get the adjusted parameter types * ISO C99 6.7.5.3, ISO C++98 8.3.4-3 + * @throws DOMException */ - public IType[] getParameterTypes(); + public IType[] getParameterTypes() throws DOMException; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,8 +12,6 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression; -import org.eclipse.cdt.core.parser.IScanner; -import org.eclipse.cdt.core.parser.IToken; /** @@ -48,18 +46,11 @@ public IASTName newName(char[] name); /** - * @deprecated use {@link #newTranslationUnit(IScanner)}, instead. + * Calling the method getASTNodeFactory() on the translation unit returned by this + * method will return the node factory that was used to create the IASTTranslationUnit. */ - @Deprecated public IASTTranslationUnit newTranslationUnit(); - - /** - * Creates a new translation unit that cooperates with the given scanner in order - * to track macro-expansions and location information. - * @param scanner the preprocessor the translation unit interacts with. - * @since 5.2 - */ - public IASTTranslationUnit newTranslationUnit(IScanner scanner); + public IASTLiteralExpression newLiteralExpression(int kind, String rep); @@ -167,39 +158,4 @@ public IASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name); - /** - * Provides the offsets for a node. The offsets are artificial numbers that identify the - * position of a node in the translation unit. They are not file-offsets. You can obtain - * valid offsets via {@link IToken#getOffset()} or {@link IToken#getEndOffset()} from tokens - * provided by the scanner for this translation unit. - * May throw an exception when the node provided was not created by this factory. - * @param node a node created by this factory - * @param offset the offset (inclusive) for the node - * @param endOffset the end offset (exclusive) for the node - * @see #newTranslationUnit(IScanner) - * @since 5.2 - */ - public void setOffsets(IASTNode node, int offset, int endOffset); - - /** - * Provides the end offset for a node. The offset is an artificial numbers that identifies the - * position of a node in the translation unit. It is not a file-offset. You can obtain a - * valid offset via {@link IToken#getEndOffset()} from a token provided by the scanner for - * this translation unit. - * May throw an exception when the node provided was not created by this factory. - * @param node a node created by this factory - * @param endOffset the end offset (exclusive) for the node - * @see #newTranslationUnit(IScanner) - * @since 5.2 - */ - void setEndOffset(IASTNode node, int endOffset); - - /** - * Adjusts the end-offset of a node to be the same as the end-offset of a given node. - * May throw an exception when either one of the nodes provided was not created by this factory. - * @param node a node created by this factory - * @param endNode a node created by this factory defining the end for the other node. - * @since 5.2 - */ - void setEndOffset(IASTNode node, IASTNode endNode); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IPointerType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IPointerType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IPointerType.java Wed Aug 05 17:35:39 2009 -0500 @@ -17,8 +17,9 @@ public interface IPointerType extends IType { /** * get the type that this is a pointer to + * @throws DOMException */ - public IType getType(); + public IType getType() throws DOMException; /** * is this a const pointer diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IQualifierType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IQualifierType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IQualifierType.java Wed Aug 05 17:35:39 2009 -0500 @@ -30,6 +30,7 @@ /** * get the type that this is qualifying + * @throws DOMException */ - public IType getType(); + public IType getType() throws DOMException; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java Wed Aug 05 17:35:39 2009 -0500 @@ -19,6 +19,6 @@ /** * Returns the type that this thing is a typedef of */ - public IType getType(); + public IType getType() throws DOMException; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java Wed Aug 05 17:35:39 2009 -0500 @@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier; -import org.eclipse.cdt.core.parser.IScanner; /** * Factory for AST nodes for the C++ programming language. @@ -38,19 +37,7 @@ */ public interface ICPPNodeFactory extends INodeFactory { - /** - * @deprecated use {@link #newTranslationUnit(IScanner)}, instead. - */ - @Deprecated public ICPPASTTranslationUnit newTranslationUnit(); - - /** - * Creates a new translation unit that cooperates with the given scanner in order - * to track macro-expansions and location information. - * @scanner the preprocessor the translation unit interacts with. - * @since 5.2 - */ - public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner); public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java Wed Aug 05 17:35:39 2009 -0500 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; /** @@ -20,6 +21,8 @@ /** * get the type that this is a reference of + * + * @throws DOMException */ - public IType getType(); + public IType getType() throws DOMException; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexChangeEvent.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexChangeEvent.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexChangeEvent.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,10 +51,4 @@ * true, the files of the set have been written after the index was cleared. */ public Set getFilesWritten(); - - /** - * Returns true when a new file had been added to the index. - * @since 5.2 - */ - public boolean hasNewFile(); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/ResourceContainerRelativeLocationConverter.java Wed Aug 05 17:35:39 2009 -0500 @@ -7,15 +7,15 @@ * * Contributors: * Andrew Ferguson (Symbian) - Initial implementation - *******************************************************************************/ -package org.eclipse.cdt.core.index; + *******************************************************************************/ +package org.eclipse.cdt.core.index; import org.eclipse.cdt.internal.core.index.IndexFileLocation; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Path; /** * A location converter for converting project resource locations to be relative to a specified container. * Resources outside of the associated project will not be converted (ignored). @@ -35,7 +35,7 @@ public ResourceContainerRelativeLocationConverter(IContainer container) { this.fullPath = container.getFullPath(); this.root = ResourcesPlugin.getWorkspace().getRoot(); - } + } /* * (non-Javadoc) * @see org.eclipse.cdt.core.index.IIndexLocationConverter#fromInternalFormat(java.lang.String) @@ -43,7 +43,7 @@ public IIndexFileLocation fromInternalFormat(String raw) { IResource member= root.getFile(fullPath.append(raw)); return new IndexFileLocation(member.getLocationURI(), member.getFullPath().toString()); - } + } /* * (non-Javadoc) * @see org.eclipse.cdt.core.index.IIndexLocationConverter#toInternalFormat(org.eclipse.cdt.core.index.IIndexFileLocation) @@ -58,4 +58,4 @@ } return null; } -} +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerInfo.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerInfo.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerInfo.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * Copyright (c) 2002, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,15 +30,6 @@ /** * Returns an array of paths that are searched when processing an include directive. * see {@link IExtendedScannerInfo#getLocalIncludePath()} - *

- * In order to handle framework includes used on Apple Computers you can make use of - * the two variables: '__framework__' and '__header__'. - *
E.g.: /System/Library/Frameworks/__framework__.framework/Headers/__header__, - * /System/Library/Frameworks/__framework__.framework/PrivateHeaders/__header__ - * would handle the framework search for '/System/Library/Frameworks' - *
The variables are handled only, if a search path element makes use of both of the variables. - * The __framework__ variable will receive the first segment of the include, the __header__ variable - * the rest. Such a search path element is not used for directives with a single segment (e.g. 'header.h') */ public String[] getIncludePaths(); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java Wed Aug 05 17:35:39 2009 -0500 @@ -123,7 +123,7 @@ private void createEnumValues(IASTEnumerationSpecifier parent) { IASTEnumerator[] etors= parent.getEnumerators(); - int cv= -1; + long cv= -1; boolean isknown= true; for (IASTEnumerator etor : etors) { cv++; @@ -134,7 +134,7 @@ isknown= false; if (nv != null) { isknown= true; - cv= nv.intValue(); + cv= nv.longValue(); } } if (etor instanceof ASTEnumerator) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java Wed Aug 05 17:35:39 2009 -0500 @@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; @@ -137,12 +136,4 @@ } return active; } - - public static boolean isSameType(IType type1, IType type2) { - if (type1 == type2) - return true; - if (type1 == null || type2 == null) - return false; - return type1.isSameType(type2); - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java Wed Aug 05 17:35:39 2009 -0500 @@ -33,7 +33,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement; import org.eclipse.cdt.core.dom.ast.IASTDoStatement; -import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; @@ -94,35 +93,21 @@ fDeclarator= d; } } - - protected static class Decl extends Exception { - public Decl() { - } + protected static class FoundDeclaratorException extends Exception { + private static final long serialVersionUID = 0; - public IASTDeclSpecifier fDeclSpec1; - public IASTDeclSpecifier fDeclSpec2; - - public IASTDeclarator fDtor1; - public IASTDeclarator fDtor2; - public IToken fDtorToken1; + public IASTDeclSpecifier declSpec; + public IASTDeclarator declarator; - public Decl set(IASTDeclSpecifier declspec, IASTDeclarator dtor, IToken dtorToken) { - fDeclSpec1= declspec; - fDtor1= dtor; - fDtorToken1= dtorToken; - fDeclSpec2= null; - fDtor2= null; - return this; - } + public IASTDeclSpecifier altSpec; + public IASTDeclarator altDeclarator; + + public IToken currToken; - public Decl set(IASTDeclSpecifier declspec1, IASTDeclarator dtor1, IASTDeclSpecifier declspec2, IASTDeclarator dtor2) { - fDeclSpec1= declspec1; - fDtor1= dtor1; - fDtorToken1= null; - fDeclSpec2= declspec2; - fDtor2= dtor2; - return this; - } + public FoundDeclaratorException(IASTDeclarator d, IToken t) { + this.declarator = d; + this.currToken =t; + } } private static final ASTVisitor MARK_INACTIVE = new ASTGenericVisitor(true) { @@ -1399,9 +1384,36 @@ return compoundStatement(); } - protected abstract IASTDeclarator initDeclarator(IASTDeclSpecifier declSpec, DeclarationOptions option) + protected abstract IASTDeclarator initDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException, FoundAggregateInitializer; + /** + * @param option the options with which to parse the declaration + * @throws FoundDeclaratorException encountered EOF while looking ahead + * @throws FoundAggregateInitializer found aggregate initializer, needs special treatment + * because of scalability. + */ + protected void lookAheadForDeclarator(final DeclarationOptions option) + throws FoundDeclaratorException, FoundAggregateInitializer { + IToken mark = null; + try { + mark = mark(); + final IASTDeclarator dtor= initDeclarator(option); + final IToken la = LA(1); + if (la == null || la == mark) + return; + + if (verifyLookaheadDeclarator(option, dtor, la)) + throw new FoundDeclaratorException(dtor, la); + } catch (BacktrackException bte) { + } catch (EndOfFileException e) { + } finally { + if (mark != null) + backup(mark); + } + } + + protected abstract boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator d, IToken nextToken); /** * Parse an enumeration specifier, as according to the ANSI specs in C & @@ -1518,98 +1530,7 @@ protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException; - - /** - * Parses for two alternatives of a declspec sequence. If there is a second alternative the token after the second alternative - * is returned, such that the parser can continue after both variants. - */ - protected abstract Decl declSpecifierSeq(DeclarationOptions option) throws BacktrackException, EndOfFileException; - - /** - * Parses for two alternatives of a declspec sequence followed by a initDeclarator. - * A second alternative is accepted only, if it ends at the same point of the first alternative. Otherwise the - * longer alternative is selected. - */ - protected Decl declSpecifierSequence_initDeclarator(final DeclarationOptions option, boolean acceptCompoundWithoutDtor) throws EndOfFileException, FoundAggregateInitializer, BacktrackException { - Decl result= declSpecifierSeq(option); - - final int lt1 = LTcatchEOF(1); - if (lt1 == IToken.tEOC) - return result; - - // support simple declarations without declarators - final boolean acceptEmpty = acceptCompoundWithoutDtor && specifiesCompound(result.fDeclSpec1); - if (acceptEmpty) { - switch(lt1) { - case 0: - case IToken.tEOC: - case IToken.tSEMI: - return result; - } - } - - final IToken dtorMark1= mark(); - final IToken dtorMark2= result.fDtorToken1; - final IASTDeclSpecifier declspec1= result.fDeclSpec1; - final IASTDeclSpecifier declspec2= result.fDeclSpec2; - IASTDeclarator dtor1, dtor2; - try { - // declarator for first variant - dtor1= initDeclarator(declspec1, option); - } catch (FoundAggregateInitializer e) { - e.fDeclSpec= declspec1; - throw e; - } catch (BacktrackException e) { - if (acceptEmpty) { - backup(dtorMark1); - return result.set(declspec1, null, null); - } - - // try second variant, if possible - if (dtorMark2 == null) - throw e; - - backup(dtorMark2); - dtor2= initDeclarator(declspec2, option); - return result.set(declspec2, dtor2, dtorMark2); - } - - // first variant was a success. If possible, try second one. - if (dtorMark2 == null) { - return result.set(declspec1, dtor1, dtorMark1); - } - - final IToken end1= mark(); - backup(dtorMark2); - try { - dtor2= initDeclarator(declspec2, option); - } catch (BacktrackException e) { - backup(end1); - return result.set(declspec1, dtor1, dtorMark1); - } - - final IToken end2= mark(); - if (end1 == end2) { - return result.set(declspec1, dtor1, declspec2, dtor2); - } - if (end1.getEndOffset() > end2.getEndOffset()) { - backup(end1); - return result.set(declspec1, dtor1, dtorMark1); - } - - return result.set(declspec2, dtor2, dtorMark2); - } - - protected boolean specifiesCompound(IASTDeclSpecifier declSpec) { - if (declSpec instanceof IASTCompositeTypeSpecifier) - return true; - if (declSpec instanceof IASTElaboratedTypeSpecifier) - return true; - if (declSpec instanceof IASTEnumerationSpecifier) - return true; - - return false; - } + protected abstract IASTDeclSpecifier declSpecifierSeq(DeclarationOptions option) throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer; protected IASTDeclaration[] problemDeclaration(int offset, BacktrackException bt, DeclarationOptions option) { failParse(); @@ -1693,15 +1614,25 @@ protected IASTDeclaration functionStyleAsmDeclaration() throws BacktrackException, EndOfFileException { + final int offset= LA(1).getOffset(); - IASTDeclSpecifier declSpec; + IASTDeclSpecifier declSpec= null; IASTDeclarator dtor; try { - Decl decl= declSpecifierSequence_initDeclarator(DeclarationOptions.FUNCTION_STYLE_ASM, false); - declSpec= decl.fDeclSpec1; - dtor= decl.fDtor1; - } catch (FoundAggregateInitializer lie) { - declSpec= lie.fDeclSpec; + declSpec = declSpecifierSeq(DeclarationOptions.FUNCTION_STYLE_ASM); + dtor = initDeclarator(DeclarationOptions.FUNCTION_STYLE_ASM); + } catch (FoundDeclaratorException e) { + if (e.altSpec != null) { + declSpec= e.altSpec; + dtor= e.altDeclarator; + } else { + declSpec = e.declSpec; + dtor= e.declarator; + } + backup( e.currToken ); + } catch (FoundAggregateInitializer lie) { + if (declSpec == null) + declSpec= lie.fDeclSpec; dtor= addInitializer(lie, DeclarationOptions.FUNCTION_STYLE_ASM); } @@ -1709,7 +1640,7 @@ throwBacktrack(LA(1)); final IASTDeclarator fdtor= ASTQueries.findTypeRelevantDeclarator(dtor); - if (!(fdtor instanceof IASTFunctionDeclarator)) + if (dtor instanceof IASTFunctionDeclarator == false) throwBacktrack(offset, LA(1).getEndOffset() - offset); final int compoundOffset= LA(1).getOffset(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java Wed Aug 05 17:35:39 2009 -0500 @@ -27,7 +27,7 @@ public static final DeclarationOptions GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_CONSTRUCTOR_INITIALIZER), - FUNCTION_STYLE_ASM= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER | ALLOW_ABSTRACT), + FUNCTION_STYLE_ASM= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER), C_MEMBER= new DeclarationOptions(ALLOW_BITFIELD | ALLOW_ABSTRACT), CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD), LOCAL= new DeclarationOptions(ALLOW_CONSTRUCTOR_INITIALIZER), diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,29 +1,36 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM Corporation) - initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM Corporation - initial API and implementation *******************************************************************************/ + +/* + * Created on Dec 13, 2004 + */ package org.eclipse.cdt.internal.core.dom.parser; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; /** * Internal interface representing types that contain other types + * @author aniefer */ public interface ITypeContainer extends IType { /** * get the type this contains + * @throws DOMException */ - IType getType(); + IType getType() throws DOMException; /** * set the type this contains + * @param type */ void setType(IType type); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/NodeFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/NodeFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser; - -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.INodeFactory; - -/** - * Abstract base class for node factories. - */ -public abstract class NodeFactory implements INodeFactory { - - public final void setOffsets(IASTNode node, int offset, int endOffset) { - ((ASTNode) node).setOffsetAndLength(offset, endOffset-offset); - } - - public final void setEndOffset(IASTNode node, int endOffset) { - ASTNode a= (ASTNode) node; - a.setLength(endOffset - a.getOffset()); - } - - public final void setEndOffset(IASTNode node, IASTNode endNode) { - ASTNode a= (ASTNode) node; - ASTNode e= (ASTNode) endNode; - a.setLength(e.getOffset() + e.getLength() - a.getOffset()); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java Wed Aug 05 17:35:39 2009 -0500 @@ -41,7 +41,7 @@ protected char[] arg; protected IASTNode node; private final String message = null; - private IBinding[] candidateBindings; + private final IBinding[] candidateBindings; public ProblemBinding(IASTName name, int id) { this(name, id, null, null); @@ -73,10 +73,6 @@ public IBinding[] getCandidateBindings() { return candidateBindings != null ? candidateBindings : IBinding.EMPTY_BINDING_ARRAY; } - - public void setCandidateBindings(IBinding[] foundBindings) { - candidateBindings= foundBindings; - } protected static final String[] errorMessages; static { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,7 +45,6 @@ public class Value implements IValue { public static final int MAX_RECURSION_DEPTH = 25; public final static IValue UNKNOWN= new Value("".toCharArray(), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); //$NON-NLS-1$ - public final static IValue NOT_INITIALIZED= new Value("<__>".toCharArray(), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); //$NON-NLS-1$ private static final String SCOPE_OP = "::"; //$NON-NLS-1$ private static final char UNIQUE_CHAR = '_'; @@ -226,8 +225,8 @@ */ public static boolean referencesTemplateParameter(IValue tval) { final char[] rep= tval.getInternalExpression(); - for (char element : rep) { - if (element == TEMPLATE_PARAM_CHAR) + for (int i = 0; i < rep.length; i++) { + if (rep[i] == TEMPLATE_PARAM_CHAR) return true; } return false; @@ -238,7 +237,8 @@ */ public static boolean isDependentValue(IValue nonTypeValue) { final char[] rep= nonTypeValue.getInternalExpression(); - for (final char c : rep) { + for (int i = 0; i < rep.length; i++) { + final char c = rep[i]; if (c == REFERENCE_CHAR || c == TEMPLATE_PARAM_CHAR) return true; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -162,16 +162,20 @@ } protected int rwArgumentForFunctionCall(final IASTFunctionCallExpression func, int parameterIdx, int indirection) { - final IASTExpression functionNameExpression = func.getFunctionNameExpression(); - if (functionNameExpression != null) { - final IType type= functionNameExpression.getExpressionType(); - if (type instanceof IFunctionType) { - IType[] ptypes= ((IFunctionType) type).getParameterTypes(); - if (ptypes != null && ptypes.length > parameterIdx) { - return rwAssignmentToType(ptypes[parameterIdx], indirection); + try { + final IASTExpression functionNameExpression = func.getFunctionNameExpression(); + if (functionNameExpression != null) { + final IType type= functionNameExpression.getExpressionType(); + if (type instanceof IFunctionType) { + IType[] ptypes= ((IFunctionType) type).getParameterTypes(); + if (ptypes != null && ptypes.length > parameterIdx) { + return rwAssignmentToType(ptypes[parameterIdx], indirection); + } } } } + catch (DOMException e) { + } return READ | WRITE; // fallback } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java Wed Aug 05 17:35:39 2009 -0500 @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -113,10 +114,14 @@ public IType getExpressionType() { IType t = getArrayExpression().getExpressionType(); - if (t instanceof IPointerType) - return ((IPointerType)t).getType(); - else if (t instanceof IArrayType) - return ((IArrayType)t).getType(); + try { + if (t instanceof IPointerType) + return ((IPointerType)t).getType(); + else if (t instanceof IArrayType) + return ((IArrayType)t).getType(); + } catch (DOMException e) { + return e.getProblem(); + } return t; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java Wed Aug 05 17:35:39 2009 -0500 @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -114,10 +115,14 @@ public IType getExpressionType() { IType type = getFunctionNameExpression().getExpressionType(); - while (type instanceof ITypeContainer) - type = ((ITypeContainer) type).getType(); - if (type instanceof IFunctionType) - return ((IFunctionType) type).getReturnType(); + try { + while (type instanceof ITypeContainer) + type = ((ITypeContainer) type).getType(); + if (type instanceof IFunctionType) + return ((IFunctionType) type).getReturnType(); + } catch (DOMException e) { + return e.getProblem(); + } return null; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java Wed Aug 05 17:35:39 2009 -0500 @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; @@ -101,10 +102,14 @@ public IType getExpressionType() { IType type = getOperand().getExpressionType(); int op = getOperator(); - if (op == IASTUnaryExpression.op_star && (type instanceof IPointerType || type instanceof IArrayType)) { - return ((ITypeContainer) type).getType(); - } else if (op == IASTUnaryExpression.op_amper) { - return new CPointerType(type, 0); + try { + if (op == IASTUnaryExpression.op_star && (type instanceof IPointerType || type instanceof IArrayType)) { + return ((ITypeContainer) type).getType(); + } else if (op == IASTUnaryExpression.op_amper) { + return new CPointerType(type, 0); + } + } catch (DOMException e) { + return e.getProblem(); } return type; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java Wed Aug 05 17:35:39 2009 -0500 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Devin Steffler (IBM Corporation) - initial API and implementation + * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -16,14 +16,14 @@ import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier; import org.eclipse.cdt.core.dom.ast.c.ICArrayType; -import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.index.IIndexType; +/** + * @author dsteffle + */ public class CArrayType implements ICArrayType, ITypeContainer { IType type; ICASTArrayModifier mod; @@ -35,7 +35,7 @@ public boolean isSameType(IType obj) { if (obj == this) return true; - if (obj instanceof ITypedef || obj instanceof IIndexType) + if (obj instanceof ITypedef) return obj.isSameType(this); if (obj instanceof ICArrayType) { ICArrayType at = (ICArrayType) obj; @@ -46,24 +46,18 @@ if (isVolatile() != at.isVolatile()) return false; if (isVariableLength() != at.isVariableLength()) return false; - return at.getType().isSameType(type) && hasSameSize(at); + return at.getType().isSameType(type); } catch (DOMException e) { return false; } } + // Workaround for bug 182976, no PDOMCArrayType. + else if (obj instanceof IArrayType && obj instanceof IIndexType) { + return obj.isSameType(this); + } return false; } - private boolean hasSameSize(IArrayType rhs) { - IValue s1 = getSize(); - IValue s2 = rhs.getSize(); - if (s1 == s2) - return true; - if (s1 == null || s2 == null) - return false; - return CharArrayUtils.equals(s1.getSignature(), s2.getSignature()); - } - /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IArrayType#getType() */ @@ -123,17 +117,9 @@ return mod; } - public IValue getSize() { - if (mod != null) { - IASTExpression sizeExpression = mod.getConstantExpression(); - if (sizeExpression != null) { - return Value.create(sizeExpression, Value.MAX_RECURSION_DEPTH); - } - } - return null; - } - - @Deprecated + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IArrayType#getArraySizeExpression() + */ public IASTExpression getArraySizeExpression() { if (mod != null) return mod.getConstantExpression(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,19 +1,23 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Devin Steffler (IBM Corporation) - initial API and implementation + * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; +/** + * @author dsteffle + */ public class CFunctionType implements IFunctionType { IType[] parameters = null; IType returnType = null; @@ -35,11 +39,19 @@ if( o instanceof IFunctionType ){ IFunctionType ft = (IFunctionType) o; IType [] fps; - fps = ft.getParameterTypes(); + try { + fps = ft.getParameterTypes(); + } catch ( DOMException e ) { + return false; + } if( fps.length != parameters.length ) return false; - if( ! returnType.isSameType( ft.getReturnType() ) ) - return false; + try { + if( ! returnType.isSameType( ft.getReturnType() ) ) + return false; + } catch ( DOMException e1 ) { + return false; + } for( int i = 0; i < parameters.length; i++ ) if( ! parameters[i].isSameType( fps[i] ) ) return false; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java Wed Aug 05 17:35:39 2009 -0500 @@ -6,8 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Mike Kucera (IBM Corporation) - initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -78,15 +77,15 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator; import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier; -import org.eclipse.cdt.core.parser.IScanner; -import org.eclipse.cdt.internal.core.dom.parser.NodeFactory; /** * Abstract factory implementation that creates AST nodes for C99. * These can be overridden in subclasses to change the * implementations of the nodes. + * + * @author Mike Kucera */ -public class CNodeFactory extends NodeFactory implements ICNodeFactory { +public class CNodeFactory implements ICNodeFactory { private static final CNodeFactory DEFAULT_INSTANCE = new CNodeFactory(); @@ -94,16 +93,9 @@ return DEFAULT_INSTANCE; } + public IASTTranslationUnit newTranslationUnit() { - return newTranslationUnit(null); - } - - public IASTTranslationUnit newTranslationUnit(IScanner scanner) { CASTTranslationUnit tu = new CASTTranslationUnit(); - - if (scanner != null) { - tu.setLocationResolver(scanner.getLocationResolver()); - } tu.setASTNodeFactory(this); return tu; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,20 +1,24 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Devin Steffler (IBM Rational Software) - Initial API and implementation + * IBM Rational Software - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICPointerType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +/** + * @author dsteffle + */ public class CPointerType implements ICPointerType, ITypeContainer { static public final int IS_CONST = 1; static public final int IS_RESTRICT = 1 << 1; @@ -38,11 +42,15 @@ if( obj instanceof ICPointerType ){ ICPointerType pt = (ICPointerType) obj; - if( isConst() != pt.isConst() ) return false; - if( isRestrict() != pt.isRestrict() ) return false; - if( isVolatile() != pt.isVolatile() ) return false; - - return pt.getType().isSameType( nextType ); + try { + if( isConst() != pt.isConst() ) return false; + if( isRestrict() != pt.isRestrict() ) return false; + if( isVolatile() != pt.isVolatile() ) return false; + + return pt.getType().isSameType( nextType ); + } catch ( DOMException e ) { + return false; + } } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,15 +1,16 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Devin Steffler (IBM Rational Software) - Initial API and implementation + * IBM Rational Software - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; @@ -21,6 +22,9 @@ import org.eclipse.cdt.core.dom.ast.c.ICQualifierType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +/** + * @author dsteffle + */ public class CQualifierType implements ICQualifierType, ITypeContainer { private boolean isConst; @@ -53,13 +57,17 @@ if( obj instanceof ICQualifierType ){ ICQualifierType qt = (ICQualifierType) obj; - if( isConst() != qt.isConst() ) return false; - if( isRestrict() != qt.isRestrict() ) return false; - if( isVolatile() != qt.isVolatile() ) return false; - - if( type == null ) - return false; - return type.isSameType( qt.getType() ); + try { + if( isConst() != qt.isConst() ) return false; + if( isRestrict() != qt.isRestrict() ) return false; + if( isVolatile() != qt.isVolatile() ) return false; + + if( type == null ) + return false; + return type.isSameType( qt.getType() ); + } catch ( DOMException e ) { + return false; + } } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypedef.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -86,12 +86,15 @@ public boolean isSameType( IType t ) { if( t == this ) return true; - if( t instanceof ITypedef ) { - IType temp = getType(); - if( temp != null ) - return temp.isSameType( ((ITypedef)t).getType()); - return false; - } + if( t instanceof ITypedef ) + try { + IType temp = getType(); + if( temp != null ) + return temp.isSameType( ((ITypedef)t).getType()); + return false; + } catch ( DOMException e ) { + return false; + } IType temp = getType(); if( temp != null ) diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariableReadWriteFlags.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; @@ -81,17 +82,21 @@ if (indirection == 0) { return READ; } - while(indirection > 0 && (type instanceof IPointerType)) { - type= ((IPointerType) type).getType(); - indirection--; + try { + while(indirection > 0 && (type instanceof IPointerType)) { + type= ((IPointerType) type).getType(); + indirection--; + } + if (indirection == 0) { + if (type instanceof IQualifierType) { + return ((IQualifierType) type).isConst() ? READ : READ | WRITE; + } + else if (type instanceof IPointerType) { + return ((IPointerType) type).isConst() ? READ : READ | WRITE; + } + } } - if (indirection == 0) { - if (type instanceof IQualifierType) { - return ((IQualifierType) type).isConst() ? READ : READ | WRITE; - } - else if (type instanceof IPointerType) { - return ((IPointerType) type).isConst() ? READ : READ | WRITE; - } + catch (DOMException e) { } return READ | WRITE; // fallback } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java Wed Aug 05 17:35:39 2009 -0500 @@ -603,7 +603,11 @@ IType type = fieldOwner.getExpressionType(); while (type != null && type instanceof ITypeContainer) { - type = ((ITypeContainer)type).getType(); + try { + type = ((ITypeContainer)type).getType(); + } catch (DOMException e) { + return e.getProblem(); + } } if (type != null && type instanceof ICompositeType) { @@ -922,10 +926,14 @@ } } else if (struct instanceof ITypeContainer) { IType type; - type = ((ITypeContainer)struct).getType(); - while (type instanceof ITypeContainer && !(type instanceof CStructure)) { - type = ((ITypeContainer)type).getType(); - } + try { + type = ((ITypeContainer)struct).getType(); + while (type instanceof ITypeContainer && !(type instanceof CStructure)) { + type = ((ITypeContainer)type).getType(); + } + } catch (DOMException e) { + return e.getProblem(); + } if (type instanceof CStructure) @@ -1277,25 +1285,29 @@ IType paramType = type; // Remove typedefs ready for subsequent processing. while (paramType instanceof ITypedef) { - paramType = ((ITypedef)paramType).getType(); + try { + paramType = ((ITypedef)paramType).getType(); + } catch (DOMException e) { + paramType= null; + } } //C99: 6.7.5.3-7 a declaration of a parameter as "array of type" shall be adjusted to "qualified pointer to type", where the //type qualifiers (if any) are those specified within the[and] of the array type derivation if (paramType instanceof IArrayType) { // the index does not yet return ICArrayTypes IArrayType at = (IArrayType) paramType; - int q= 0; - if (at instanceof ICArrayType) { - ICArrayType cat= (ICArrayType) at; - try { + try { + int q= 0; + if (at instanceof ICArrayType) { + ICArrayType cat= (ICArrayType) at; if (cat.isConst()) q |= CPointerType.IS_CONST; if (cat.isVolatile()) q |= CPointerType.IS_VOLATILE; if (cat.isRestrict()) q |= CPointerType.IS_RESTRICT; - } catch (DOMException e) { - // ignore the qualifiers } + type = new CPointerType(at.getType(), q); + } catch (DOMException e) { + // ignore the qualifiers } - type = new CPointerType(at.getType(), q); } else if (paramType instanceof IFunctionType) { //-8 A declaration of a parameter as "function returning type" shall be adjusted to "pointer to function returning type" type = new CPointerType(paramType, 0); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java Wed Aug 05 17:35:39 2009 -0500 @@ -90,6 +90,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; +import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; import org.eclipse.cdt.internal.core.dom.parser.BacktrackException; import org.eclipse.cdt.internal.core.dom.parser.DeclarationOptions; @@ -291,31 +292,64 @@ return simpleDeclaration(declOption); } - private IASTDeclaration simpleDeclaration(final DeclarationOptions declOption) throws BacktrackException, EndOfFileException { + private IASTDeclaration simpleDeclaration(final DeclarationOptions declOption) + throws BacktrackException, EndOfFileException { if (LT(1) == IToken.tLBRACE) throwBacktrack(LA(1)); final int firstOffset= LA(1).getOffset(); int endOffset= firstOffset; boolean insertSemi= false; + boolean parseDtors= true; IASTDeclSpecifier declSpec= null; IASTDeclarator dtor= null; IASTDeclSpecifier altDeclSpec= null; - IASTDeclarator altDtor= null; + IASTDeclarator altDeclarator= null; IToken markBeforDtor= null; try { - Decl decl= declSpecifierSequence_initDeclarator(declOption, true); - markBeforDtor= decl.fDtorToken1; - declSpec= decl.fDeclSpec1; - dtor= decl.fDtor1; - altDeclSpec= decl.fDeclSpec2; - altDtor= decl.fDtor2; + declSpec = declSpecifierSeq(declOption); + final int lt1= LTcatchEOF(1); + switch(lt1) { + case 0: // eof + case IToken.tEOC: + case IToken.tSEMI: + parseDtors= false; + insertSemi= lt1==0; + if (lt1 == IToken.tSEMI) + endOffset= consume().getEndOffset(); + else + endOffset= calculateEndOffset(declSpec); + break; + + default: + markBeforDtor= mark(); + try { + dtor= initDeclarator(declOption); + } catch (BacktrackException e) { + backup(markBeforDtor); + } catch (EndOfFileException e) { + backup(markBeforDtor); + } + } } catch (FoundAggregateInitializer lie) { - declSpec= lie.fDeclSpec; + if (declSpec == null) + declSpec= lie.fDeclSpec; // scalability: don't keep references to tokens, initializer may be large declarationMark= null; + markBeforDtor= null; dtor= addInitializer(lie, declOption); + } catch (FoundDeclaratorException e) { + if (e.altSpec != null) { + declSpec= e.altSpec; + dtor= e.altDeclarator; + altDeclSpec= e.declSpec; + altDeclarator= e.declarator; + } else { + declSpec = e.declSpec; + dtor= e.declarator; + } + backup( e.currToken ); } catch (BacktrackException e) { IASTNode node= e.getNodeBeforeProblem(); if (node instanceof IASTDeclSpecifier) { @@ -327,12 +361,12 @@ } IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; - if (dtor != null) { + if (parseDtors) { declarators= new IASTDeclarator[]{dtor}; while (LTcatchEOF(1) == IToken.tCOMMA) { consume(); try { - dtor= initDeclarator(declSpec, declOption); + dtor= initDeclarator(declOption); } catch (FoundAggregateInitializer e) { // scalability: don't keep references to tokens, initializer may be large declarationMark= null; @@ -342,44 +376,44 @@ declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, dtor); } declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators ); - } - - final int lt1= LTcatchEOF(1); - switch (lt1) { - case IToken.tEOC: - endOffset= figureEndOffset(declSpec, declarators); - break; - case IToken.tSEMI: - endOffset= consume().getEndOffset(); - break; - case IToken.tLBRACE: - return functionDefinition(firstOffset, declSpec, declarators); + + final int lt1= LTcatchEOF(1); + switch (lt1) { + case IToken.tLBRACE: + return functionDefinition(firstOffset, declSpec, declarators); - default: - if (declOption != DeclarationOptions.LOCAL) { - insertSemi= true; - if (markBeforDtor != null) { - endOffset= calculateEndOffset(declSpec); - if (firstOffset != endOffset && !isOnSameLine(endOffset, markBeforDtor.getOffset())) { - backup(markBeforDtor); - declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; + case IToken.tSEMI: + endOffset= consume().getEndOffset(); + break; + case IToken.tEOC: + endOffset= figureEndOffset(declSpec, declarators); + break; + default: + if (declOption != DeclarationOptions.LOCAL) { + insertSemi= true; + if (markBeforDtor != null) { + endOffset= calculateEndOffset(declSpec); + if (firstOffset != endOffset && !isOnSameLine(endOffset, markBeforDtor.getOffset())) { + backup(markBeforDtor); + declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; + break; + } + } + endOffset= figureEndOffset(declSpec, declarators); + if (lt1 == 0) { break; } - } - endOffset= figureEndOffset(declSpec, declarators); - if (lt1 == 0) { - break; - } - if (firstOffset != endOffset) { - if (!isOnSameLine(endOffset, LA(1).getOffset())) { - break; - } - if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) { - break; + if (firstOffset != endOffset) { + if (!isOnSameLine(endOffset, LA(1).getOffset())) { + break; + } + if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) { + break; + } } } + throwBacktrack(LA(1)); } - throwBacktrack(LA(1)); } // no function body @@ -388,10 +422,10 @@ simpleDeclaration.addDeclarator(declarator); setRange(simpleDeclaration, firstOffset, endOffset); - if (altDeclSpec != null && altDtor != null) { - simpleDeclaration = new CASTAmbiguousSimpleDeclaration(simpleDeclaration, altDeclSpec, altDtor); - setRange(simpleDeclaration, firstOffset, endOffset); - } + if ( altDeclSpec != null && altDeclarator != null) { + simpleDeclaration= new CASTAmbiguousSimpleDeclaration(simpleDeclaration, altDeclSpec, altDeclarator); + setRange(simpleDeclaration, firstOffset, endOffset); + } if (insertSemi) { IASTProblem problem= createProblem(IProblem.SYNTAX_ERROR, endOffset, 0); @@ -432,7 +466,7 @@ @Override protected void setupTranslationUnit() throws DOMException { - translationUnit = nodeFactory.newTranslationUnit(scanner); + translationUnit = nodeFactory.newTranslationUnit(); translationUnit.setIndex(index); // add built-in names to the scope @@ -444,6 +478,8 @@ ASTInternal.addBinding(tuScope, binding); } } + if(translationUnit instanceof ASTTranslationUnit) + ((ASTTranslationUnit)translationUnit).setLocationResolver(scanner.getLocationResolver()); } @@ -704,18 +740,24 @@ if (!canBeTypeSpecifier()) { return null; } - final int offset = mark().getOffset(); + IToken mark = mark(); + int startingOffset = mark.getOffset(); IASTDeclSpecifier declSpecifier = null; IASTDeclarator declarator = null; fPreventKnrCheck++; try { - Decl decl= declSpecifierSequence_initDeclarator(option, false); - declSpecifier= decl.fDeclSpec1; - declarator= decl.fDtor1; - } catch (FoundAggregateInitializer lie) { - // type-ids have not compound initializers - return null; + try { + declSpecifier= declSpecifierSeq(option); + declarator= declarator(option); + } catch (FoundDeclaratorException e) { + declSpecifier= e.declSpec; + declarator= e.declarator; + backup(e.currToken); + } catch (FoundAggregateInitializer lie) { + // type-ids have not compound initializers + return null; + } } catch (BacktrackException bt) { return null; } finally { @@ -723,7 +765,8 @@ } IASTTypeId result = nodeFactory.newTypeId(declSpecifier, declarator); - setRange(result, offset, figureEndOffset(declSpecifier, declarator)); + ((ASTNode) result).setOffsetAndLength(startingOffset, figureEndOffset( + declSpecifier, declarator) - startingOffset); return result; } @@ -788,283 +831,292 @@ SHORT=0x10, UNSIGNED= 0x20, SIGNED=0x40, COMPLEX=0x80, IMAGINARY=0x100; @Override - protected Decl declSpecifierSeq(final DeclarationOptions declOption) throws BacktrackException, EndOfFileException { + protected IASTDeclSpecifier declSpecifierSeq(final DeclarationOptions declOption) + throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer { + + final int offset= LA(1).getOffset(); + int endOffset= offset; int storageClass= IASTDeclSpecifier.sc_unspecified; int simpleType= IASTSimpleDeclSpecifier.t_unspecified; int options= 0; int isLong= 0; - IToken returnToken= null; - IASTDeclSpecifier result= null; - IASTDeclSpecifier altResult= null; - try { - IASTName identifier= null; - IASTExpression typeofExpression= null; - IASTProblem problem= null; + IASTName identifier= null; + IASTDeclSpecifier result= null; + IASTExpression typeofExpression= null; + IASTProblem problem= null; - boolean encounteredRawType= false; - boolean encounteredTypename= false; - - final int offset= LA(1).getOffset(); - int endOffset= offset; + boolean encounteredRawType= false; + boolean encounteredTypename= false; - declSpecifiers: for (;;) { - final int lt1= LTcatchEOF(1); - switch (lt1) { - case 0: // eof - break declSpecifiers; - // storage class specifiers - case IToken.t_auto: - storageClass = IASTDeclSpecifier.sc_auto; - endOffset= consume().getEndOffset(); - break; - case IToken.t_register: - storageClass = IASTDeclSpecifier.sc_register; - endOffset= consume().getEndOffset(); - break; - case IToken.t_static: - storageClass = IASTDeclSpecifier.sc_static; - endOffset= consume().getEndOffset(); - break; - case IToken.t_extern: - storageClass = IASTDeclSpecifier.sc_extern; - endOffset= consume().getEndOffset(); - break; - case IToken.t_typedef: - storageClass = IASTDeclSpecifier.sc_typedef; - endOffset= consume().getEndOffset(); - break; + declSpecifiers: for (;;) { + final int lt1= LTcatchEOF(1); + switch (lt1) { + case 0: // eof + break declSpecifiers; + // storage class specifiers + case IToken.t_auto: + storageClass = IASTDeclSpecifier.sc_auto; + endOffset= consume().getEndOffset(); + break; + case IToken.t_register: + storageClass = IASTDeclSpecifier.sc_register; + endOffset= consume().getEndOffset(); + break; + case IToken.t_static: + storageClass = IASTDeclSpecifier.sc_static; + endOffset= consume().getEndOffset(); + break; + case IToken.t_extern: + storageClass = IASTDeclSpecifier.sc_extern; + endOffset= consume().getEndOffset(); + break; + case IToken.t_typedef: + storageClass = IASTDeclSpecifier.sc_typedef; + endOffset= consume().getEndOffset(); + break; - // Function Specifier - case IToken.t_inline: - options |= INLINE; - endOffset= consume().getEndOffset(); - break; + // Function Specifier + case IToken.t_inline: + options |= INLINE; + endOffset= consume().getEndOffset(); + break; - // Type Qualifiers - case IToken.t_const: - options |= CONST; - endOffset= consume().getEndOffset(); - break; - case IToken.t_volatile: - options |= VOLATILE; - endOffset= consume().getEndOffset(); - break; - case IToken.t_restrict: - options |= RESTRICT; - endOffset= consume().getEndOffset(); - break; + // Type Qualifiers + case IToken.t_const: + options |= CONST; + endOffset= consume().getEndOffset(); + break; + case IToken.t_volatile: + options |= VOLATILE; + endOffset= consume().getEndOffset(); + break; + case IToken.t_restrict: + options |= RESTRICT; + endOffset= consume().getEndOffset(); + break; - // Type Specifiers - case IToken.t_void: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_void; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_char: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_char; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_short: - if (encounteredTypename) - break declSpecifiers; - options |= SHORT; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_int: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_int; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_long: - if (encounteredTypename) - break declSpecifiers; - isLong++; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_float: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_float; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_double: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_double; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_signed: - if (encounteredTypename) - break declSpecifiers; - options |= SIGNED; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_unsigned: - if (encounteredTypename) - break declSpecifiers; - options |= UNSIGNED; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t__Bool: - if (encounteredTypename) - break declSpecifiers; - simpleType = ICASTSimpleDeclSpecifier.t_Bool; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t__Complex: - if (encounteredTypename) - break declSpecifiers; - options |= COMPLEX; - endOffset= consume().getEndOffset(); - break; - case IToken.t__Imaginary: - if (encounteredTypename) - break declSpecifiers; - options |= IMAGINARY; - endOffset= consume().getEndOffset(); - break; - - case IToken.tIDENTIFIER: - case IToken.tCOMPLETION: - case IToken.tEOC: - if (encounteredTypename || encounteredRawType) - break declSpecifiers; - - if ((endOffset != offset || declOption.fAllowEmptySpecifier) && LT(1) != IToken.tCOMPLETION) { - altResult= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); - returnToken= mark(); - } + // Type Specifiers + case IToken.t_void: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_void; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_char: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_char; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_short: + if (encounteredTypename) + break declSpecifiers; + options |= SHORT; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_int: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_int; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_long: + if (encounteredTypename) + break declSpecifiers; + isLong++; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_float: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_float; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_double: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_double; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_signed: + if (encounteredTypename) + break declSpecifiers; + options |= SIGNED; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_unsigned: + if (encounteredTypename) + break declSpecifiers; + options |= UNSIGNED; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t__Bool: + if (encounteredTypename) + break declSpecifiers; + simpleType = ICASTSimpleDeclSpecifier.t_Bool; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t__Complex: + if (encounteredTypename) + break declSpecifiers; + options |= COMPLEX; + endOffset= consume().getEndOffset(); + break; + case IToken.t__Imaginary: + if (encounteredTypename) + break declSpecifiers; + options |= IMAGINARY; + endOffset= consume().getEndOffset(); + break; - identifier = identifier(); - endOffset= calculateEndOffset(identifier); - encounteredTypename= true; - break; - case IToken.t_struct: - case IToken.t_union: - if (encounteredTypename || encounteredRawType) - break declSpecifiers; - try { - result= structOrUnionSpecifier(); - } catch (BacktrackException bt) { - result= elaboratedTypeSpecifier(); - } - endOffset= calculateEndOffset(result); - encounteredTypename= true; - break; - case IToken.t_enum: - if (encounteredTypename || encounteredRawType) - break declSpecifiers; - try { - result= enumSpecifier(); - } catch (BacktrackException bt) { - if (bt.getNodeBeforeProblem() instanceof IASTDeclSpecifier) { - result= (IASTDeclSpecifier) bt.getNodeBeforeProblem(); - problem = bt.getProblem(); - break declSpecifiers; - } else { - result= elaboratedTypeSpecifier(); - } - } - endOffset= calculateEndOffset(result); - encounteredTypename= true; - break; - - case IGCCToken.t__attribute__: // if __attribute__ is after the declSpec - if (!supportAttributeSpecifiers) - throwBacktrack(LA(1)); - __attribute_decl_seq(true, false); - break; - case IGCCToken.t__declspec: // __declspec precedes the identifier - if (identifier != null || !supportDeclspecSpecifiers) - throwBacktrack(LA(1)); - __attribute_decl_seq(false, true); - break; - - case IGCCToken.t_typeof: - if (encounteredRawType || encounteredTypename) - throwBacktrack(LA(1)); + case IToken.tIDENTIFIER: + case IToken.tCOMPLETION: + case IToken.tEOC: + if (encounteredTypename || encounteredRawType) { + break declSpecifiers; + } + + try { + if (endOffset != offset || declOption.fAllowEmptySpecifier) { + lookAheadForDeclarator(declOption); + } + } catch (FoundAggregateInitializer e) { + e.fDeclSpec= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); + throw e; + } catch (FoundDeclaratorException e) { + e.declSpec= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); - final boolean wasInBinary= inBinaryExpression; - try { - inBinaryExpression= false; - typeofExpression = parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), - IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof); - } finally { - inBinaryExpression= wasInBinary; - } - encounteredTypename= true; - endOffset= calculateEndOffset(typeofExpression); - break; - - default: - if (lt1 >= IExtensionToken.t__otherDeclSpecModifierFirst && lt1 <= IExtensionToken.t__otherDeclSpecModifierLast) { - handleOtherDeclSpecModifier(); - endOffset= LA(1).getOffset(); - break; - } - break declSpecifiers; - } - - if (encounteredRawType && encounteredTypename) - throwBacktrack(LA(1)); - } + IToken mark= mark(); + try { + final IASTName id= identifier(); // for the specifier + final IASTDeclarator altDtor = initDeclarator(declOption); + if (LA(1) == e.currToken) { + e.altDeclarator= altDtor; + e.altSpec= buildNamedTypeSpecifier(id, storageClass, options, offset, calculateEndOffset(id)); + } + } catch (FoundAggregateInitializer lie) { + lie.fDeclSpec= e.declSpec; + throw lie; + } catch (BacktrackException bt) { + } finally { + backup(mark); + } + throw e; + } + identifier = identifier(); + endOffset= calculateEndOffset(identifier); + encounteredTypename= true; + break; + case IToken.t_struct: + case IToken.t_union: + if (encounteredTypename || encounteredRawType) + break declSpecifiers; + try { + result= structOrUnionSpecifier(); + } catch (BacktrackException bt) { + result= elaboratedTypeSpecifier(); + } + endOffset= calculateEndOffset(result); + encounteredTypename= true; + break; + case IToken.t_enum: + if (encounteredTypename || encounteredRawType) + break declSpecifiers; + try { + result= enumSpecifier(); + } catch (BacktrackException bt) { + if (bt.getNodeBeforeProblem() instanceof IASTDeclSpecifier) { + result= (IASTDeclSpecifier) bt.getNodeBeforeProblem(); + problem = bt.getProblem(); + break declSpecifiers; + } else { + result= elaboratedTypeSpecifier(); + } + } + endOffset= calculateEndOffset(result); + encounteredTypename= true; + break; + + case IGCCToken.t__attribute__: // if __attribute__ is after the declSpec + if (!supportAttributeSpecifiers) + throwBacktrack(LA(1)); + __attribute_decl_seq(true, false); + break; + case IGCCToken.t__declspec: // __declspec precedes the identifier + if (identifier != null || !supportDeclspecSpecifiers) + throwBacktrack(LA(1)); + __attribute_decl_seq(false, true); + break; - // check for empty specification - if (!encounteredRawType && !encounteredTypename && LT(1) != IToken.tEOC && !declOption.fAllowEmptySpecifier) { - if (offset == endOffset) { - throwBacktrack(LA(1)); - } - } - - if (result != null) { - configureDeclSpec(result, storageClass, options); - if ((options & RESTRICT) != 0) { - if (result instanceof ICASTCompositeTypeSpecifier) { - ((ICASTCompositeTypeSpecifier) result).setRestrict(true); - } else if (result instanceof CASTEnumerationSpecifier) { - ((CASTEnumerationSpecifier) result).setRestrict(true); - } else if (result instanceof CASTElaboratedTypeSpecifier) { - ((CASTElaboratedTypeSpecifier) result).setRestrict(true); - } - } - setRange(result, offset, endOffset); - if (problem != null) - throwBacktrack(problem, result); - } else if (identifier != null) { - result= buildNamedTypeSpecifier(identifier, storageClass, options, offset, endOffset); - } else { - result= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); - } - } catch (BacktrackException e) { - if (returnToken != null) { - backup(returnToken); - result= altResult; - altResult= null; - returnToken= null; - } else { - throw e; + case IGCCToken.t_typeof: + if (encounteredRawType || encounteredTypename) + throwBacktrack(LA(1)); + + final boolean wasInBinary= inBinaryExpression; + try { + inBinaryExpression= false; + typeofExpression = parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), + IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof); + } finally { + inBinaryExpression= wasInBinary; + } + encounteredTypename= true; + endOffset= calculateEndOffset(typeofExpression); + break; + + default: + if (lt1 >= IExtensionToken.t__otherDeclSpecModifierFirst && lt1 <= IExtensionToken.t__otherDeclSpecModifierLast) { + handleOtherDeclSpecModifier(); + endOffset= LA(1).getOffset(); + break; + } + break declSpecifiers; + } + + if (encounteredRawType && encounteredTypename) + throwBacktrack(LA(1)); + } + + // check for empty specification + if (!encounteredRawType && !encounteredTypename && LT(1) != IToken.tEOC && !declOption.fAllowEmptySpecifier) { + if (offset == endOffset) { + throwBacktrack(LA(1)); } } - Decl target= new Decl(); - target.fDeclSpec1= result; - target.fDeclSpec2= altResult; - target.fDtorToken1= returnToken; - return target; + + if (result != null) { + configureDeclSpec(result, storageClass, options); + if ((options & RESTRICT) != 0) { + if (result instanceof ICASTCompositeTypeSpecifier) { + ((ICASTCompositeTypeSpecifier) result).setRestrict(true); + } else if (result instanceof CASTEnumerationSpecifier) { + ((CASTEnumerationSpecifier) result).setRestrict(true); + } else if (result instanceof CASTElaboratedTypeSpecifier) { + ((CASTElaboratedTypeSpecifier) result).setRestrict(true); + } + } + ((ASTNode) result).setOffsetAndLength(offset, endOffset - offset); + if (problem != null) + throwBacktrack(problem, result); + + return result; + } + + if (identifier != null) + return buildNamedTypeSpecifier(identifier, storageClass, options, offset, endOffset); + + return buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); } private ICASTTypedefNameSpecifier buildNamedTypeSpecifier(IASTName name, int storageClass, @@ -1106,6 +1158,31 @@ declSpec.setInline((options & INLINE) != 0); } + @Override + protected boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator dtor, IToken nextToken) { + switch (nextToken.getType()) { + case IToken.tCOMMA: + return true; + case IToken.tLBRACE: + if (option == DeclarationOptions.GLOBAL || option == DeclarationOptions.C_MEMBER + || option == DeclarationOptions.FUNCTION_STYLE_ASM) { + if (ASTQueries.findTypeRelevantDeclarator(dtor) instanceof IASTFunctionDeclarator) { + return true; + } + } + break; + case IToken.tSEMI: + return option == DeclarationOptions.GLOBAL || option == DeclarationOptions.C_MEMBER || + option == DeclarationOptions.LOCAL; + + case IToken.tRPAREN: + return option == DeclarationOptions.PARAMETER + || option == DeclarationOptions.C_PARAMETER_NON_ABSTRACT; + } + return false; + } + + /** * Parse a class/struct/union definition. * @@ -1192,18 +1269,11 @@ @Override - protected IASTDeclarator initDeclarator(IASTDeclSpecifier declspec, final DeclarationOptions option) + protected IASTDeclarator initDeclarator(final DeclarationOptions option) throws EndOfFileException, BacktrackException, FoundAggregateInitializer { - IASTDeclarator d = declarator(declspec, option); + IASTDeclarator d = declarator(option); - final int lt1= LTcatchEOF(1); - if (lt1 == IToken.tLBRACE) { - if (!(ASTQueries.findTypeRelevantDeclarator(d) instanceof IASTFunctionDeclarator)) { - throwBacktrack(LA(1)); - } - } - - if (lt1 == IToken.tASSIGN && LT(2) == IToken.tLBRACE) + if (LTcatchEOF(1) == IToken.tASSIGN && LT(2) == IToken.tLBRACE) throw new FoundAggregateInitializer(d); IASTInitializer i = optionalCInitializer(); @@ -1229,7 +1299,7 @@ return d; } - protected IASTDeclarator declarator(IASTDeclSpecifier declSpec, DeclarationOptions option) throws EndOfFileException, BacktrackException { + protected IASTDeclarator declarator(DeclarationOptions option) throws EndOfFileException, BacktrackException { final int startingOffset = LA(1).getOffset(); int endOffset = startingOffset; @@ -1275,7 +1345,7 @@ if (LT(1) == IToken.tRPAREN) throwBacktrack(LA(1)); - final IASTDeclarator nested= declarator(declSpec, option); + final IASTDeclarator nested= declarator(option); endOffset= consume(IToken.tRPAREN).getEndOffset(); final IASTDeclarator cand2= declarator(pointerOps, null, nested, startingOffset, endOffset, option); if (cand1 == null || cand1End == null) @@ -1667,11 +1737,14 @@ try { fPreventKnrCheck++; - Decl decl= declSpecifierSequence_initDeclarator(option, false); - declSpec= decl.fDeclSpec1; - declarator= decl.fDtor1; - altDeclSpec= decl.fDeclSpec2; - altDeclarator= decl.fDtor2; + declSpec= declSpecifierSeq(option); + declarator = declarator(option); + } catch(FoundDeclaratorException fd) { + declSpec= fd.declSpec; + declarator= fd.declarator; + altDeclSpec= fd.altSpec; + altDeclarator= fd.altDeclarator; + backup(fd.currToken); } catch (FoundAggregateInitializer lie) { declSpec= lie.fDeclSpec; declarator= lie.fDeclarator; @@ -1685,8 +1758,8 @@ if (altDeclarator != null && altDeclSpec != null) { IASTParameterDeclaration alt = nodeFactory.newParameterDeclaration(altDeclSpec, altDeclarator); ((ASTNode) alt).setOffsetAndLength(startingOffset, length); - // order is important, prefer variant with declspec over the one without - result= new CASTAmbiguousParameterDeclaration(result, alt); + // order is important, prefer alternative over the declarator found via the lookahead. + result= new CASTAmbiguousParameterDeclaration(alt, result); ((ASTNode) result).setOffsetAndLength((ASTNode) alt); } return result; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 IBM Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Markus Schorn - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser.cpp; - -import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IProblemBinding; -import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode; -import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; -import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousSimpleDeclaration; -import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; - -/** - * Handles ambiguities for simple declarations. - *
- * class C { - * C(D); // if D a type we have a constructor, otherwise this declares the field D. - * }; - */ -public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration { - - private IASTSimpleDeclaration fSimpleDecl; - private IASTDeclSpecifier fAltDeclSpec; - private IASTDeclarator fAltDtor; - - public CPPASTAmbiguousSimpleDeclaration(IASTSimpleDeclaration decl, IASTDeclSpecifier declSpec, IASTDeclarator dtor) { - fSimpleDecl= decl; - fAltDeclSpec= declSpec; - fAltDtor= dtor; - } - - @Override - protected void beforeResolution() { - // populate containing scope, so that it will not be affected by the alternative branches. - IScope scope= CPPVisitor.getContainingScope(this); - if (scope instanceof IASTInternalScope) { - ((IASTInternalScope) scope).populateCache(); - } - } - - @Override - public IASTNode[] getNodes() { - return new IASTNode[] {fSimpleDecl, fAltDeclSpec, fAltDtor}; - } - - public IASTSimpleDeclaration copy() { - throw new UnsupportedOperationException(); - } - - public void addDeclarator(IASTDeclarator declarator) { - fSimpleDecl.addDeclarator(declarator); - } - - public IASTDeclSpecifier getDeclSpecifier() { - return fSimpleDecl.getDeclSpecifier(); - } - - public IASTDeclarator[] getDeclarators() { - return fSimpleDecl.getDeclarators(); - } - - public void setDeclSpecifier(IASTDeclSpecifier declSpec) { - fSimpleDecl.setDeclSpecifier(declSpec); - } - - @Override - public final IASTNode resolveAmbiguity(ASTVisitor visitor) { - final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); - IASTNode nodeToReplace= this; - - // handle nested ambiguities first - owner.replace(nodeToReplace, fSimpleDecl); - IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0]; - dtor.accept(visitor); - - - // find nested names - final NameCollector nameCollector= new NameCollector(); - dtor.accept(nameCollector); - final IASTName[] names= nameCollector.getNames(); - - // resolve names - boolean hasIssue= false; - for (IASTName name : names) { - try { - IBinding b = name.resolveBinding(); - if (b instanceof IProblemBinding) { - hasIssue= true; - break; - } - } catch (Exception t) { - hasIssue= true; - break; - } - } - if (hasIssue) { - // use the alternate version - final IASTAmbiguityParent parent = (IASTAmbiguityParent) fSimpleDecl; - parent.replace(fSimpleDecl.getDeclSpecifier(), fAltDeclSpec); - parent.replace(dtor, fAltDtor); - } - - // resolve further nested ambiguities - fSimpleDecl.accept(visitor); - return fSimpleDecl; - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java Wed Aug 05 17:35:39 2009 -0500 @@ -223,7 +223,11 @@ case ICPPASTBinaryExpression.op_pmarrow: case ICPPASTBinaryExpression.op_pmdot: if (type2 instanceof ICPPPointerToMemberType) { - return ((ICPPPointerToMemberType) type2).getType(); + try { + return ((ICPPPointerToMemberType) type2).getType(); + } catch (DOMException e) { + return e.getProblem(); + } } return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, getRawSignature().toCharArray()); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java Wed Aug 05 17:35:39 2009 -0500 @@ -231,10 +231,7 @@ } else if (t instanceof ICPPClassType) { ICPPFunction op = CPPSemantics.findOverloadedOperator(this, (ICPPClassType)t); if (op != null) { - // overload can be a surrogate function call, which consists of a conversion and a call to - // a dynamically computed function pointer. - if(!(op instanceof CPPImplicitFunction)) - overload = op; + overload = op; return op.getType().getReturnType(); } } else if (t instanceof IPointerType) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java Wed Aug 05 17:35:39 2009 -0500 @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -252,7 +253,11 @@ public IType getExpressionType() { IType t= CPPVisitor.createType(getTypeId()); if (t instanceof IArrayType) { - t= ((IArrayType) t).getType(); + try { + t= ((IArrayType) t).getType(); + } catch (DOMException e) { + return e.getProblem(); + } } return new CPPPointerType(t); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,9 +12,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVQ; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; @@ -232,13 +230,17 @@ if (type instanceof IProblemBinding) { return type; } - IType operator = findOperatorReturnType(); - if(operator != null) { - return operator; - } else if (type instanceof IPointerType || type instanceof IArrayType) { - return ((ITypeContainer) type).getType(); - } else if (type instanceof ICPPUnknownType) { - return CPPUnknownClass.createUnnamedInstance(); + try { + IType operator = findOperatorReturnType(); + if(operator != null) { + return operator; + } else if (type instanceof IPointerType || type instanceof IArrayType) { + return ((ITypeContainer) type).getType(); + } else if (type instanceof ICPPUnknownType) { + return CPPUnknownClass.createUnnamedInstance(); + } + } catch (DOMException e) { + return e.getProblem(); } return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray()); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java Wed Aug 05 17:35:39 2009 -0500 @@ -6,35 +6,33 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM Corporation) - initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM Corporation - initial API and implementation *******************************************************************************/ + +/* + * Created on Dec 13, 2004 + */ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -import org.eclipse.cdt.internal.core.dom.parser.Value; +/** + * @author aniefer + */ public class CPPArrayType implements IArrayType, ITypeContainer { private IType type; private IASTExpression sizeExpression; - private IValue value= Value.NOT_INITIALIZED; - + public CPPArrayType(IType type) { this.type = type; } - public CPPArrayType(IType type, IValue value) { - this.type= type; - this.value= value; - } - public CPPArrayType(IType type, IASTExpression sizeExp) { this.type = type; this.sizeExpression = sizeExp; @@ -55,34 +53,20 @@ return ((ITypedef) obj).isSameType(this); if (obj instanceof IArrayType) { - final IArrayType rhs = (IArrayType) obj; - IType objType = rhs.getType(); - if (objType != null) { - if (objType.isSameType(type)) { - IValue s1= getSize(); - IValue s2= rhs.getSize(); - if (s1 == s2) - return true; - if (s1 == null || s2 == null) - return false; - return CharArrayUtils.equals(s1.getSignature(), s2.getSignature()); - } - } + try { + IType objType = ((IArrayType) obj).getType(); + if (objType != null) + return objType.isSameType(type); + } catch (DOMException e) { + return false; + } } return false; } - - public IValue getSize() { - if (value != Value.NOT_INITIALIZED) - return value; - - if (sizeExpression == null) - return value= null; - - return value= Value.create(sizeExpression, Value.MAX_RECURSION_DEPTH); - } - @Deprecated + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IArrayType#getArraySizeExpression() + */ public IASTExpression getArraySizeExpression() { return sizeExpression; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java Wed Aug 05 17:35:39 2009 -0500 @@ -99,9 +99,9 @@ } char[] className = name.getLookupKey(); - IParameter[] voidPs = new IParameter[] { new CPPParameter(CPPSemantics.VOID_TYPE, 0) }; + IParameter[] voidPs = new IParameter[] { new CPPParameter(CPPSemantics.VOID_TYPE) }; IType pType = new CPPReferenceType(SemanticUtil.addQualifiers(clsType, true, false)); - IParameter[] ps = new IParameter[] { new CPPParameter(pType, 0) }; + IParameter[] ps = new IParameter[] { new CPPParameter(pType) }; int i= 0; ImplicitsAnalysis ia= new ImplicitsAnalysis(compTypeSpec); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java Wed Aug 05 17:35:39 2009 -0500 @@ -164,18 +164,18 @@ return definition; } - public final void addDefinition(IASTNode node) { + public void addDefinition(IASTNode node) { ICPPASTFunctionDeclarator dtor = extractFunctionDtor(node); if (dtor != null) { - updateFunctionParameterBindings(dtor); + updateParameterBindings(dtor); definition = dtor; } } - public final void addDeclaration(IASTNode node) { + public void addDeclaration(IASTNode node) { ICPPASTFunctionDeclarator dtor = extractFunctionDtor(node); if (dtor != null) { - updateFunctionParameterBindings(dtor); + updateParameterBindings(dtor); if (declarations == null) { declarations = new ICPPASTFunctionDeclarator[] { dtor }; @@ -194,7 +194,7 @@ } private ICPPASTFunctionDeclarator extractFunctionDtor(IASTNode node) { - while (node instanceof IASTName) + if (node instanceof IASTName) node = node.getParent(); if (node instanceof IASTDeclarator == false) return null; @@ -213,7 +213,7 @@ if (size > 0) { for (int i = 0; i < size; i++) { IASTParameterDeclaration p = params[i]; - final IASTName name = getParamName(p); + final IASTName name = ASTQueries.findInnermostDeclarator(p.getDeclarator()).getName(); final IBinding binding= name.resolveBinding(); if (binding instanceof IParameter) { result[i]= (IParameter) binding; @@ -287,60 +287,67 @@ return type; } - public IBinding resolveParameter(CPPParameter param) { - int pos= param.getParameterPosition(); + public IBinding resolveParameter(IASTParameterDeclaration param) { + IASTDeclarator dtor = param.getDeclarator(); + while (dtor.getNestedDeclarator() != null) + dtor = dtor.getNestedDeclarator(); + IASTName name = dtor.getName(); + IBinding binding = name.getBinding(); + if (binding != null) + return binding; - int tdeclLen= declarations == null ? 0 : declarations.length; - for (int i= -1; i < tdeclLen; i++) { - ICPPASTFunctionDeclarator tdecl; - if (i == -1) { - tdecl= definition; - if (tdecl == null) - continue; - } else { - tdecl= declarations[i]; - if (tdecl == null) - break; - } - - IASTParameterDeclaration[] params = tdecl.getParameters(); - if (pos < params.length) { - final IASTName oName = getParamName(params[pos]); - return oName.resolvePreBinding(); + IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) param.getParent(); + IASTParameterDeclaration[] ps = fdtor.getParameters(); + int i = 0; + for (; i < ps.length; i++) { + if (param == ps[i]) + break; + } + + //create a new binding and set it for the corresponding parameter in all known defns and decls + binding = new CPPParameter(name); + IASTParameterDeclaration temp = null; + if (definition != null) { + IASTParameterDeclaration[] paramDecls = definition.getParameters(); + if (paramDecls.length > i) { // This will be less than i if we have a void parameter + temp = paramDecls[i]; + IASTName n = ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName(); + if (n != name) { + n.setBinding(binding); + ASTInternal.addDeclaration(binding, n); + } } } - return param; + if (declarations != null) { + for (int j = 0; j < declarations.length && declarations[j] != null; j++) { + IASTParameterDeclaration[] paramDecls = declarations[j].getParameters(); + if (paramDecls.length > i) { + temp = paramDecls[i]; + IASTName n = ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName(); + if (n != name) { + n.setBinding(binding); + ASTInternal.addDeclaration(binding, n); + } + } + } + } + return binding; } - - private IASTName getParamName(final IASTParameterDeclaration paramDecl) { - return ASTQueries.findInnermostDeclarator(paramDecl.getDeclarator()).getName(); - } - protected final void updateFunctionParameterBindings(ICPPASTFunctionDeclarator fdtor) { - IASTParameterDeclaration[] updateParams = fdtor.getParameters(); - - int k= 0; - int tdeclLen= declarations == null ? 0 : declarations.length; - for (int i= -1; i < tdeclLen && k < updateParams.length; i++) { - ICPPASTFunctionDeclarator tdecl; - if (i == -1) { - tdecl= definition; - if (tdecl == null) - continue; - } else { - tdecl= declarations[i]; - if (tdecl == null) - break; - } - - IASTParameterDeclaration[] params = tdecl.getParameters(); - int end= Math.min(params.length, updateParams.length); - for (; k < end; k++) { - final IASTName oName = getParamName(params[k]); - IBinding b= oName.resolvePreBinding(); - IASTName n = getParamName(updateParams[k]); - n.setBinding(b); - ASTInternal.addDeclaration(b, n); + protected void updateParameterBindings(ICPPASTFunctionDeclarator fdtor) { + ICPPASTFunctionDeclarator orig = definition != null ? definition : declarations[0]; + IASTParameterDeclaration[] ops = orig.getParameters(); + IASTParameterDeclaration[] nps = fdtor.getParameters(); + CPPParameter temp = null; + for (int i = 0; i < ops.length; i++) { + temp = (CPPParameter) ASTQueries.findInnermostDeclarator(ops[i].getDeclarator()).getName().getBinding(); + if (temp != null && nps.length > i) { //length could be different, ie 0 or 1 with void + IASTDeclarator dtor = nps[i].getDeclarator(); + while (dtor.getNestedDeclarator() != null) + dtor = dtor.getNestedDeclarator(); + IASTName name = dtor.getName(); + name.setBinding(temp); + ASTInternal.addDeclaration(temp, name); } } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java Wed Aug 05 17:35:39 2009 -0500 @@ -32,7 +32,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; -import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** @@ -158,100 +157,84 @@ return false; } - public IBinding resolveParameter(CPPParameter param) { - int pos= param.getParameterPosition(); + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction#resolveParameter(org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration) + */ + public IBinding resolveParameter(IASTParameterDeclaration param) { + IASTDeclarator dtor = param.getDeclarator(); + while (dtor.getNestedDeclarator() != null) + dtor = dtor.getNestedDeclarator(); + IASTName name = dtor.getName(); + IBinding binding = name.getBinding(); + if (binding != null) + return binding; - final IASTNode[] decls= getDeclarations(); - int tdeclLen= decls == null ? 0 : decls.length; - for (int i= -1; i < tdeclLen; i++) { - ICPPASTFunctionDeclarator tdecl; - if (i == -1) { - tdecl= (ICPPASTFunctionDeclarator) getDefinition(); - if (tdecl == null) - continue; - } else if (decls != null){ - tdecl= (ICPPASTFunctionDeclarator) decls[i]; - if (tdecl == null) - break; - } else { + ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) param.getParent(); + IASTParameterDeclaration[] ps = fdtor.getParameters(); + int i = 0; + for (; i < ps.length; i++) { + if (param == ps[i]) break; - } - - IASTParameterDeclaration[] params = tdecl.getParameters(); - if (pos < params.length) { - final IASTName oName = getParamName(params[pos]); - return oName.resolvePreBinding(); - } } - return param; + + try { + IParameter[] params = getParameters(); + if (i < params.length) { + final IParameter myParam = params[i]; + name.setBinding(myParam); + ASTInternal.addDeclaration(myParam, name); + return myParam; + } + + } catch (DOMException e) { + return e.getProblem(); + } + return null; } - protected void updateFunctionParameterBindings(ICPPASTFunctionDeclarator fdtor) { - IASTParameterDeclaration[] updateParams = fdtor.getParameters(); - - int k= 0; - final IASTNode[] decls= getDeclarations(); - int tdeclLen= decls == null ? 0 : decls.length; - for (int i= -1; i < tdeclLen && k < updateParams.length; i++) { - ICPPASTFunctionDeclarator tdecl; - if (i == -1) { - tdecl= (ICPPASTFunctionDeclarator) getDefinition(); - if (tdecl == null) - continue; - } else if (decls != null) { - tdecl= (ICPPASTFunctionDeclarator) decls[i]; - if (tdecl == null) - break; - } else { - break; - } - - IASTParameterDeclaration[] params = tdecl.getParameters(); - int end= Math.min(params.length, updateParams.length); - for (; k < end; k++) { - final IASTName oName = getParamName(params[k]); - IBinding b= oName.resolvePreBinding(); - IASTName n = getParamName(updateParams[k]); - n.setBinding(b); - ASTInternal.addDeclaration(b, n); - } - } - } - - private IASTName getParamName(final IASTParameterDeclaration paramDecl) { - return ASTQueries.findInnermostDeclarator(paramDecl.getDeclarator()).getName(); - } - - private ICPPASTFunctionDeclarator extractFunctionDtor(IASTNode node) { - if (node instanceof IASTName) - node = node.getParent(); - if (node instanceof IASTDeclarator == false) - return null; - node= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) node); - if (node instanceof ICPPASTFunctionDeclarator == false) - return null; - - return (ICPPASTFunctionDeclarator) node; - } - @Override public void addDefinition(IASTNode node) { - ICPPASTFunctionDeclarator dtor = extractFunctionDtor(node); - if (dtor != null) { - updateFunctionParameterBindings(dtor); - super.addDefinition(dtor); - } + IASTNode n = node; + while (n instanceof IASTName) + n = n.getParent(); + if (!(n instanceof ICPPASTFunctionDeclarator)) + return; + updateParameterBindings((ICPPASTFunctionDeclarator) n); + super.addDefinition(n); } @Override public void addDeclaration(IASTNode node) { - ICPPASTFunctionDeclarator dtor = extractFunctionDtor(node); - if (dtor != null) { - updateFunctionParameterBindings(dtor); - super.addDeclaration(dtor); - } + IASTNode n = node; + while (n instanceof IASTName) + n = n.getParent(); + if (!(n instanceof ICPPASTFunctionDeclarator)) + return; + updateParameterBindings((ICPPASTFunctionDeclarator) n); + super.addDeclaration(n); } + protected void updateParameterBindings(ICPPASTFunctionDeclarator fdtor) { + IParameter[] params = null; + try { + params = getParameters(); + } catch (DOMException e) { + return; + } + IASTParameterDeclaration[] nps = fdtor.getParameters(); + for (int i = 0; i < nps.length; i++) { + final IParameter param = params[i]; + if (param != null) { + IASTDeclarator dtor = nps[i].getDeclarator(); + while (dtor.getNestedDeclarator() != null) + dtor = dtor.getNestedDeclarator(); + IASTName name = dtor.getName(); + name.setBinding(param); + ASTInternal.addDeclaration(param, name); + } + } + } + @Override public String toString() { StringBuilder result = new StringBuilder(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java Wed Aug 05 17:35:39 2009 -0500 @@ -113,11 +113,7 @@ public void addDefinition(IASTNode node) { if (!(node instanceof IASTName)) return; - ICPPASTFunctionDeclarator fdecl= getDeclaratorByName(node); - if (fdecl == null) - return; - - updateFunctionParameterBindings(fdecl); + updateFunctionParameterBindings((IASTName) node); super.addDefinition(node); } @@ -125,12 +121,24 @@ public void addDeclaration(IASTNode node) { if (!(node instanceof IASTName)) return; - ICPPASTFunctionDeclarator fdecl= getDeclaratorByName(node); - if (fdecl == null) - return; + updateFunctionParameterBindings((IASTName) node); + super.addDeclaration(node); + } - updateFunctionParameterBindings(fdecl); - super.addDeclaration(node); + private void updateFunctionParameterBindings(IASTName declName) { + IASTName defName = definition != null ? definition : declarations[0]; + ICPPASTFunctionDeclarator orig = getDeclaratorByName(defName); + IASTParameterDeclaration[] ops = orig.getParameters(); + IASTParameterDeclaration[] nps = getDeclaratorByName(declName).getParameters(); + CPPParameter temp = null; + for(int i = 0; i < nps.length; i++) { + temp = (CPPParameter) ASTQueries.findInnermostDeclarator(ops[i].getDeclarator()).getName().getBinding(); + if (temp != null) { + IASTName name = ASTQueries.findInnermostDeclarator(nps[i].getDeclarator()).getName(); + name.setBinding(temp); + ASTInternal.addDeclaration(temp, name); + } + } } public IParameter[] getParameters() { @@ -204,70 +212,50 @@ return false; } - public IBinding resolveParameter(CPPParameter param) { - int pos= param.getParameterPosition(); + public IBinding resolveParameter(IASTParameterDeclaration param) { + IASTName name = ASTQueries.findInnermostDeclarator(param.getDeclarator()).getName(); + IBinding binding = name.getBinding(); + if (binding != null) + return binding; - final IASTNode[] decls= getDeclarations(); - int tdeclLen= decls == null ? 0 : decls.length; - for (int i= -1; i < tdeclLen; i++) { - ICPPASTFunctionDeclarator tdecl; - if (i == -1) { - tdecl= getDeclaratorByName(getDefinition()); - if (tdecl == null) - continue; - } else if (decls != null){ - tdecl= getDeclaratorByName(decls[i]); - if (tdecl == null) - break; - } else { + ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) param.getParent(); + IASTParameterDeclaration[] ps = fdtor.getParameters(); + int i = 0; + for (; i < ps.length; i++) { + if (param == ps[i]) break; - } - - IASTParameterDeclaration[] params = tdecl.getParameters(); - if (pos < params.length) { - final IASTName oName = getParamName(params[pos]); - return oName.resolvePreBinding(); + } + + //create a new binding and set it for the corresponding parameter in all known defns and decls + binding = new CPPParameter(name); + IASTParameterDeclaration temp = null; + if (definition != null) { + ICPPASTFunctionDeclarator fdecl= getDeclaratorByName(definition); + if (fdecl != null) { + temp = fdecl.getParameters()[i]; + IASTName n = ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName(); + if (n != name) { + n.setBinding(binding); + ASTInternal.addDeclaration(binding, n); + } } } - return param; - } - - protected void updateFunctionParameterBindings(ICPPASTFunctionDeclarator fdtor) { - IASTParameterDeclaration[] updateParams = fdtor.getParameters(); - - int k= 0; - final IASTNode[] decls= getDeclarations(); - int tdeclLen= decls == null ? 0 : decls.length; - for (int i= -1; i < tdeclLen && k < updateParams.length; i++) { - ICPPASTFunctionDeclarator tdecl; - if (i == -1) { - tdecl= getDeclaratorByName(getDefinition()); - if (tdecl == null) - continue; - } else if (decls != null) { - tdecl= getDeclaratorByName(decls[i]); - if (tdecl == null) - break; - } else { - break; - } - - IASTParameterDeclaration[] params = tdecl.getParameters(); - int end= Math.min(params.length, updateParams.length); - for (; k < end; k++) { - final IASTName oName = getParamName(params[k]); - IBinding b= oName.resolvePreBinding(); - IASTName n = getParamName(updateParams[k]); - n.setBinding(b); - ASTInternal.addDeclaration(b, n); + if (declarations != null) { + for(int j = 0; j < declarations.length && declarations[j] != null; j++) { + ICPPASTFunctionDeclarator fdecl= getDeclaratorByName(declarations[j]); + if (fdecl != null) { + temp = fdecl.getParameters()[i]; + IASTName n = ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName(); + if (n != name) { + n.setBinding(binding); + ASTInternal.addDeclaration(binding, n); + } + } } } + return binding; } - private IASTName getParamName(final IASTParameterDeclaration paramDecl) { - return ASTQueries.findInnermostDeclarator(paramDecl.getDeclarator()).getName(); - } - public boolean isStatic() { return hasStorageClass(IASTDeclSpecifier.sc_static); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java Wed Aug 05 17:35:39 2009 -0500 @@ -51,12 +51,20 @@ if (o instanceof ICPPFunctionType) { ICPPFunctionType ft = (ICPPFunctionType) o; IType[] fps; - fps = ft.getParameterTypes(); - //constructors & destructors have null return type - if ((returnType == null) ^ (ft.getReturnType() == null)) - return false; - else if (returnType != null && ! returnType.isSameType(ft.getReturnType())) - return false; + try { + fps = ft.getParameterTypes(); + } catch (DOMException e) { + return false; + } + try { + //constructors & destructors have null return type + if ((returnType == null) ^ (ft.getReturnType() == null)) + return false; + else if (returnType != null && ! returnType.isSameType(ft.getReturnType())) + return false; + } catch (DOMException e1) { + return false; + } try { if (parameters.length == 1 && fps.length == 0) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java Wed Aug 05 17:35:39 2009 -0500 @@ -11,10 +11,15 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; +import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; +import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; /** * The CPPImplicitFunction is used to represent implicit functions that exist on the translation @@ -78,6 +83,58 @@ } @Override + public IBinding resolveParameter(IASTParameterDeclaration param) { + IASTName aName = ASTQueries.findInnermostDeclarator(param.getDeclarator()).getName(); + IParameter binding = (IParameter) aName.getBinding(); + if (binding != null) + return binding; + + // get the index in the parameter list + ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) param.getParent(); + IASTParameterDeclaration[] ps = fdtor.getParameters(); + int i = 0; + for (; i < ps.length; i++) { + if (param == ps[i]) + break; + } + + // set the binding for the corresponding parameter in all known defns and decls + binding = parms[i]; + IASTParameterDeclaration temp = null; + if (definition != null) { + temp = definition.getParameters()[i]; + IASTName n = ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName(); + n.setBinding(binding); + ASTInternal.addDeclaration(binding, n); + } + if (declarations != null) { + for (int j = 0; j < declarations.length && declarations[j] != null; j++) { + temp = declarations[j].getParameters()[i]; + IASTName n = ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName(); + n.setBinding(binding); + ASTInternal.addDeclaration(binding, n); + } + } + return binding; + } + + @Override + protected void updateParameterBindings(ICPPASTFunctionDeclarator fdtor) { + if (parms != null) { + IASTParameterDeclaration[] nps = fdtor.getParameters(); + if (nps.length != parms.length) + return; + + for (int i = 0; i < nps.length; i++) { + IASTName aName = ASTQueries.findInnermostDeclarator(nps[i].getDeclarator()).getName(); + final IParameter param = parms[i]; + aName.setBinding(param); + ASTInternal.addDeclaration(param, aName); + } + } + } + + @Override public boolean takesVarArgs() { return takesVarArgs; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java Wed Aug 05 17:35:39 2009 -0500 @@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; @@ -56,21 +57,23 @@ @Override public boolean isSameType(IType t) { - if (t == this) - return true; - if (t instanceof ITypedef) { - IType temp = getType(); - if (temp != null) - return temp.isSameType(((ITypedef) t).getType()); - return false; - } - - IType temp; - temp = getType(); - if (temp != null) - return temp.isSameType(t); - return false; - } + if( t == this ) + return true; + if( t instanceof ITypedef ) { + IType temp = getType(); + if( temp != null ) + try { + return temp.isSameType( ((ITypedef)t).getType()); + } catch (DOMException e) {} + return false; + } + + IType temp; + temp = getType(); + if( temp != null ) + return temp.isSameType( t ); + return false; + } @Override public Object clone(){ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java Wed Aug 05 17:35:39 2009 -0500 @@ -7,7 +7,6 @@ * * Contributors: * Mike Kucera (IBM) - initial API and implementation - * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -104,14 +103,12 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier; -import org.eclipse.cdt.core.parser.IScanner; -import org.eclipse.cdt.internal.core.dom.parser.NodeFactory; /** * Abstract factory implementation that creates C++ AST nodes. */ -public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory { +public class CPPNodeFactory implements ICPPNodeFactory { private static final CPPNodeFactory DEFAULT_INSTANCE = new CPPNodeFactory(); @@ -119,16 +116,9 @@ return DEFAULT_INSTANCE; } + public ICPPASTTranslationUnit newTranslationUnit() { - return newTranslationUnit(null); - } - - public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner) { CPPASTTranslationUnit tu = new CPPASTTranslationUnit(); - - if (scanner != null) { - tu.setLocationResolver(scanner.getLocationResolver()); - } tu.setASTNodeFactory(this); return tu; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java Wed Aug 05 17:35:39 2009 -0500 @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTName; @@ -31,7 +30,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; @@ -40,7 +38,7 @@ /** * Binding for a c++ function parameter */ -public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPInternalBinding, ICPPTwoPhaseBinding { +public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPInternalBinding { public static class CPPParameterProblem extends ProblemBinding implements ICPPParameter { public CPPParameterProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); @@ -85,17 +83,14 @@ private IType type = null; private IASTName[] declarations = null; - private int fPosition; - public CPPParameter(IASTName name, int pos) { + public CPPParameter(IASTName name) { this.declarations = new IASTName[] { name }; - fPosition= pos; } - public CPPParameter(IType type, int pos) { + public CPPParameter(IType type) { this.type = type; - fPosition= pos; } /* (non-Javadoc) @@ -306,28 +301,4 @@ public IValue getInitialValue() { return null; } - - public IBinding resolveFinalBinding(CPPASTNameBase name) { - // check if the binding has been updated. - IBinding current= name.getPreBinding(); - if (current != this) - return current; - - IASTNode node= getPrimaryDeclaration(); - while (node != null && !(node instanceof IASTFunctionDeclarator)) { - node= node.getParent(); - } - if (node instanceof IASTFunctionDeclarator) { - IASTName funcName= ASTQueries.findInnermostDeclarator((IASTFunctionDeclarator) node).getName(); - IBinding b= funcName.resolvePreBinding(); - if (b instanceof ICPPInternalFunction) { - return ((ICPPInternalFunction) b).resolveParameter(this); - } - } - return this; - } - - public int getParameterPosition() { - return fPosition; - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterSpecialization.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,15 +45,12 @@ } @Override - public IType specializeType(IType type) { + public IType specializeType(IType type) throws DOMException { IBinding owner= getOwner(); if (owner != null) { - try { - owner= owner.getOwner(); - if (owner instanceof ICPPClassSpecialization) { - return CPPTemplates.instantiateType(type, getTemplateParameterMap(), (ICPPClassSpecialization) owner); - } - } catch (DOMException e) { + owner= owner.getOwner(); + if (owner instanceof ICPPClassSpecialization) { + return CPPTemplates.instantiateType(type, getTemplateParameterMap(), (ICPPClassSpecialization) owner); } } return CPPTemplates.instantiateType(type, getTemplateParameterMap(), null); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTPointer; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; @@ -70,7 +71,10 @@ IPointerType pt = (IPointerType) o; if (isConst == pt.isConst() && isVolatile == pt.isVolatile()) { - return type.isSameType(pt.getType()); + try { + return type.isSameType(pt.getType()); + } catch (DOMException e) { + } } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java Wed Aug 05 17:35:39 2009 -0500 @@ -6,18 +6,22 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM Corporation) - initial API and implementation + * IBM Corporation - initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.IIndexType; +/** + * @author aniefer + */ public class CPPQualifierType implements IQualifierType, ITypeContainer { private final boolean isConst; private final boolean isVolatile; @@ -36,8 +40,11 @@ return false; IQualifierType pt = (IQualifierType) o; - if (isConst() == pt.isConst() && isVolatile() == pt.isVolatile()) - return type.isSameType(pt.getType()); + try { + if (isConst() == pt.isConst() && isVolatile() == pt.isVolatile()) + return type.isSameType(pt.getType()); + } catch (DOMException e) { + } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,21 +1,29 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM Corporation) - initial API and implementation + * IBM Corporation - initial API and implementation *******************************************************************************/ + +/* + * Created on Dec 15, 2004 + */ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +/** + * @author aniefer + */ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer { IType type = null; @@ -42,7 +50,11 @@ return (obj == null); if (obj instanceof ICPPReferenceType) { - return type.isSameType(((ICPPReferenceType) obj).getType()); + try { + return type.isSameType(((ICPPReferenceType) obj).getType()); + } catch (DOMException e) { + return false; + } } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSpecialization.java Wed Aug 05 17:35:39 2009 -0500 @@ -51,7 +51,7 @@ this.argumentMap = argumentMap; } - public IType specializeType(IType type) { + public IType specializeType(IType type) throws DOMException { if (owner instanceof ICPPClassSpecialization) { return CPPTemplates.instantiateType(type, getTemplateParameterMap(), (ICPPClassSpecialization) owner); } else { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java Wed Aug 05 17:35:39 2009 -0500 @@ -65,10 +65,14 @@ if (o == this) return true; if (o instanceof ITypedef) { - IType t = getType(); - if (t != null) - return t.isSameType(((ITypedef)o).getType()); - return false; + try { + IType t = getType(); + if (t != null) + return t.isSameType(((ITypedef)o).getType()); + return false; + } catch (DOMException e) { + return false; + } } IType t = getType(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedefSpecialization.java Wed Aug 05 17:35:39 2009 -0500 @@ -33,7 +33,7 @@ final static class RecursionResolvingBinding extends ProblemBinding { public RecursionResolvingBinding(IASTNode node, char[] arg) { super(node, IProblemBinding.SEMANTIC_RECURSION_IN_LOOKUP, arg); - Assert.isTrue(CPPASTNameBase.sAllowRecursionBindings, getMessage()); + Assert.isTrue(CPPASTName.sAllowRecursionBindings, getMessage()); } } @@ -54,7 +54,7 @@ /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.ITypedef#getType() */ - public IType getType() { + public IType getType() throws DOMException { if (type == null) { try { if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) { @@ -66,11 +66,7 @@ if (type instanceof ITypedef && type instanceof ICPPSpecialization) { ITypedef td= (ITypedef) type; if (CharArrayUtils.equals(td.getNameCharArray(), getNameCharArray())) { - IBinding owner= getOwner(); - try { - owner = ((ICPPSpecialization) type).getOwner(); - } catch (DOMException e) { - } + IBinding owner= ((ICPPSpecialization) type).getOwner(); if (owner instanceof IType) { if (((IType) owner).isSameType((ICPPClassType) getOwner())) { type = new RecursionResolvingBinding(getDefinition(), getNameCharArray()); @@ -112,15 +108,23 @@ if (o == this) return true; if (o instanceof ITypedef) { - IType t = getType(); - if (t != null) - return t.isSameType(((ITypedef) o).getType()); - return false; + try { + IType t = getType(); + if (t != null) + return t.isSameType(((ITypedef) o).getType()); + return false; + } catch (DOMException e) { + return false; + } } - IType t = getType(); - if (t != null) - return t.isSameType(o); + try { + IType t = getType(); + if (t != null) + return t.isSameType(o); + } catch (DOMException e) { + return false; + } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java Wed Aug 05 17:35:39 2009 -0500 @@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; @@ -126,12 +127,12 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; +import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; import org.eclipse.cdt.internal.core.dom.parser.BacktrackException; import org.eclipse.cdt.internal.core.dom.parser.DeclarationOptions; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** * This is our implementation of the IParser interface, serving as a parser for @@ -1674,27 +1675,61 @@ final int firstOffset= LA(1).getOffset(); int endOffset= firstOffset; boolean insertSemi= false; - - IASTDeclSpecifier declSpec= null; + boolean parseDtors= true; + + ICPPASTDeclSpecifier declSpec= null; IASTDeclarator dtor= null; - IASTDeclSpecifier altDeclSpec= null; - IASTDeclarator altDtor= null; IToken markBeforDtor= null; try { - Decl decl= declSpecifierSequence_initDeclarator(declOption, true); - markBeforDtor= decl.fDtorToken1; - declSpec= decl.fDeclSpec1; - dtor= decl.fDtor1; - altDeclSpec= decl.fDeclSpec2; - altDtor= decl.fDtor2; + declSpec = declSpecifierSeq(declOption); + final int lt1= LTcatchEOF(1); + switch(lt1) { + case 0: // eof + case IToken.tEOC: + case IToken.tSEMI: + if (lt1 != IToken.tEOC && !validWithoutDtor(declOption, declSpec)) + throwBacktrack(LA(1)); + + parseDtors= false; + insertSemi= lt1==0; + if (lt1 == IToken.tSEMI) + endOffset= consume().getEndOffset(); + else + endOffset= calculateEndOffset(declSpec); + break; + + case IToken.tCOMMA: + throwBacktrack(LA(1)); + break; + default: + markBeforDtor= mark(); + try { + dtor= initDeclarator(declSpec, declOption); + } catch (BacktrackException e) { + if (!validWithoutDtor(declOption, declSpec)) + throw e; + backup(markBeforDtor); + } catch (EndOfFileException e) { + if (!validWithoutDtor(declOption, declSpec)) + throw e; + backup(markBeforDtor); + } + break; + } } catch (FoundAggregateInitializer lie) { - declSpec= lie.fDeclSpec; + if (declSpec == null) + declSpec= (ICPPASTDeclSpecifier) lie.fDeclSpec; // scalability: don't keep references to tokens, initializer may be large declarationMark= null; + markBeforDtor= null; dtor= addInitializer(lie, declOption); + } catch (FoundDeclaratorException e) { + declSpec= (ICPPASTDeclSpecifier) e.declSpec; + dtor= e.declarator; + backup(e.currToken); } catch (BacktrackException e) { IASTNode node= e.getNodeBeforeProblem(); - if (node instanceof IASTDeclSpecifier && specifiesCompound((IASTDeclSpecifier) node)) { + if (node instanceof ICPPASTDeclSpecifier && validWithoutDtor(declOption, (ICPPASTDeclSpecifier) node)) { IASTSimpleDeclaration d= nodeFactory.newSimpleDeclaration((IASTDeclSpecifier) node); setRange(d, node); throwBacktrack(e.getProblem(), d); @@ -1703,7 +1738,7 @@ } IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; - if (dtor != null) { + if (parseDtors) { declarators= new IASTDeclarator[]{dtor}; while (LTcatchEOF(1) == IToken.tCOMMA) { consume(); @@ -1718,62 +1753,50 @@ declarators = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, declarators, dtor); } declarators = (IASTDeclarator[]) ArrayUtil.removeNulls(IASTDeclarator.class, declarators); + + final int lt1= LTcatchEOF(1); + switch (lt1) { + case IToken.tEOC: + endOffset= figureEndOffset(declSpec, declarators); + break; + case IToken.tSEMI: + endOffset= consume().getEndOffset(); + break; + case IToken.t_try: + case IToken.tCOLON: + case IToken.tLBRACE: + return functionDefinition(firstOffset, declSpec, declarators); + default: + if (declOption != DeclarationOptions.LOCAL) { + insertSemi= true; + if (validWithoutDtor(declOption, declSpec)) { + if (markBeforDtor != null && !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) { + backup(markBeforDtor); + declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; + endOffset= calculateEndOffset(declSpec); + break; + } + } + endOffset= figureEndOffset(declSpec, declarators); + if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) { + break; + } + if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) { + break; + } + } + throwBacktrack(LA(1)); + } } - final int lt1= LTcatchEOF(1); - switch (lt1) { - case IToken.tEOC: - endOffset= figureEndOffset(declSpec, declarators); - break; - case IToken.tSEMI: - endOffset= consume().getEndOffset(); - break; - case IToken.t_try: - case IToken.tCOLON: - case IToken.tLBRACE: - return functionDefinition(firstOffset, declSpec, declarators); - default: - if (declOption != DeclarationOptions.LOCAL) { - insertSemi= true; - if (specifiesCompound(declSpec) && markBeforDtor != null && !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) { - backup(markBeforDtor); - declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; - endOffset= calculateEndOffset(declSpec); - break; - } - endOffset= figureEndOffset(declSpec, declarators); - if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) { - break; - } - if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) { - break; - } - } - throwBacktrack(LA(1)); + // no function body + IASTSimpleDeclaration simpleDeclaration= nodeFactory.newSimpleDeclaration(declSpec); + for (IASTDeclarator declarator : declarators) { + simpleDeclaration.addDeclarator(declarator); } - // no function body + ((ASTNode) simpleDeclaration).setOffsetAndLength(firstOffset, endOffset-firstOffset); - final boolean isAmbiguous= altDeclSpec != null && altDtor != null && declarators.length == 1; - IASTSimpleDeclaration simpleDeclaration; - if (isAmbiguous) { - // class C { C(T); }; // if T is a type this is a constructor, so - // prefer the empty declspec, it shall be used if both variants show no problems - simpleDeclaration= nodeFactory.newSimpleDeclaration(altDeclSpec); - simpleDeclaration.addDeclarator(altDtor); - } else { - simpleDeclaration= nodeFactory.newSimpleDeclaration(declSpec); - for (IASTDeclarator declarator : declarators) { - simpleDeclaration.addDeclarator(declarator); - } - } - - setRange(simpleDeclaration, firstOffset, endOffset); - if (isAmbiguous) { - simpleDeclaration = new CPPASTAmbiguousSimpleDeclaration(simpleDeclaration, declSpec, dtor); - setRange(simpleDeclaration, firstOffset, endOffset); - } - if (insertSemi) { IASTProblem problem= createProblem(IProblem.SYNTAX_ERROR, endOffset, 0); throwBacktrack(problem, simpleDeclaration); @@ -1781,6 +1804,17 @@ return simpleDeclaration; } + private boolean validWithoutDtor(DeclarationOptions option, ICPPASTDeclSpecifier declSpec) { + if (declSpec instanceof IASTCompositeTypeSpecifier) + return true; + if (declSpec instanceof IASTElaboratedTypeSpecifier) + return true; + if (declSpec instanceof IASTEnumerationSpecifier) + return true; + + return option == DeclarationOptions.FUNCTION_STYLE_ASM; + } + private IASTDeclaration functionDefinition(final int firstOffset, IASTDeclSpecifier declSpec, IASTDeclarator[] dtors) throws EndOfFileException, BacktrackException { @@ -1906,26 +1940,28 @@ IASTDeclSpecifier declSpec= null; IASTDeclarator declarator; try { - Decl decl= declSpecifierSequence_initDeclarator(DeclarationOptions.PARAMETER, false); - declSpec= decl.fDeclSpec1; - declarator= decl.fDtor1; + declSpec= declSpecifierSeq(DeclarationOptions.PARAMETER); + declarator= initDeclarator(declSpec, DeclarationOptions.PARAMETER); + } catch (FoundDeclaratorException e) { + declSpec= e.declSpec; + declarator= e.declarator; + backup(e.currToken); } catch (FoundAggregateInitializer lie) { - declSpec= lie.fDeclSpec; + if (declSpec == null) + declSpec= lie.fDeclSpec; declarator= addInitializer(lie, DeclarationOptions.PARAMETER); } final ICPPASTParameterDeclaration parm = nodeFactory.newParameterDeclaration(declSpec, declarator); final int endOffset = figureEndOffset(declSpec, declarator); - setRange(parm, startOffset, endOffset); + ((ASTNode) parm).setOffsetAndLength(startOffset, endOffset - startOffset); return parm; } private final static int INLINE=0x1, CONST=0x2, RESTRICT=0x4, VOLATILE=0x8, - SHORT=0x10, UNSIGNED= 0x20, SIGNED=0x40, COMPLEX=0x80, IMAGINARY=0x100, - VIRTUAL=0x200, EXPLICIT=0x400, FRIEND=0x800; - private static final int FORBID_IN_EMPTY_DECLSPEC = - CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND; + SHORT=0x10, UNSIGNED= 0x20, SIGNED=0x40, COMPLEX=0x80, IMAGINARY=0x100, + VIRTUAL=0x200, EXPLICIT=0x400, FRIEND=0x800; /** @@ -1941,318 +1977,343 @@ * ("typename")? name | * { "class" | "struct" | "union" } classSpecifier | * {"enum"} enumSpecifier + * @throws FoundAggregateInitializer */ @Override - protected Decl declSpecifierSeq(final DeclarationOptions option) throws BacktrackException, EndOfFileException { - int storageClass = IASTDeclSpecifier.sc_unspecified; + protected ICPPASTDeclSpecifier declSpecifierSeq(final DeclarationOptions option) + throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer { + int storageClass = IASTDeclSpecifier.sc_unspecified; int simpleType = IASTSimpleDeclSpecifier.t_unspecified; int options= 0; int isLong= 0; - IToken returnToken= null; - ICPPASTDeclSpecifier result= null; - ICPPASTDeclSpecifier altResult= null; - try { - IASTName identifier= null; - IASTExpression typeofExpression= null; - IASTProblem problem= null; - - boolean isTypename = false; - boolean encounteredRawType= false; - boolean encounteredTypename= false; - - final int offset = LA(1).getOffset(); - int endOffset= offset; - - declSpecifiers: for (;;) { - final int lt1= LTcatchEOF(1); - switch (lt1) { - case 0: // encountered eof - break declSpecifiers; - // storage class specifiers - case IToken.t_auto: - storageClass = IASTDeclSpecifier.sc_auto; - endOffset= consume().getEndOffset(); - break; - case IToken.t_register: - storageClass = IASTDeclSpecifier.sc_register; - endOffset= consume().getEndOffset(); - break; - case IToken.t_static: - storageClass = IASTDeclSpecifier.sc_static; - endOffset= consume().getEndOffset(); - break; - case IToken.t_extern: - storageClass = IASTDeclSpecifier.sc_extern; - endOffset= consume().getEndOffset(); - break; - case IToken.t_mutable: - storageClass = ICPPASTDeclSpecifier.sc_mutable; - endOffset= consume().getEndOffset(); - break; - case IToken.t_typedef: - storageClass = IASTDeclSpecifier.sc_typedef; - endOffset= consume().getEndOffset(); - break; - // function specifiers - case IToken.t_inline: - options |= INLINE; - endOffset= consume().getEndOffset(); - break; - case IToken.t_virtual: - options |= VIRTUAL; - endOffset= consume().getEndOffset(); - break; - case IToken.t_explicit: - options |= EXPLICIT; - endOffset= consume().getEndOffset(); - break; - case IToken.t_friend: - options |= FRIEND; - endOffset= consume().getEndOffset(); - break; - // type specifier - case IToken.t_const: - options |= CONST; - endOffset= consume().getEndOffset(); - break; - case IToken.t_volatile: - options |= VOLATILE; - endOffset= consume().getEndOffset(); - break; - case IToken.t_restrict: - options |= RESTRICT; - endOffset= consume().getEndOffset(); - break; - case IToken.t_signed: - if (encounteredTypename) - break declSpecifiers; - options |= SIGNED; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_unsigned: - if (encounteredTypename) - break declSpecifiers; - options |= UNSIGNED; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_short: - if (encounteredTypename) - break declSpecifiers; - options |= SHORT; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_long: - if (encounteredTypename) - break declSpecifiers; - isLong++; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t__Complex: - if (encounteredTypename) - break declSpecifiers; - options |= COMPLEX; - endOffset= consume().getEndOffset(); - break; - case IToken.t__Imaginary: - if (encounteredTypename) - break declSpecifiers; - options |= IMAGINARY; - endOffset= consume().getEndOffset(); - break; - case IToken.t_char: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_char; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_wchar_t: - if (encounteredTypename) - break declSpecifiers; - simpleType = ICPPASTSimpleDeclSpecifier.t_wchar_t; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_bool: - if (encounteredTypename) - break declSpecifiers; - simpleType = ICPPASTSimpleDeclSpecifier.t_bool; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_int: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_int; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_float: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_float; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_double: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_double; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_void: - if (encounteredTypename) - break declSpecifiers; - simpleType = IASTSimpleDeclSpecifier.t_void; - encounteredRawType= true; - endOffset= consume().getEndOffset(); - break; - case IToken.t_typename: - if (encounteredTypename || encounteredRawType) - break declSpecifiers; - consume(); - identifier= qualifiedName(); - endOffset= calculateEndOffset(identifier); - isTypename = true; - encounteredTypename= true; - break; - case IToken.tBITCOMPLEMENT: - case IToken.tCOLONCOLON: - case IToken.tIDENTIFIER: - case IToken.tCOMPLETION: - if (encounteredRawType || encounteredTypename) - break declSpecifiers; - - if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) { - if ((options & FORBID_IN_EMPTY_DECLSPEC) == 0 && storageClass == IASTDeclSpecifier.sc_unspecified) { - altResult= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); - returnToken= mark(); - } - } - - identifier= qualifiedName(); - if (identifier.getLookupKey().length == 0 && LT(1) != IToken.tEOC) - throwBacktrack(LA(1)); - - endOffset= calculateEndOffset(identifier); - encounteredTypename= true; - break; - case IToken.t_class: - case IToken.t_struct: - case IToken.t_union: - if (encounteredTypename || encounteredRawType) - break declSpecifiers; - try { - result= classSpecifier(); - } catch (BacktrackException bt) { - result= elaboratedTypeSpecifier(); - } - endOffset= calculateEndOffset(result); - encounteredTypename= true; - break; - - case IToken.t_enum: - if (encounteredTypename || encounteredRawType) - break declSpecifiers; - try { - result= (ICPPASTDeclSpecifier) enumSpecifier(); - } catch (BacktrackException bt) { - if (bt.getNodeBeforeProblem() instanceof ICPPASTDeclSpecifier) { - result= (ICPPASTDeclSpecifier) bt.getNodeBeforeProblem(); - problem= bt.getProblem(); - break declSpecifiers; - } else { - result= elaboratedTypeSpecifier(); - } - } - endOffset= calculateEndOffset(result); - encounteredTypename= true; - break; - - case IGCCToken.t__attribute__: // if __attribute__ is after the declSpec - if (!supportAttributeSpecifiers) - throwBacktrack(LA(1)); - __attribute_decl_seq(true, false); - break; - case IGCCToken.t__declspec: // __declspec precedes the identifier - if (identifier != null || !supportDeclspecSpecifiers) - throwBacktrack(LA(1)); - __attribute_decl_seq(false, true); - break; - - case IGCCToken.t_typeof: - if (encounteredRawType || encounteredTypename) - throwBacktrack(LA(1)); - - final boolean wasInBinary= inBinaryExpression; - try { - inBinaryExpression= false; - typeofExpression= parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), - IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof); - } finally { - inBinaryExpression= wasInBinary; - } - - encounteredTypename= true; - endOffset= calculateEndOffset(typeofExpression); - break; - - default: - if (lt1 >= IExtensionToken.t__otherDeclSpecModifierFirst && lt1 <= IExtensionToken.t__otherDeclSpecModifierLast) { - handleOtherDeclSpecModifier(); - endOffset= LA(1).getOffset(); - break; - } - break declSpecifiers; - } - - if (encounteredRawType && encounteredTypename) - throwBacktrack(LA(1)); - } - - // check for empty specification - if (!encounteredRawType && !encounteredTypename && LT(1) != IToken.tEOC && !option.fAllowEmptySpecifier) { - throwBacktrack(LA(1)); - } - - if (result != null) { - configureDeclSpec(result, storageClass, options); - // cannot store restrict in the cpp-nodes. - // if ((options & RESTRICT) != 0) { - // } - setRange(result, offset, endOffset); - if (problem != null) { - throwBacktrack(problem, result); - } - } else if (identifier != null) { - result= buildNamedTypeSpecifier(identifier, isTypename, storageClass, options, offset, endOffset); - } else { - result= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); - } - } catch (BacktrackException e) { - if (returnToken != null) { - backup(returnToken); - result= altResult; - altResult= null; - returnToken= null; - } else { - throw e; - } + IASTName identifier= null; + ICPPASTDeclSpecifier result= null; + IASTExpression typeofExpression= null; + IASTProblem problem= null; + + boolean isTypename = false; + boolean encounteredRawType= false; + boolean encounteredTypename= false; + + final int offset = LA(1).getOffset(); + int endOffset= offset; + + declSpecifiers: for (;;) { + final int lt1= LTcatchEOF(1); + switch (lt1) { + case 0: // encountered eof + break declSpecifiers; + // storage class specifiers + case IToken.t_auto: + storageClass = IASTDeclSpecifier.sc_auto; + endOffset= consume().getEndOffset(); + break; + case IToken.t_register: + storageClass = IASTDeclSpecifier.sc_register; + endOffset= consume().getEndOffset(); + break; + case IToken.t_static: + storageClass = IASTDeclSpecifier.sc_static; + endOffset= consume().getEndOffset(); + break; + case IToken.t_extern: + storageClass = IASTDeclSpecifier.sc_extern; + endOffset= consume().getEndOffset(); + break; + case IToken.t_mutable: + storageClass = ICPPASTDeclSpecifier.sc_mutable; + endOffset= consume().getEndOffset(); + break; + case IToken.t_typedef: + storageClass = IASTDeclSpecifier.sc_typedef; + endOffset= consume().getEndOffset(); + break; + // function specifiers + case IToken.t_inline: + options |= INLINE; + endOffset= consume().getEndOffset(); + break; + case IToken.t_virtual: + options |= VIRTUAL; + endOffset= consume().getEndOffset(); + break; + case IToken.t_explicit: + options |= EXPLICIT; + endOffset= consume().getEndOffset(); + break; + case IToken.t_friend: + options |= FRIEND; + endOffset= consume().getEndOffset(); + break; + // type specifier + case IToken.t_const: + options |= CONST; + endOffset= consume().getEndOffset(); + break; + case IToken.t_volatile: + options |= VOLATILE; + endOffset= consume().getEndOffset(); + break; + case IToken.t_restrict: + options |= RESTRICT; + endOffset= consume().getEndOffset(); + break; + case IToken.t_signed: + if (encounteredTypename) + break declSpecifiers; + options |= SIGNED; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_unsigned: + if (encounteredTypename) + break declSpecifiers; + options |= UNSIGNED; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_short: + if (encounteredTypename) + break declSpecifiers; + options |= SHORT; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_long: + if (encounteredTypename) + break declSpecifiers; + isLong++; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t__Complex: + if (encounteredTypename) + break declSpecifiers; + options |= COMPLEX; + endOffset= consume().getEndOffset(); + break; + case IToken.t__Imaginary: + if (encounteredTypename) + break declSpecifiers; + options |= IMAGINARY; + endOffset= consume().getEndOffset(); + break; + case IToken.t_char: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_char; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_wchar_t: + if (encounteredTypename) + break declSpecifiers; + simpleType = ICPPASTSimpleDeclSpecifier.t_wchar_t; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_bool: + if (encounteredTypename) + break declSpecifiers; + simpleType = ICPPASTSimpleDeclSpecifier.t_bool; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_int: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_int; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_float: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_float; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_double: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_double; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_void: + if (encounteredTypename) + break declSpecifiers; + simpleType = IASTSimpleDeclSpecifier.t_void; + encounteredRawType= true; + endOffset= consume().getEndOffset(); + break; + case IToken.t_typename: + if (encounteredTypename || encounteredRawType) + break declSpecifiers; + consume(); + identifier= qualifiedName(); + endOffset= calculateEndOffset(identifier); + isTypename = true; + encounteredTypename= true; + break; + case IToken.tBITCOMPLEMENT: + case IToken.tCOLONCOLON: + case IToken.tIDENTIFIER: + case IToken.tCOMPLETION: + if (encounteredRawType || encounteredTypename) + break declSpecifiers; + + try { + if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) { + lookAheadForDeclarator(option); + } + } catch (FoundAggregateInitializer e) { + e.fDeclSpec= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); + throw e; + }catch (FoundDeclaratorException e) { + if (e.currToken.getType() == IToken.tEOC || option == DeclarationOptions.FUNCTION_STYLE_ASM + || canBeConstructorDestructorOrConversion(option, storageClass, options, e.declarator)) { + e.declSpec= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); + throw e; + } + } + + identifier= qualifiedName(); + if (identifier.getLookupKey().length == 0 && LT(1) != IToken.tEOC) + throwBacktrack(LA(1)); + + endOffset= calculateEndOffset(identifier); + encounteredTypename= true; + break; + case IToken.t_class: + case IToken.t_struct: + case IToken.t_union: + if (encounteredTypename || encounteredRawType) + break declSpecifiers; + try { + result= classSpecifier(); + } catch (BacktrackException bt) { + result= elaboratedTypeSpecifier(); + } + endOffset= calculateEndOffset(result); + encounteredTypename= true; + break; + + case IToken.t_enum: + if (encounteredTypename || encounteredRawType) + break declSpecifiers; + try { + result= (ICPPASTDeclSpecifier) enumSpecifier(); + } catch (BacktrackException bt) { + if (bt.getNodeBeforeProblem() instanceof ICPPASTDeclSpecifier) { + result= (ICPPASTDeclSpecifier) bt.getNodeBeforeProblem(); + problem= bt.getProblem(); + break declSpecifiers; + } else { + result= elaboratedTypeSpecifier(); + } + } + endOffset= calculateEndOffset(result); + encounteredTypename= true; + break; + + case IGCCToken.t__attribute__: // if __attribute__ is after the declSpec + if (!supportAttributeSpecifiers) + throwBacktrack(LA(1)); + __attribute_decl_seq(true, false); + break; + case IGCCToken.t__declspec: // __declspec precedes the identifier + if (identifier != null || !supportDeclspecSpecifiers) + throwBacktrack(LA(1)); + __attribute_decl_seq(false, true); + break; + + case IGCCToken.t_typeof: + if (encounteredRawType || encounteredTypename) + throwBacktrack(LA(1)); + + final boolean wasInBinary= inBinaryExpression; + try { + inBinaryExpression= false; + typeofExpression= parseTypeidInParenthesisOrUnaryExpression(false, consume().getOffset(), + IGNUASTTypeIdExpression.op_typeof, IGNUASTUnaryExpression.op_typeof); + } finally { + inBinaryExpression= wasInBinary; + } + + encounteredTypename= true; + endOffset= calculateEndOffset(typeofExpression); + break; + + default: + if (lt1 >= IExtensionToken.t__otherDeclSpecModifierFirst && lt1 <= IExtensionToken.t__otherDeclSpecModifierLast) { + handleOtherDeclSpecModifier(); + endOffset= LA(1).getOffset(); + break; + } + break declSpecifiers; + } + + if (encounteredRawType && encounteredTypename) + throwBacktrack(LA(1)); + } + + // check for empty specification + if (!encounteredRawType && !encounteredTypename && LT(1) != IToken.tEOC && !option.fAllowEmptySpecifier) { + throwBacktrack(LA(1)); } - Decl target= new Decl(); - target.fDeclSpec1= result; - target.fDeclSpec2= altResult; - target.fDtorToken1= returnToken; - return target; + if (result != null) { + configureDeclSpec(result, storageClass, options); + // cannot store restrict in the cpp-nodes. + // if ((options & RESTRICT) != 0) { + // } + ((ASTNode) result).setOffsetAndLength(offset, endOffset - offset); + if (problem != null) { + throwBacktrack(problem, result); + } + return result; + } + + if (identifier != null) + return buildNamedTypeSpecifier(identifier, isTypename, storageClass, options, offset, endOffset); + + return buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset); } + private boolean canBeConstructorDestructorOrConversion(DeclarationOptions declOption, int storageClass, int options, IASTDeclarator dtor) { + final int forbid= CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND; + if (storageClass == IASTDeclSpecifier.sc_unspecified && (options & forbid) == 0) { + if (ASTQueries.findTypeRelevantDeclarator(dtor) instanceof IASTFunctionDeclarator) { + IASTName name= ASTQueries.findInnermostDeclarator(dtor).getName(); + if (name instanceof ICPPASTQualifiedName) { + final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name; + final IASTName names[]= qname.getNames(); + final int len = names.length; + final IASTName lastName = names[len-1]; + + if (len > 1 && CharArrayUtils.equals(names[len-2].getLookupKey(), lastName.getLookupKey())) + return true; // constructor + + name= lastName; + } + if (name instanceof ICPPASTTemplateId) + name= ((ICPPASTTemplateId) name).getTemplateName(); + + if (name instanceof ICPPASTConversionName) + return true; + + final char[] nchars= name.getLookupKey(); + if (nchars.length > 0 && nchars[0] == '~') + return true; // destructor + if (declOption == DeclarationOptions.CPP_MEMBER && CharArrayUtils.equals(nchars, currentClassName)) + return true; + } + } + return false; + } + private ICPPASTNamedTypeSpecifier buildNamedTypeSpecifier(IASTName name, boolean isTypename, int storageClass, int options, int offset, int endOffset) { ICPPASTNamedTypeSpecifier declSpec = nodeFactory.newTypedefNameSpecifier(name); @@ -2304,6 +2365,39 @@ declSpec.setExplicit((options & EXPLICIT) != 0); } + @Override + protected boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator dtor, IToken nextToken) { + switch (nextToken.getType()) { + case IToken.tCOMMA: + return true; + + case IToken.tCOLON: + case IToken.t_try: + case IToken.t_catch: + case IToken.tLBRACE: + case IToken.t_const: + case IToken.t_volatile: + if (option == DeclarationOptions.GLOBAL || option == DeclarationOptions.CPP_MEMBER + || option == DeclarationOptions.FUNCTION_STYLE_ASM) { + if (ASTQueries.findTypeRelevantDeclarator(dtor) instanceof IASTFunctionDeclarator) { + return true; + } + } + break; + case IToken.tSEMI: + return option == DeclarationOptions.GLOBAL || option == DeclarationOptions.CPP_MEMBER || + option == DeclarationOptions.LOCAL; + + case IToken.tRPAREN: + return option == DeclarationOptions.PARAMETER; + + case IToken.tEOC: + return true; + } + return false; + } + + /** * Parse an elaborated type specifier. * @@ -2342,8 +2436,15 @@ ((ASTNode) elaboratedTypeSpec).setOffsetAndLength(t.getOffset(), calculateEndOffset(name) - t.getOffset()); return elaboratedTypeSpec; } + + + @Override + protected IASTDeclarator initDeclarator(DeclarationOptions option) + throws EndOfFileException, BacktrackException, FoundAggregateInitializer { + // called from the lookahead, only. + return initDeclarator(DtorStrategy.PREFER_FUNCTION, option); + } - @Override protected IASTDeclarator initDeclarator(IASTDeclSpecifier declspec, DeclarationOptions option) throws EndOfFileException, BacktrackException, FoundAggregateInitializer { final IToken mark= mark(); @@ -2353,33 +2454,16 @@ BacktrackException bt= null; try { dtor1= initDeclarator(DtorStrategy.PREFER_FUNCTION, option); - verifyDtor(declspec, dtor1, option); - - int lt1= LTcatchEOF(1); - switch(lt1) { - case 0: - return dtor1; - case IToken.tCOLON: - // a colon can be used after a type-id in a conditional expression - if (option != DeclarationOptions.CPP_MEMBER && option != DeclarationOptions.GLOBAL) - break; - //$FALL-THROUGH$ - - case IToken.tLBRACE: - case IToken.t_throw: case IToken.t_try: - case IToken.t_const: case IToken.t_volatile: - if (ASTQueries.findTypeRelevantDeclarator(dtor1) instanceof IASTFunctionDeclarator) { - return dtor1; - } else { - dtor1= null; - throwBacktrack(LA(1)); - } - } - - if (!(dtor1 instanceof IASTFunctionDeclarator)) + if (dtor1 instanceof IASTFunctionDeclarator == false) return dtor1; end1= LA(1); + switch(end1.getType()) { + case IToken.tLBRACE: case IToken.tCOLON: + case IToken.t_throw: case IToken.t_try: + case IToken.t_const: case IToken.t_volatile: + return dtor1; + } } catch (BacktrackException e) { bt= e; } @@ -2419,45 +2503,6 @@ return dtor; } - /** - * Tries to detect illegal versions of declarations - */ - private void verifyDtor(IASTDeclSpecifier declspec, IASTDeclarator dtor, DeclarationOptions opt) throws BacktrackException { - if (CPPVisitor.doesNotSpecifyType(declspec)) { - if (ASTQueries.findTypeRelevantDeclarator(dtor) instanceof IASTFunctionDeclarator) { - boolean isQualified= false; - IASTName name= ASTQueries.findInnermostDeclarator(dtor).getName(); - if (name instanceof ICPPASTQualifiedName) { - isQualified= true; - name= name.getLastName(); - } - if (name instanceof ICPPASTTemplateId) - name= ((ICPPASTTemplateId) name).getTemplateName(); - - // accept conversion operator - if (name instanceof ICPPASTConversionName) - return; - - // accept destructor - final char[] nchars= name.getLookupKey(); - if (nchars.length > 0 && nchars[0] == '~') - return; - - if (opt == DeclarationOptions.CPP_MEMBER) { - // accept constructor within class body - if (CharArrayUtils.equals(nchars, currentClassName)) - return; - } else if (isQualified) { - // accept qualified constructor outside of class body - return; - } - } - - ASTNode node= (ASTNode) dtor; - throwBacktrack(node.getOffset(), node.getLength()); - } - } - private boolean canHaveConstructorInitializer(IASTDeclSpecifier declspec, IASTDeclarator dtor) { if (declspec instanceof ICPPASTDeclSpecifier) { ICPPASTDeclSpecifier cppspec= (ICPPASTDeclSpecifier) declspec; @@ -2642,15 +2687,19 @@ if (!canBeTypeSpecifier()) { return null; } - final int offset = mark().getOffset(); + int startingOffset = mark().getOffset(); IASTDeclSpecifier declSpecifier = null; IASTDeclarator declarator = null; - rejectLogicalOperatorInTemplateID++; try { - Decl decl= declSpecifierSequence_initDeclarator(option, false); - declSpecifier= decl.fDeclSpec1; - declarator= decl.fDtor1; + declSpecifier = declSpecifierSeq(option); + if (LT(1) != IToken.tEOC) { + declarator= declarator(DtorStrategy.PREFER_FUNCTION, option); + } + } catch (FoundDeclaratorException e) { + declSpecifier= e.declSpec; + declarator= e.declarator; + backup(e.currToken); } catch (FoundAggregateInitializer lie) { // type-ids have no initializers return null; @@ -2660,7 +2709,7 @@ rejectLogicalOperatorInTemplateID--; } IASTTypeId result = nodeFactory.newTypeId(declSpecifier, declarator); - setRange(result, offset, figureEndOffset(declSpecifier, declarator)); + ((ASTNode) result).setOffsetAndLength(startingOffset, figureEndOffset(declSpecifier, declarator) - startingOffset); return result; } @@ -3295,23 +3344,27 @@ private IASTSimpleDeclaration simpleSingleDeclaration(DeclarationOptions options) throws BacktrackException, EndOfFileException { final int startOffset= LA(1).getOffset(); - IASTDeclSpecifier declSpec; + IASTDeclSpecifier declSpec= null; IASTDeclarator declarator; try { - Decl decl= declSpecifierSequence_initDeclarator(options, true); - declSpec= decl.fDeclSpec1; - declarator= decl.fDtor1; + declSpec= declSpecifierSeq(options); + declarator= initDeclarator(declSpec, options); + } catch (FoundDeclaratorException e) { + declSpec= e.declSpec; + declarator= e.declarator; + backup(e.currToken); } catch (FoundAggregateInitializer lie) { - declSpec= lie.fDeclSpec; + if (declSpec == null) + declSpec= lie.fDeclSpec; declarator= addInitializer(lie, options); } final int endOffset = figureEndOffset(declSpec, declarator); final IASTSimpleDeclaration decl= nodeFactory.newSimpleDeclaration(declSpec); - if (declarator != null) - decl.addDeclarator(declarator); + decl.addDeclarator(declarator); ((ASTNode) decl).setOffsetAndLength(startOffset, endOffset - startOffset); + return decl; } @@ -3337,7 +3390,7 @@ @Override protected void setupTranslationUnit() throws DOMException { - translationUnit = nodeFactory.newTranslationUnit(scanner); + translationUnit = nodeFactory.newTranslationUnit(); translationUnit.setIndex(index); // add built-in names to the scope @@ -3350,6 +3403,8 @@ ASTInternal.addBinding(tuScope, binding); } } + if(translationUnit instanceof ASTTranslationUnit) + ((ASTTranslationUnit)translationUnit).setLocationResolver(scanner.getLocationResolver()); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IBinding; /** @@ -19,11 +20,8 @@ */ public interface ICPPInternalFunction extends ICPPInternalBinding { - /** - * Called to resolve the parameter in the second phase. - */ - public IBinding resolveParameter(CPPParameter parameter); - + public IBinding resolveParameter( IASTParameterDeclaration param ); + /** * Returns whether there is a static declaration for this function. * @param resolveAll checks for names that are not yet resolved to this binding. diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,365 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; - -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -import org.eclipse.cdt.core.dom.ast.DOMException; -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IProblemBinding; -import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; -import org.eclipse.cdt.core.index.IIndexFileSet; -import org.eclipse.cdt.core.parser.util.ArrayUtil; -import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; -import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; - -/** - * Helper class for performing the base class lookup. First a directed graph without loops is computed to represent the base - * class hierarchy up to those bases for which the lookup finds matches. Next, from these leaves we search for virtual bases - * that are hidden. With this information the matches are extracted from the graph. - */ -class BaseClassLookup { - public static void lookupInBaseClasses(LookupData data, ICPPClassScope classScope, IIndexFileSet fileSet) { - if (classScope == null) - return; - - final ICPPClassType classType= classScope.getClassType(); - if (classType == null) - return; - - final HashMap infoMap = new HashMap(); - BaseClassLookup rootInfo= lookupInBaseClass(data, null, false, classType, fileSet, infoMap, 0); - if (data.contentAssist) { - rootInfo.collectResultForContentAssist(data); - } else { - hideVirtualBases(rootInfo, infoMap); - IBinding[] result= rootInfo.collectResult(data, true, null); - verifyResult(data, result); - } - } - - - private final ICPPClassType fClassType; - private IBinding[] fBindings; - private List fChildren= Collections.emptyList(); - private BitSet fVirtual; - private boolean fHiddenAsVirtualBase= false; - private boolean fPropagationDone= false; - private boolean fCollected; - private boolean fCollectedAsRegularBase; - - private BaseClassLookup(ICPPClassType type) { - fClassType= type; - } - ICPPClassType getClassType() { - return fClassType; - } - - IBinding[] getResult() { - return fBindings; - } - boolean containsVirtualBase() { - return (fVirtual != null && fVirtual.nextSetBit(0) >= 0); - } - boolean hasMatches() { - return fBindings != null && fBindings.length > 0 && fBindings[0] != null; - } - - public void addBase(boolean virtual, BaseClassLookup baseInfo) { - if (virtual && fHiddenAsVirtualBase) - return; - - if (fChildren.isEmpty()) { - fChildren= new ArrayList(); - fVirtual= new BitSet(); - } - fVirtual.set(fChildren.size(), virtual); - fChildren.add(baseInfo); - } - - public void setResult(IBinding[] bindings) { - fBindings= bindings; - } - - public void setHiddenAsVirtualBase() { - fHiddenAsVirtualBase= true; - } - public void propagateHiddenAsVirtual() { - if (fPropagationDone) - return; - fPropagationDone= true; - for (int i=0; i infoMap, int depth) { - if (depth++ > CPPSemantics.MAX_INHERITANCE_DEPTH) - return null; - - if (baseClassScope != null) { - BaseClassLookup info= infoMap.get(baseClassScope); - if (info != null) { - // avoid loops - if (info.getResult() == null) { - data.problem = new ProblemBinding(null, IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, root.getNameCharArray()); - return null; - } - return info; - } - } - - // this is the first time to handle the class - BaseClassLookup result; - IBinding[] matches= IBinding.EMPTY_BINDING_ARRAY; - if (baseClassScope == null) { - result= new BaseClassLookup(root); - try { - infoMap.put(root.getCompositeScope(), result); - } catch (DOMException e) { - // ignore - } - } else { - result= new BaseClassLookup(baseClassScope.getClassType()); - infoMap.put(baseClassScope, result); - try { - IBinding[] members= CPPSemantics.getBindingsFromScope(baseClassScope, fileSet, data); - if (data.typesOnly) { - CPPSemantics.removeObjects(members); - } - if (members != null && members.length > 0 && members[0] != null) { - if (data.prefixLookup) { - matches= members; - } else { - result.setResult(members); - return result; - } - } - } catch (DOMException e) { - // continue the lookup - } - } - - // there is no result in the baseClass itself or we do content assist, we have to examine its base-classes - ICPPClassType baseClass= result.getClassType(); - if (baseClass != null) { - ICPPBase[] grandBases= null; - try { - grandBases= baseClass.getBases(); - } catch (DOMException e) { - // assume that there are no bases - } - if (grandBases != null && grandBases.length > 0) { - HashSet grandBaseBindings= grandBases.length > 1 ? new HashSet() : null; - for (ICPPBase grandBase : grandBases) { - if (grandBase instanceof IProblemBinding) - continue; - - try { - IBinding grandBaseBinding = grandBase.getBaseClass(); - if (!(grandBaseBinding instanceof ICPPClassType)) { - // 14.6.2.3 scope is not examined - if (grandBaseBinding instanceof ICPPUnknownBinding) { - if (data.skippedScope == null) - data.skippedScope= root; - } - continue; - } - - final ICPPClassType grandBaseClass = (ICPPClassType) grandBaseBinding; - if (grandBaseBindings != null && !grandBaseBindings.add(grandBaseClass)) - continue; - - final IScope grandBaseScope= grandBaseClass.getCompositeScope(); - if (grandBaseScope == null || grandBaseScope instanceof ICPPInternalUnknownScope) { - // 14.6.2.3 scope is not examined - if (data.skippedScope == null) - data.skippedScope= root; - continue; - } - if (!(grandBaseScope instanceof ICPPClassScope)) - continue; - - BaseClassLookup baseInfo= lookupInBaseClass(data, (ICPPClassScope) grandBaseScope, grandBase.isVirtual(), root, fileSet, infoMap, depth); - if (baseInfo != null) - result.addBase(grandBase.isVirtual(), baseInfo); - } catch (DOMException e) { - // move on to next base - } - } - } - } - result.setResult(matches); - return result; - } - static void hideVirtualBases(BaseClassLookup rootInfo, HashMap infoMap) { - boolean containsVirtualBase= false; - final BaseClassLookup[] allInfos = infoMap.values().toArray(new BaseClassLookup[infoMap.size()]); - for (BaseClassLookup info : allInfos) { - if (info.containsVirtualBase()) { - containsVirtualBase= true; - break; - } - } - if (containsVirtualBase) { - for (BaseClassLookup info : allInfos) { - if (info.hasMatches()) { - info.hideVirtualBases(infoMap, 0); - } - } - } - } - - void hideVirtualBases(HashMap infoMap, int depth) { - if (depth++ > CPPSemantics.MAX_INHERITANCE_DEPTH) - return; - - if (fClassType != null) { - ICPPBase[] bases= null; - try { - bases= fClassType.getBases(); - } catch (DOMException e) { - // assume that there are no bases - } - if (bases != null && bases.length > 0) { - for (ICPPBase base : bases) { - if (base instanceof IProblemBinding) - continue; - - try { - IBinding baseBinding = base.getBaseClass(); - if (!(baseBinding instanceof ICPPClassType)) { - continue; - } - - final ICPPClassType baseClass = (ICPPClassType) baseBinding; - final IScope baseScope= baseClass.getCompositeScope(); - if (!(baseScope instanceof ICPPClassScope)) - continue; - - BaseClassLookup baseInfo= infoMap.get(baseScope); - if (baseInfo != null) { - if (base.isVirtual()) { - baseInfo.setHiddenAsVirtualBase(); - } - baseInfo.propagateHiddenAsVirtual(); - } else { - // mark to catch recursions - baseInfo= new BaseClassLookup(baseClass); - infoMap.put(baseScope, baseInfo); - baseInfo.hideVirtualBases(infoMap, depth); - } - } catch (DOMException e) { - // move on to next base - } - } - } - } - } - public void collectResultForContentAssist(LookupData data) { - if (fCollected) - return; - fCollected= true; - - data.foundItems = CPPSemantics.mergePrefixResults((CharArrayObjectMap) data.foundItems, fBindings, true); - for (int i=0; i(2); + + data.inheritanceChain.put(lookIn); + + // workaround to fix 185828 + if (data.inheritanceChain.size() > CPPSemantics.MAX_INHERITANCE_DEPTH) { + return null; + } + + HashSet baseBindings= bases.length > 1 ? new HashSet() : null; + for (ICPPBase base : bases) { + if (base instanceof IProblemBinding) + continue; + + try { + IBinding b = base.getBaseClass(); + if (!(b instanceof ICPPClassType)) { + // 14.6.2.3 scope is not examined + if (b instanceof ICPPUnknownBinding) { + if (data.skippedScope == null) + data.skippedScope= overallScope; + } + continue; + } + + final ICPPClassType cls = (ICPPClassType) b; + if (baseBindings != null && !baseBindings.add(cls)) + continue; + + inherited = null; + final ICPPScope classScope = (ICPPScope) cls.getCompositeScope(); + if (classScope == null || classScope instanceof ICPPInternalUnknownScope) { + // 14.6.2.3 scope is not examined + if (data.skippedScope == null) + data.skippedScope= overallScope; + continue; + } + if (!base.isVirtual() || !data.visited.containsKey(classScope)) { + if (base.isVirtual()) { + data.visited.put(classScope); + } + + // if the inheritanceChain already contains the parent, then that + // is circular inheritance + if (!data.inheritanceChain.containsKey(classScope)) { + //is this name define in this scope? + IBinding[] inCurrentScope= getBindingsFromScope(classScope, fileSet, data); + if (data.typesOnly) { + removeObjects(inCurrentScope); + } + final boolean isEmpty= inCurrentScope.length == 0 || inCurrentScope[0] == null; + if (data.contentAssist) { + Object temp = lookupInParents(data, classScope, overallScope, fileSet); + if (!isEmpty) { + inherited = mergePrefixResults(null, inCurrentScope, true); + inherited = mergePrefixResults((CharArrayObjectMap) inherited, + (CharArrayObjectMap) temp, true); + } else { + inherited= temp; + } + } else if (isEmpty) { + inherited= lookupInParents(data, classScope, overallScope, fileSet); + } else { + inherited= inCurrentScope; + visitVirtualBaseClasses(data, cls); + } + } else { + data.problem = new ProblemBinding(null, IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, + cls.getNameCharArray(), data.getFoundBindings()); + return null; + } + } + + if (inherited != null) { + if (result == null) { + result = inherited; + } else if (!data.contentAssist) { + if (result instanceof Object[]) { + Object[] r = (Object[]) result; + for (int j = 0; j < r.length && r[j] != null; j++) { + if (checkForAmbiguity(data, r[j], inherited)) { + data.problem = new ProblemBinding(data.astName, + IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getFoundBindings()); + return null; + } + } + } else { + if (checkForAmbiguity(data, result, inherited)) { + data.problem = new ProblemBinding(data.astName, + IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getFoundBindings()); + return null; + } + } + } else { + CharArrayObjectMap temp = (CharArrayObjectMap) inherited; + CharArrayObjectMap r = (CharArrayObjectMap) result; + char[] key = null; + int tempSize = temp.size(); + for (int ii = 0; ii < tempSize; ii++) { + key = temp.keyAt(ii); + if (!r.containsKey(key)) { + r.put(key, temp.get(key)); + } else { + //TODO: prefixLookup ambiguity checking + } + } + } + } + } catch (DOMException e) { + // assume that the base has not been specified + } + } + + data.inheritanceChain.remove(lookIn); + + return result; + } + + public static void visitVirtualBaseClasses(LookupData data, ICPPClassType cls) throws DOMException { + if (data.inheritanceChain == null) + data.inheritanceChain = new ObjectSet(2); + + IScope scope = cls.getCompositeScope(); + if (scope != null) + data.inheritanceChain.put(scope); + + ICPPBase[] bases = cls.getBases(); + + for (ICPPBase base : bases) { + IBinding b = base.getBaseClass(); + if (b instanceof ICPPClassType) { + IScope bScope = ((ICPPClassType)b).getCompositeScope(); + if (base.isVirtual()) { + if (bScope != null) + data.visited.put(bScope); + } else if (bScope != null) { + if (!data.inheritanceChain.containsKey(bScope)) + visitVirtualBaseClasses(data, (ICPPClassType) b); + else + data.problem = new ProblemBinding(null, IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, cls.getNameCharArray()); + } + } + } + + if (scope != null) + data.inheritanceChain.remove(scope); + } + + private static boolean checkForAmbiguity(LookupData data, Object n, Object names) throws DOMException { + if (names instanceof Object[]) { + names = ArrayUtil.trim(Object.class, (Object[]) names); + if (((Object[])names).length == 0) + return false; + } + + IBinding binding= (n instanceof IBinding) ? (IBinding) n : ((IASTName) n).resolveBinding(); + + int idx= 0; + Object[] objs= null; + Object o= names; + if (names instanceof Object[]) { + objs= (Object[]) names; + o= objs[0]; + idx= 1; + } + + while (o != null) { + IBinding b = (o instanceof IBinding) ? (IBinding) o : ((IASTName)o).resolveBinding(); + + if (b instanceof ICPPUsingDeclaration) { + objs = ArrayUtil.append(Object.class, objs, ((ICPPUsingDeclaration)b).getDelegates()); + } else { + if (binding != b) + return true; + + boolean ok = false; + // 3.4.5-4 if the id-expression in a class member access is a qualified id... the result + // is not required to be a unique base class... + if (binding instanceof ICPPClassType) { + IASTNode parent = data.astName.getParent(); + if (parent instanceof ICPPASTQualifiedName && + parent.getPropertyInParent() == IASTFieldReference.FIELD_NAME) { + ok = true; + } + } + // it is not ambiguous if they are the same thing and it is static or an enumerator + if (binding instanceof IEnumerator || + (binding instanceof IFunction && ASTInternal.isStatic((IFunction) binding, false)) || + (binding instanceof IVariable && ((IVariable)binding).isStatic())) { + ok = true; + } + if (!ok) + return true; + } + if (objs != null && idx < objs.length) + o = objs[idx++]; + else + o = null; + } + return false; + } /** * Stores the using directive with the scope where the members of the nominated namespace will appear. @@ -1278,10 +1461,9 @@ ASTInternal.addName(scope, name); return; } - if (declaration == null || declaration instanceof ASTAmbiguousNode) { + if (declaration == null) return; - } - + if (declaration instanceof IASTSimpleDeclaration) { IASTSimpleDeclaration simpleDeclaration = (IASTSimpleDeclaration) declaration; ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) simpleDeclaration.getDeclSpecifier(); @@ -2320,7 +2502,11 @@ IType[] result = null; for (int i = 0; i < types.length && types[i] != null; i++) { IType[] pts = null; - pts = types[i].getParameterTypes(); + try { + pts = types[i].getParameterTypes(); + } catch (DOMException e) { + continue; + } if (pts.length > idx) result = (IType[]) ArrayUtil.append(IType.class, result, pts[idx]); } @@ -2455,7 +2641,7 @@ return type; char[] operatorName = OverloadableOperator.ARROW.toCharArray(); - IASTExpression[] args = {owner}; + IASTExpression[] args = {null}; // bug 205964: as long as the type is a class type, recurse. // Be defensive and allow a max of 10 levels. @@ -2517,7 +2703,7 @@ public static ICPPFunction findOverloadedOperator(IASTArraySubscriptExpression exp) { char[] name = OverloadableOperator.BRACKET.toCharArray(); - IASTExpression[] args = {exp.getArrayExpression(), exp.getSubscriptExpression()}; + IASTExpression[] args = { null, exp.getSubscriptExpression() }; IType type1 = exp.getArrayExpression().getExpressionType(); IType ultimateType1 = SemanticUtil.getUltimateTypeUptoPointers(type1); return findOverloadedOperator(exp, args, ultimateType1, name, false); @@ -2531,15 +2717,15 @@ if (param instanceof IASTExpressionList) { IASTExpression[] actualArgs = ((IASTExpressionList)param).getExpressions(); ArrayList argsToPass = new ArrayList(actualArgs.length + 1); - argsToPass.add(exp.getFunctionNameExpression()); + argsToPass.add(null); for (IASTExpression e : actualArgs) { argsToPass.add(e); } args = argsToPass.toArray(new IASTExpression[argsToPass.size()]); } else if (param != null) { - args = new IASTExpression[] { exp.getFunctionNameExpression(), param }; + args = new IASTExpression[] { null, param }; } else { - args = new IASTExpression[] { exp.getFunctionNameExpression() }; + args = new IASTExpression[] { null }; } return findOverloadedOperator(exp, args, type, name, false); @@ -2551,7 +2737,11 @@ IType type = exp.getExpressionType(); if (type instanceof IProblem) return null; - type = ((IPointerType)type).getType(); + try { + type = ((IPointerType)type).getType(); + } catch (DOMException e) { + return null; + } IASTTypeId typeId = exp.getTypeId().copy(); IASTExpression sizeExpression = new CPPASTTypeIdExpression(IASTTypeIdExpression.op_sizeof, typeId); @@ -2582,9 +2772,13 @@ IType type1 = exp.getOperand().getExpressionType(); IType ultimateType1 = SemanticUtil.getUltimateTypeUptoPointers(type1); if (ultimateType1 instanceof IPointerType) { - IType classType = ((IPointerType)ultimateType1).getType(); - if (classType instanceof ICPPClassType) - return (ICPPClassType) classType; + try { + IType classType = ((IPointerType)ultimateType1).getType(); + if (classType instanceof ICPPClassType) + return (ICPPClassType) classType; + } catch (DOMException e) { + return null; + } } return null; } @@ -2684,17 +2878,13 @@ } private static ICPPFunction findOverloadedOperator(IASTExpression parent, IASTExpression[] args, IType methodLookupType, char[] operatorName, boolean lookupNonMember) { - ICPPClassType callToObjectOfClassType= null; - // Find a method LookupData methodData = null; CPPASTName methodName = null; if (methodLookupType instanceof IProblemBinding) return null; if (methodLookupType instanceof ICPPClassType) { - ICPPClassType classType = (ICPPClassType)methodLookupType; - - methodName = new CPPASTName(operatorName); + methodName = new CPPASTName(operatorName); methodName.setParent(parent); methodName.setPropertyInParent(STRING_LOOKUP_PROPERTY); methodData = new LookupData(methodName); @@ -2702,14 +2892,10 @@ methodData.forceQualified = true; // (13.3.1.2.3) try { - IScope scope = classType.getCompositeScope(); + IScope scope = ((ICPPClassType)methodLookupType).getCompositeScope(); if (scope == null) return null; lookup(methodData, scope); - - if (parent instanceof IASTFunctionCallExpression) { - callToObjectOfClassType= classType; - } } catch (DOMException e) { return null; } @@ -2718,7 +2904,7 @@ // Find a function LookupData funcData = null; CPPASTName funcName = null; - if (lookupNonMember || callToObjectOfClassType != null) { + if (lookupNonMember) { funcName = new CPPASTName(operatorName); funcName.setParent(parent); funcName.setPropertyInParent(STRING_LOOKUP_PROPERTY); @@ -2727,35 +2913,16 @@ funcData.ignoreMembers = true; // (13.3.1.2.3) try { - if (lookupNonMember) { - IScope scope = CPPVisitor.getContainingScope(parent); - if (scope == null) - return null; - lookup(funcData, scope); - } - if (callToObjectOfClassType != null) { - // 13.3.1.1.2 call to object of class type - ICPPMethod[] ops = SemanticUtil.getConversionOperators(callToObjectOfClassType); - for (ICPPMethod op : ops) { - IFunctionType ft= op.getType(); - if (ft != null) { - IType rt= SemanticUtil.getNestedType(ft.getReturnType(), SemanticUtil.TDEF); - if (rt instanceof IPointerType) { - IType ptt= SemanticUtil.getNestedType(((IPointerType)rt).getType(), SemanticUtil.TDEF); - if (ptt instanceof IFunctionType) { - IFunctionType ft2= (IFunctionType) ptt; - IBinding sf= createSurrogateCallFunction(parent.getTranslationUnit().getScope(), ft2.getReturnType(), rt, ft2.getParameterTypes()); - mergeResults(funcData, sf, false); - } - } - } - } - } + IScope scope = CPPVisitor.getContainingScope(parent); + if (scope == null) + return null; + lookup(funcData, scope); } catch (DOMException e) { return null; } } + // Resolve ambiguities try { IBinding binding = null; if (methodData != null && funcData != null) { @@ -2777,22 +2944,7 @@ return null; } - private static IBinding createSurrogateCallFunction(IScope scope, IType returnType, IType rt, IType[] parameterTypes) { - IType[] parms = new IType[parameterTypes.length+1]; - IParameter[] theParms = new IParameter[parms.length]; - - parms[0] = rt; - theParms[0]= new CPPBuiltinParameter(rt); - for (int i = 1; i < parms.length; i++) { - IType t = parameterTypes[i-1]; - parms[i]= t; - theParms[i]= new CPPBuiltinParameter(t); - } - ICPPFunctionType functionType = new CPPFunctionType(returnType, parms); - return new CPPImplicitFunction(CALL_FUNCTION, scope, functionType, theParms, false); - } - - private static boolean isUserDefined(IType type) { + private static boolean isUserDefined(IType type) { return type instanceof ICPPClassType || type instanceof IEnumeration; } @@ -2907,7 +3059,7 @@ ICPPASTTemplateDeclaration templateDecl = CPPTemplates.getTemplateDeclaration(name); if (templateDecl != null) { if (templateDecl instanceof ICPPASTTemplateSpecialization) { - if (!(function instanceof ICPPSpecialization)) + if (!(function instanceof ICPPTemplateInstance)) return false; } else { if (!(function instanceof ICPPTemplateDefinition)) diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java Wed Aug 05 17:35:39 2009 -0500 @@ -96,7 +96,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization; @@ -843,11 +842,11 @@ } if (type instanceof ITypeContainer) { - final ITypeContainer typeContainer = (ITypeContainer) type; - IType nestedType = typeContainer.getType(); + final ITypeContainer tc = (ITypeContainer) type; + IType nestedType = tc.getType(); IType newNestedType = instantiateType(nestedType, tpMap, within); - if (typeContainer instanceof ICPPPointerToMemberType) { - ICPPPointerToMemberType ptm = (ICPPPointerToMemberType) typeContainer; + if (type instanceof ICPPPointerToMemberType) { + ICPPPointerToMemberType ptm = (ICPPPointerToMemberType) type; IType memberOfClass = ptm.getMemberOfClass(); IType newMemberOfClass = instantiateType(memberOfClass, tpMap, within); if (newNestedType != nestedType || newMemberOfClass != memberOfClass) { @@ -855,22 +854,13 @@ return new CPPPointerToMemberType(newNestedType, newMemberOfClass, ptm.isConst(), ptm.isVolatile()); } - return typeContainer; - } - } else if (typeContainer instanceof IArrayType) { - IArrayType at= (IArrayType) typeContainer; - IValue asize= at.getSize(); - if (asize != null) { - IValue newSize= instantiateValue(asize, tpMap, within, Value.MAX_RECURSION_DEPTH); - if (newSize != asize) { - return new CPPArrayType(newNestedType, newSize); - } + return type; } } if (newNestedType != nestedType) { - return SemanticUtil.replaceNestedType(typeContainer, newNestedType); + return SemanticUtil.replaceNestedType(tc, newNestedType); } - return typeContainer; + return type; } return type; @@ -1010,7 +1000,7 @@ } public static void associateTemplateDeclarations(ICPPASTInternalTemplateDeclaration tdecl) { - // find innermost template declaration + // find innermost template decl IASTDeclaration decl= tdecl.getDeclaration(); while (decl instanceof ICPPASTInternalTemplateDeclaration) { tdecl= (ICPPASTInternalTemplateDeclaration) decl; @@ -1018,7 +1008,7 @@ } final ICPPASTInternalTemplateDeclaration innerMostTDecl= tdecl; - // find name declared within the template declaration + // find name declared in nested declaration IASTName name= getNameForDeclarationInTemplateDeclaration(decl); // count template declarations @@ -1033,7 +1023,7 @@ // determine association of names with template declarations boolean lastIsTemplate= true; - int missingTemplateDecls= 0; + int additionalLevels= 0; if (name instanceof ICPPASTQualifiedName) { ICPPASTQualifiedName qname= (ICPPASTQualifiedName) name; final IASTName lastName = qname.getLastName(); @@ -1042,7 +1032,8 @@ // count template-ids int idcount= 0; final IASTName[] ns= qname.getNames(); - for (final IASTName n : ns) { + for (int j = 0; j < ns.length; j++) { + final IASTName n = ns[j]; if (n instanceof ICPPASTTemplateId) { idcount++; } @@ -1062,23 +1053,25 @@ } if (lastIsID && !isCtorWithTemplateID) { - missingTemplateDecls= idcount-tdeclcount; + additionalLevels= idcount-tdeclcount; } else { - missingTemplateDecls= idcount+1-tdeclcount; - if (missingTemplateDecls > 0) { + additionalLevels= idcount+1-tdeclcount; + if (additionalLevels > 0) { // last name is probably not a template - missingTemplateDecls--; + additionalLevels--; lastIsTemplate= false; CharArraySet tparnames= collectTemplateParameterNames(outerMostTDecl); int j= 0; - for (IASTName n : ns) { + IASTName n; + for (int i = 0; i < ns.length; i++) { + n = ns[j]; if (n instanceof ICPPASTTemplateId) { // if we find a dependent id, there can be no explicit specialization. ICPPASTTemplateId id= (ICPPASTTemplateId) n; if (usesTemplateParameter(id, tparnames)) break; - if (j++ == missingTemplateDecls) { + if (j++ == additionalLevels) { IBinding b= n.resolveBinding(); if (b instanceof ICPPTemplateInstance && b instanceof ICPPClassType) { try { @@ -1086,7 +1079,7 @@ if (!(s instanceof ICPPClassSpecializationScope)) { // template-id of an explicit specialization. // here we don't have a template declaration. (see 14.7.3.5) - missingTemplateDecls++; + additionalLevels++; lastIsTemplate= true; } } catch (DOMException e) { @@ -1101,12 +1094,12 @@ } } - if (missingTemplateDecls < 0) { - missingTemplateDecls= 0; // too many template declarations + if (additionalLevels < 0) { + additionalLevels= 0; // too many template declarations } // determine nesting level of parent - int level= missingTemplateDecls; + int level= additionalLevels; if (!CPPVisitor.isFriendFunctionDeclaration(innerMostTDecl.getDeclaration())) { node= outerMostTDecl.getParent(); while (node != null) { @@ -1565,16 +1558,23 @@ static private IType getArgumentTypeForDeduction(IType type, boolean parameterIsAReferenceType) { type = SemanticUtil.getSimplifiedType(type); if (type instanceof ICPPReferenceType) { - type = ((ICPPReferenceType) type).getType(); + try { + type = ((ICPPReferenceType) type).getType(); + } catch (DOMException e) { + } } IType result = type; if (!parameterIsAReferenceType) { - if (type instanceof IArrayType) { - result = new CPPPointerType(((IArrayType) type).getType()); - } else if (type instanceof IFunctionType) { - result = new CPPPointerType(type); - } else { - result = SemanticUtil.getNestedType(type, SemanticUtil.TDEF | SemanticUtil.CVQ | SemanticUtil.PTR_CVQ ); + try { + if (type instanceof IArrayType) { + result = new CPPPointerType(((IArrayType) type).getType()); + } else if (type instanceof IFunctionType) { + result = new CPPPointerType(type); + } else { + result = SemanticUtil.getNestedType(type, SemanticUtil.TDEF | SemanticUtil.CVQ | SemanticUtil.PTR_CVQ ); + } + } catch (DOMException e) { + result = e.getProblem(); } } return result; @@ -1607,32 +1607,6 @@ } p = ((ICPPReferenceType) p).getType(); a = ((ICPPReferenceType) a).getType(); - } else if (p instanceof IArrayType) { - if (!(a instanceof IArrayType)) { - return false; - } - IArrayType aa= (IArrayType) a; - IArrayType pa= (IArrayType) p; - IValue as= aa.getSize(); - IValue ps= pa.getSize(); - if (as != ps) { - if (as == null || ps == null) - return false; - - int parPos= Value.isTemplateParameter(ps); - if (parPos >= 0) { - ICPPTemplateArgument old= map.getArgument(parPos); - if (old == null) { - map.put(parPos, new CPPTemplateArgument(ps, new CPPBasicType(IBasicType.t_int, 0))); - } else if (!ps.equals(old.getNonTypeValue())) { - return false; - } - } else if (!ps.equals(as)) { - return false; - } - } - p = pa.getType(); - a = aa.getType(); } else if (p instanceof IQualifierType) { if (a instanceof IQualifierType) { a = ((IQualifierType) a).getType(); //TODO a = strip qualifiers from p out of a @@ -1953,7 +1927,7 @@ if (!(paramType instanceof IType)) return null; - IParameter[] functionParameters = new IParameter[] { new CPPParameter((IType) paramType, 0) }; + IParameter[] functionParameters = new IParameter[] { new CPPParameter((IType) paramType) }; return new CPPImplicitFunctionTemplate(specialization.getTemplateParameters(), functionParameters); } catch (DOMException e) { @@ -1962,8 +1936,12 @@ } static private boolean isValidType(IType t) { - while (t instanceof ITypeContainer) { - t = ((ITypeContainer) t).getType(); + try { + while (t instanceof ITypeContainer) { + t = ((ITypeContainer) t).getType(); + } + } catch (DOMException e) { + return false; } return !(t instanceof IProblemBinding); } @@ -2054,7 +2032,11 @@ if (paramType instanceof IFunctionType) { paramType = new CPPPointerType(paramType); } else if (paramType instanceof IArrayType) { - paramType = new CPPPointerType(((IArrayType) paramType).getType()); + try { + paramType = new CPPPointerType(((IArrayType) paramType).getType()); + } catch (DOMException e) { + paramType = e.getProblem(); + } } Cost cost = Conversions.checkStandardConversionSequence(arg, paramType, false); return cost != null && cost.getRank() != Rank.NO_MATCH; @@ -2108,30 +2090,30 @@ } public static boolean isDependentType(IType t) { - while (true) { - if (t instanceof ICPPUnknownType) - return true; - - if (t instanceof ICPPFunctionType) { - final ICPPFunctionType ft = (ICPPFunctionType) t; - if (containsDependentType(ft.getParameterTypes())) + try { + while (true) { + if (t instanceof ICPPUnknownType) return true; - t= ft.getReturnType(); - } else if (t instanceof ICPPPointerToMemberType) { - ICPPPointerToMemberType ptmt= (ICPPPointerToMemberType) t; - if (isDependentType(ptmt.getMemberOfClass())) - return true; - t= ptmt.getType(); - } else if (t instanceof ITypeContainer) { - if (t instanceof IArrayType) { - IValue asize= ((IArrayType) t).getSize(); - if (asize != null && Value.isDependentValue(asize)) + + if (t instanceof ICPPFunctionType) { + final ICPPFunctionType ft = (ICPPFunctionType) t; + if (containsDependentType(ft.getParameterTypes())) + return true; + t= ft.getReturnType(); + } else if (t instanceof ICPPPointerToMemberType) { + ICPPPointerToMemberType ptmt= (ICPPPointerToMemberType) t; + if (isDependentType(ptmt.getMemberOfClass())) return true; + t= ptmt.getType(); + } else if (t instanceof ITypeContainer) { + t= ((ITypeContainer) t).getType(); + } else { + return false; } - t= ((ITypeContainer) t).getType(); - } else { - return false; } + } catch (DOMException e) { + // treat as non-dependent + return false; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVariableReadWriteFlags.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; @@ -49,22 +50,31 @@ if (!(type instanceof ICPPReferenceType)) { return READ; } - type= ((ICPPReferenceType) type).getType(); - } - while(indirection > 0 && (type instanceof ITypeContainer)) { - if (type instanceof IPointerType) { - indirection--; + try { + type= ((ICPPReferenceType) type).getType(); } - type= ((ITypeContainer) type).getType(); + catch (DOMException e) { + return READ; // fallback + } } - if (indirection == 0) { - if (type instanceof IQualifierType) { - return ((IQualifierType) type).isConst() ? READ : READ | WRITE; + try { + while(indirection > 0 && (type instanceof ITypeContainer)) { + if (type instanceof IPointerType) { + indirection--; + } + type= ((ITypeContainer) type).getType(); } - else if (type instanceof IPointerType) { - return ((IPointerType) type).isConst() ? READ : READ | WRITE; + if (indirection == 0) { + if (type instanceof IQualifierType) { + return ((IQualifierType) type).isConst() ? READ : READ | WRITE; + } + else if (type instanceof IPointerType) { + return ((IPointerType) type).isConst() ? READ : READ | WRITE; + } } } + catch (DOMException e) { + } return READ | WRITE; // fallback } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java Wed Aug 05 17:35:39 2009 -0500 @@ -166,6 +166,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerToMemberType; import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.index.IIndexScope; @@ -366,9 +367,11 @@ // 7.1.5.3-2 ... If name lookup does not find a declaration for the name, the elaborated-type-specifier is ill-formed // unless it is of the simple form class-key identifier - if (mustBeSimple && elabType.getName() instanceof ICPPASTQualifiedName) + if (mustBeSimple && + (elabType.getName() instanceof ICPPASTQualifiedName || elabType.getKind() == IASTElaboratedTypeSpecifier.k_enum)) { return binding; - + } + try { boolean template = false; ICPPScope scope = (ICPPScope) getContainingScope(name); @@ -453,7 +456,6 @@ } return binding; } - private static IBinding createBinding(IASTDeclaration declaration) { if (declaration instanceof ICPPASTNamespaceDefinition) { ICPPASTNamespaceDefinition namespaceDef = (ICPPASTNamespaceDefinition) declaration; @@ -499,7 +501,6 @@ return null; } - private static IBinding createBinding(IASTDeclarator declarator) { IASTNode parent = findOutermostDeclarator(declarator).getParent(); declarator= findInnermostDeclarator(declarator); @@ -557,13 +558,16 @@ if (!(findOutermostDeclarator(fdtor).getParent() instanceof IASTDeclaration) || findTypeRelevantDeclarator(fdtor) != fdtor) return null; - IASTParameterDeclaration[] params = fdtor.getParameters(); - int i=0; - for(;i v) { + minValue = v; + } + if (maxValue < v) { + maxValue = v; + } + } + } + } + } catch (DOMException e) { + return 0; + } + // TODO(sprigogin): Use values of __INT_MAX__ and __LONG_MAX__ macros + if (minValue >= Integer.MIN_VALUE && maxValue <= Integer.MAX_VALUE) { + return 0; + } else if (minValue >= 0 && maxValue <= 0xFFFFFFFFL) { + return IS_UNSIGNED; + } else if (minValue >= Long.MIN_VALUE && maxValue <= Long.MAX_VALUE) { + return IS_LONG; + } else { + // This branch is unreachable due to limitations of Java long type. + return IS_UNSIGNED | IS_LONG; + } + } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java Wed Aug 05 17:35:39 2009 -0500 @@ -18,31 +18,7 @@ import java.util.List; import java.util.Map; -import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; -import org.eclipse.cdt.core.dom.ast.DOMException; -import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; -import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; -import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTExpression; -import org.eclipse.cdt.core.dom.ast.IASTExpressionList; -import org.eclipse.cdt.core.dom.ast.IASTFieldReference; -import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; -import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTIdExpression; -import org.eclipse.cdt.core.dom.ast.IASTInitializer; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTTypeId; -import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IPointerType; -import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.*; import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; @@ -88,6 +64,10 @@ */ public ObjectSet visited= new ObjectSet(1); + /* + * Used to detect circular inheritance + */ + public ObjectSet inheritanceChain; @SuppressWarnings("unchecked") public ObjectSet associated = ObjectSet.EMPTY_SET; @@ -580,8 +560,8 @@ } if (checkForDependentName) { IType[] types= getFunctionArgumentTypes(); - for (IType type : types) { - if (CPPTemplates.isDependentType(type)) { + for (int i = 0; i < types.length; i++) { + if (CPPTemplates.isDependentType(types[i])) { checkPointOfDecl= false; break; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java Wed Aug 05 17:35:39 2009 -0500 @@ -189,49 +189,53 @@ boolean ptr= (options & PTR) != 0; boolean mptr= (options & MPTR) != 0; assert !(ptrcvq && (ptr || mptr)); - while (true) { - IType t= null; - if (type instanceof IPointerType) { - final boolean isMbrPtr = type instanceof ICPPPointerToMemberType; - if ((ptr && !isMbrPtr) || (mptr && isMbrPtr)) { - t= ((IPointerType) type).getType(); - } else if (ptrcvq) { - if (type instanceof CPPPointerType) { - return ((CPPPointerType) type).stripQualifiers(); - } - IPointerType p= (IPointerType) type; - if (p.isConst() || p.isVolatile()) { - if (p instanceof ICPPPointerToMemberType) { - final IType memberOfClass = ((ICPPPointerToMemberType) p).getMemberOfClass(); - if (memberOfClass instanceof ICPPClassType) - return new CPPPointerToMemberType(p.getType(), memberOfClass, false, false); - } else { - return new CPPPointerType(p.getType(), false, false); + try { + while (true) { + IType t= null; + if (type instanceof IPointerType) { + final boolean isMbrPtr = type instanceof ICPPPointerToMemberType; + if ((ptr && !isMbrPtr) || (mptr && isMbrPtr)) { + t= ((IPointerType) type).getType(); + } else if (ptrcvq) { + if (type instanceof CPPPointerType) { + return ((CPPPointerType) type).stripQualifiers(); + } + IPointerType p= (IPointerType) type; + if (p.isConst() || p.isVolatile()) { + if (p instanceof ICPPPointerToMemberType) { + final IType memberOfClass = ((ICPPPointerToMemberType) p).getMemberOfClass(); + if (memberOfClass instanceof ICPPClassType) + return new CPPPointerToMemberType(p.getType(), memberOfClass, false, false); + } else { + return new CPPPointerType(p.getType(), false, false); + } } } + } else if (tdef && type instanceof ITypedef) { + t= ((ITypedef) type).getType(); + } else if (type instanceof IQualifierType) { + final IQualifierType qt = (IQualifierType) type; + if (((options & CVQ) != 0)) { + t= qt.getType(); + } else if (tdef) { + IType temp= qt.getType(); + if (temp instanceof ITypedef) { + temp= getNestedType(temp, TDEF); + return addQualifiers(temp, qt.isConst(), qt.isVolatile()); + } + } + } else if ((options & ARRAY) != 0 && type instanceof IArrayType) { + t= ((IArrayType) type).getType(); + } else if ((options & REF) != 0 && type instanceof ICPPReferenceType) { + t= ((ICPPReferenceType) type).getType(); } - } else if (tdef && type instanceof ITypedef) { - t= ((ITypedef) type).getType(); - } else if (type instanceof IQualifierType) { - final IQualifierType qt = (IQualifierType) type; - if (((options & CVQ) != 0)) { - t= qt.getType(); - } else if (tdef) { - IType temp= qt.getType(); - if (temp instanceof ITypedef) { - temp= getNestedType(temp, TDEF); - return addQualifiers(temp, qt.isConst(), qt.isVolatile()); - } - } - } else if ((options & ARRAY) != 0 && type instanceof IArrayType) { - t= ((IArrayType) type).getType(); - } else if ((options & REF) != 0 && type instanceof ICPPReferenceType) { - t= ((ICPPReferenceType) type).getType(); + if (t == null) + return type; + + type= t; } - if (t == null) - return type; - - type= t; + } catch (DOMException e) { + return e.getProblem(); } } @@ -349,9 +353,13 @@ public static IType adjustParameterType(final IType pt, boolean forFunctionType) { // bug 239975 IType t= SemanticUtil.getNestedType(pt, TDEF); - if (t instanceof IArrayType) { - IArrayType at = (IArrayType) t; - return new CPPPointerType(at.getType()); + try { + if (t instanceof IArrayType) { + IArrayType at = (IArrayType) t; + return new CPPPointerType(at.getType()); + } + } catch (DOMException e) { + return e.getProblem(); } if (t instanceof IFunctionType) { return new CPPPointerType(pt); @@ -367,25 +375,28 @@ public static IType addQualifiers(IType baseType, boolean cnst, boolean vol) { if (cnst || vol) { - if (baseType instanceof IQualifierType) { - IQualifierType qt= (IQualifierType) baseType; - if ((cnst && !qt.isConst()) || (vol && !qt.isVolatile())) { - return new CPPQualifierType(qt.getType(), cnst || qt.isConst(), vol || qt.isVolatile()); + try { + if (baseType instanceof IQualifierType) { + IQualifierType qt= (IQualifierType) baseType; + if ((cnst && !qt.isConst()) || (vol && !qt.isVolatile())) { + return new CPPQualifierType(qt.getType(), cnst || qt.isConst(), vol || qt.isVolatile()); + } + return baseType; + } else if (baseType instanceof ICPPPointerToMemberType) { + ICPPPointerToMemberType pt= (ICPPPointerToMemberType) baseType; + if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) { + return new CPPPointerToMemberType(pt.getType(), pt.getMemberOfClass(), cnst + || pt.isConst(), vol || pt.isVolatile()); + } + return baseType; + } else if (baseType instanceof IPointerType) { + IPointerType pt= (IPointerType) baseType; + if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) { + return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile()); + } + return baseType; } - return baseType; - } else if (baseType instanceof ICPPPointerToMemberType) { - ICPPPointerToMemberType pt= (ICPPPointerToMemberType) baseType; - if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) { - return new CPPPointerToMemberType(pt.getType(), pt.getMemberOfClass(), cnst - || pt.isConst(), vol || pt.isVolatile()); - } - return baseType; - } else if (baseType instanceof IPointerType) { - IPointerType pt= (IPointerType) baseType; - if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())) { - return new CPPPointerType(pt.getType(), cnst || pt.isConst(), vol || pt.isVolatile()); - } - return baseType; + } catch (DOMException e) { } return new CPPQualifierType(baseType, cnst, vol); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/ArrayTypeClone.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/ArrayTypeClone.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/ArrayTypeClone.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bryan Wilkinson (QNX) - Initial API and implementation + * QNX - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; @@ -15,10 +15,11 @@ import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +/** + * @author Bryan Wilkinson + */ public class ArrayTypeClone implements IIndexType, IArrayType, ITypeContainer { private final IArrayType delegate; private IType type; @@ -34,33 +35,23 @@ if (!(type instanceof IArrayType)) return false; - IType type1= this.getType(); - if (type1 == null) - return false; + try { + IType type1= this.getType(); + if (type1 == null) + return false; - IArrayType rhs = (IArrayType) type; - if (type1.isSameType(rhs.getType())) { - IValue s1= getSize(); - IValue s2= rhs.getSize(); - if (s1 == s2) - return true; - if (s1 == null || s2 == null) - return false; - return CharArrayUtils.equals(s1.getSignature(), s2.getSignature()); + IArrayType rhs = (IArrayType) type; + return type1.isSameType(rhs.getType()); + } catch (DOMException e) { } return false; } - public IValue getSize() { - return delegate.getSize(); - } - - @Deprecated public IASTExpression getArraySizeExpression() throws DOMException { return delegate.getArraySizeExpression(); } - public IType getType() { + public IType getType() throws DOMException { if (type == null) { return delegate.getType(); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPReferenceTypeClone.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPReferenceTypeClone.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPReferenceTypeClone.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,20 +1,24 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bryan Wilkinson (QNX) - Initial API and implementation + * QNX - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +/** + * @author Bryan Wilkinson + */ public class CPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, IIndexType { private final ICPPReferenceType delegate; private IType type; @@ -23,7 +27,7 @@ this.delegate = reference; } - public IType getType() { + public IType getType() throws DOMException { if (type == null) { return delegate.getType(); } @@ -38,9 +42,12 @@ return false; ICPPReferenceType rhs = (ICPPReferenceType) type; - IType type1= getType(); - if (type1 != null) { - return type1.isSameType(rhs.getType()); + try { + IType type1= getType(); + if (type1 != null) { + return type1.isSameType(rhs.getType()); + } + } catch (DOMException e) { } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007, 2008 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bryan Wilkinson (QNX) - Initial API and implementation + * QNX - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; @@ -20,6 +20,9 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.core.runtime.CoreException; +/** + * @author Bryan Wilkinson + */ public class CPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, ICPPBinding { protected final ITypedef delegate; private IType type; @@ -28,7 +31,7 @@ this.delegate = typedef; } - public IType getType() { + public IType getType() throws DOMException { if (type == null) { return delegate.getType(); } @@ -61,14 +64,18 @@ } public boolean isSameType(IType type) { - IType myrtype = getType(); - if (myrtype == null) - return false; + try { + IType myrtype = getType(); + if (myrtype == null) + return false; - if (type instanceof ITypedef) { - type= ((ITypedef) type).getType(); + if (type instanceof ITypedef) { + type= ((ITypedef) type).getType(); + } + return myrtype.isSameType(type); + } catch (DOMException e) { } - return myrtype.isSameType(type); + return false; } public void setType(IType type) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexCPPBindingConstants.java Wed Aug 05 17:35:39 2009 -0500 @@ -61,5 +61,4 @@ int CPP_FRIEND_DECLARATION = IIndexBindingConstants.LAST_CONSTANT + 45; int CPP_TEMPLATE_TEMPLATE_PARAMETER= IIndexBindingConstants.LAST_CONSTANT + 46; int CPP_CLASS_TEMPLATE_PARTIAL_SPEC_SPEC = IIndexBindingConstants.LAST_CONSTANT + 47; - int CPP_UNKNOWN_BINDING = IIndexBindingConstants.LAST_CONSTANT + 48; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java Wed Aug 05 17:35:39 2009 -0500 @@ -79,11 +79,6 @@ public static final String PROPERTY_FRAGMENT_FORMAT_VERSION= "org.eclipse.cdt.internal.core.index.fragment.format.version"; //$NON-NLS-1$ /** - * Property key for storing whether indexer has to resume or not. - */ - public static final String PROPERTY_RESUME_INDEXER= "org.eclipse.cdt.internal.core.index.resume"; //$NON-NLS-1$ - - /** * Returns the file for the given location and linkage. * May return null, if no such file exists. * This method may only return files that are actually managed by this fragment. diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/PointerTypeClone.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/PointerTypeClone.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/PointerTypeClone.java Wed Aug 05 17:35:39 2009 -0500 @@ -6,17 +6,21 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bryan Wilkinson (QNX) - Initial API and implementation + * QNX - Initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.index; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +/** + * @author Bryan Wilkinson + */ public class PointerTypeClone implements IPointerType, ITypeContainer, IIndexType { protected final IPointerType delegate; private IType type; @@ -25,7 +29,7 @@ this.delegate = pointer; } - public IType getType() { + public IType getType() throws DOMException { if (type == null) { return delegate.getType(); } @@ -51,11 +55,14 @@ return false; IPointerType rhs = (IPointerType) type; - if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) { - IType type1= getType(); - if (type1 != null) { - return type1.isSameType(rhs.getType()); + try { + if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) { + IType type1= getType(); + if (type1 != null) { + return type1.isSameType(rhs.getType()); + } } + } catch (DOMException e) { } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/QualifierTypeClone.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/QualifierTypeClone.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/QualifierTypeClone.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,21 +1,24 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 QNX Software Systems and others. + * Copyright (c) 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bryan Wilkinson (QNX) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * QNX - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +/** + * @author Bryan Wilkinson + */ public class QualifierTypeClone implements IQualifierType, ITypeContainer, IIndexType { private final IQualifierType delegate; private IType type; @@ -24,7 +27,7 @@ this.delegate = qualifier; } - public IType getType() { + public IType getType() throws DOMException { if (type == null) { return delegate.getType(); } @@ -46,9 +49,12 @@ return false; IQualifierType pt = (IQualifierType) type; - if (isConst() == pt.isConst() && isVolatile() == pt.isVolatile()) { - IType myType= getType(); - return myType != null && myType.isSameType(pt.getType()); + try { + if (isConst() == pt.isConst() && isVolatile() == pt.isVolatile()) { + IType myType= getType(); + return myType != null && myType.isSameType(pt.getType()); + } + } catch (DOMException e) { } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeArrayType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeArrayType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeArrayType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,18 +1,18 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IArrayType; -import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.ArrayTypeClone; @@ -21,17 +21,12 @@ super((ITypeContainer) arrayType, cf); } + public IASTExpression getArraySizeExpression() throws DOMException { + fail(); return null; + } + @Override public Object clone() { return new ArrayTypeClone(this); } - - public IValue getSize() { - return ((IArrayType) type).getSize(); - } - - @Deprecated - public IASTExpression getArraySizeExpression() { - return null; - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeFunctionType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeFunctionType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeFunctionType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.index.IIndexType; @@ -20,7 +21,7 @@ super(rtype, cf); } - public IType[] getParameterTypes() { + public IType[] getParameterTypes() throws DOMException { IType[] result = ((IFunctionType) type).getParameterTypes(); for (int i = 0; i < result.length; i++) { result[i] = cf.getCompositeType((IIndexType)result[i]); @@ -28,7 +29,7 @@ return result; } - public IType getReturnType() { + public IType getReturnType() throws DOMException { return cf.getCompositeType((IIndexType) ((IFunctionType) type).getReturnType()); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositePointerType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositePointerType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositePointerType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,22 +1,23 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.PointerTypeClone; public class CompositePointerType extends CompositeTypeContainer implements IPointerType { - public CompositePointerType(IPointerType pointerType, ICompositesFactory cf) { + public CompositePointerType(IPointerType pointerType, ICompositesFactory cf) throws DOMException { super((ITypeContainer) pointerType, cf); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeQualifierType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeQualifierType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeQualifierType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2008 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,13 +10,14 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.QualifierTypeClone; public class CompositeQualifierType extends CompositeTypeContainer implements IQualifierType { - public CompositeQualifierType(IQualifierType qualifierType, ICompositesFactory cf) { + public CompositeQualifierType(IQualifierType qualifierType, ICompositesFactory cf) throws DOMException { super((ITypeContainer) qualifierType, cf); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeTypeContainer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeTypeContainer.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeTypeContainer.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,9 +8,11 @@ * Contributors: * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ + package org.eclipse.cdt.internal.core.index.composite; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.IIndexType; @@ -21,12 +23,16 @@ super(rtype, cf); } - public final IType getType() { + public final IType getType() throws DOMException { return cf.getCompositeType((IIndexType) ((ITypeContainer) type).getType()); } @Override public String toString() { - return ASTTypeUtil.getType(getType()); + try { + return ASTTypeUtil.getType(getType()); + } catch (DOMException e) { + return ""; //$NON-NLS-1$ + } } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/ICompositesFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/ICompositesFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/ICompositesFactory.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2008 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.index.IIndexBinding; @@ -25,7 +26,7 @@ * Returns a composite (in the sense of potentially spanning multiple index fragments - i.e. not to be confused * with ICompositeType) type for the specified type. */ - public IType getCompositeType(IIndexType rtype); + public IType getCompositeType(IIndexType rtype) throws DOMException; /** * Returns a composite (index context carrying) binding for the specified binding. It does not diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CCompositesFactory.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2008 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -68,7 +68,7 @@ /* * @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType) */ - public IType getCompositeType(IIndexType rtype) { + public IType getCompositeType(IIndexType rtype) throws DOMException { IType result; if(rtype==null) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCTypedef.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCTypedef.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCTypedef.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,15 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.c; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; @@ -22,7 +23,7 @@ super(cf, rbinding); } - public IType getType() { + public IType getType() throws DOMException { IType type = ((ITypedef)rbinding).getType(); return cf.getCompositeType((IIndexType)type); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.index.composite.cpp; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IBasicType; @@ -116,7 +117,7 @@ /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType) */ - public IType getCompositeType(IIndexType rtype) { + public IType getCompositeType(IIndexType rtype) throws DOMException { IType result; if (rtype instanceof ICPPSpecialization) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPPointerToMemberType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPPointerToMemberType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPPointerToMemberType.java Wed Aug 05 17:35:39 2009 -0500 @@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.internal.core.index.CPPPointerToMemberTypeClone; @@ -20,7 +21,7 @@ class CompositeCPPPointerToMemberType extends CompositePointerType implements ICPPPointerToMemberType { - CompositeCPPPointerToMemberType(ICompositesFactory cf, ICPPPointerToMemberType pointerToMemberType) { + CompositeCPPPointerToMemberType(ICompositesFactory cf, ICPPPointerToMemberType pointerToMemberType) throws DOMException { super(pointerToMemberType, cf); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPReferenceType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPReferenceType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPReferenceType.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,15 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.CPPReferenceTypeClone; @@ -17,7 +18,7 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; class CompositeCPPReferenceType extends CompositeTypeContainer implements ICPPReferenceType { - public CompositeCPPReferenceType(ICPPReferenceType referenceType, ICompositesFactory cf) { + public CompositeCPPReferenceType(ICPPReferenceType referenceType, ICompositesFactory cf) throws DOMException { super((ITypeContainer) referenceType, cf); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPTypedef.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,15 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2008 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; @@ -23,7 +24,7 @@ super(cf, delegate); } - public IType getType() { + public IType getType() throws DOMException { IType type = ((ITypedef)rbinding).getType(); return cf.getCompositeType((IIndexType)type); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Symbian Software Systems and others. + * Copyright (c) 2007, 2008 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,9 +41,9 @@ CPPTemplateParameterMap result= new CPPTemplateParameterMap(keys.length); try { - for (Integer key : keys) { - ICPPTemplateArgument arg= preresult.getArgument(key); - result.put(key, convert(cf, arg)); + for(int i = 0; i < keys.length; i++) { + ICPPTemplateArgument arg= preresult.getArgument(keys[i]); + result.put(keys[i], convert(cf, arg)); } } catch(DOMException de) { CCorePlugin.log(de); @@ -148,8 +148,12 @@ @Deprecated private static IType[] getArguments(ICompositesFactory cf, IType[] result) { - for(int i=0; i { - T checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath); + T checkFile(String path, String fileName, boolean isHeuristicMatch); } - final private IIncludeFileTester createCodeReaderTester= new IIncludeFileTester() { - public IncludeFileContent checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath) { - final IncludeFileContent fc= fCodeReaderFactory.getContentForInclusion(path); + final private IIncludeFileTester createCodeReaderTester= new IIncludeFileTester() { + public IncludeFileContent checkFile(String path, String fileName, boolean isHeuristicMatch) { + final String finalPath = ScannerUtility.createReconciledPath(path, fileName); + final IncludeFileContent fc= fCodeReaderFactory.getContentForInclusion(finalPath); if (fc != null) { fc.setFoundByHeuristics(isHeuristicMatch); - fc.setFoundOnPath(onPath); } return fc; } @@ -111,11 +112,12 @@ private static class IncludeResolution {String fLocation; boolean fHeuristic;} final private IIncludeFileTester createPathTester= new IIncludeFileTester() { - public IncludeResolution checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath) { - if (fCodeReaderFactory.getInclusionExists(path)) { + public IncludeResolution checkFile(String path, String fileName, boolean isHeuristicMatch) { + String finalPath= ScannerUtility.createReconciledPath(path, fileName); + if (fCodeReaderFactory.getInclusionExists(finalPath)) { IncludeResolution res= new IncludeResolution(); res.fHeuristic= isHeuristicMatch; - res.fLocation= path; + res.fLocation= finalPath; return res; } return null; @@ -166,7 +168,8 @@ final private char[] fAdditionalNumericLiteralSuffixes; final private CharArrayIntMap fKeywords; final private CharArrayIntMap fPPKeywords; - private IncludeSearchPathElement[] fIncludeSearchPath; + final private String[] fIncludePaths; + final private String[] fQuoteIncludePaths; private String[][] fPreIncludedFiles= null; private int fContentAssistLimit= -1; @@ -204,6 +207,9 @@ fPPKeywords= new CharArrayIntMap(40, -1); configureKeywords(language, configuration); + fIncludePaths= info.getIncludePaths(); + fQuoteIncludePaths= getQuoteIncludePath(info); + fExpressionEvaluator= new ExpressionEvaluator(); fMacroDefinitionParser= new MacroDefinitionParser(); fMacroExpander= new MacroExpander(this, fMacroDictionary, fLocationMap, fLexOptions); @@ -212,10 +218,9 @@ fIncludeFileResolutionHeuristics= (IIncludeFileResolutionHeuristics) ((IAdaptable) readerFactory).getAdapter(IIncludeFileResolutionHeuristics.class); } - final String filePath= new String(reader.filename); - configureIncludeSearchPath(new File(filePath).getParentFile(), info); setupMacroDictionary(configuration, info, language); + final String filePath= new String(reader.filename); fAllIncludedFiles.add(filePath); ILocationCtx ctx= fLocationMap.pushTranslationUnit(filePath, reader.buffer); fCodeReaderFactory.reportTranslationUnitFile(filePath); @@ -313,35 +318,21 @@ return array == null ? EMPTY_CHAR_ARRAY : array; } - private void configureIncludeSearchPath(File directory, IScannerInfo info) { - String[] searchPath= info.getIncludePaths(); - int idx= 0; + private String[] getQuoteIncludePath(IScannerInfo info) { if (info instanceof IExtendedScannerInfo) { final IExtendedScannerInfo einfo= (IExtendedScannerInfo) info; - final String[] quoteIncludeSearchPath= einfo.getLocalIncludePath(); - if (quoteIncludeSearchPath != null && quoteIncludeSearchPath.length > 0) { - fIncludeSearchPath= new IncludeSearchPathElement[quoteIncludeSearchPath.length + searchPath.length]; - for (String qip : quoteIncludeSearchPath) { - fIncludeSearchPath[idx++]= new IncludeSearchPathElement(makeAbsolute(directory, qip), true); - } - } + final String[] qip= einfo.getLocalIncludePath(); + if (qip != null && qip.length > 0) { + final String[] result= new String[qip.length + fIncludePaths.length]; + System.arraycopy(qip, 0, result, 0, qip.length); + System.arraycopy(fIncludePaths, 0, result, qip.length, fIncludePaths.length); + return result; + } } - if (fIncludeSearchPath == null) { - fIncludeSearchPath= new IncludeSearchPathElement[searchPath.length]; - } - for (String path : searchPath) { - fIncludeSearchPath[idx++]= new IncludeSearchPathElement(makeAbsolute(directory, path), false); - } + return info.getIncludePaths(); } - private String makeAbsolute(File directory, String inlcudePath) { - if (directory == null || new File(inlcudePath).isAbsolute()) { - return inlcudePath; - } - return ScannerUtility.createReconciledPath(directory.getAbsolutePath(), inlcudePath); - } - - private void setupMacroDictionary(IScannerExtensionConfiguration config, IScannerInfo info, ParserLanguage lang) { + private void setupMacroDictionary(IScannerExtensionConfiguration config, IScannerInfo info, ParserLanguage lang) { // built in macros fMacroDictionary.put(__CDT_PARSER__.getNameCharArray(), __CDT_PARSER__); fMacroDictionary.put(__STDC__.getNameCharArray(), __STDC__); @@ -881,20 +872,20 @@ } } - private T findInclusion(final String includeDirective, final boolean quoteInclude, + private T findInclusion(final String filename, final boolean quoteInclude, final boolean includeNext, final String currentFile, final IIncludeFileTester tester) { T reader = null; // filename is an absolute path or it is a Linux absolute path on a windows machine - if (new File(includeDirective).isAbsolute() || includeDirective.startsWith("/")) { //$NON-NLS-1$ - return tester.checkFile(includeDirective, false, null); + if (new File(filename).isAbsolute() || filename.startsWith("/")) { //$NON-NLS-1$ + return tester.checkFile(EMPTY_STRING, filename, false); } if (currentFile != null && quoteInclude && !includeNext) { // Check to see if we find a match in the current directory final File currentDir= new File(currentFile).getParentFile(); if (currentDir != null) { - final String fileLocation = ScannerUtility.createReconciledPath(currentDir.getAbsolutePath(), includeDirective); - reader = tester.checkFile(fileLocation, false, null); + String absolutePath = currentDir.getAbsolutePath(); + reader = tester.checkFile(absolutePath, filename, false); if (reader != null) { return reader; } @@ -903,31 +894,43 @@ // if we're not include_next, then we are looking for the first occurrence of // the file, otherwise, we ignore all the paths before the current directory - IncludeSearchPathElement searchAfter= includeNext ? fCurrentContext.getFoundOnPath() : null; - for (IncludeSearchPathElement path : fIncludeSearchPath) { - if (searchAfter != null) { - if (searchAfter.equals(path)) { - searchAfter= null; + final String[] isp= quoteInclude ? fQuoteIncludePaths : fIncludePaths; + if (isp != null) { + int i=0; + if (includeNext && currentFile != null) { + final File currentDir= new File(currentFile).getParentFile(); + if (currentDir != null) { + i= findIncludePos(isp, currentDir) + 1; } - } else if (quoteInclude || !path.isForQuoteIncludesOnly()) { - String fileLocation = path.getLocation(includeDirective); - if (fileLocation != null) { - reader= tester.checkFile(fileLocation, false, path); - if (reader != null) { - return reader; - } + } + for (; i < isp.length; ++i) { + reader= tester.checkFile(isp[i], filename, false); + if (reader != null) { + return reader; } } } if (fIncludeFileResolutionHeuristics != null) { - String location= fIncludeFileResolutionHeuristics.findInclusion(includeDirective, currentFile); + String location= fIncludeFileResolutionHeuristics.findInclusion(filename, currentFile); if (location != null) { - return tester.checkFile(location, true, null); + return tester.checkFile(null, location, true); } } return null; } + private int findIncludePos(String[] paths, File currentDirectory) { + for (; currentDirectory != null; currentDirectory = currentDirectory.getParentFile()) { + for (int i = 0; i < paths.length; ++i) { + File pathDir = new File(paths[i]); + if (currentDirectory.equals(pathDir)) + return i; + } + } + + return -1; + } + @Override public String toString() { StringBuffer buffer = new StringBuffer("Scanner @ file:"); //$NON-NLS-1$ @@ -1188,7 +1191,6 @@ fAllIncludedFiles.add(path); ILocationCtx ctx= fLocationMap.pushInclusion(poundOffset, nameOffsets[0], nameOffsets[1], condEndOffset, reader.buffer, path, headerName, userInclude, isHeuristic, fi.isSource()); ScannerContext fctx= new ScannerContext(ctx, fCurrentContext, new Lexer(reader.buffer, fLexOptions, this, this)); - fctx.setFoundOnPath(fi.getFoundOnPath()); fCurrentContext= fctx; } break; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeFileContent.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeFileContent.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeFileContent.java Wed Aug 05 17:35:39 2009 -0500 @@ -46,7 +46,6 @@ private boolean fHeuristic; private boolean fIsSource= false; private List fFiles; - private IncludeSearchPathElement fFoundOnPath; /** * For skipping include files. @@ -166,12 +165,4 @@ public void setIsSource(boolean isSource) { fIsSource= isSource; } - - public IncludeSearchPathElement getFoundOnPath() { - return fFoundOnPath; - } - - public void setFoundOnPath(IncludeSearchPathElement isp) { - fFoundOnPath= isp; - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeSearchPathElement.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.parser.scanner; - -import java.io.File; - -/** - * Represents an entry of the include search path - */ -final class IncludeSearchPathElement { - private static final boolean NON_SLASH_SEPARATOR = File.separatorChar != '/'; - public static final String FRAMEWORK_VAR = "__framework__"; //$NON-NLS-1$ - public static final String FILE_VAR = "__header__"; //$NON-NLS-1$ - - - private final String fPath; - private final boolean fForQuoteIncludesOnly; - private final boolean fIsFrameworkDirectory; - - IncludeSearchPathElement(String path, boolean forQuoteIncludesOnly) { - fPath= path; - fForQuoteIncludesOnly= forQuoteIncludesOnly; - - if (path.indexOf('_') != -1 && path.indexOf(FRAMEWORK_VAR) != -1 && path.indexOf(FILE_VAR) != -1) { - fIsFrameworkDirectory= true; - } else { - fIsFrameworkDirectory= false; - } - } - - public boolean isForQuoteIncludesOnly() { - return fForQuoteIncludesOnly; - } - - public String getLocation(String includeDirective) { - if (fIsFrameworkDirectory) { - int firstSep = firstSeparator(includeDirective); - if (firstSep < 1) { - return null; - } - String framework = includeDirective.substring(0, firstSep); - String file= includeDirective.substring(firstSep+1); - if (file.length() == 0) - return null; - - StringBuilder buf= new StringBuilder(fPath); - replace(buf, FRAMEWORK_VAR, framework); - replace(buf, FILE_VAR, file); - return ScannerUtility.reconcilePath(buf.toString()); - } - return ScannerUtility.createReconciledPath(fPath, includeDirective); - } - - private int firstSeparator(String path) { - int firstSep= path.indexOf('/'); - if (NON_SLASH_SEPARATOR) { - firstSep= Math.max(firstSep, path.indexOf(File.separatorChar)); - } - return firstSep; - } - - private void replace(StringBuilder buf, String find, final String replace) { - int idx= buf.indexOf(find); - if (idx >= 0) { - buf.replace(idx, idx+find.length(), replace); - } - } -} \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java Wed Aug 05 17:35:39 2009 -0500 @@ -44,7 +44,6 @@ private Token fTokens; private ArrayList fConditionals= null; private CodeState fCurrentState= CodeState.eActive; - private IncludeSearchPathElement fFoundOnPath; /** * @param ctx @@ -57,7 +56,9 @@ } public ScannerContext(ILocationCtx ctx, ScannerContext parent, TokenList tokens) { - this (ctx, parent, (Lexer) null); + fLocationCtx= ctx; + fParent= parent; + fLexer= null; fTokens= tokens.first(); fInactiveState= CodeState.eSkipInactive; // no branches in result of macro expansion } @@ -269,18 +270,4 @@ return 0; return fConditionals.size(); } - - /** - * Returns the element of the include search path that was used to find this context, or null if not applicable. - */ - public IncludeSearchPathElement getFoundOnPath() { - return fFoundOnPath; - } - - /** - * Returns the element of the include search path that was used to find this context, or null if not applicable. - */ - public void setFoundOnPath(IncludeSearchPathElement foundOnPath) { - fFoundOnPath= foundOnPath; - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java Wed Aug 05 17:35:39 2009 -0500 @@ -43,7 +43,6 @@ import org.eclipse.cdt.core.parser.ScannerInfo; import org.eclipse.cdt.internal.core.dom.AbstractCodeReaderFactory; import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics; -import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory; @@ -307,8 +306,6 @@ final ArrayList ifilesToRemove= new ArrayList(); extractFiles(files, ifilesToRemove, monitor); - setResume(true); - // remove files from index removeFilesInIndex(fFilesToRemove, ifilesToRemove, monitor); @@ -316,9 +313,6 @@ for (int linkageID : getLinkagesToParse()) { parseLinkage(linkageID, files, monitor); } - if (!monitor.isCanceled()) { - setResume(false); - } } finally { fIndex.flush(); } @@ -329,15 +323,6 @@ } } - private void setResume(boolean value) throws InterruptedException, CoreException { - fIndex.acquireWriteLock(1); - try { - fIndex.getWritableFragment().setProperty(IIndexFragment.PROPERTY_RESUME_INDEXER, String.valueOf(value)); - } finally { - fIndex.releaseWriteLock(1); - } - } - private void extractFiles(Map> files, List iFilesToRemove, IProgressMonitor monitor) throws CoreException { final boolean forceAll= (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexUpdatePolicy.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexUpdatePolicy.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexUpdatePolicy.java Wed Aug 05 17:35:39 2009 -0500 @@ -72,37 +72,35 @@ return fIndexer; } - public boolean isAutomatic() { - return fKind != MANUAL; - } - public IPDOMIndexerTask handleDelta(ITranslationUnit[] force, ITranslationUnit[] changed, ITranslationUnit[] removed) { if (isNullIndexer()) { return null; } switch(fKind) { - case MANUAL: + case IndexUpdatePolicy.MANUAL: return null; - case POST_CHANGE: + case IndexUpdatePolicy.POST_CHANGE: if (fIndexer != null) { return fIndexer.createTask(force, changed, removed); } break; } - for (ITranslationUnit tu : removed) { + for (int i = 0; i < removed.length; i++) { + ITranslationUnit tu = removed[i]; fForce.remove(tu); fTimestamp.remove(tu); fRemoved.add(tu); } - for (ITranslationUnit tu : force) { + for (int i = 0; i < force.length; i++) { + ITranslationUnit tu = force[i]; fForce.add(tu); fTimestamp.remove(tu); fRemoved.remove(tu); } - for (ITranslationUnit element : changed) { - ITranslationUnit tu = element; + for (int i = 0; i < changed.length; i++) { + ITranslationUnit tu = changed[i]; if (!fForce.contains(tu)) { fTimestamp.add(tu); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java Wed Aug 05 17:35:39 2009 -0500 @@ -179,14 +179,17 @@ * 82.0 - offsets for using directives, bug 270806 * #83.0# - unconditionally store name in PDOMInclude, bug 272815 - <> * 84.0 - storing free record pointers as (ptr>>3) and allocated pointers as (ptr-2)>>3 RECPTR_DENSE_VERSION - * - * CDT 7.0 development (versions not supported on the 6.0.x branch) - * 90.0 - support for array sizes, bug 269926 - * 91.0 - storing unknown bindings other than unknown class types, bug 284686. */ - private static final int MIN_SUPPORTED_VERSION= version(91, 0); - private static final int MAX_SUPPORTED_VERSION= version(91, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(91, 0); + private static final int MIN_SUPPORTED_VERSION= version(83, 0); + private static final int MAX_SUPPORTED_VERSION= version(84, Short.MAX_VALUE); + private static int DEFAULT_VERSION = version(83, 0); + public static final int DENSE_RECPTR_VERSION = version(84, 0); + + static { + if (System.getProperty("org.eclipse.cdt.core.parser.pdom.useDensePointers", "false").equals("true")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + DEFAULT_VERSION= DENSE_RECPTR_VERSION; + } + } private static int version(int major, int minor) { return (major << 16) + minor; @@ -229,6 +232,15 @@ private boolean fReloaded= false; private boolean fNewFiles= false; + public void clear() { + fReloaded= false; + fCleared= false; + fNewFiles= false; + + fClearedFiles.clear(); + fFilesWritten.clear(); + } + private void setCleared() { fCleared= true; fReloaded= false; @@ -258,10 +270,6 @@ public boolean hasNewFiles() { return fNewFiles; } - - public boolean isTrivial() { - return !fCleared && !fReloaded && !fNewFiles && fClearedFiles.isEmpty() && fFilesWritten.isEmpty(); - } } public static interface IListener { public void handleChange(PDOM pdom, ChangeEvent event); @@ -374,9 +382,8 @@ } private void fireChange(ChangeEvent event) { - if (listeners == null || event.isTrivial()) + if (listeners == null) return; - Iterator i = listeners.iterator(); while (i.hasNext()) i.next().handleChange(this, event); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMFileSet.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMFileSet.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMFileSet.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java Wed Aug 05 17:35:39 2009 -0500 @@ -236,8 +236,8 @@ try { ICProject[] projects= model.getCModel().getCProjects(); - for (ICProject project : projects) { - addProject(project); + for (int i = 0; i < projects.length; i++) { + addProject(projects[i]); } } catch (CModelException e) { CCorePlugin.log(e); @@ -517,7 +517,7 @@ return null; } - private void createIndexer(ICProject project, IProgressMonitor pm) throws InterruptedException { + private void createIndexer(ICProject project, IProgressMonitor pm) { assert !Thread.holdsLock(fProjectToPDOM); IProject prj= project.getProject(); try { @@ -540,24 +540,13 @@ } if (!rebuild) { registerIndexer(project, indexer); - IPDOMIndexerTask task= policy.createTask(); + IPDOMIndexerTask task= createPolicy(project).createTask(); if (task != null) { enqueue(task); - } else { + } + else { enqueue(new TriggerNotificationTask(this, pdom)); } - if (policy.isAutomatic()) { - boolean resume= false; - pdom.acquireReadLock(); - try { - resume= "true".equals(pdom.getProperty(IIndexFragment.PROPERTY_RESUME_INDEXER)); //$NON-NLS-1$ - } finally { - pdom.releaseReadLock(); - } - if (resume) { - enqueue(new PDOMUpdateTask(indexer, IIndexManager.UPDATE_CHECK_TIMESTAMPS)); - } - } return; } } @@ -623,7 +612,8 @@ } synchronized (fTaskQueue) { int i=0; - for (IPDOMIndexerTask task : fTaskQueue) { + for (Iterator it = fTaskQueue.iterator(); it.hasNext();) { + final IPDOMIndexerTask task= it.next(); final IPDOMIndexer ti = task.getIndexer(); if (ti != null && referencing.contains(ti.getProject().getProject())) { fTaskQueue.add(i, subjob); @@ -705,12 +695,7 @@ if (project.isOpen() && !postponeSetup(cproject)) { syncronizeProjectSettings(project, new SubProgressMonitor(monitor, 1)); if (getIndexer(cproject) == null) { - try { - createIndexer(cproject, new SubProgressMonitor(monitor, 99)); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return Status.CANCEL_STATUS; - } + createIndexer(cproject, new SubProgressMonitor(monitor, 99)); } } return Status.OK_STATUS; @@ -906,7 +891,8 @@ ICProject[] cProjects; try { cProjects = CoreModel.getDefault().getCModel().getCProjects(); - for (ICProject project : cProjects) { + for (int i = 0; i < cProjects.length; i++) { + ICProject project = cProjects[i]; reindex(project); } } catch (CModelException e) { @@ -978,8 +964,8 @@ fIndexerStateEvent.setState(state); Object[] listeners= fStateListeners.getListeners(); monitor.beginTask(Messages.PDOMManager_notifyTask_message, listeners.length); - for (Object listener2 : listeners) { - final IIndexerStateListener listener = (IIndexerStateListener) listener2; + for (int i = 0; i < listeners.length; i++) { + final IIndexerStateListener listener = (IIndexerStateListener) listeners[i]; SafeRunner.run(new ISafeRunnable(){ public void handleException(Throwable exception) { CCorePlugin.log(exception); @@ -1017,8 +1003,8 @@ fIndexChangeEvent.setAffectedProject(finalProject, e); Object[] listeners= fChangeListeners.getListeners(); monitor.beginTask(Messages.PDOMManager_notifyTask_message, listeners.length); - for (Object listener2 : listeners) { - final IIndexChangeListener listener = (IIndexChangeListener) listener2; + for (int i = 0; i < listeners.length; i++) { + final IIndexChangeListener listener = (IIndexChangeListener) listeners[i]; SafeRunner.run(new ISafeRunnable(){ public void handleException(Throwable exception) { CCorePlugin.log(exception); @@ -1340,7 +1326,8 @@ void handlePostBuildEvent() { assert !Thread.holdsLock(fProjectToPDOM); synchronized (fUpdatePolicies) { - for (IndexUpdatePolicy policy : fUpdatePolicies.values()) { + for (Iterator i = fUpdatePolicies.values().iterator(); i.hasNext();) { + IndexUpdatePolicy policy= i.next(); IPDOMIndexerTask task= policy.createTask(); if (task != null) { enqueue(task); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java Wed Aug 05 17:35:39 2009 -0500 @@ -139,8 +139,8 @@ * @since 4.0 */ public void addSymbols(IASTTranslationUnit ast, IIndexFileLocation[] ifls, IWritableIndex index, - int readlockCount, boolean flushIndex, int configHash, ITodoTaskUpdater taskUpdater, - IProgressMonitor pm) throws InterruptedException, CoreException { + int readlockCount, boolean flushIndex, int configHash, ITodoTaskUpdater taskUpdater, IProgressMonitor pm) + throws InterruptedException, CoreException { if (fShowProblems) { fShowInclusionProblems= true; fShowScannerProblems= true; @@ -159,8 +159,7 @@ resolveNames(symbolMap, ifls, stati, pm); // index update - storeSymbolsInIndex(symbolMap, ifls, ast.getLinkage().getLinkageID(), configHash, contextIncludes, - index, readlockCount, flushIndex, stati, pm); + storeSymbolsInIndex(symbolMap, ifls, ast.getLinkage().getLinkageID(), configHash, contextIncludes, index, readlockCount, flushIndex, stati, pm); if (taskUpdater != null) { taskUpdater.updateTasks(ast.getComments(), ifls); @@ -187,14 +186,13 @@ } } - private void storeSymbolsInIndex(final Map symbolMap, IIndexFileLocation[] ifls, - int linkageID, int configHash, HashSet contextIncludes, - IWritableIndex index, int readlockCount, boolean flushIndex, + private void storeSymbolsInIndex(final Map symbolMap, IIndexFileLocation[] ifls, int linkageID, int configHash, + HashSet contextIncludes, IWritableIndex index, int readlockCount, boolean flushIndex, ArrayList stati, IProgressMonitor pm) throws InterruptedException, CoreException { index.acquireWriteLock(readlockCount); long start= System.currentTimeMillis(); try { - for (int i= 0; i < ifls.length; i++) { + for (int i=0; i symbolMap, IIndexFileLocation[] ifls, - ArrayList stati, IProgressMonitor pm) { + private void resolveNames(final Map symbolMap, IIndexFileLocation[] ifls, ArrayList stati, IProgressMonitor pm) { long start= System.currentTimeMillis(); for (IIndexFileLocation path : ifls) { if (pm.isCanceled()) { @@ -257,8 +253,7 @@ } else if (name.isReference()) { if (binding instanceof ICPPTemplateParameter || binding instanceof ICPPUnknownBinding || - ((fSkipReferences & SKIP_TYPE_REFERENCES) != 0 && - isTypeReferenceBinding(binding))) { + ((fSkipReferences & SKIP_TYPE_REFERENCES) != 0 && isTypeReferenceBinding(binding))) { if (!isRequiredReference(name)) { na[0]= null; } else { @@ -279,8 +274,8 @@ } if (th != null) { if (!reported) { - stati.add(CCorePlugin.createStatus(NLS.bind(Messages.PDOMWriter_errorResolvingName, - name.toString(), path.getURI().getPath()), th)); + stati.add(CCorePlugin.createStatus( + NLS.bind(Messages.PDOMWriter_errorResolvingName, name.toString(), path.getURI().getPath()), th)); } reported= true; j.remove(); @@ -291,8 +286,8 @@ fStatistics.fResolutionTime += System.currentTimeMillis()-start; } - private void extractSymbols(IASTTranslationUnit ast, final Map symbolMap, - Collection contextIncludes) throws CoreException { + private void extractSymbols(IASTTranslationUnit ast, final Map symbolMap, Collection contextIncludes) throws CoreException { + final HashSet contextIFLs= new HashSet(); final IIndexFileLocation astIFL = fResolver.resolveASTPath(ast.getFilePath()); @@ -312,7 +307,8 @@ if (include.isActive()) { if (!include.isResolved()) { unresolvedIncludes++; - } else if (updateSource) { + } + else if (updateSource) { // the include was parsed, check if we want to update the included file in the index final IIndexFileLocation targetIFL= fResolver.resolveASTPath(include.getPath()); if (symbolMap.containsKey(targetIFL) && contextIFLs.add(targetIFL)) { @@ -425,15 +421,13 @@ lists.fNames.add(thing); } - private void addToMap(Map map, IIndexFileLocation location, - IASTPreprocessorIncludeStatement thing) { + private void addToMap(Map map, IIndexFileLocation location, IASTPreprocessorIncludeStatement thing) { Symbols lists= map.get(location); if (lists != null) lists.fIncludes.add(thing); } - private void addToMap(Map map, IIndexFileLocation location, - IASTPreprocessorStatement thing) { + private void addToMap(Map map, IIndexFileLocation location, IASTPreprocessorStatement thing) { Symbols lists= map.get(location); if (lists != null) lists.fMacros.add(thing); @@ -446,9 +440,8 @@ return false; } - private IIndexFragmentFile storeFileInIndex(IWritableIndex index, IIndexFileLocation location, - Map symbolMap, int linkageID, int configHash, - Set contextIncludes) throws CoreException { + private IIndexFragmentFile storeFileInIndex(IWritableIndex index, IIndexFileLocation location, Map symbolMap, + int linkageID, int configHash, Set contextIncludes) throws CoreException { Set clearedContexts= Collections.emptySet(); IIndexFragmentFile file= index.getWritableFile(linkageID, location); if (file != null) { @@ -471,7 +464,7 @@ } IncludeInformation[] includeInfos= new IncludeInformation[lists.fIncludes.size()]; - for (int i= 0; i < lists.fIncludes.size(); i++) { + for (int i=0; i= MAX_DB_SIZE) { - Object bindings[] = { this.getLocation().getAbsolutePath(), MAX_DB_SIZE }; + long max_size; + if (usesDensePointers()) { + max_size = ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS)); + } else { + max_size = ((long) 1 << (Integer.SIZE - 1)); + } + if (address >= max_size) { + Object bindings[] = { this.getLocation().getAbsolutePath(), max_size }; throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, CCorePlugin.STATUS_PDOM_TOO_LARGE, NLS.bind(CCorePlugin .getResourceString("pdom.DatabaseTooLarge"), bindings), null)); //$NON-NLS-1$ @@ -373,6 +377,13 @@ } /** + * Returns whether this database uses dense pointers. + */ + boolean usesDensePointers() { + return getVersion() >= PDOM.DENSE_RECPTR_VERSION; + } + + /** * for testing purposes, only. */ private long createNewChunks(int numChunks) throws CoreException { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeComparator.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeComparator.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeComparator.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 QNX Software Systems and others. + * Copyright (c) 2005 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeVisitor.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeVisitor.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IBTreeVisitor.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 QNX Software Systems and others. + * Copyright (c) 2005, 2006 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IString.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IString.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IString.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 QNX Software Systems and others. + * Copyright (c) 2006, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ListItem.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ListItem.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ListItem.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 QNX Software Systems and others. + * Copyright (c) 2006, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 QNX Software Systems and others. + * Copyright (c) 2006, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 QNX Software Systems and others. + * Copyright (c) 2006, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMArrayType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMArrayType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMArrayType.java Wed Aug 05 17:35:39 2009 -0500 @@ -17,42 +17,32 @@ import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; -import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; -import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.index.ArrayTypeClone; import org.eclipse.cdt.internal.core.index.IIndexBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexType; -import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.core.runtime.CoreException; public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, ITypeContainer { private static final int TYPE = PDOMNode.RECORD_SIZE; - private static final int ARRAYSIZE= TYPE + Database.PTR_SIZE; @SuppressWarnings("hiding") - private static final int RECORD_SIZE= ARRAYSIZE + Database.PTR_SIZE; + private static final int RECORD_SIZE= TYPE+4; - private IType fCachedType= null; - private IValue fCachedValue= Value.NOT_INITIALIZED; - public PDOMArrayType(PDOMLinkage linkage, long record) { super(linkage, record); } public PDOMArrayType(PDOMLinkage linkage, PDOMNode parent, IArrayType type) throws CoreException { super(linkage, parent); - PDOMNode targetTypeNode = getLinkage().addType(this, type.getType()); - if (targetTypeNode != null) { - long typeRec = targetTypeNode.getRecord(); - final Database db = getDB(); - db.putRecPtr(record + TYPE, typeRec); - IValue val= type.getSize(); - if (val != null) { - long ptr= PDOMValue.store(db, linkage, val); - db.putRecPtr(record + ARRAYSIZE, ptr); + try { + PDOMNode targetTypeNode = getLinkage().addType(this, type.getType()); + if (targetTypeNode != null) { + long typeRec = targetTypeNode.getRecord(); + getDB().putRecPtr(record + TYPE, typeRec); } + } catch (DOMException e) { + CCorePlugin.log(e); } } @@ -66,33 +56,18 @@ return IIndexBindingConstants.ARRAY_TYPE; } - public IType getType() { - if (fCachedType == null) { - try { - PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + TYPE)); - if (node instanceof IType) { - return fCachedType= (IType) node; - } - } catch (CoreException e) { - CCorePlugin.log(e); - } - } - return fCachedType; + public IASTExpression getArraySizeExpression() throws DOMException { + return null; } - - public IValue getSize() { - if (fCachedValue == Value.NOT_INITIALIZED) { - try { - final Database db = getDB(); - long ptr= db.getRecPtr(record + ARRAYSIZE); - return fCachedValue= PDOMValue.restore(db, getLinkage(), ptr); - } catch (CoreException e) { - CCorePlugin.log(e); - } - return fCachedValue= null; + public IType getType() { + try { + PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + TYPE)); + return node instanceof IType ? (IType)node : null; + } catch (CoreException e) { + CCorePlugin.log(e); + return null; } - return fCachedValue; } public boolean isSameType(IType type) { @@ -102,19 +77,14 @@ if( !( type instanceof IArrayType )) return false; - IType type1= this.getType(); - if( type1 == null ) - return false; - - IArrayType rhs = (IArrayType) type; - if (type1.isSameType(rhs.getType())) { - IValue s1 = getSize(); - IValue s2 = rhs.getSize(); - if (s1 == s2) - return true; - if (s1 == null || s2 == null) - return false; - return CharArrayUtils.equals(s1.getSignature(), s2.getSignature()); + try { + IType type1= this.getType(); + if( type1 == null ) + return false; + + IArrayType rhs = (IArrayType) type; + return type1.isSameType( rhs.getType() ); + } catch (DOMException e) { } return false; } @@ -133,9 +103,4 @@ linkage.deleteType(getType(), record); super.delete(linkage); } - - @Deprecated - public IASTExpression getArraySizeExpression() throws DOMException { - return null; - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java Wed Aug 05 17:35:39 2009 -0500 @@ -175,14 +175,8 @@ return null; } - public final PDOMNode getNode(long record) throws CoreException { - if (record == 0) { - return null; - } - final int nodeType= PDOMNode.getNodeType(fDatabase, record); - switch (nodeType) { - case LINKAGE: - return null; + public PDOMNode getNode(long record) throws CoreException { + switch (PDOMNode.getNodeType(fDatabase, record)) { case POINTER_TYPE: return new PDOMPointerType(this, record); case ARRAY_TYPE: @@ -190,11 +184,9 @@ case QUALIFIER_TYPE: return new PDOMQualifierType(this, record); } - return getNode(record, nodeType); + return null; } - abstract public PDOMNode getNode(long record, int nodeType) throws CoreException; - public PDOMNode addType(PDOMNode parent, IType type) throws CoreException { if (type instanceof IPointerType) return new PDOMPointerType(this, parent, (IPointerType)type); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java Wed Aug 05 17:35:39 2009 -0500 @@ -15,10 +15,12 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; +import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.IIndexBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexType; @@ -55,21 +57,25 @@ Database db = getDB(); - // type - long typeRec = 0; - byte flags = 0; - if (type != null) { - IType targetType= type.getType(); - PDOMNode targetTypeNode = getLinkage().addType(this, targetType); - if (targetTypeNode != null) - typeRec = targetTypeNode.getRecord(); - if (type.isConst()) - flags |= CONST; - if (type.isVolatile()) - flags |= VOLATILE; + try { + // type + long typeRec = 0; + byte flags = 0; + if (type != null) { + IType targetType= type.getType(); + PDOMNode targetTypeNode = getLinkage().addType(this, targetType); + if (targetTypeNode != null) + typeRec = targetTypeNode.getRecord(); + if (type.isConst()) + flags |= CONST; + if (type.isVolatile()) + flags |= VOLATILE; + } + db.putRecPtr(record + TYPE, typeRec); + db.putByte(record + FLAGS, flags); + } catch (DOMException e) { + throw new CoreException(Util.createStatus(e)); } - db.putRecPtr(record + TYPE, typeRec); - db.putByte(record + FLAGS, flags); } @Override @@ -135,11 +141,14 @@ return false; IPointerType rhs = (IPointerType) type; - if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) { - IType type1= getType(); - if (type1 != null) { - return type1.isSameType(rhs.getType()); + try { + if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) { + IType type1= getType(); + if (type1 != null) { + return type1.isSameType(rhs.getType()); + } } + } catch (DOMException e) { } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java Wed Aug 05 17:35:39 2009 -0500 @@ -14,10 +14,12 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICQualifierType; +import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.IIndexBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexType; @@ -54,21 +56,26 @@ Database db = getDB(); - if (type != null) { - IType targetType = type.getType(); - PDOMNode targetTypeNode = getLinkage().addType(this, targetType); - if (targetTypeNode != null) { - db.putRecPtr(record + TYPE, targetTypeNode.getRecord()); - } - // flags - byte flags = 0; - if (type.isConst()) - flags |= CONST; - if (type.isVolatile()) - flags |= VOLATILE; - if (type instanceof ICQualifierType && ((ICQualifierType)type).isRestrict()) - flags |= RESTRICT; - db.putByte(record + FLAGS, flags); + // type + try { + if (type != null) { + IType targetType = type.getType(); + PDOMNode targetTypeNode = getLinkage().addType(this, targetType); + if (targetTypeNode != null) { + db.putRecPtr(record + TYPE, targetTypeNode.getRecord()); + } + // flags + byte flags = 0; + if (type.isConst()) + flags |= CONST; + if (type.isVolatile()) + flags |= VOLATILE; + if (type instanceof ICQualifierType && ((ICQualifierType)type).isRestrict()) + flags |= RESTRICT; + db.putByte(record + FLAGS, flags); + } + } catch (DOMException e) { + throw new CoreException(Util.createStatus(e)); } } @@ -140,12 +147,15 @@ return false; IQualifierType pt = (IQualifierType) type; - boolean flagsMatch= isConst() == pt.isConst() && isVolatile() == pt.isVolatile(); - if (flagsMatch && type instanceof ICQualifierType) - flagsMatch &= isRestrict() == ((ICQualifierType) type).isRestrict(); - if (flagsMatch) { - IType myType= getType(); - return myType != null && myType.isSameType(pt.getType()); + try { + boolean flagsMatch= isConst() == pt.isConst() && isVolatile() == pt.isVolatile(); + if (flagsMatch && type instanceof ICQualifierType) + flagsMatch &= isRestrict() == ((ICQualifierType) type).isRestrict(); + if (flagsMatch) { + IType myType= getType(); + return myType != null && myType.isSameType(pt.getType()); + } + } catch (DOMException e) { } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunctionType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunctionType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunctionType.java Wed Aug 05 17:35:39 2009 -0500 @@ -61,17 +61,20 @@ public PDOMCFunctionType(PDOMLinkage linkage, PDOMNode parent, IFunctionType type) throws CoreException { super(linkage, parent); - PDOMNodeLinkedList list= new PDOMNodeLinkedList(parent.getLinkage(), record + TYPELIST, true); - setReturnType(type.getReturnType()); - IType[] pt= type.getParameterTypes(); - for (IType element : pt) { - PDOMNode typeNode; - if (element == null || element instanceof IProblemBinding) { - typeNode= null; - } else { - typeNode= linkage.addType(this, element); + try { + PDOMNodeLinkedList list= new PDOMNodeLinkedList(parent.getLinkage(), record + TYPELIST, true); + setReturnType(type.getReturnType()); + IType[] pt= type.getParameterTypes(); + for (int i = 0; i < pt.length; i++) { + PDOMNode typeNode; + if (pt[i] == null || pt[i] instanceof IProblemBinding) { + typeNode= null; + } else { + typeNode= linkage.addType(this, pt[i]); + } + list.addMember(typeNode); } - list.addMember(typeNode); + } catch (DOMException de) { } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java Wed Aug 05 17:35:39 2009 -0500 @@ -296,8 +296,11 @@ } @Override - public PDOMNode getNode(long record, int nodeType) throws CoreException { - switch (nodeType) { + public PDOMNode getNode(long record) throws CoreException { + if (record == 0) + return null; + + switch (PDOMNode.getNodeType(getDB(), record)) { case CVARIABLE: return new PDOMCVariable(this, record); case CFUNCTION: @@ -320,8 +323,7 @@ return new PDOMCFunctionType(this, record); } - assert false; - return null; + return super.getNode(record); } @Override diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java Wed Aug 05 17:35:39 2009 -0500 @@ -95,7 +95,8 @@ return true; } IType[] params= ft.getParameterTypes(); - for (IType param : params) { + for (int i = 0; i < params.length; i++) { + IType param = params[i]; if (introducesRecursion(param, tdname)) { return true; } @@ -130,14 +131,18 @@ } public boolean isSameType(IType type) { - IType myrtype = getType(); - if (myrtype == null) - return false; - - if (type instanceof ITypedef) { - type= ((ITypedef)type).getType(); + try { + IType myrtype = getType(); + if (myrtype == null) + return false; + + if (type instanceof ITypedef) { + type= ((ITypedef)type).getType(); + } + return myrtype.isSameType(type); + } catch (DOMException e) { } - return myrtype.isSameType(type); + return false; } @Override diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionType.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; @@ -36,10 +37,10 @@ public boolean isVolatile() { return false; } - public IType[] getParameterTypes() { + public IType[] getParameterTypes() throws DOMException { return IType.EMPTY_TYPE_ARRAY; } - public IType getReturnType() { + public IType getReturnType() throws DOMException { return FALLBACK_RETURN_TYPE; } public boolean isSameType(IType type) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java Wed Aug 05 17:35:39 2009 -0500 @@ -313,18 +313,6 @@ if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) { pdomBinding = new PDOMCPPField(this, parent, (ICPPField) binding); } - } else if (binding instanceof ICPPClassTemplate) { - pdomBinding= new PDOMCPPClassTemplate(this, parent, (ICPPClassTemplate) binding); - } else if (binding instanceof ICPPClassType) { - if (binding instanceof ICPPUnknownClassInstance) { - pdomBinding= new PDOMCPPUnknownClassInstance(this, parent, (ICPPUnknownClassInstance) binding); - } else if (binding instanceof ICPPUnknownClassType) { - pdomBinding= new PDOMCPPUnknownClassType(this, parent, (ICPPUnknownClassType) binding); - } else { - pdomBinding= new PDOMCPPClassType(this, parent, (ICPPClassType) binding); - } - } else if (binding instanceof ICPPUnknownBinding) { - pdomBinding= new PDOMCPPUnknownBinding(this, parent, (ICPPUnknownBinding) binding); } else if (binding instanceof ICPPVariable) { ICPPVariable var= (ICPPVariable) binding; pdomBinding = new PDOMCPPVariable(this, parent, var); @@ -346,6 +334,16 @@ } } else if (binding instanceof ICPPFunction) { pdomBinding = new PDOMCPPFunction(this, parent, (ICPPFunction) binding, true); + } else if (binding instanceof ICPPClassTemplate) { + pdomBinding= new PDOMCPPClassTemplate(this, parent, (ICPPClassTemplate) binding); + } else if (binding instanceof ICPPClassType) { + if (binding instanceof ICPPUnknownClassInstance) { + pdomBinding= new PDOMCPPUnknownClassInstance(this, parent, (ICPPUnknownClassInstance) binding); + } else if (binding instanceof ICPPUnknownClassType) { + pdomBinding= new PDOMCPPUnknownClassType(this, parent, (ICPPUnknownClassType) binding); + } else { + pdomBinding= new PDOMCPPClassType(this, parent, (ICPPClassType) binding); + } } else if (binding instanceof ICPPNamespaceAlias) { pdomBinding = new PDOMCPPNamespaceAlias(this, parent, (ICPPNamespaceAlias) binding); } else if (binding instanceof ICPPNamespace) { @@ -733,8 +731,11 @@ } @Override - public PDOMNode getNode(long record, int nodeType) throws CoreException { - switch (nodeType) { + public PDOMNode getNode(long record) throws CoreException { + if (record == 0) + return null; + + switch (PDOMNode.getNodeType(getDB(), record)) { case CPPVARIABLE: return new PDOMCPPVariable(this, record); case CPPFUNCTION: @@ -791,8 +792,6 @@ return new PDOMCPPClassInstance(this, record); case CPP_DEFERRED_CLASS_INSTANCE: return new PDOMCPPDeferredClassInstance(this, record); - case CPP_UNKNOWN_BINDING: - return new PDOMCPPUnknownBinding(this, record); case CPP_UNKNOWN_CLASS_TYPE: return new PDOMCPPUnknownClassType(this, record); case CPP_UNKNOWN_CLASS_INSTANCE: @@ -827,9 +826,9 @@ return new PDOMCPPFunctionType(this, record); case CPP_PARAMETER_SPECIALIZATION: return new PDOMCPPParameterSpecialization(this, record); + default: + return super.getNode(record); } - assert false : "nodeid= " + nodeType; //$NON-NLS-1$ - return null; } @Override diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPReferenceType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPReferenceType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPReferenceType.java Wed Aug 05 17:35:39 2009 -0500 @@ -13,9 +13,11 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; +import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.index.CPPReferenceTypeClone; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; @@ -44,15 +46,19 @@ Database db = getDB(); - // type - long typeRec = 0; - if (type != null) { - IType targetType = type.getType(); - PDOMNode targetTypeNode = getLinkage().addType(this, targetType); - if (targetTypeNode != null) - typeRec = targetTypeNode.getRecord(); + try { + // type + long typeRec = 0; + if (type != null) { + IType targetType = type.getType(); + PDOMNode targetTypeNode = getLinkage().addType(this, targetType); + if (targetTypeNode != null) + typeRec = targetTypeNode.getRecord(); + } + db.putRecPtr(record + TYPE, typeRec); + } catch (DOMException e) { + throw new CoreException(Util.createStatus(e)); } - db.putRecPtr(record + TYPE, typeRec); } @Override @@ -90,9 +96,12 @@ return false; ICPPReferenceType rhs = (ICPPReferenceType) type; - IType type1= getType(); - if (type1 != null) { - return type1.isSameType(rhs.getType()); + try { + IType type1= getType(); + if (type1 != null) { + return type1.isSameType(rhs.getType()); + } + } catch (DOMException e) { } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java Wed Aug 05 17:35:39 2009 -0500 @@ -100,7 +100,8 @@ return true; } IType[] params= ft.getParameterTypes(); - for (IType param : params) { + for (int i = 0; i < params.length; i++) { + IType param = params[i]; if (introducesRecursion(param, parentRec, tdname)) { return true; } @@ -135,17 +136,21 @@ } public boolean isSameType(IType type) { - IType myrtype = getType(); - if (myrtype == null) - return false; - - if (type instanceof ITypedef) { - type= ((ITypedef)type).getType(); - if (type == null) { + try { + IType myrtype = getType(); + if (myrtype == null) return false; + + if (type instanceof ITypedef) { + type= ((ITypedef)type).getType(); + if (type == null) { + return false; + } } + return myrtype.isSameType(type); + } catch (DOMException e) { } - return myrtype.isSameType(type); + return false; } @Override diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedefSpecialization.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedefSpecialization.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedefSpecialization.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,9 +12,11 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedefSpecialization; import org.eclipse.cdt.internal.core.index.CPPTypedefClone; @@ -53,6 +55,8 @@ PDOMNode typeNode = parent.getLinkage().addType(this, type); if (typeNode != null) getDB().putRecPtr(record + TYPE, typeNode.getRecord()); + } catch (DOMException e) { + throw new CoreException(Util.createStatus(e)); } finally { if (typedef instanceof CPPTypedefSpecialization) { ((CPPTypedefSpecialization) typedef).incResolutionDepth(-1); @@ -74,7 +78,7 @@ return IIndexCPPBindingConstants.CPP_TYPEDEF_SPECIALIZATION; } - public IType getType() { + public IType getType() throws DOMException { try { PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + TYPE)); return node instanceof IType ? (IType)node : null; @@ -87,16 +91,23 @@ public boolean isSameType(IType o) { if( this.equals(o) ) return true; - if( o instanceof ITypedef ) { - IType t = getType(); - if( t != null ) - return t.isSameType( ((ITypedef)o).getType()); - return false; - } + if( o instanceof ITypedef ) + try { + IType t = getType(); + if( t != null ) + return t.isSameType( ((ITypedef)o).getType()); + return false; + } catch ( DOMException e ) { + return false; + } - IType t = getType(); - if( t != null ) - return t.isSameType( o ); + try { + IType t = getType(); + if( t != null ) + return t.isSameType( o ); + } catch ( DOMException e ) { + return false; + } return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUnknownBinding.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUnknownBinding.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Markus Schorn (Wind River Systems) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.pdom.dom.cpp; - -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; -import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; -import org.eclipse.core.runtime.CoreException; - -/** - * Models unknown bindings. The class is directly used for objects (variables, functions, ...) and - * serves as a base for unknown types. - */ -class PDOMCPPUnknownBinding extends PDOMCPPBinding implements ICPPUnknownBinding { - - @SuppressWarnings("hiding") - protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE; - - public PDOMCPPUnknownBinding(PDOMLinkage linkage, PDOMNode parent, ICPPUnknownBinding binding) throws CoreException { - super(linkage, parent, binding.getNameCharArray()); - } - - public PDOMCPPUnknownBinding(PDOMLinkage linkage, long bindingRecord) { - super(linkage, bindingRecord); - } - - @Override - protected int getRecordSize() { - return RECORD_SIZE; - } - - @Override - public int getNodeType() { - return IIndexCPPBindingConstants.CPP_UNKNOWN_BINDING; - } - - public ICPPScope asScope() { - return null; - } - - @Override - public boolean mayHaveChildren() { - return false; - } - - public IASTName getUnknownName() { - return new CPPASTName(getNameCharArray()); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUnknownClassType.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUnknownClassType.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUnknownClassType.java Wed Aug 05 17:35:39 2009 -0500 @@ -31,6 +31,7 @@ import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.Util; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType; @@ -47,18 +48,18 @@ /** * @author Sergey Prigogin */ -class PDOMCPPUnknownClassType extends PDOMCPPUnknownBinding implements ICPPClassScope, ICPPUnknownClassType, +class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope, ICPPUnknownClassType, IPDOMMemberOwner, IIndexType, IIndexScope { private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 0; // byte private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4; @SuppressWarnings("hiding") - protected static final int RECORD_SIZE = PDOMCPPUnknownBinding.RECORD_SIZE + 8; + protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 8; private ICPPScope unknownScope; public PDOMCPPUnknownClassType(PDOMLinkage linkage, PDOMNode parent, ICPPUnknownClassType classType) throws CoreException { - super(linkage, parent, classType); + super(linkage, parent, classType.getNameCharArray()); setKind(classType); // linked list is initialized by storage being zero'd by malloc @@ -120,8 +121,7 @@ return this; } - @Override - public ICPPScope asScope() { + public ICPPScope asScope() { if (unknownScope == null) { unknownScope= new PDOMCPPUnknownScope(this, getUnknownName()); } @@ -262,6 +262,10 @@ return ICPPClassType.EMPTY_CLASS_ARRAY; } + public IASTName getUnknownName() { + return new CPPASTName(getNameCharArray()); + } + public boolean isAnonymous() { return false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java Wed Aug 05 17:35:39 2009 -0500 @@ -28,12 +28,12 @@ import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; import org.eclipse.cdt.core.cdtvariables.IUserVarSupplier; +import org.eclipse.cdt.core.dom.CDOM; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.parser.IScannerInfoProvider; @@ -95,11 +95,10 @@ public static final int STATUS_CDTPROJECT_MISMATCH = 2; public static final int CDT_PROJECT_NATURE_ID_MISMATCH = 3; /** - * Status code for core exception that is thrown if a pdom grew larger than the supported limit. - * @since 5.2 + * Will be public and final in the next CDT version. + * @noreference */ - public static final int STATUS_PDOM_TOO_LARGE = 4; - + public static int STATUS_PDOM_TOO_LARGE = 4; public static final String PLUGIN_ID = "org.eclipse.cdt.core"; //$NON-NLS-1$ public static final String BUILDER_MODEL_ID = PLUGIN_ID + ".CBuildModel"; //$NON-NLS-1$ @@ -1008,12 +1007,8 @@ return getPluginPreferences().getBoolean(PREF_USE_STRUCTURAL_PARSE_MODE); } - /** - * @deprecated use {@link ITranslationUnit} or {@link ILanguage} to construct ASTs, instead. - */ - @Deprecated - public org.eclipse.cdt.core.dom.CDOM getDOM() { - return org.eclipse.cdt.core.dom.CDOM.getInstance(); + public CDOM getDOM() { + return CDOM.getInstance(); } public ICdtVariableManager getCdtVariableManager(){ @@ -1267,14 +1262,4 @@ public static IPDOMManager getPDOMManager() { return getDefault().pdomManager; } - - /** - * Returns preference controlling whether source roots are shown at the top of projects - * or embedded within the resource tree of projects when they are not top level folders. - * - * @return boolean preference value - */ - public static boolean showSourceRootsAtTopOfProject() { - return getDefault().getPluginPreferences().getBoolean( CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT); - } } \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java Wed Aug 05 17:35:39 2009 -0500 @@ -135,9 +135,4 @@ * Attempt to show source files for executable binaries. */ public static final String SHOW_SOURCE_FILES_IN_BINARIES = CCorePlugin.PLUGIN_ID + ".showSourceFilesInBinaries"; //$NON-NLS-1$ - - /** - * Show source roots at the top level of projects. - */ - public static final String SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT = CCorePlugin.PLUGIN_ID + ".showSourceRootsAtTopLevelOfProject"; //$NON-NLS-1$ } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java Wed Aug 05 17:35:39 2009 -0500 @@ -2198,35 +2198,35 @@ * @param wrapStyle the given wrapping style * @param indentStyle the given indent style * - * @return the new alignment value + * @return the new alignement value */ public static String createAlignmentValue(boolean forceSplit, int wrapStyle, int indentStyle) { int alignmentValue = 0; - switch (wrapStyle) { - case WRAP_COMPACT: + switch(wrapStyle) { + case WRAP_COMPACT : alignmentValue |= Alignment.M_COMPACT_SPLIT; break; - case WRAP_COMPACT_FIRST_BREAK: + case WRAP_COMPACT_FIRST_BREAK : alignmentValue |= Alignment.M_COMPACT_FIRST_BREAK_SPLIT; break; - case WRAP_NEXT_PER_LINE: + case WRAP_NEXT_PER_LINE : alignmentValue |= Alignment.M_NEXT_PER_LINE_SPLIT; break; - case WRAP_NEXT_SHIFTED: + case WRAP_NEXT_SHIFTED : alignmentValue |= Alignment.M_NEXT_SHIFTED_SPLIT; break; - case WRAP_ONE_PER_LINE: + case WRAP_ONE_PER_LINE : alignmentValue |= Alignment.M_ONE_PER_LINE_SPLIT; break; } if (forceSplit) { alignmentValue |= Alignment.M_FORCE; } - switch (indentStyle) { - case INDENT_BY_ONE: + switch(indentStyle) { + case INDENT_BY_ONE : alignmentValue |= Alignment.M_INDENT_BY_ONE; break; - case INDENT_ON_COLUMN: + case INDENT_ON_COLUMN : alignmentValue |= Alignment.M_INDENT_ON_COLUMN; } return String.valueOf(alignmentValue); @@ -2349,16 +2349,16 @@ } try { int existingValue = Integer.parseInt(value) & Alignment.SPLIT_MASK; - switch (existingValue) { - case Alignment.M_COMPACT_SPLIT: + switch(existingValue) { + case Alignment.M_COMPACT_SPLIT : return WRAP_COMPACT; - case Alignment.M_COMPACT_FIRST_BREAK_SPLIT: + case Alignment.M_COMPACT_FIRST_BREAK_SPLIT : return WRAP_COMPACT_FIRST_BREAK; - case Alignment.M_NEXT_PER_LINE_SPLIT: + case Alignment.M_NEXT_PER_LINE_SPLIT : return WRAP_NEXT_PER_LINE; - case Alignment.M_NEXT_SHIFTED_SPLIT: + case Alignment.M_NEXT_SHIFTED_SPLIT : return WRAP_NEXT_SHIFTED; - case Alignment.M_ONE_PER_LINE_SPLIT: + case Alignment.M_ONE_PER_LINE_SPLIT : return WRAP_ONE_PER_LINE; default: return WRAP_NO_SPLIT; @@ -2419,11 +2419,11 @@ throw WRONG_ARGUMENT; } switch(indentStyle) { - case INDENT_BY_ONE: - case INDENT_DEFAULT: - case INDENT_ON_COLUMN: + case INDENT_BY_ONE : + case INDENT_DEFAULT : + case INDENT_ON_COLUMN : break; - default: + default : throw WRONG_ARGUMENT; } try { @@ -2431,10 +2431,10 @@ // clear existing indent bits existingValue &= ~(Alignment.M_INDENT_BY_ONE | Alignment.M_INDENT_ON_COLUMN); switch(indentStyle) { - case INDENT_BY_ONE: + case INDENT_BY_ONE : existingValue |= Alignment.M_INDENT_BY_ONE; break; - case INDENT_ON_COLUMN: + case INDENT_ON_COLUMN : existingValue |= Alignment.M_INDENT_ON_COLUMN; } return String.valueOf(existingValue); @@ -2466,13 +2466,13 @@ if (value == null) { throw WRONG_ARGUMENT; } - switch (wrappingStyle) { - case WRAP_COMPACT: - case WRAP_COMPACT_FIRST_BREAK: - case WRAP_NEXT_PER_LINE: - case WRAP_NEXT_SHIFTED: - case WRAP_NO_SPLIT: - case WRAP_ONE_PER_LINE: + switch(wrappingStyle) { + case WRAP_COMPACT : + case WRAP_COMPACT_FIRST_BREAK : + case WRAP_NEXT_PER_LINE : + case WRAP_NEXT_SHIFTED : + case WRAP_NO_SPLIT : + case WRAP_ONE_PER_LINE : break; default: throw WRONG_ARGUMENT; @@ -2481,20 +2481,20 @@ int existingValue = Integer.parseInt(value); // clear existing split bits existingValue &= ~(Alignment.SPLIT_MASK); - switch (wrappingStyle) { - case WRAP_COMPACT: + switch(wrappingStyle) { + case WRAP_COMPACT : existingValue |= Alignment.M_COMPACT_SPLIT; break; - case WRAP_COMPACT_FIRST_BREAK: + case WRAP_COMPACT_FIRST_BREAK : existingValue |= Alignment.M_COMPACT_FIRST_BREAK_SPLIT; break; - case WRAP_NEXT_PER_LINE: + case WRAP_NEXT_PER_LINE : existingValue |= Alignment.M_NEXT_PER_LINE_SPLIT; break; - case WRAP_NEXT_SHIFTED: + case WRAP_NEXT_SHIFTED : existingValue |= Alignment.M_NEXT_SHIFTED_SPLIT; break; - case WRAP_ONE_PER_LINE: + case WRAP_ONE_PER_LINE : existingValue |= Alignment.M_ONE_PER_LINE_SPLIT; break; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties Wed Aug 05 17:35:39 2009 -0500 @@ -22,7 +22,7 @@ CoreModel.NullBinaryParser.Null_Format=Null Format CoreModel.PathEntry.IllegalContainerPath= Illegal container entry -CoreModel.PathEntry.DuplicateEntry= Duplicate path entries found: {0} +CoreModel.PathEntry.DuplicateEntry= Duplicate path entries CoreModel.PathEntry.NestedEntry= Nested path entries CoreModel.PathEntry.InvalidPathEntry= Invalid path diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java Wed Aug 05 17:35:39 2009 -0500 @@ -59,8 +59,6 @@ defaultPreferences.putBoolean(CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true); defaultPreferences.putBoolean(CCorePlugin.PREF_USE_STRUCTURAL_PARSE_MODE, false); - - defaultPreferences.putBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true); // indexer defaults IndexerPreferences.initializeDefaultPreferences(defaultPreferences); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/cdtvariables/CdtVariableResolver.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 Intel Corporation and others. + * Copyright (c) 2005, 2007 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,50 +7,31 @@ * * Contributors: * Intel Corporation - Initial API and implementation - * Andrew Gvozdev (Quoin Inc.) *******************************************************************************/ package org.eclipse.cdt.utils.cdtvariables; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.cdtvariables.ICdtVariableStatus; /** - * Utility class to resolve macro references. Provides fixture to parse ${macro} - * expressions and replace macros with actual values using {@link IVariableSubstitutor}. + * This is the utility class used to resolve macro references and that provides + * other functionality related to the macro resolving * * @since 3.0 */ public class CdtVariableResolver { private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - public static final String VARIABLE_PREFIX = "${"; //$NON-NLS-1$ - private static final String VARIABLE_PREFIX_MASKED = "$\1"; //$NON-NLS-1$ - public static final char VARIABLE_SUFFIX = '}'; - private static final char VARIABLE_SUFFIX_MASKED = '\2'; - public static final char VARIABLE_ESCAPE_CHAR = '\\'; - private static final char VARIABLE_ESCAPE_CHAR_MASKED = '\3'; + public static final String VARIABLE_PREFIX = "${"; //$NON-NLS-1$ + public static final char VARIABLE_SUFFIX = '}'; + public static final char VARIABLE_ESCAPE_CHAR = '\\'; + private static final int VARIABLE_PREFIX_LENGTH = VARIABLE_PREFIX.length(); - // Regular expression fragments - private static final String RE_VPREFIX = "\\$\\{"; //$NON-NLS-1$ - private static final String RE_VSUFFIX = "\\}"; //$NON-NLS-1$ - private static final String RE_VNAME = "[^${}]*"; //$NON-NLS-1$ - private static final String RE_BSLASH = "[\\\\]"; // *one* backslash //$NON-NLS-1$ - - /** - * Converts list of strings to one string using given string as delimiter, - * i.e -> "string1:string2:string3" - * - * @param value - list of strings to convert. - * @param listDelimiter - delimiter. - * @return all strings from the list separated with given delimiter. - */ static public String convertStringListToString(String value[], String listDelimiter) { if(value == null || value.length == 0) @@ -66,61 +47,17 @@ } /** - * Resolves macros of kind ${Macro} in the given string by calling the macro substitutor - * for each macro reference found. Macros can be inside one another like - * ${workspace_loc:/${ProjName}/} but resolved just once. No recursive or concatenated - * macro names are allowed. It is possible to prevent macro from expanding using backslash \$. + * resolves macros in the given string by calling the macro subsitutor for each macro reference found * - * @param string - macro expression. - * @param substitutor - macro resolution provider to retrieve macro values. + * @param string + * @param substitutor * @return resolved string * - * @throws CdtVariableException if substitutor can't handle the macro and returns null or throws. + * @throws CdtVariableException */ static public String resolveToString(String string, IVariableSubstitutor substitutor) throws CdtVariableException{ - if (string==null) { - return EMPTY_STRING; - } - - final Pattern pattern = Pattern.compile(".*?("+RE_BSLASH+"*)("+RE_VPREFIX+"("+RE_VNAME+")"+RE_VSUFFIX+").*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - - StringBuffer buffer = new StringBuffer(string); - int limit=string.length(); - for (Matcher matcher = pattern.matcher(buffer);matcher.matches();matcher = pattern.matcher(buffer)) { - String bSlashes=matcher.group(1); - String macro=matcher.group(2); - String name=matcher.group(3); - String resolved = name.length()>0 ? substitutor.resolveToString(name) : EMPTY_STRING; - if (resolved==null) { - throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED, null, string, name); - } - if (limit-- < 0) { - // to prevent incidental looping - throw new CdtVariableException(ICdtVariableStatus.TYPE_ERROR, name, matcher.group(0), resolved); - } - - int nBSlashes=bSlashes.length(); - if ((nBSlashes & 1)==1) { - // if odd number of backslashes in front of "${...}" do not expand macro - resolved = macro; - } - // Only one expansion is allowed, so hide any text interfering with macro syntax - resolved=resolved.replace(VARIABLE_PREFIX, VARIABLE_PREFIX_MASKED); - resolved=resolved.replace(VARIABLE_SUFFIX, VARIABLE_SUFFIX_MASKED); - buffer.replace(matcher.start(2), matcher.end(2), resolved); - // collapse and hide backslashes \\\\${Macro} -> \\MacroValue or \\\\\${Macro} -> \\${Macro} - buffer.replace(matcher.start(1), matcher.end(1), - bSlashes.substring(0, nBSlashes/2).replace(VARIABLE_ESCAPE_CHAR, VARIABLE_ESCAPE_CHAR_MASKED)); - } - String result = buffer.toString(); - - // take hidden data back - result=result.replace(VARIABLE_PREFIX_MASKED, VARIABLE_PREFIX); - result=result.replace(VARIABLE_SUFFIX_MASKED, VARIABLE_SUFFIX); - result=result.replace(VARIABLE_ESCAPE_CHAR_MASKED, VARIABLE_ESCAPE_CHAR); - - return result; + return (String)resolve(string,substitutor,false,false); } /** @@ -130,26 +67,108 @@ * @param string * @param substitutor * @throws CdtVariableException - * - * @deprecated Use {@link #resolveToString} which would do full nested expansion. */ - @Deprecated static public void checkVariables(String string, IVariableSubstitutor substitutor) throws CdtVariableException{ - resolveToString(string, substitutor); + resolve(string, substitutor, false, true); + } + + static private Object resolve(String string, IVariableSubstitutor substitutor, boolean asList, boolean checkOnly) + throws CdtVariableException{ + if(string == null) + return EMPTY_STRING; + + int macroStart = -1; + int macroEnd = -1; + int processed = 0; + StringBuffer buffer = checkOnly ? null : new StringBuffer(); + boolean listMode = false; + String listValue[] = null; + final int length = string.length(); + + do{ + //find macro prefix + macroStart = string.indexOf(VARIABLE_PREFIX, macroEnd+1); + if(macroStart == -1){ + if(buffer != null) + buffer.append(string.substring(processed,length)); + break; + } + + //macro prefix found, find macro suffix + macroEnd = string.indexOf(VARIABLE_SUFFIX, macroStart); + if(macroEnd == -1){ + if(buffer != null) + buffer.append(string.substring(processed,length)); + break; + } + + if(asList && macroStart == 0 && macroEnd == length - 1) + listMode = true; + + //check whether macro is prepended with the back-clash + if(macroStart > 0 && VARIABLE_ESCAPE_CHAR == string.charAt(macroStart - 1)){ + int num; + for(num = macroStart-2; num >= 0 && VARIABLE_ESCAPE_CHAR == string.charAt(num); num--){} + + //number of back-slashes + num = macroStart - num - 1; + if(buffer != null) + buffer.append(string.substring(processed,macroStart - ((num + 1) >> 1))); + + if((num & 1) == 0) + processed = macroStart; + else { + if(buffer != null) + buffer.append(string.substring(macroStart,macroEnd+1)); + processed = macroEnd+1; + continue; + } + } + + if(macroStart > processed && buffer != null) + buffer.append(string.substring(processed,macroStart)); + + String name = string.substring(macroStart + VARIABLE_PREFIX_LENGTH, macroEnd); + if(!EMPTY_STRING.equals(name)){ + + if(listMode){ + listValue = substitutor.resolveToStringList(name); + if(listValue == null) + throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED,(String)null,string,name); + } + else{ + String resolved = substitutor.resolveToString(name); + if(resolved == null) + throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED,(String)null,string,name); + if(buffer != null) + buffer.append(resolved); + } + } + processed = macroEnd+1; + + }while(true); + + if(asList){ + String result[] = null; + if(listMode){ + if(listValue != null) + result = listValue; + else + result = new String[0]; + } + else if(buffer != null) + result = new String[]{buffer.toString()}; + return result; + } + else if(buffer != null) + return buffer.toString(); + return null; } /** - * Resolves array of macros using {@code substitutor} to pull macro's list of values. - * Note that each macro of input array can in turn provide list of values and - * the resulting array combines all of them. - * - * @param values - input array of macros. - * @param substitutor - macro resolution provider to retrieve macro values. - * @param ignoreErrors - if {@code true} then exceptions are caught and ignored. - * @return array of resolved values. - * @throws CdtVariableException if substitutor throws {@link CdtVariableException} - * and {@code ignoreErrors}={@code null}. + * resolves macros in the array of string-list values + * @throws CdtVariableException */ static public String[] resolveStringListValues(String values[], IVariableSubstitutor substitutor, boolean ignoreErrors) throws CdtVariableException { @@ -183,40 +202,16 @@ } /** - * Resolves macro ${ListMacro} in the given String to the String-list using substitutor - * to pull macro's list of values. If the provided string is not exactly a single macro - * it is treated as macro expression and result is put into the first element of resulting array. - * - * @param string - input string. - * @param substitutor - macro resolution provider to retrieve macro values. - * @return array of resolved values. - * @throws CdtVariableException if substitutor can't handle the macro and returns null or throws. + * Resolves macros in the given String to the String-list + * @throws CdtVariableException */ static public String[] resolveToStringList(String string, IVariableSubstitutor substitutor) throws CdtVariableException{ - - StringBuffer buffer = new StringBuffer(string); - final Pattern pattern = Pattern.compile("^"+RE_VPREFIX+"("+RE_VNAME+")"+RE_VSUFFIX+"$"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - Matcher matcher = pattern.matcher(buffer); - if (matcher.matches()) { - String name=matcher.group(1); - if (name.equals(EMPTY_STRING)) { - return new String[0]; - } - String[] result = substitutor.resolveToStringList(name); - if (result==null) { - throw new CdtVariableException(ICdtVariableStatus.TYPE_MACRO_UNDEFINED, null, string, name); - } - return result; - } - return new String[] {resolveToString(string, substitutor)}; + return (String[])resolve(string,substitutor,true,false); } /** - * Test for String-list type of macro. - * - * @param macroType - type of tested macro. - * @return {@code true} if the given macro is a String-list macro. + * returns true if the given macro is a String-list macro. */ public static boolean isStringListVariable(int macroType){ switch(macroType){ @@ -231,12 +226,8 @@ } /** - * Checks the macros integrity for the given context. If test fails {@link CdtVariableException} - * is thrown. - * - * @param info - context information to acquire list of available macros. - * @param substitutor - macro resolution provider to retrieve macro values. - * @throws CdtVariableException propagated up if {@code substitutor} throws. + * checks the macros integrity for the given context + * @throws CdtVariableException */ public static void checkIntegrity( IVariableContextInfo info, @@ -256,14 +247,68 @@ } /** - * Constructs a macro reference given the macro name + * creates a macro reference given the macro name * e.g. if the "macro1" name is passed, returns "${macro1}" * - * @param name - macro name. - * @return macro variable in form "${macro}" + * @param name + * @return String */ public static String createVariableReference(String name){ return VARIABLE_PREFIX + name + VARIABLE_SUFFIX; } + /** + * Returns the array of the explicit file macros, referenced in the given string + * (Explicit file macros are the file-specific macros, whose values are not provided + * by the tool-integrator. As a result these macros contain explicit values, but not the values + * specified in the format of the builder automatic variables and text functions) + * + * @param expression + * @param contextType + * @param contextData + * @return + */ +/* public static IBuildMacro[] getReferencedExplitFileMacros(String expression, int contextType, Object contextData){ + ExplicitFileMacroCollector collector = new ExplicitFileMacroCollector(contextType,contextData); + try { + resolveToString(expression,collector); + } catch (BuildMacroException e){ + } + return collector.getExplicisFileMacros(); + } +*/ +/* static public ICdtVariable[] filterMacros(ICdtVariable macros[], String remove[]){ + + if(macros == null || macros.length == 0) + return macros; + + ICdtVariable filtered[] = new ICdtVariable[macros.length]; + int filteredNum = 0; + for(int i = 0; i < macros.length; i++){ + ICdtVariable var = macros[i]; + String name = null; + if(var != null && (name = EnvVarOperationProcessor.normalizeName(var.getName())) != null){ + boolean skip = false; + if(remove != null && remove.length > 0){ + for(int j = 0; j < remove.length; j++){ + if(remove[j] != null && remove[j].equals(name)){ + skip = true; + break; + } + } + } + if(!skip) + filtered[filteredNum++] = var; + } + } + + if(filteredNum != filtered.length){ + IBuildMacro m[] = new IBuildMacro[filteredNum]; + for(int i = 0; i < filteredNum; i++) + m[i] = filtered[i]; + filtered = m; + } + return filtered; + } +*/ } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/plugin.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/plugin.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/plugin.properties Wed Aug 05 17:35:39 2009 -0500 @@ -11,7 +11,6 @@ # Ken Ryall (Nokia) - Added support for breakpoint problems( 170027 ) # Ken Ryall (Nokia) - Added support for Breakpoint Actions ( 118308 ) # IBM Corporation -# Texas Instruments - added extension point for source container type (279473) ############################################################################### pluginName=C/C++ Development Tools Debug Model providerName=Eclipse CDT @@ -22,7 +21,6 @@ CDebugger.name=C/C++ Development Tools Core Debugger Extension BreakpointAction.name=Breakpoint Action Extension -SupportedSourceContainerTypes.name=C/C++ Supported Source Container Types Extension cLineBreakpoints.name=C/C++ Line Breakpoints cAddressBreakpoints.name=C/C++ Address Breakpoints diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/plugin.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/plugin.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/plugin.xml Wed Aug 05 17:35:39 2009 -0500 @@ -5,11 +5,6 @@ - - - - - @@ -261,20 +256,5 @@ markerType="org.eclipse.cdt.debug.core.cBreakpointMarker"> - - - - - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/BreakpointAction.exsd --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/BreakpointAction.exsd Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/BreakpointAction.exsd Wed Aug 05 17:35:39 2009 -0500 @@ -1,106 +1,106 @@ - - - - - - - - - Extension to provide additional actions to execute when a breakpoint is hit. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - Copyright (c) 2007 Nokia and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Eclipse Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/epl-v10.html - - - - + + + + + + + + + Extension to provide additional actions to execute when a breakpoint is hit. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + + + + + Copyright (c) 2007 Nokia and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html + + + + diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/ExecutablesImporter.exsd --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/ExecutablesImporter.exsd Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ - - - - - - - - - This extension points allows you to extened the executables manager in CDT by providing your own executables importer. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CDT 7.0 - - - - - - - - - <extension - point="org.eclipse.cdt.debug.core.ExecutablesImporter"> - <modifier class="com.xyz.MyExecutablesImporter"/> - </extension> - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/ExecutablesProvider.exsd --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/ExecutablesProvider.exsd Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ - - - - - - - - - This extension points allows you to extened the executables manager in CDT by providing your own executables provider for certain types of projects. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CDT 7.0 - - - - - - - - - <extension - point="org.eclipse.cdt.debug.core.ExecutablesProvider"> - <modifier class="com.xyz.MyExecutablesProvider"/> - </extension> - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/SourceFilesProvider.exsd --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/SourceFilesProvider.exsd Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ - - - - - - - - - This extension points allows you to extened the executables manager in CDT by providing your own source files provider for certain types of executables. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CDT 7.0 - - - - - - - - - <extension - point="org.eclipse.cdt.debug.core.SourceFilesProvider"> - <modifier class="com.xyz.MySourceFilesProvider"/> - </extension> - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/SourceRemappingProvider.exsd --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/SourceRemappingProvider.exsd Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ - - - - - - - - - This extension points allows you to extened the executables manager in CDT by providing your own source remapping provider. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CDT 7.0 - - - - - - - - - <extension - point="org.eclipse.cdt.debug.core.SourceRemappingProvider"> - <modifier class="com.xyz.MySourceRemappingProvider"/> - </extension> - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/SupportedSourceContainerTypes.exsd --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/schema/SupportedSourceContainerTypes.exsd Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ - - - - - - - - - The extension point provides a mechanism for contributing source container types to the preference page "C/C++, Debug,Common Source Lookup Path". - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Value of this attribute must be a contribution to the extension point "org.eclipse.debug.core.sourceContainerTypes". - - - - - - - - - - - - - - - - In the above example, C debugger specifies that it supports absolutePath contaner type. -<pre> - <extension - point="org.eclipse.cdt.debug.core.supportedSourceContainerTypes"> - <sourceContainer - id="org.eclipse.cdt.debug.core.containerType.absolutePath"/> - </extension> -</pre> - - - - - - - - - Value of the attribute id must be a contribution to the extension point "org.eclipse.debug.core.sourceContainerTypes". - - - - - - - - - - Copyright (c) 2009 Texas Instruments and others -All rights reserved. This program and the accompanying materials -are made available under the terms of the Eclipse Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/epl-v10.html - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java Wed Aug 05 17:35:39 2009 -0500 @@ -50,19 +50,6 @@ public static final String ATTR_PROJECT_NAME = CDT_LAUNCH_ID + ".PROJECT_ATTR"; //$NON-NLS-1$ /** - * Launch configuration attribute value constants for build before launch. - */ - public static final int BUILD_BEFORE_LAUNCH_DISABLED = 0; - public static final int BUILD_BEFORE_LAUNCH_ENABLED = 1; - public static final int BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING = 2; - - /** - * Launch configuration attribute key. The value is the ID of the project's - * build configuration that should be used when a build is required before launch. - */ - public static final String ATTR_BUILD_BEFORE_LAUNCH = CDT_LAUNCH_ID + ".ATTR_BUILD_BEFORE_LAUNCH_ATTR"; //$NON-NLS-1$ - - /** * Launch configuration attribute key. The value is the ID of the project's * build configuration that should be used when a build is required before launch. */ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java Wed Aug 05 17:35:39 2009 -0500 @@ -135,7 +135,7 @@ * @noreference This method is not intended to be referenced by clients. * @since 6.0 */ - public synchronized TranslationUnit[] getSourceFiles(IProgressMonitor monitor) { + public TranslationUnit[] getSourceFiles(IProgressMonitor monitor) { if (!refreshSourceFiles) return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ; @@ -241,7 +241,7 @@ this.refreshSourceFiles = refreshSourceFiles; } - public synchronized String getOriginalLocation(ITranslationUnit tu) { + public String getOriginalLocation(ITranslationUnit tu) { String orgLocation = remappedPaths.get(tu); if (orgLocation == null) orgLocation = tu.getLocation().toOSString(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java Wed Aug 05 17:35:39 2009 -0500 @@ -11,50 +11,29 @@ package org.eclipse.cdt.debug.core.executables; -import java.text.DateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Map; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; -import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.internal.core.executables.ExecutablesChangeEvent; import org.eclipse.cdt.debug.internal.core.executables.StandardExecutableImporter; +import org.eclipse.cdt.debug.internal.core.executables.StandardExecutableProvider; import org.eclipse.cdt.debug.internal.core.executables.StandardSourceFileRemapping; import org.eclipse.cdt.debug.internal.core.executables.StandardSourceFilesProvider; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.osgi.service.debug.DebugOptions; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; +import org.eclipse.debug.core.DebugPlugin; /** * The Executables Manager maintains a collection of executables built by all of @@ -64,78 +43,28 @@ * @author Ken Ryall * */ -public class ExecutablesManager extends PlatformObject implements IResourceChangeListener, ICProjectDescriptionListener { +public class ExecutablesManager extends PlatformObject { - private static final String EXECUTABLES_MANAGER_DEBUG_TRACING = CDebugCorePlugin.PLUGIN_ID + "EXECUTABLES_MANAGER_DEBUG_TRACING"; //$NON-NLS-1$ - - private Map executablesProviderMap = new HashMap(); - private Map> executablesMap = new HashMap>(); - private List changeListeners = Collections.synchronizedList(new ArrayList()); - private List executableProviders; - private List sourceFileProviders; - private List sourceFileRemappings; - private List executableImporters; - - private boolean DEBUG; + private final HashMap executables = new HashMap(); + private final List changeListeners = Collections.synchronizedList(new ArrayList()); + private final List sourceFileRemappings = Collections.synchronizedList(new ArrayList()); + private final List executableProviders = Collections.synchronizedList(new ArrayList()); + private final List sourceFileProviders = Collections.synchronizedList(new ArrayList()); + private final List executableImporters = Collections.synchronizedList(new ArrayList()); + private boolean refreshNeeded = true; + private boolean tempDisableRefresh = false; private final Job refreshJob = new Job("Get Executables") { @Override public IStatus run(IProgressMonitor monitor) { - - trace("Get Executables job started at " - + getStringFromTimestamp(System.currentTimeMillis())); - - List projects = getProjectsToCheck(); - - SubMonitor subMonitor = SubMonitor - .convert(monitor, projects.size()); - - for (IProject project : projects) { - if (subMonitor.isCanceled()) { - trace("Get Executables job cancelled at " - + getStringFromTimestamp(System.currentTimeMillis())); - return Status.CANCEL_STATUS; - } - - subMonitor.subTask("Checking project: " + project.getName()); - - // get the executables provider for this project - IProjectExecutablesProvider provider = getExecutablesProviderForProject(project); - if (provider != null) { - trace("Getting executables for project: " - + project.getName() + " using " - + provider.toString()); - - // store the list of executables for this project - synchronized (executablesMap) { - executablesMap.put(project, provider.getExecutables( - project, subMonitor.newChild(1, - SubMonitor.SUPPRESS_NONE))); - } - } - } - - // notify the listeners - synchronized (changeListeners) { - for (IExecutablesChangeListener listener : changeListeners) { - listener.executablesListChanged(); - } - } - - trace("Get Executables job finished at " - + getStringFromTimestamp(System.currentTimeMillis())); - + refreshExecutables(monitor); return Status.OK_STATUS; } }; private static ExecutablesManager executablesManager = null; - - /** - * Get the executables manager instance - * @return the executables manager - */ + public static ExecutablesManager getExecutablesManager() { if (executablesManager == null) executablesManager = new ExecutablesManager(); @@ -143,130 +72,126 @@ } public ExecutablesManager() { - // check if debugging is enabled - BundleContext context = CDebugCorePlugin.getDefault().getBundle() - .getBundleContext(); - if (context != null) { - ServiceReference reference = CDebugCorePlugin.getDefault() - .getBundle().getBundleContext().getServiceReference( - DebugOptions.class.getName()); - if (reference != null) { - DebugOptions service = (DebugOptions) context - .getService(reference); - if (service != null) { - try { - DEBUG = service.getBooleanOption( - EXECUTABLES_MANAGER_DEBUG_TRACING, false); - } finally { - // we have what we want - release the service - context.ungetService(reference); - } - } - } - } - - refreshJob.setPriority(Job.SHORT); - - // load the extension points - loadExecutableProviderExtensions(); - loadSoureFileProviderExtensions(); - loadSoureRemappingExtensions(); - loadExecutableImporterExtensions(); - - // add the standard providers - executableProviders.add(0, new StandardExecutableProvider()); - sourceFileProviders.add(0, new StandardSourceFilesProvider()); - sourceFileRemappings.add(0, new StandardSourceFileRemapping()); - executableImporters.add(0, new StandardExecutableImporter()); - - // listen for events we're interested in - ResourcesPlugin.getWorkspace().addResourceChangeListener( - this, - IResourceChangeEvent.POST_CHANGE - | IResourceChangeEvent.POST_BUILD); - CoreModel.getDefault().getProjectDescriptionManager() - .addCProjectDescriptionListener(this, - CProjectDescriptionEvent.DATA_APPLIED); - - // schedule a refresh so we get up to date - scheduleRefresh(); - + addSourceFileRemapping(new StandardSourceFileRemapping()); + addExecutableImporter(new StandardExecutableImporter()); + addExecutablesProvider(new StandardExecutableProvider()); + addSourceFilesProvider(new StandardSourceFilesProvider()); } - /** - * Adds an executable listener - * @param listener the listener to add - */ public void addExecutablesChangeListener(IExecutablesChangeListener listener) { changeListeners.add(listener); } - /** - * Removes an executable listener - * @param listener the listener to remove - */ public void removeExecutablesChangeListener(IExecutablesChangeListener listener) { changeListeners.remove(listener); } - + public void addSourceFileRemapping(ISourceFileRemapping remapping) { + sourceFileRemappings.add(remapping); + } + + public void removeSourceFileRemapping(ISourceFileRemapping remapping) { + sourceFileRemappings.remove(remapping); + } + + public void addExecutableImporter(IExecutableImporter importer) { + executableImporters.add(importer); + } + + public void removeExecutableImporter(IExecutableImporter importer) { + executableImporters.remove(importer); + } + + public void addExecutablesProvider(IExecutableProvider provider) { + executableProviders.add(provider); + } + + /** + * @since 6.0 + */ + public void addSourceFilesProvider(ISourceFilesProvider provider) { + sourceFileProviders.add(provider); + } /** - * Gets the list of executables in the workspace. - * @return the list of executables which may be empty - */ - public Collection getExecutables() { - trace("getExecutables called at " + getStringFromTimestamp(System.currentTimeMillis())); - List executables = new ArrayList(); + * @since 6.0 + */ + public void removeSourceFilesProvider(ISourceFilesProvider provider) { + sourceFileProviders.remove(provider); + } + + public void removeExecutablesProvider(IExecutableProvider provider) { + executableProviders.remove(provider); + } + + public IStatus refreshExecutables(IProgressMonitor monitor) { + if (tempDisableRefresh) { + return Status.OK_STATUS; + } + + + synchronized (executables) { + HashMap oldList = new HashMap(executables); + executables.clear(); + + IExecutableProvider[] exeProviders = getExecutableProviders(); + + Arrays.sort(exeProviders, new Comparator() { - synchronized (executablesMap) { - for (List exes : executablesMap.values()) { - for (Executable exe : exes) { - if (!executables.contains(exe)) { - executables.add(exe); - } + public int compare(IExecutableProvider arg0, IExecutableProvider arg1) { + int p0 = arg0.getPriority(); + int p1 = arg1.getPriority(); + if (p0 > p1) + return 1; + if (p0 < p1) + return -1; + return 0; + }}); + refreshNeeded = false; + monitor.beginTask("Refresh Executables", exeProviders.length); + for (IExecutableProvider provider : exeProviders) { + Executable[] exes = provider.getExecutables(new SubProgressMonitor(monitor, 1)); + for (Executable executable : exes) { + executables.put(executable.getPath().toOSString(), executable); + } + } + monitor.done(); + + synchronized (changeListeners) { + Collection newExes = executables.values(); + Executable[] exeArray = newExes.toArray(new Executable[newExes.size()]); + Collection oldExes = oldList.values(); + Executable[] oldArray = oldExes.toArray(new Executable[oldExes.size()]); + for (IExecutablesChangeListener listener : changeListeners) { + listener.executablesChanged(new ExecutablesChangeEvent(oldArray, exeArray)); } } } - trace("getExecutables returned at " + getStringFromTimestamp(System.currentTimeMillis())); + return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; + } + + public Executable[] getExecutables() { + if (refreshNeeded) { + try { + refreshJob.schedule(); + refreshJob.join(); + } catch (InterruptedException e) { + DebugPlugin.log( e ); + } + } - return executables; - + synchronized (executables) + { + Collection exes = executables.values(); + return exes.toArray(new Executable[exes.size()]); + } } /** - * Gets the collection of executables for the given project - * @param project the project - * @return collection of executables which may be empty - */ - public Collection getExecutablesForProject(IProject project) { - List executables = new ArrayList(); - - synchronized (executablesMap) { - List exes = executablesMap.get(project); - if (exes != null) { - for (Executable exe : exes) { - if (!executables.contains(exe)) { - executables.add(exe); - } - } - } - } - return executables; - } - - - /** - * Attempt to remap the path to the given source file in the given executable using - * source file mapping extensions - * @param executable the executable - * @param filePath the absolute path to the source file - * @return the new path to the source file, which was remapped if possible - * - * @since 6.0 - */ + * @since 6.0 + */ public String remapSourceFile(Executable executable, String filePath) { synchronized (sourceFileRemappings) { for (ISourceFileRemapping remapping : sourceFileRemappings) { @@ -278,64 +203,45 @@ return filePath; } - /** - * Import the given executables into the manager - * @param fileNames the absolute paths of the executables to import - * @param monitor progress monitor - */ - public void importExecutables(final String[] fileNames, - IProgressMonitor monitor) { + public void importExecutables(final String[] fileNames, IProgressMonitor monitor) { boolean handled = false; - monitor.beginTask("Import Executables", executableImporters.size()); - synchronized (executableImporters) { - Collections.sort(executableImporters, - new Comparator() { - - public int compare(IExecutableImporter arg0, - IExecutableImporter arg1) { - int p0 = arg0.getPriority(fileNames); - int p1 = arg1.getPriority(fileNames); - if (p0 < p1) - return 1; - if (p0 > p1) - return -1; - return 0; - } - }); + try { + + tempDisableRefresh = true; + monitor.beginTask("Import Executables", executableImporters.size()); + synchronized (executableImporters) { + Collections.sort(executableImporters, new Comparator() { - for (IExecutableImporter importer : executableImporters) { - if (handled || monitor.isCanceled()) { - break; - } - } - } + public int compare(IExecutableImporter arg0, IExecutableImporter arg1) { + int p0 = arg0.getPriority(fileNames); + int p1 = arg1.getPriority(fileNames); + if (p0 < p1) + return 1; + if (p0 > p1) + return -1; + return 0; + }}); - scheduleRefresh(); - } - - /** - * Determines if the given executable is currently known by the manager - * - * @param exePath - * the absolute path to the executable - * @return true if the manager knows about it, false otherwise - */ - public boolean executableExists(IPath exePath) { - synchronized (executablesMap) { - for (List exes : executablesMap.values()) { - for (Executable exe : exes) { - if (exe.getPath().equals(exePath)) { - return true; - + for (IExecutableImporter importer : executableImporters) { + handled = importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1)); + if (handled || monitor.isCanceled()) { + break; } } } + } finally { + tempDisableRefresh = false; } - - return false; + + if (handled) + refreshExecutables(monitor); + monitor.done(); } + public ISourceFileRemapping[] getSourceFileRemappings() { + return sourceFileRemappings.toArray(new ISourceFileRemapping[sourceFileRemappings.size()]); + } public IExecutableProvider[] getExecutableProviders() { return executableProviders.toArray(new IExecutableProvider[executableProviders.size()]); @@ -348,17 +254,31 @@ return sourceFileProviders.toArray(new ISourceFilesProvider[sourceFileProviders.size()]); } + public IExecutableImporter[] getExecutableImporters() { + return executableImporters.toArray(new IExecutableImporter[executableImporters.size()]); + } + + public void scheduleRefresh(IExecutableProvider provider, long delay) { + refreshNeeded = true; + refreshJob.schedule(delay); + } + + public boolean refreshNeeded() { + return refreshNeeded; + } + + public boolean executableExists(IPath exePath) { + synchronized (executables) { + return executables.containsKey(exePath.toOSString()); + } + } + /** - * Get the list of source files for the given executable - * @param executable the executable - * @param monitor progress monitor - * @return an array of source files which may be empty - */ - public String[] getSourceFiles(final Executable executable, IProgressMonitor monitor) { - String[] result = new String[0]; - trace("getSourceFiles called at " + getStringFromTimestamp(System.currentTimeMillis()) + " for " + executable.getPath().toOSString()); - - + * @since 6.0 + */ + public String[] getSourceFiles(final Executable executable, + IProgressMonitor monitor) { + String[] result = new String[0]; synchronized (sourceFileProviders) { Collections.sort(sourceFileProviders, new Comparator() { @@ -375,467 +295,67 @@ monitor.beginTask("Finding source files in " + executable.getName(), sourceFileProviders.size()); for (ISourceFilesProvider provider : sourceFileProviders) { String[] sourceFiles = provider.getSourceFiles(executable, new SubProgressMonitor(monitor, 1)); - if (sourceFiles.length > 0) { + if (sourceFiles.length > 0) + { result = sourceFiles; - trace("getSourceFiles got " + sourceFiles.length + " files from " + provider.toString()); break; } } - - trace("getSourceFiles returned at " + getStringFromTimestamp(System.currentTimeMillis())); - monitor.done(); } return result; } /** - * Removes the given executables - * @param executables the array of executables to be removed - * @param monitor progress monitor - * @return IStatus of the operation - * - * @since 6.0 - */ - public IStatus removeExecutables(Executable[] executables, - IProgressMonitor monitor) { - MultiStatus status = new MultiStatus(CDebugCorePlugin.PLUGIN_ID, - IStatus.WARNING, - "Couldn't remove all of the selected executables", null); + * @since 6.0 + */ + public IStatus removeExecutables(Executable[] executables, IProgressMonitor monitor) { + IExecutableProvider[] exeProviders = getExecutableProviders(); + + IStatus result = Status.OK_STATUS; + + Arrays.sort(exeProviders, new Comparator() { - monitor.beginTask("Remove Executables", executables.length); + public int compare(IExecutableProvider arg0, IExecutableProvider arg1) { + int p0 = arg0.getPriority(); + int p1 = arg1.getPriority(); + if (p0 > p1) + return 1; + if (p0 < p1) + return -1; + return 0; + } + }); + MultiStatus combinedStatus = new MultiStatus(CDebugCorePlugin.PLUGIN_ID, IStatus.WARNING, "Couldn't remove all of the selected executables", null); + refreshNeeded = false; + monitor.beginTask("Remove Executables", exeProviders.length); for (Executable executable : executables) { - IProjectExecutablesProvider provider = getExecutablesProviderForProject(executable - .getProject()); - if (provider != null) { - IStatus result = provider.removeExecutable(executable, - new SubProgressMonitor(monitor, 1)); - if (result.isOK()) { - // remove the exe from the list - List exes = executablesMap.get(executable - .getProject()); - if (exes != null) { - exes.remove(executable); - } - } else { - status.add(result); - } + boolean handled = false; + IStatus rmvStatus = Status.OK_STATUS;; + for (IExecutableProvider provider : exeProviders) { + if (!handled) + { + rmvStatus = provider.removeExecutable(executable, new SubProgressMonitor(monitor, 1)); + handled = rmvStatus.getSeverity() == IStatus.OK; + } + } + if (!handled) + { + combinedStatus.add(rmvStatus); + result = combinedStatus; } } - - // notify listeners that the list has changed. only do this if at least - // one delete succeeded. - if (status.getChildren().length != executables.length) { - synchronized (changeListeners) { - for (IExecutablesChangeListener listener : changeListeners) { - listener.executablesListChanged(); - } - } - } - - return status; + monitor.done(); + + return result; } /** - * Refresh the list of executables for the given projects - * @param projects the list of projects, or null. if null or the list - * is empty, all projects will be refreshed. - */ - public void refresh(List projects) { - if (projects == null || projects.size() == 0) { - // clear the entire cache - executablesMap.clear(); - } else { - for (IProject project : projects) { - executablesMap.remove(project); - } - } - - scheduleRefresh(); - - } - - public void resourceChanged(IResourceChangeEvent event) { - - synchronized (executablesMap) { - // project needs to be refreshed after a build/clean as the binary - // may - // be added/removed/renamed etc. - if (event.getType() == IResourceChangeEvent.POST_BUILD) { - Object obj = event.getSource(); - if (obj != null && obj instanceof IProject) { - if (executablesMap.containsKey(obj)) { - List executables = executablesMap - .remove(obj); - - trace("Scheduling refresh because project " - + ((IProject) obj).getName() - + " built or cleaned"); - - scheduleRefresh(); - - // notify the listeners that these executables have - // possibly changed - if (executables != null && executables.size() > 0) { - synchronized (changeListeners) { - for (IExecutablesChangeListener listener : changeListeners) { - listener.executablesChanged(executables); - } - } - } - } - } - return; - } - - // refresh when projects are opened or closed. note that deleted - // projects are handled later in this method. new projects are - // handled - // in handleEvent. resource changed events always start at the - // workspace - // root, so projects are the next level down - boolean refreshNeeded = false; - IResourceDelta[] projects = event.getDelta().getAffectedChildren(); - for (IResourceDelta projectDelta : projects) { - if ((projectDelta.getFlags() & IResourceDelta.OPEN) != 0) { - if (projectDelta.getKind() == IResourceDelta.CHANGED) { - // project was opened or closed - if (executablesMap.containsKey(projectDelta - .getResource())) { - executablesMap.remove(projectDelta.getResource()); - } - refreshNeeded = true; - } - } - } - - if (refreshNeeded) { - trace("Scheduling refresh because project(s) opened or closed"); - - scheduleRefresh(); - return; - } - - try { - event.getDelta().accept(new IResourceDeltaVisitor() { - - public boolean visit(IResourceDelta delta) - throws CoreException { - if (delta.getKind() == IResourceDelta.ADDED - || delta.getKind() == IResourceDelta.REMOVED) { - IResource deltaResource = delta.getResource(); - if (deltaResource != null) { - boolean refresh = false; - if (delta.getKind() == IResourceDelta.REMOVED - && deltaResource instanceof IProject) { - // project deleted - if (executablesMap - .containsKey(deltaResource)) { - executablesMap.remove(deltaResource); - refresh = true; - - trace("Scheduling refresh because project " - + deltaResource.getName() - + " deleted"); - } - } else { - // see if a binary has been added/removed - IPath resourcePath = deltaResource - .getLocation(); - if (resourcePath != null - && Executable - .isExecutableFile(resourcePath)) { - if (executablesMap - .containsKey(deltaResource - .getProject())) { - executablesMap.remove(deltaResource - .getProject()); - refresh = true; - - trace("Scheduling refresh because a binary was added/removed"); - } - } - } - - if (refresh) { - scheduleRefresh(); - return false; - } - } - } - return true; - } - }); - } catch (CoreException e) { - } - } - } - - public void handleEvent(CProjectDescriptionEvent event) { - // this handles the cases where the active build configuration changes, - // and when new projects are created or loaded at startup. - boolean refresh = false; - - int eventType = event.getEventType(); - - if (eventType == CProjectDescriptionEvent.DATA_APPLIED) { - - synchronized (executablesMap) { - // see if the active build config has changed - ICProjectDescription newDesc = event - .getNewCProjectDescription(); - ICProjectDescription oldDesc = event - .getOldCProjectDescription(); - if (oldDesc != null && newDesc != null) { - String newConfigName = newDesc.getActiveConfiguration() - .getName(); - String oldConfigName = oldDesc.getActiveConfiguration() - .getName(); - if (!newConfigName.equals(oldConfigName)) { - if (executablesMap.containsKey(newDesc.getProject())) { - executablesMap.remove(newDesc.getProject()); - refresh = true; - - trace("Scheduling refresh because active build configuration changed"); - } - } - } else if (newDesc != null && oldDesc == null) { - // project just created - refresh = true; - - trace("Scheduling refresh because project " - + newDesc.getProject().getName() + " created"); - } - } - } - - if (refresh) { - scheduleRefresh(); - } - } - - private List getProjectsToCheck() { - - List projects = new ArrayList(); - - synchronized (executablesMap) { - // look for any CDT projects not in our cache - for (IProject project : ResourcesPlugin.getWorkspace().getRoot() - .getProjects()) { - if (!executablesMap.containsKey(project)) { - if (CoreModel.hasCNature(project)) { - projects.add(project); - } - } - } - } - - return projects; + * @since 6.0 + */ + public void setRefreshNeeded(boolean refresh) { + refreshNeeded = true; } - private void scheduleRefresh() { - trace("scheduleRefresh called at " - + getStringFromTimestamp(System.currentTimeMillis())); - - refreshJob.cancel(); - refreshJob.schedule(); - } - - private IProjectExecutablesProvider getExecutablesProviderForProject( - IProject project) { - IProjectExecutablesProvider provider = executablesProviderMap - .get(project); - if (provider == null) { - // not cached yet. get the list of project natures from the - // providers and - // pick the one with the closest match - try { - IProjectDescription description = project.getDescription(); - int mostNaturesMatched = 0; - for (IProjectExecutablesProvider exeProvider : executableProviders) { - List natures = exeProvider.getProjectNatures(); - - int naturesMatched = 0; - for (String nature : description.getNatureIds()) { - if (natures.contains(nature)) { - naturesMatched++; - } - } - - if (naturesMatched > mostNaturesMatched) { - provider = exeProvider; - mostNaturesMatched = naturesMatched; - } - } - - // cache it - executablesProviderMap.put(project, provider); - - } catch (CoreException e) { - e.printStackTrace(); - } - } - - return provider; - } - - private void loadExecutableProviderExtensions() { - executableProviders = Collections - .synchronizedList(new ArrayList()); - - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = extensionRegistry - .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID - + ".ExecutablesProvider"); //$NON-NLS-1$ - IExtension[] extensions = extensionPoint.getExtensions(); - - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - IConfigurationElement[] elements = extension - .getConfigurationElements(); - IConfigurationElement element = elements[0]; - - boolean failed = false; - try { - Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ - if (extObject instanceof IProjectExecutablesProvider) { - executableProviders - .add((IProjectExecutablesProvider) extObject); - } else { - failed = true; - } - } catch (CoreException e) { - failed = true; - } - - if (failed) { - CDebugCorePlugin - .log("Unable to load ExecutablesProvider extension from " - + extension.getContributor().getName()); - } - } - } - - private void loadSoureFileProviderExtensions() { - sourceFileProviders = Collections - .synchronizedList(new ArrayList()); - - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = extensionRegistry - .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID - + ".SourceFilesProvider"); //$NON-NLS-1$ - IExtension[] extensions = extensionPoint.getExtensions(); - - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - IConfigurationElement[] elements = extension - .getConfigurationElements(); - IConfigurationElement element = elements[0]; - - boolean failed = false; - try { - Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ - if (extObject instanceof ISourceFilesProvider) { - sourceFileProviders.add((ISourceFilesProvider) extObject); - } else { - failed = true; - } - } catch (CoreException e) { - failed = true; - } - - if (failed) { - CDebugCorePlugin - .log("Unable to load SourceFilesProvider extension from " - + extension.getContributor().getName()); - } - } - } - - private void loadSoureRemappingExtensions() { - sourceFileRemappings = Collections - .synchronizedList(new ArrayList()); - - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = extensionRegistry - .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID - + ".SourceRemappingProvider"); //$NON-NLS-1$ - IExtension[] extensions = extensionPoint.getExtensions(); - - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - IConfigurationElement[] elements = extension - .getConfigurationElements(); - IConfigurationElement element = elements[0]; - - boolean failed = false; - try { - Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ - if (extObject instanceof ISourceFileRemapping) { - sourceFileRemappings.add((ISourceFileRemapping) extObject); - } else { - failed = true; - } - } catch (CoreException e) { - failed = true; - } - - if (failed) { - CDebugCorePlugin - .log("Unable to load SourceRemappingProvider extension from " - + extension.getContributor().getName()); - } - } - } - - private void loadExecutableImporterExtensions() { - executableImporters = Collections - .synchronizedList(new ArrayList()); - - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint extensionPoint = extensionRegistry - .getExtensionPoint(CDebugCorePlugin.PLUGIN_ID - + ".ExecutablesImporter"); //$NON-NLS-1$ - IExtension[] extensions = extensionPoint.getExtensions(); - - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - IConfigurationElement[] elements = extension - .getConfigurationElements(); - IConfigurationElement element = elements[0]; - - boolean failed = false; - try { - Object extObject = element.createExecutableExtension("class"); //$NON-NLS-1$ - if (extObject instanceof IExecutableImporter) { - executableImporters.add((IExecutableImporter) extObject); - } else { - failed = true; - } - } catch (CoreException e) { - failed = true; - } - - if (failed) { - CDebugCorePlugin - .log("Unable to load ExecutablesImporter extension from " - + extension.getContributor().getName()); - } - } - } - - private void trace(String msg) { - if (DEBUG) { - // TODO use Logger? - System.out.println(msg); - } - } - - private String getStringFromTimestamp(long timestamp) { - return DateFormat.getTimeInstance(DateFormat.MEDIUM).format( - new Date(timestamp)); - } -} - - \ No newline at end of file +} \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutableImporter.java Wed Aug 05 17:35:39 2009 -0500 @@ -42,6 +42,6 @@ /** * @since 6.0 */ - public boolean importExecutables(String[] fileNames, IProgressMonitor monitor); + public abstract boolean importExecutables(String[] fileNames, IProgressMonitor monitor); -} +} \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,21 +12,9 @@ package org.eclipse.cdt.debug.core.executables; import java.util.EventListener; -import java.util.List; public interface IExecutablesChangeListener extends EventListener { - /** - * Called whenever the list of executables in the workspace changes, e.g. a - * project was opened/closed/created/deleted - */ - public void executablesListChanged(); + public void executablesChanged(IExecutablesChangeEvent event); - /** - * Called whenever some executables have changed, e.g. when a project is rebuilt or - * cleaned. The content may have changed for example, so the list of source files - * may be different. - * @param executables - */ - public void executablesChanged(List executables); -} +} \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IProjectExecutablesProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.executables; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; - -/** - * IProjectExecutablesProvider supplies a list of executables for a project - * to the Executables Manager. - * - * @author Warren Paul - * - */ -public interface IProjectExecutablesProvider { - - /** - * Get the list of project natures that should be present in projects that - * this provider will get the list of executables for. Since there could - * be any number of executable providers, the one that matches the given - * project natures the closest will be chosen. - * @return the list of project nature id's - */ - List getProjectNatures(); - - /** - * Get the list of executables for the given project - * @param project the project to get the executables for - * @param monitor progress monitor - * @return the list of executables (which may be empty) - */ - List getExecutables(IProject project, IProgressMonitor monitor); - - /** - * Remove the given executable. Note that the project can be obtained from Executable. - * @param executable the executable to remove - * @param monitor progress monitor - * @return the status of the remove operation - */ - IStatus removeExecutable(Executable executable, IProgressMonitor monitor); - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.debug.core.executables; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.cdt.core.CCProjectNature; -import org.eclipse.cdt.core.CProjectNature; -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.CDebugCorePlugin; -import org.eclipse.cdt.internal.core.model.CModelManager; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubMonitor; -import org.eclipse.debug.core.DebugPlugin; - -public class StandardExecutableProvider implements IProjectExecutablesProvider { - - List supportedNatureIds = new ArrayList(); - - public StandardExecutableProvider() { - supportedNatureIds.add(CProjectNature.C_NATURE_ID); - supportedNatureIds.add(CCProjectNature.CC_NATURE_ID); - } - - public List getProjectNatures() { - return supportedNatureIds; - } - - public List getExecutables(IProject project, IProgressMonitor monitor) { - List executables = new ArrayList(); - - ICProject cproject = CModelManager.getDefault().create(project); - try { - IBinary[] binaries = cproject.getBinaryContainer().getBinaries(); - - SubMonitor progress = SubMonitor.convert(monitor, binaries.length); - - for (IBinary binary : binaries) { - if (progress.isCanceled()) { - break; - } - - if (binary.isExecutable() || binary.isSharedLib()) { - IPath exePath = binary.getResource().getLocation(); - if (exePath == null) - exePath = binary.getPath(); - executables.add(new Executable(exePath, project, binary.getResource())); - } - - progress.worked(1); - } - } catch (CModelException e) { - } - - return executables; - } - - public IStatus removeExecutable(Executable executable, IProgressMonitor monitor) { - IResource exeResource = executable.getResource(); - if (exeResource != null) { - try { - exeResource.delete(true, monitor); - } catch (CoreException e) { - DebugPlugin.log( e ); - } - return Status.OK_STATUS; - } - return new Status(IStatus.WARNING, CDebugCorePlugin.PLUGIN_ID, "Can't remove " + executable.getName() + ": it is built by project \"" + executable.getProject().getName() + "\""); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToAddress.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,35 +1,35 @@ -/******************************************************************************* - * Copyright (c) 2008 Freescale Semiconductor and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Freescale Semiconductor - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; - -import org.eclipse.cdt.core.IAddress; -import org.eclipse.debug.core.DebugException; - -/** - * Provides the ability to move the instruction pointer of a debug target to the given address. - * @since 6.0 - */ -public interface IMoveToAddress { - - /** - * Returns whether this operation is currently available for this element. - * - * @return whether this operation is currently available - */ - public boolean canMoveToAddress( IAddress address ); - - /** - * Causes this element can move the instruction pointer to the specified address. - * - * @exception DebugException on failure. Reasons include: - */ - public void moveToAddress( IAddress address ) throws DebugException; -} +/******************************************************************************* + * Copyright (c) 2008 Freescale Semiconductor and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Freescale Semiconductor - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.core.model; + +import org.eclipse.cdt.core.IAddress; +import org.eclipse.debug.core.DebugException; + +/** + * Provides the ability to move the instruction pointer of a debug target to the given address. + * @since 6.0 + */ +public interface IMoveToAddress { + + /** + * Returns whether this operation is currently available for this element. + * + * @return whether this operation is currently available + */ + public boolean canMoveToAddress( IAddress address ); + + /** + * Causes this element can move the instruction pointer to the specified address. + * + * @exception DebugException on failure. Reasons include: + */ + public void moveToAddress( IAddress address ) throws DebugException; +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IMoveToLine.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,34 +1,34 @@ -/******************************************************************************* - * Copyright (c) 2008 Freescale Semiconductor and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Freescale Semiconductor - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; - -import org.eclipse.debug.core.DebugException; - -/** - * Provides the ability to move the instruction pointer of a debug target to the given line. - * @since 6.0 - */ -public interface IMoveToLine { - - /** - * Returns whether this operation is currently available for this file and line number. - * - * @return whether this operation is currently available - */ - public boolean canMoveToLine( String fileName, int lineNumber ); - - /** - * Causes this element to move the instruction pointer to the specified line. - * - * @exception DebugException on failure. Reasons include: - */ - public void moveToLine( String fileName, int lineNumber ) throws DebugException; -} +/******************************************************************************* + * Copyright (c) 2008 Freescale Semiconductor and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Freescale Semiconductor - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.core.model; + +import org.eclipse.debug.core.DebugException; + +/** + * Provides the ability to move the instruction pointer of a debug target to the given line. + * @since 6.0 + */ +public interface IMoveToLine { + + /** + * Returns whether this operation is currently available for this file and line number. + * + * @return whether this operation is currently available + */ + public boolean canMoveToLine( String fileName, int lineNumber ); + + /** + * Causes this element to move the instruction pointer to the specified line. + * + * @exception DebugException on failure. Reasons include: + */ + public void moveToLine( String fileName, int lineNumber ) throws DebugException; +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtAddress.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,35 +1,35 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; - -import org.eclipse.cdt.core.IAddress; -import org.eclipse.debug.core.DebugException; - -/** - * Provides the ability to resume a debug target at the given address. - * @since 6.0 - */ -public interface IResumeAtAddress { - - /** - * Returns whether this operation is currently available for this element. - * - * @return whether this operation is currently available - */ - public boolean canResumeAtAddress( IAddress address ); - - /** - * Causes this element to resume the execution at the specified address. - * - * @exception DebugException on failure. Reasons include: - */ - public void resumeAtAddress( IAddress address ) throws DebugException; -} +/******************************************************************************* + * Copyright (c) 2004, 2008 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.core.model; + +import org.eclipse.cdt.core.IAddress; +import org.eclipse.debug.core.DebugException; + +/** + * Provides the ability to resume a debug target at the given address. + * @since 6.0 + */ +public interface IResumeAtAddress { + + /** + * Returns whether this operation is currently available for this element. + * + * @return whether this operation is currently available + */ + public boolean canResumeAtAddress( IAddress address ); + + /** + * Causes this element to resume the execution at the specified address. + * + * @exception DebugException on failure. Reasons include: + */ + public void resumeAtAddress( IAddress address ) throws DebugException; +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IResumeAtLine.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,50 +1,50 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.core.model; - -import org.eclipse.core.resources.IFile; -import org.eclipse.debug.core.DebugException; - -/** - * Provides the ability to resume a debug target at the given line. - * @since 6.0 - */ -public interface IResumeAtLine { - - /** - * Returns whether this operation is currently available for this file and line number. - * - * @return whether this operation is currently available - */ - public boolean canResumeAtLine( IFile file, int lineNumber ); - - /** - * Causes this element to resume the execution at the specified line. - * - * @exception DebugException - * on failure. Reasons include: - */ - public void resumeAtLine( IFile file, int lineNumber ) throws DebugException; - - /** - * Returns whether this operation is currently available for this file and line number. - * - * @return whether this operation is currently available - */ - public boolean canResumeAtLine( String fileName, int lineNumber ); - - /** - * Causes this element to resume the execution at the specified line. - * - * @exception DebugException on failure. Reasons include: - */ - public void resumeAtLine( String fileName, int lineNumber ) throws DebugException; -} +/******************************************************************************* + * Copyright (c) 2004, 2006 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.core.model; + +import org.eclipse.core.resources.IFile; +import org.eclipse.debug.core.DebugException; + +/** + * Provides the ability to resume a debug target at the given line. + * @since 6.0 + */ +public interface IResumeAtLine { + + /** + * Returns whether this operation is currently available for this file and line number. + * + * @return whether this operation is currently available + */ + public boolean canResumeAtLine( IFile file, int lineNumber ); + + /** + * Causes this element to resume the execution at the specified line. + * + * @exception DebugException + * on failure. Reasons include: + */ + public void resumeAtLine( IFile file, int lineNumber ) throws DebugException; + + /** + * Returns whether this operation is currently available for this file and line number. + * + * @return whether this operation is currently available + */ + public boolean canResumeAtLine( String fileName, int lineNumber ); + + /** + * Causes this element to resume the execution at the specified line. + * + * @exception DebugException on failure. Reasons include: + */ + public void resumeAtLine( String fileName, int lineNumber ) throws DebugException; +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/ExecutablesChangeEvent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/ExecutablesChangeEvent.java Wed Aug 05 17:35:39 2009 -0500 @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2008 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.core.executables; + +import org.eclipse.cdt.debug.core.executables.Executable; +import org.eclipse.cdt.debug.core.executables.IExecutablesChangeEvent; +import org.eclipse.core.runtime.PlatformObject; + +public class ExecutablesChangeEvent extends PlatformObject implements IExecutablesChangeEvent { + + private Executable[] oldExecutables; + private Executable[] newExecutables; + + public ExecutablesChangeEvent(Executable[] oldList, Executable[] newList) { + oldExecutables = oldList; + newExecutables = newList; + } + + public Executable[] getCurrentExecutables() { + return newExecutables; + } + + public Executable[] getPreviousExecutables() { + return oldExecutables; + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardExecutableProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardExecutableProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -0,0 +1,194 @@ +/******************************************************************************* + * Copyright (c) 2008 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.debug.internal.core.executables; + +import java.util.ArrayList; + +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.ICProject; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.executables.Executable; +import org.eclipse.cdt.debug.core.executables.ExecutablesManager; +import org.eclipse.cdt.debug.core.executables.IExecutableProvider; +import org.eclipse.cdt.internal.core.model.CModelManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugPlugin; + +public class StandardExecutableProvider implements IResourceChangeListener, ICProjectDescriptionListener, IExecutableProvider { + + private ArrayList executables = new ArrayList(); + + public StandardExecutableProvider() { + ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); + CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, + CProjectDescriptionEvent.DATA_APPLIED | CProjectDescriptionEvent.LOADED); + } + + public void resourceChanged(IResourceChangeEvent event) { + + // refresh when projects are opened or closed. note that deleted + // projects are handled later + // in this method. new projects are handled in handleEvent. + // resource changed events always start at the workspace root, so + // projects + // are the next level down + IResourceDelta[] projects = event.getDelta().getAffectedChildren(); + for (IResourceDelta projectDelta : projects) { + if ((projectDelta.getFlags() & IResourceDelta.OPEN) != 0) { + if (projectDelta.getKind() == IResourceDelta.CHANGED) { + // project was opened or closed + ExecutablesManager.getExecutablesManager().scheduleRefresh(this, 0); + return; + } + } + } + + try { + final StandardExecutableProvider provider = this; + event.getDelta().accept(new IResourceDeltaVisitor() { + + public boolean visit(IResourceDelta delta) throws CoreException { + if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.REMOVED) { + IResource deltaResource = delta.getResource(); + if (deltaResource != null) { + boolean refresh = false; + if (delta.getKind() == IResourceDelta.REMOVED && deltaResource instanceof IProject) { + // project deleted + refresh = true; + } else { + // see if a binary has been added/removed + IPath resourcePath = delta.getResource().getLocation(); + if (resourcePath != null && Executable.isExecutableFile(resourcePath)) { + refresh = true; + } + } + if (refresh) { + ExecutablesManager.getExecutablesManager().scheduleRefresh(provider, 0); + return false; + } + } + } + return true; + } + }); + } catch (CoreException e) { + } + } + + public void handleEvent(CProjectDescriptionEvent event) { + // this handles the cases where the active build configuration changes, + // and when new + // projects are created. + boolean refresh = false; + + int eventType = event.getEventType(); + + if (eventType == CProjectDescriptionEvent.DATA_APPLIED) { + // see if the active build config has changed + ICProjectDescription newDesc = event.getNewCProjectDescription(); + ICProjectDescription oldDesc = event.getOldCProjectDescription(); + if (oldDesc != null && newDesc != null) { + String newConfigName = newDesc.getActiveConfiguration().getName(); + String oldConfigName = oldDesc.getActiveConfiguration().getName(); + refresh = (!newConfigName.equals(oldConfigName)); + } else if (newDesc != null && oldDesc == null) { + // project just created + refresh = true; + } + } + + if (refresh) { + ExecutablesManager.getExecutablesManager().scheduleRefresh(this, 0); + } + } + + public Executable[] getExecutables(IProgressMonitor monitor) { + synchronized (executables) { + executables.clear(); + + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject[] projects = root.getProjects(); + + monitor.beginTask("Checking C/C++ Projects", projects.length); + + for (IProject project : projects) { + + if (monitor.isCanceled()) + break; + + try { + if (CoreModel.hasCNature(project)) { + CModelManager manager = CModelManager.getDefault(); + ICProject cproject = manager.create(project); + try { + IBinary[] binaries = cproject.getBinaryContainer().getBinaries(); + for (IBinary binary : binaries) { + if (binary.isExecutable() || binary.isSharedLib()) { + IPath exePath = binary.getResource().getLocation(); + if (exePath == null) + exePath = binary.getPath(); + Executable exe = new Executable(exePath, project, binary.getResource()); + executables.add(exe); + } + } + } catch (CModelException e) { + } + } + } catch (Exception e) { + DebugPlugin.log( e ); + } + monitor.worked(1); + } + monitor.done(); + } + return executables.toArray(new Executable[executables.size()]); + } + + public int getPriority() { + return NORMAL_PRIORITY; + } + + public IStatus removeExecutable(Executable executable, IProgressMonitor monitor) { + IResource exeResource = executable.getResource(); + if (exeResource != null) + { + if (exeResource.isLinked()) + { + try { + exeResource.delete(true, monitor); + } catch (CoreException e) { + DebugPlugin.log( e ); + } + } + return Status.OK_STATUS; + } + return new Status(IStatus.WARNING, CDebugCorePlugin.PLUGIN_ID, "Can't remove " + executable.getName() + ": it is built by project \"" + executable.getProject().getName() + "\""); + } + +} \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupDirector.java Wed Aug 05 17:35:39 2009 -0500 @@ -7,8 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - * Nokia - Added support for AbsoluteSourceContainer( 159833 ) - * Texas Instruments - added extension point for source container type (279473) + * Nokia - Added support for AbsoluteSourceContainer( 159833 ) *******************************************************************************/ package org.eclipse.cdt.debug.internal.core.sourcelookup; @@ -16,7 +15,6 @@ import java.util.HashSet; import java.util.Set; -import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer; import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer; @@ -24,12 +22,8 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.debug.core.sourcelookup.ISourceContainerType; @@ -37,6 +31,7 @@ import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer; import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer; import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer; +import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer; /** * C/C++ source lookup director. @@ -44,7 +39,16 @@ public class CSourceLookupDirector extends AbstractSourceLookupDirector { private static Set fSupportedTypes; - private static Object fSupportedTypesLock = new Object(); + + static { + fSupportedTypes = new HashSet(); + fSupportedTypes.add( WorkspaceSourceContainer.TYPE_ID ); + fSupportedTypes.add( ProjectSourceContainer.TYPE_ID ); + fSupportedTypes.add( FolderSourceContainer.TYPE_ID ); + fSupportedTypes.add( DirectorySourceContainer.TYPE_ID ); + fSupportedTypes.add( MappingSourceContainer.TYPE_ID ); + fSupportedTypes.add( AbsolutePathSourceContainer.TYPE_ID ); + } /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants() @@ -56,7 +60,6 @@ * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#supportsSourceContainerType(org.eclipse.debug.core.sourcelookup.ISourceContainerType) */ public boolean supportsSourceContainerType( ISourceContainerType type ) { - readSupportedContainerTypes(); return fSupportedTypes.contains( type.getId() ); } @@ -189,23 +192,4 @@ } return path; } - - // >> Bugzilla 279473 - private void readSupportedContainerTypes() { - synchronized (fSupportedTypesLock) { - if( fSupportedTypes == null) { - fSupportedTypes = new HashSet(); - String name = CDebugCorePlugin.PLUGIN_ID+".supportedSourceContainerTypes"; //$NON-NLS-1$; - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( name); - if( extensionPoint != null) - for( IExtension extension : extensionPoint.getExtensions()) - for( IConfigurationElement configurationElements : extension.getConfigurationElements()) { - String id = configurationElements.getAttribute("id");//$NON-NLS-1$; - if( id != null) - fSupportedTypes.add(id); - } - } - } - } - // << Bugzilla 279473 } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui.tests/core/org/eclipse/cdt/debug/core/tests/.cvsignore diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesContentProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesContentProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesContentProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -17,6 +17,9 @@ import org.eclipse.cdt.debug.core.executables.Executable; import org.eclipse.cdt.debug.core.executables.ExecutablesManager; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITreeContentProvider; @@ -26,7 +29,10 @@ class ExecutablesContentProvider extends ColumnLabelProvider implements IStructuredContentProvider, ITreeContentProvider { + private TreeViewer viewer; + public ExecutablesContentProvider(TreeViewer viewer) { + this.viewer = viewer; } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { @@ -37,8 +43,42 @@ public Object[] getElements(final Object inputElement) { if (inputElement instanceof ExecutablesManager) { - ExecutablesManager em = (ExecutablesManager) inputElement; - return em.getExecutables().toArray(); + final ExecutablesManager em = (ExecutablesManager) inputElement; + if (em.refreshNeeded()) { + // do this asynchronously. just return an empty array + // immediately, and then refresh the view + // once the list of executables has been calculated. this can + // take a while and we don't want + // to block the UI. + Job refreshJob = new Job(Messages.ExecutablesContentProvider_FetchingExecutables) { + + @Override + protected IStatus run(IProgressMonitor monitor) { + IStatus status = em.refreshExecutables(monitor); + + // Are we in the UIThread? If so spin it until we are done + if (!viewer.getControl().isDisposed()) { + if (viewer.getControl().getDisplay().getThread() == Thread.currentThread()) { + viewer.refresh(inputElement); + } else { + viewer.getControl().getDisplay().asyncExec(new Runnable() { + public void run() { + viewer.refresh(inputElement); + } + }); + } + } + + monitor.done(); + return status; + } + }; + + refreshJob.schedule(); + + } else { + return em.getExecutables(); + } } return new Object[] {}; } @@ -100,4 +140,4 @@ return new Object[] {}; } -} +} \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java Wed Aug 05 17:35:39 2009 -0500 @@ -271,10 +271,6 @@ public void selectionChanged(SelectionChangedEvent event) { ISelection newSelection = event.getSelection(); if (newSelection instanceof IStructuredSelection) { - - // update the remove action - removeAction.setEnabled(!newSelection.isEmpty()); - final Object firstElement = ((IStructuredSelection) newSelection).getFirstElement(); Job setectExeJob = new Job(Messages.ExecutablesView_Select_Executable) { @@ -285,19 +281,20 @@ Executable executable = (Executable)firstElement; this.setName(Messages.ExecutablesView_Finding_Sources_Job_Name + executable.getName()); executable.getSourceFiles(monitor); - - UIJob selectExeUIJob = new UIJob(Messages.ExecutablesView_Select_Executable){ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - sourceFilesViewer.setInput(firstElement); + } + UIJob selectExeUIJob = new UIJob(Messages.ExecutablesView_Select_Executable){ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + sourceFilesViewer.setInput(firstElement); + if (firstElement instanceof Executable) { sourceFilesViewer.packColumns(); - return Status.OK_STATUS; - }}; + } + return Status.OK_STATUS; + }}; selectExeUIJob.schedule(); - } - return Status.OK_STATUS; + return Status.OK_STATUS; }}; - setectExeJob.schedule(); + setectExeJob.schedule(); } } }); @@ -363,7 +360,6 @@ private Action createRemoveAction() { Action action = new Action("Remove") { - public void run() { ISelection selection = getExecutablesViewer().getSelection(); if (selection instanceof IStructuredSelection) @@ -408,7 +404,7 @@ action.setToolTipText("Remove the selected executables"); action.setImageDescriptor(ExecutablesView.DESC_REMOVE); action.setDisabledImageDescriptor(ExecutablesView.DESC_REMOVE_DISABLED); - action.setEnabled(false); + action.setEnabled(true); return action; } @@ -464,7 +460,7 @@ private Action createRefreshAction() { Action action = new Action(Messages.ExecutablesView_Refresh) { public void run() { - ExecutablesManager.getExecutablesManager().refresh(null); + ExecutablesManager.getExecutablesManager().scheduleRefresh(null, 0); } }; action.setToolTipText(Messages.ExecutablesView_RefreshList); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewer.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewer.java Wed Aug 05 17:35:39 2009 -0500 @@ -10,9 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.views.executables; -import java.util.List; import org.eclipse.cdt.debug.core.executables.Executable; import org.eclipse.cdt.debug.core.executables.ExecutablesManager; +import org.eclipse.cdt.debug.core.executables.IExecutablesChangeEvent; import org.eclipse.cdt.debug.core.executables.IExecutablesChangeListener; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -166,50 +166,39 @@ return new ExecutablesViewerComparator(sortType, column_sort_order[sortType]); } - public void executablesChanged(final List executables) { - // some executables have been updated. if one of them is currently - // selected, we need to update the source file list - UIJob refreshJob = new UIJob(Messages.ExecutablesViewer_RefreshExecutablesView) { - - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - // if the user has selected an executable, they expect its - // list of source files to be refreshed automatically - if (getSelection() != null && - getSelection() instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection)getSelection(); - - Object firstElement = selection.getFirstElement(); - if (firstElement instanceof Executable) { - Executable executable = (Executable) firstElement; - if (executables.contains(executable)) { - executable.setRefreshSourceFiles(true); - setSelection(selection); - } - } - } - return Status.OK_STATUS; - } - }; - refreshJob.schedule(); - } - - public void executablesListChanged() { - // Executables list has changed so refresh the view. - UIJob refreshJob = new UIJob( - Messages.ExecutablesViewer_RefreshExecutablesView) { + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.debug.core.executables.IExecutablesChangeListener#executablesChanged(org.eclipse.cdt.debug.core.executables.IExecutablesChangeEvent) + */ + public void executablesChanged(IExecutablesChangeEvent event) { + // Executables have changed so refresh the view. + final ExecutablesViewer viewer = this; + UIJob refreshJob = new UIJob(Messages.ExecutablesViewer_RefreshExecutablesView) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { - refresh(null); - packColumns(); + // if the user has selected an executable, they expect its + // list of source files to be refreshed automatically + if (viewer.getSelection() != null && + viewer.getSelection() instanceof IStructuredSelection) { + IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); + + Object firstElement = selection.getFirstElement(); + if (firstElement instanceof Executable) { + Executable executable = (Executable)firstElement; + executable.setRefreshSourceFiles(true); + viewer.setSelection(selection); + } + } + viewer.refresh(null); + viewer.packColumns(); return Status.OK_STATUS; } }; refreshJob.schedule(); } - @Override protected String getColumnOrderKey() { return P_COLUMN_ORDER_KEY_EXE; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesLabelProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesLabelProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesLabelProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -70,7 +70,7 @@ if (cell.getElement() instanceof ITranslationUnit) { Executable executable = (Executable) viewer.getInput(); Path path = new Path(executable.getOriginalLocation((ITranslationUnit) cell.getElement())); - cell.setText(path.toOSString()); + cell.setText(executable.getOriginalLocation((ITranslationUnit) cell.getElement())); if (path.toFile().exists()) cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); else diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsList.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,183 +1,183 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import java.util.StringTokenizer; - -import org.eclipse.cdt.debug.core.CDebugCorePlugin; -import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; - -public class ActionsList extends Composite { - - private Button removeButton; - private Table table; - - public ActionsList(Composite parent, int style) { - super(parent, style); - final GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 4; - setLayout(gridLayout); - - table = new Table(this, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI); - final GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - gridData.heightHint = 60; - gridData.horizontalSpan = 4; - table.setLayoutData(gridData); - table.setLinesVisible(true); - table.setHeaderVisible(true); - table.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - }); - - final TableColumn nameTableColumn = new TableColumn(table, SWT.NONE); - nameTableColumn.setWidth(120); - nameTableColumn.setText(Messages.getString("ActionsList.0")); //$NON-NLS-1$ - - final TableColumn typeTableColumn = new TableColumn(table, SWT.NONE); - typeTableColumn.setWidth(120); - typeTableColumn.setText(Messages.getString("ActionsList.1")); //$NON-NLS-1$ - - final TableColumn summaryTableColumn = new TableColumn(table, SWT.NONE); - summaryTableColumn.setWidth(120); - summaryTableColumn.setText(Messages.getString("ActionsList.2")); //$NON-NLS-1$ - - removeButton = new Button(this, SWT.NONE); - removeButton.setText(Messages.getString("ActionsList.3")); //$NON-NLS-1$ - - removeButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - HandleRemoveButton(); - } - }); - - final Button upButton = new Button(this, SWT.NONE); - upButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(final SelectionEvent e) { - HandleUpButton(); - } - }); - upButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END)); - upButton.setText(Messages.getString("ActionsList.4")); //$NON-NLS-1$ - - final Button downButton = new Button(this, SWT.NONE); - downButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(final SelectionEvent e) { - HandleDownButton(); - } - }); - downButton.setText(Messages.getString("ActionsList.5")); //$NON-NLS-1$ - // - - updateButtons(); - } - - public void addAction(IBreakpointAction action) { - TableItem[] currentItems = table.getItems(); - boolean alreadyInList = false; - for (int i = 0; i < currentItems.length && !alreadyInList; i++) { - alreadyInList = ((IBreakpointAction) currentItems[i].getData()).equals(action); - } - if (!alreadyInList) { - final TableItem tableItem = new TableItem(table, SWT.NONE); - tableItem.setText(0, action.getName()); - tableItem.setText(1, action.getTypeName()); - tableItem.setText(2, action.getSummary()); - tableItem.setData(action); - } - updateButtons(); - } - - public String getActionNames() { - StringBuffer result = new StringBuffer(); - TableItem[] currentItems = table.getItems(); - for (int i = 0; i < currentItems.length; i++) { - if (i > 0) - result.append(','); - result.append(((IBreakpointAction) currentItems[i].getData()).getName()); - } - return result.toString(); - } - - private void swapItems(TableItem item, TableItem item2) { - String[] item2Text = { item2.getText(0), item2.getText(1), item2.getText(2) }; - Object item2Data = item2.getData(); - - item2.setText(0, item.getText(0)); - item2.setText(1, item.getText(1)); - item2.setText(2, item.getText(2)); - item2.setData(item.getData()); - - item.setText(0, item2Text[0]); - item.setText(1, item2Text[1]); - item.setText(2, item2Text[2]); - item.setData(item2Data); - } - - protected void HandleUpButton() { - int[] selection = table.getSelectionIndices(); - if (selection.length == 1 && selection[0] > 0) { - swapItems(table.getItem(selection[0]), table.getItem(selection[0] - 1)); - } - } - - protected void HandleDownButton() { - int[] selection = table.getSelectionIndices(); - if (selection.length == 1 && selection[0] < (table.getItemCount() - 1)) { - swapItems(table.getItem(selection[0]), table.getItem(selection[0] + 1)); - } - } - - protected void HandleRemoveButton() { - table.remove(table.getSelectionIndices()); - if (table.getItemCount() > 0) { - table.select(table.getItemCount() - 1); - } - updateButtons(); - } - - public void setNames(String actionNames) { - - table.removeAll(); - StringTokenizer tok = new StringTokenizer(actionNames, ","); //$NON-NLS-1$ - - while (tok.hasMoreTokens()) { - String actionName = tok.nextToken(); - IBreakpointAction action = CDebugCorePlugin.getDefault().getBreakpointActionManager().findBreakpointAction(actionName); - if (action != null) { - final TableItem tableItem = new TableItem(table, SWT.NONE); - tableItem.setText(0, action.getName()); - tableItem.setText(1, action.getTypeName()); - tableItem.setText(2, action.getSummary()); - tableItem.setData(action); - } - } - - updateButtons(); - } - - public void updateButtons() { - TableItem[] selectedItems = table.getSelection(); - removeButton.setEnabled(selectedItems.length > 0); - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.util.StringTokenizer; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +public class ActionsList extends Composite { + + private Button removeButton; + private Table table; + + public ActionsList(Composite parent, int style) { + super(parent, style); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 4; + setLayout(gridLayout); + + table = new Table(this, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI); + final GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); + gridData.heightHint = 60; + gridData.horizontalSpan = 4; + table.setLayoutData(gridData); + table.setLinesVisible(true); + table.setHeaderVisible(true); + table.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateButtons(); + } + }); + + final TableColumn nameTableColumn = new TableColumn(table, SWT.NONE); + nameTableColumn.setWidth(120); + nameTableColumn.setText(Messages.getString("ActionsList.0")); //$NON-NLS-1$ + + final TableColumn typeTableColumn = new TableColumn(table, SWT.NONE); + typeTableColumn.setWidth(120); + typeTableColumn.setText(Messages.getString("ActionsList.1")); //$NON-NLS-1$ + + final TableColumn summaryTableColumn = new TableColumn(table, SWT.NONE); + summaryTableColumn.setWidth(120); + summaryTableColumn.setText(Messages.getString("ActionsList.2")); //$NON-NLS-1$ + + removeButton = new Button(this, SWT.NONE); + removeButton.setText(Messages.getString("ActionsList.3")); //$NON-NLS-1$ + + removeButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + HandleRemoveButton(); + } + }); + + final Button upButton = new Button(this, SWT.NONE); + upButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(final SelectionEvent e) { + HandleUpButton(); + } + }); + upButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END)); + upButton.setText(Messages.getString("ActionsList.4")); //$NON-NLS-1$ + + final Button downButton = new Button(this, SWT.NONE); + downButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(final SelectionEvent e) { + HandleDownButton(); + } + }); + downButton.setText(Messages.getString("ActionsList.5")); //$NON-NLS-1$ + // + + updateButtons(); + } + + public void addAction(IBreakpointAction action) { + TableItem[] currentItems = table.getItems(); + boolean alreadyInList = false; + for (int i = 0; i < currentItems.length && !alreadyInList; i++) { + alreadyInList = ((IBreakpointAction) currentItems[i].getData()).equals(action); + } + if (!alreadyInList) { + final TableItem tableItem = new TableItem(table, SWT.NONE); + tableItem.setText(0, action.getName()); + tableItem.setText(1, action.getTypeName()); + tableItem.setText(2, action.getSummary()); + tableItem.setData(action); + } + updateButtons(); + } + + public String getActionNames() { + StringBuffer result = new StringBuffer(); + TableItem[] currentItems = table.getItems(); + for (int i = 0; i < currentItems.length; i++) { + if (i > 0) + result.append(','); + result.append(((IBreakpointAction) currentItems[i].getData()).getName()); + } + return result.toString(); + } + + private void swapItems(TableItem item, TableItem item2) { + String[] item2Text = { item2.getText(0), item2.getText(1), item2.getText(2) }; + Object item2Data = item2.getData(); + + item2.setText(0, item.getText(0)); + item2.setText(1, item.getText(1)); + item2.setText(2, item.getText(2)); + item2.setData(item.getData()); + + item.setText(0, item2Text[0]); + item.setText(1, item2Text[1]); + item.setText(2, item2Text[2]); + item.setData(item2Data); + } + + protected void HandleUpButton() { + int[] selection = table.getSelectionIndices(); + if (selection.length == 1 && selection[0] > 0) { + swapItems(table.getItem(selection[0]), table.getItem(selection[0] - 1)); + } + } + + protected void HandleDownButton() { + int[] selection = table.getSelectionIndices(); + if (selection.length == 1 && selection[0] < (table.getItemCount() - 1)) { + swapItems(table.getItem(selection[0]), table.getItem(selection[0] + 1)); + } + } + + protected void HandleRemoveButton() { + table.remove(table.getSelectionIndices()); + if (table.getItemCount() > 0) { + table.select(table.getItemCount() - 1); + } + updateButtons(); + } + + public void setNames(String actionNames) { + + table.removeAll(); + StringTokenizer tok = new StringTokenizer(actionNames, ","); //$NON-NLS-1$ + + while (tok.hasMoreTokens()) { + String actionName = tok.nextToken(); + IBreakpointAction action = CDebugCorePlugin.getDefault().getBreakpointActionManager().findBreakpointAction(actionName); + if (action != null) { + final TableItem tableItem = new TableItem(table, SWT.NONE); + tableItem.setText(0, action.getName()); + tableItem.setText(1, action.getTypeName()); + tableItem.setText(2, action.getSummary()); + tableItem.setData(action); + } + } + + updateButtons(); + } + + public void updateButtons() { + TableItem[] selectedItems = table.getSelection(); + removeButton.setEnabled(selectedItems.length > 0); + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPreferencePage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPreferencePage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPreferencePage.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,64 +1,64 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import org.eclipse.cdt.debug.core.CDebugCorePlugin; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.PlatformUI; - -public class ActionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - - private String contextHelpID = "breakpoint_actions_page_help"; //$NON-NLS-1$ - - public ActionsPreferencePage() { - super(); - setPreferenceStore(CDebugUIPlugin.getDefault().getPreferenceStore()); - } - - public Control createContents(Composite parent) { - Composite container = new Composite(parent, SWT.NONE); - final GridLayout gridLayout = new GridLayout(); - container.setLayout(gridLayout); - - final Label breakpointActionsAvailableLabel = new Label(container, SWT.NONE); - breakpointActionsAvailableLabel.setText(Messages.getString("ActionsPreferencePage.0")); //$NON-NLS-1$ - final GlobalActionsList actionsList = new GlobalActionsList(container, SWT.NONE, false); - actionsList.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); - - String helpContextID = CDebugUIPlugin.PLUGIN_ID + "." + contextHelpID; //$NON-NLS-1$ - PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), helpContextID); - - return container; - } - - public void init(IWorkbench workbench) { - } - - public boolean performCancel() { - CDebugCorePlugin.getDefault().getBreakpointActionManager().revertActionData(); - return super.performCancel(); - } - - public boolean performOk() { - CDebugCorePlugin.getDefault().getBreakpointActionManager().saveActionData(); - return super.performOk(); - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.PlatformUI; + +public class ActionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + private String contextHelpID = "breakpoint_actions_page_help"; //$NON-NLS-1$ + + public ActionsPreferencePage() { + super(); + setPreferenceStore(CDebugUIPlugin.getDefault().getPreferenceStore()); + } + + public Control createContents(Composite parent) { + Composite container = new Composite(parent, SWT.NONE); + final GridLayout gridLayout = new GridLayout(); + container.setLayout(gridLayout); + + final Label breakpointActionsAvailableLabel = new Label(container, SWT.NONE); + breakpointActionsAvailableLabel.setText(Messages.getString("ActionsPreferencePage.0")); //$NON-NLS-1$ + final GlobalActionsList actionsList = new GlobalActionsList(container, SWT.NONE, false); + actionsList.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); + + String helpContextID = CDebugUIPlugin.PLUGIN_ID + "." + contextHelpID; //$NON-NLS-1$ + PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), helpContextID); + + return container; + } + + public void init(IWorkbench workbench) { + } + + public boolean performCancel() { + CDebugCorePlugin.getDefault().getBreakpointActionManager().revertActionData(); + return super.performCancel(); + } + + public boolean performOk() { + CDebugCorePlugin.getDefault().getBreakpointActionManager().saveActionData(); + return super.performOk(); + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ActionsPropertyPage.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,126 +1,126 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import org.eclipse.cdt.debug.core.CDebugCorePlugin; -import org.eclipse.cdt.debug.core.breakpointactions.BreakpointActionManager; -import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IBreakpoint; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.dialogs.PropertyPage; - -public class ActionsPropertyPage extends PropertyPage { - - private ActionsList actionsList; - private IMarker breakpointMarker; - private GlobalActionsList globalActionsList; - private String savedActionNames; - - public ActionsPropertyPage() { - super(); - } - - public Control createContents(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - - IBreakpoint breakpoint = (IBreakpoint) this.getElement().getAdapter(org.eclipse.debug.core.model.IBreakpoint.class); - breakpointMarker = breakpoint.getMarker(); - savedActionNames = breakpointMarker.getAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ - - final Label actionsTriggeredWhenLabel = new Label(container, SWT.NONE); - final GridData gridData_2 = new GridData(); - gridData_2.horizontalSpan = 2; - actionsTriggeredWhenLabel.setLayoutData(gridData_2); - actionsTriggeredWhenLabel.setText(Messages.getString("ActionsPropertyPage.1")); //$NON-NLS-1$ - - actionsList = new ActionsList(container, SWT.NONE); - final GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); - gridData.horizontalSpan = 2; - actionsList.setLayoutData(gridData); - - final GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - container.setLayout(gridLayout); - - final Label label = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL); - final GridData gridData_4 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gridData_4.horizontalSpan = 2; - label.setLayoutData(gridData_4); - - final Label allAvailableActionsLabel = new Label(container, SWT.NONE); - final GridData gridData_3 = new GridData(); - gridData_3.horizontalSpan = 2; - allAvailableActionsLabel.setLayoutData(gridData_3); - allAvailableActionsLabel.setText(Messages.getString("ActionsPropertyPage.2")); //$NON-NLS-1$ - - globalActionsList = new GlobalActionsList(container, SWT.NONE, true); - final GridData gridData_1 = new GridData(GridData.FILL_BOTH); - gridData_1.horizontalSpan = 2; - globalActionsList.setLayoutData(gridData_1); - // - - String actionNames = breakpointMarker.getAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ - actionsList.setNames(actionNames); - - globalActionsList.getAttachButton().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - HandleAttachButton(); - } - }); - - return container; - } - - protected void HandleAttachButton() { - - IBreakpointAction[] selectedActions = globalActionsList.getSelectedActions(); - for (int i = 0; i < selectedActions.length; i++) { - actionsList.addAction(selectedActions[i]); - } - } - - protected void performDefaults() { - try { - breakpointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ - actionsList.setNames(""); //$NON-NLS-1$ - } catch (CoreException e) { - } - super.performDefaults(); - } - - public boolean performCancel() { - try { - breakpointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, savedActionNames); - CDebugCorePlugin.getDefault().getBreakpointActionManager().revertActionData(); - } catch (CoreException e) { - } - return super.performCancel(); - } - - public boolean performOk() { - try { - CDebugCorePlugin.getDefault().getBreakpointActionManager().saveActionData(); - breakpointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, actionsList.getActionNames()); - } catch (CoreException e) { - } - return super.performOk(); - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.breakpointactions.BreakpointActionManager; +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.dialogs.PropertyPage; + +public class ActionsPropertyPage extends PropertyPage { + + private ActionsList actionsList; + private IMarker breakpointMarker; + private GlobalActionsList globalActionsList; + private String savedActionNames; + + public ActionsPropertyPage() { + super(); + } + + public Control createContents(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + + IBreakpoint breakpoint = (IBreakpoint) this.getElement().getAdapter(org.eclipse.debug.core.model.IBreakpoint.class); + breakpointMarker = breakpoint.getMarker(); + savedActionNames = breakpointMarker.getAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ + + final Label actionsTriggeredWhenLabel = new Label(container, SWT.NONE); + final GridData gridData_2 = new GridData(); + gridData_2.horizontalSpan = 2; + actionsTriggeredWhenLabel.setLayoutData(gridData_2); + actionsTriggeredWhenLabel.setText(Messages.getString("ActionsPropertyPage.1")); //$NON-NLS-1$ + + actionsList = new ActionsList(container, SWT.NONE); + final GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); + gridData.horizontalSpan = 2; + actionsList.setLayoutData(gridData); + + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + container.setLayout(gridLayout); + + final Label label = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL); + final GridData gridData_4 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gridData_4.horizontalSpan = 2; + label.setLayoutData(gridData_4); + + final Label allAvailableActionsLabel = new Label(container, SWT.NONE); + final GridData gridData_3 = new GridData(); + gridData_3.horizontalSpan = 2; + allAvailableActionsLabel.setLayoutData(gridData_3); + allAvailableActionsLabel.setText(Messages.getString("ActionsPropertyPage.2")); //$NON-NLS-1$ + + globalActionsList = new GlobalActionsList(container, SWT.NONE, true); + final GridData gridData_1 = new GridData(GridData.FILL_BOTH); + gridData_1.horizontalSpan = 2; + globalActionsList.setLayoutData(gridData_1); + // + + String actionNames = breakpointMarker.getAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ + actionsList.setNames(actionNames); + + globalActionsList.getAttachButton().addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + HandleAttachButton(); + } + }); + + return container; + } + + protected void HandleAttachButton() { + + IBreakpointAction[] selectedActions = globalActionsList.getSelectedActions(); + for (int i = 0; i < selectedActions.length; i++) { + actionsList.addAction(selectedActions[i]); + } + } + + protected void performDefaults() { + try { + breakpointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, ""); //$NON-NLS-1$ + actionsList.setNames(""); //$NON-NLS-1$ + } catch (CoreException e) { + } + super.performDefaults(); + } + + public boolean performCancel() { + try { + breakpointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, savedActionNames); + CDebugCorePlugin.getDefault().getBreakpointActionManager().revertActionData(); + } catch (CoreException e) { + } + return super.performCancel(); + } + + public boolean performOk() { + try { + CDebugCorePlugin.getDefault().getBreakpointActionManager().saveActionData(); + breakpointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, actionsList.getActionNames()); + } catch (CoreException e) { + } + return super.performOk(); + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/GlobalActionsList.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,200 +1,200 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.cdt.debug.core.CDebugCorePlugin; -import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; - -public class GlobalActionsList extends Composite { - - private Button attachButton = null; - private Button deleteButton = null; - private Button editButton = null; - private Button newButton = null; - private Table table = null; - - public GlobalActionsList(Composite parent, int style, boolean useAttachButton) { - super(parent, style); - final GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 5; - setLayout(gridLayout); - - table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); - table.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - HandleEditButton(); - } - - }); - - final GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.horizontalSpan = 5; - table.setLayoutData(gridData); - table.setLinesVisible(true); - table.setHeaderVisible(true); - - final TableColumn nameTableColumn = new TableColumn(table, SWT.NONE); - nameTableColumn.setWidth(120); - nameTableColumn.setText(Messages.getString("GlobalActionsList.0")); //$NON-NLS-1$ - - final TableColumn typeTableColumn = new TableColumn(table, SWT.NONE); - typeTableColumn.setWidth(120); - typeTableColumn.setText(Messages.getString("GlobalActionsList.1")); //$NON-NLS-1$ - - final TableColumn summaryTableColumn = new TableColumn(table, SWT.NONE); - summaryTableColumn.setWidth(120); - summaryTableColumn.setText(Messages.getString("GlobalActionsList.2")); //$NON-NLS-1$ - - ArrayList actions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActions(); - boolean hasActions = actions.size() > 0; - - for (Iterator iter = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActions().iterator(); iter.hasNext();) { - IBreakpointAction element = (IBreakpointAction) iter.next(); - final TableItem tableItem = new TableItem(table, SWT.NONE); - tableItem.setText(0, element.getName()); - tableItem.setText(1, element.getTypeName()); - tableItem.setText(2, element.getSummary()); - tableItem.setData(element); - } - - if (useAttachButton) { - attachButton = new Button(this, SWT.NONE); - attachButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL)); - attachButton.setText(Messages.getString("GlobalActionsList.3")); //$NON-NLS-1$ - } - - newButton = new Button(this, SWT.NONE); - newButton.setLayoutData(new GridData()); - newButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - - try { - HandleNewButton(); - } catch (CoreException e1) { - } - } - }); - newButton.setText(Messages.getString("GlobalActionsList.4")); //$NON-NLS-1$ - newButton.setEnabled(CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions().length > 0); - - editButton = new Button(this, SWT.NONE); - editButton.setText(Messages.getString("GlobalActionsList.5")); //$NON-NLS-1$ - editButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - - HandleEditButton(); - } - }); - if (!useAttachButton) - editButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL + GridData.HORIZONTAL_ALIGN_END)); - editButton.setEnabled(hasActions); - - deleteButton = new Button(this, SWT.NONE); - deleteButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - HandleDeleteButton(); - } - }); - deleteButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); - deleteButton.setText(Messages.getString("GlobalActionsList.6")); //$NON-NLS-1$ - deleteButton.setEnabled(hasActions); - // - } - - public Button getAttachButton() { - return attachButton; - } - - public IBreakpointAction[] getSelectedActions() { - TableItem[] selectedItems = table.getSelection(); - IBreakpointAction[] actionList = new IBreakpointAction[selectedItems.length]; - int actionCount = 0; - for (int i = 0; i < selectedItems.length; i++) { - actionList[actionCount++] = (IBreakpointAction) selectedItems[i].getData(); - } - return actionList; - } - - protected void HandleDeleteButton() { - TableItem[] selectedItems = table.getSelection(); - for (int i = 0; i < selectedItems.length; i++) { - IBreakpointAction action = (IBreakpointAction) selectedItems[i].getData(); - CDebugCorePlugin.getDefault().getBreakpointActionManager().deleteAction(action); - } - table.remove(table.getSelectionIndices()); - if (table.getItemCount() > 0) { - table.select(table.getItemCount() - 1); - } - updateButtons(); - } - - protected void HandleEditButton() { - - TableItem[] selectedItems = table.getSelection(); - IBreakpointAction action = (IBreakpointAction) selectedItems[0].getData(); - - ActionDialog dialog = new ActionDialog(this.getShell(), action); - int result = dialog.open(); - if (result == Window.OK) { - action.setName(dialog.getActionName()); - selectedItems[0].setText(0, action.getName()); - selectedItems[0].setText(1, action.getTypeName()); - selectedItems[0].setText(2, action.getSummary()); - } - - } - - protected void HandleNewButton() throws CoreException { - - ActionDialog dialog = new ActionDialog(this.getShell(), null); - int result = dialog.open(); - if (result == Window.OK) { - IBreakpointAction action = dialog.getBreakpointAction(); - action.setName(dialog.getActionName()); - CDebugCorePlugin.getDefault().getBreakpointActionManager().addAction(action); - final TableItem tableItem = new TableItem(table, SWT.NONE); - tableItem.setText(0, action.getName()); - tableItem.setText(1, action.getTypeName()); - tableItem.setText(2, action.getSummary()); - tableItem.setData(action); - - } - - } - - public void updateButtons() { - TableItem[] selectedItems = table.getSelection(); - if (attachButton != null) - attachButton.setEnabled(selectedItems.length > 0); - deleteButton.setEnabled(selectedItems.length > 0); - editButton.setEnabled(selectedItems.length > 0); - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +public class GlobalActionsList extends Composite { + + private Button attachButton = null; + private Button deleteButton = null; + private Button editButton = null; + private Button newButton = null; + private Table table = null; + + public GlobalActionsList(Composite parent, int style, boolean useAttachButton) { + super(parent, style); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 5; + setLayout(gridLayout); + + table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); + table.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateButtons(); + } + + public void widgetDefaultSelected(SelectionEvent e) { + HandleEditButton(); + } + + }); + + final GridData gridData = new GridData(GridData.FILL_BOTH); + gridData.horizontalSpan = 5; + table.setLayoutData(gridData); + table.setLinesVisible(true); + table.setHeaderVisible(true); + + final TableColumn nameTableColumn = new TableColumn(table, SWT.NONE); + nameTableColumn.setWidth(120); + nameTableColumn.setText(Messages.getString("GlobalActionsList.0")); //$NON-NLS-1$ + + final TableColumn typeTableColumn = new TableColumn(table, SWT.NONE); + typeTableColumn.setWidth(120); + typeTableColumn.setText(Messages.getString("GlobalActionsList.1")); //$NON-NLS-1$ + + final TableColumn summaryTableColumn = new TableColumn(table, SWT.NONE); + summaryTableColumn.setWidth(120); + summaryTableColumn.setText(Messages.getString("GlobalActionsList.2")); //$NON-NLS-1$ + + ArrayList actions = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActions(); + boolean hasActions = actions.size() > 0; + + for (Iterator iter = CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActions().iterator(); iter.hasNext();) { + IBreakpointAction element = (IBreakpointAction) iter.next(); + final TableItem tableItem = new TableItem(table, SWT.NONE); + tableItem.setText(0, element.getName()); + tableItem.setText(1, element.getTypeName()); + tableItem.setText(2, element.getSummary()); + tableItem.setData(element); + } + + if (useAttachButton) { + attachButton = new Button(this, SWT.NONE); + attachButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL)); + attachButton.setText(Messages.getString("GlobalActionsList.3")); //$NON-NLS-1$ + } + + newButton = new Button(this, SWT.NONE); + newButton.setLayoutData(new GridData()); + newButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + + try { + HandleNewButton(); + } catch (CoreException e1) { + } + } + }); + newButton.setText(Messages.getString("GlobalActionsList.4")); //$NON-NLS-1$ + newButton.setEnabled(CDebugCorePlugin.getDefault().getBreakpointActionManager().getBreakpointActionExtensions().length > 0); + + editButton = new Button(this, SWT.NONE); + editButton.setText(Messages.getString("GlobalActionsList.5")); //$NON-NLS-1$ + editButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + + HandleEditButton(); + } + }); + if (!useAttachButton) + editButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL + GridData.HORIZONTAL_ALIGN_END)); + editButton.setEnabled(hasActions); + + deleteButton = new Button(this, SWT.NONE); + deleteButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + HandleDeleteButton(); + } + }); + deleteButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + deleteButton.setText(Messages.getString("GlobalActionsList.6")); //$NON-NLS-1$ + deleteButton.setEnabled(hasActions); + // + } + + public Button getAttachButton() { + return attachButton; + } + + public IBreakpointAction[] getSelectedActions() { + TableItem[] selectedItems = table.getSelection(); + IBreakpointAction[] actionList = new IBreakpointAction[selectedItems.length]; + int actionCount = 0; + for (int i = 0; i < selectedItems.length; i++) { + actionList[actionCount++] = (IBreakpointAction) selectedItems[i].getData(); + } + return actionList; + } + + protected void HandleDeleteButton() { + TableItem[] selectedItems = table.getSelection(); + for (int i = 0; i < selectedItems.length; i++) { + IBreakpointAction action = (IBreakpointAction) selectedItems[i].getData(); + CDebugCorePlugin.getDefault().getBreakpointActionManager().deleteAction(action); + } + table.remove(table.getSelectionIndices()); + if (table.getItemCount() > 0) { + table.select(table.getItemCount() - 1); + } + updateButtons(); + } + + protected void HandleEditButton() { + + TableItem[] selectedItems = table.getSelection(); + IBreakpointAction action = (IBreakpointAction) selectedItems[0].getData(); + + ActionDialog dialog = new ActionDialog(this.getShell(), action); + int result = dialog.open(); + if (result == Window.OK) { + action.setName(dialog.getActionName()); + selectedItems[0].setText(0, action.getName()); + selectedItems[0].setText(1, action.getTypeName()); + selectedItems[0].setText(2, action.getSummary()); + } + + } + + protected void HandleNewButton() throws CoreException { + + ActionDialog dialog = new ActionDialog(this.getShell(), null); + int result = dialog.open(); + if (result == Window.OK) { + IBreakpointAction action = dialog.getBreakpointAction(); + action.setName(dialog.getActionName()); + CDebugCorePlugin.getDefault().getBreakpointActionManager().addAction(action); + final TableItem tableItem = new TableItem(table, SWT.NONE); + tableItem.setText(0, action.getName()); + tableItem.setText(1, action.getTypeName()); + tableItem.setText(2, action.getSummary()); + tableItem.setData(action); + + } + + } + + public void updateButtons() { + TableItem[] selectedItems = table.getSelection(); + if (attachButton != null) + attachButton.setEnabled(selectedItems.length > 0); + deleteButton.setEnabled(selectedItems.length > 0); + editButton.setEnabled(selectedItems.length > 0); + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/IBreakpointActionPage.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,32 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; -import org.eclipse.swt.widgets.Composite; - -/** - * - * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE - * PLUG-INS USING THIS INTERFACE WILL NEED - * TO BE REVISED TO WORK WITH FUTURE VERSIONS OF CDT. - * - */ - -public interface IBreakpointActionPage { - - public void actionDialogCanceled(); - - public void actionDialogOK(); - - public Composite createComposite(IBreakpointAction action, Composite composite, int style); - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.swt.widgets.Composite; + +/** + * + * THIS INTERFACE IS PROVISIONAL AND WILL CHANGE IN THE FUTURE + * PLUG-INS USING THIS INTERFACE WILL NEED + * TO BE REVISED TO WORK WITH FUTURE VERSIONS OF CDT. + * + */ + +public interface IBreakpointActionPage { + + public void actionDialogCanceled(); + + public void actionDialogOK(); + + public Composite createComposite(IBreakpointAction action, Composite composite, int style); + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogActionComposite.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,72 +1,72 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public class LogActionComposite extends Composite { - - private Button expressionButton; - private LogActionPage logActionPage; - private Text message; - - public LogActionComposite(Composite parent, int style, LogActionPage logActionPage) { - super(parent, style); - final GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - setLayout(gridLayout); - - this.logActionPage = logActionPage; - - final Label messageToLogLabel = new Label(this, SWT.NONE); - messageToLogLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); - messageToLogLabel.setText(Messages.getString("LogActionComposite.0")); //$NON-NLS-1$ - - message = new Text(this, SWT.BORDER | SWT.WRAP); - message.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1)); - - expressionButton = new Button(this, SWT.CHECK); - expressionButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(final SelectionEvent e) { - } - }); - expressionButton.setText(Messages.getString("LogActionComposite.1")); //$NON-NLS-1$ - // - - message.setText(this.logActionPage.getLogAction().getMessage()); - expressionButton.setSelection(this.logActionPage.getLogAction().isEvaluateExpression()); - } - - protected void checkSubclass() { - // Disable the check that prevents subclassing of SWT components - } - - public void dispose() { - super.dispose(); - } - - public boolean getIsExpression() { - return expressionButton.getSelection(); - } - - public String getMessage() { - return message.getText(); - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class LogActionComposite extends Composite { + + private Button expressionButton; + private LogActionPage logActionPage; + private Text message; + + public LogActionComposite(Composite parent, int style, LogActionPage logActionPage) { + super(parent, style); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + setLayout(gridLayout); + + this.logActionPage = logActionPage; + + final Label messageToLogLabel = new Label(this, SWT.NONE); + messageToLogLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1)); + messageToLogLabel.setText(Messages.getString("LogActionComposite.0")); //$NON-NLS-1$ + + message = new Text(this, SWT.BORDER | SWT.WRAP); + message.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1)); + + expressionButton = new Button(this, SWT.CHECK); + expressionButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(final SelectionEvent e) { + } + }); + expressionButton.setText(Messages.getString("LogActionComposite.1")); //$NON-NLS-1$ + // + + message.setText(this.logActionPage.getLogAction().getMessage()); + expressionButton.setSelection(this.logActionPage.getLogAction().isEvaluateExpression()); + } + + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + public void dispose() { + super.dispose(); + } + + public boolean getIsExpression() { + return expressionButton.getSelection(); + } + + public String getMessage() { + return message.getText(); + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/Messages.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,32 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.breakpointactions.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - // TODO Auto-generated method stub - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.breakpointactions.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + // TODO Auto-generated method stub + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceConstants.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,26 +1,26 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -/** - * Constant definitions for plug-in preferences - */ -public class PreferenceConstants { - - public static final String P_PATH = "pathPreference"; //$NON-NLS-1$ - - public static final String P_BOOLEAN = "booleanPreference"; //$NON-NLS-1$ - - public static final String P_CHOICE = "choicePreference"; //$NON-NLS-1$ - - public static final String P_STRING = "stringPreference"; //$NON-NLS-1$ - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String P_PATH = "pathPreference"; //$NON-NLS-1$ + + public static final String P_BOOLEAN = "booleanPreference"; //$NON-NLS-1$ + + public static final String P_CHOICE = "choicePreference"; //$NON-NLS-1$ + + public static final String P_STRING = "stringPreference"; //$NON-NLS-1$ + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/PreferenceInitializer.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,34 +1,34 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; - -/** - * Class used to initialize default preference values. - */ -public class PreferenceInitializer extends AbstractPreferenceInitializer { - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() - */ - public void initializeDefaultPreferences() { - IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore(); - store.setDefault(PreferenceConstants.P_BOOLEAN, true); - store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); //$NON-NLS-1$ - store.setDefault(PreferenceConstants.P_STRING, Messages.getString("PreferenceInitializer.1")); //$NON-NLS-1$ - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.P_BOOLEAN, true); + store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); //$NON-NLS-1$ + store.setDefault(PreferenceConstants.P_STRING, Messages.getString("PreferenceInitializer.1")); //$NON-NLS-1$ + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionComposite.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,164 +1,164 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; - -public class SoundActionComposite extends Composite { - - private static final String[] soundFileExtensions = new String[] { "*.wav", "*.mid", "*.au", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - "*.aiff" }; //$NON-NLS-1$ - - private Combo combo_1; - private ModifyListener comboModifyListener = null; - private File selectedSoundFile = null; - private SoundActionPage soundActionPage; - private Label soundFilePathLabel; - private Button tryItButton; - - /** - * Create the composite - * - * @param parent - * @param style - * @param page - */ - public SoundActionComposite(Composite parent, int style, SoundActionPage page) { - super(parent, style); - soundActionPage = page; - final GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - setLayout(gridLayout); - - final Label playSoundLabel = new Label(this, SWT.NONE); - playSoundLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); - playSoundLabel.setText(Messages.getString("SoundActionComposite.4")); //$NON-NLS-1$ - - combo_1 = new Combo(this, SWT.READ_ONLY); - final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); - combo_1.setLayoutData(gridData); - - comboModifyListener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (combo_1.getText().length() > 0) { - setSoundFile(combo_1.getText()); - } - } - }; - rebuildRecentSoundsCombo(); - combo_1.addModifyListener(comboModifyListener); - - final String mediaPath = page.getMediaPath(); - - final Button browseButton = new Button(this, SWT.NONE); - browseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - FileDialog dialog = new FileDialog(getShell(), SWT.NONE); - dialog.setText(Messages.getString("SoundActionComposite.5")); //$NON-NLS-1$ - dialog.setFilterExtensions(soundFileExtensions); - if (mediaPath.length() > 0) - dialog.setFilterPath(mediaPath); - - String res = dialog.open(); - if (res != null) { - setSoundFile(res); - } - } - }); - browseButton.setText(Messages.getString("SoundActionComposite.6")); //$NON-NLS-1$ - - tryItButton = new Button(this, SWT.NONE); - tryItButton.setLayoutData(new GridData()); - tryItButton.setText(Messages.getString("SoundActionComposite.7")); //$NON-NLS-1$ - tryItButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - File soundFile = new File(soundFilePathLabel.getText()); - playSoundFile(soundFile); - } - }); - - soundFilePathLabel = new Label(this, SWT.NONE); - final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL); - gridData_1.horizontalSpan = 2; - soundFilePathLabel.setLayoutData(gridData_1); - soundFilePathLabel.setText(""); //$NON-NLS-1$ - - // - if (soundActionPage.getSoundAction().getSoundFile() != null) - setSoundFile(soundActionPage.getSoundAction().getSoundFile().getAbsolutePath()); - } - - private void addRecentSound(File soundFile) { - soundActionPage.addRecentSound(soundFile); - rebuildRecentSoundsCombo(); - } - - protected void checkSubclass() { - // Disable the check that prevents subclassing of SWT components - } - - public void dispose() { - super.dispose(); - } - - public File getSoundFile() { - return selectedSoundFile; - } - - protected void playSoundFile(File soundFile) { - SoundAction.playSoundFile(soundFile); - } - - private void rebuildRecentSoundsCombo() { - combo_1.removeAll(); - - ArrayList sortedSounds = new ArrayList(soundActionPage.getRecentSounds()); - Collections.sort(sortedSounds); - - for (Iterator iter = sortedSounds.iterator(); iter.hasNext();) { - File element = (File) iter.next(); - combo_1.add(element.getAbsolutePath()); - } - } - - private void setSoundFile(String filePath) { - combo_1.removeModifyListener(comboModifyListener); - File soundFile = new File(filePath); - if (soundFile.exists()) { - addRecentSound(soundFile); - combo_1.setText(soundFile.getAbsolutePath()); - soundFilePathLabel.setText(filePath); - tryItButton.setEnabled(true); - selectedSoundFile = soundFile; - } else { - soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$ - tryItButton.setEnabled(false); - } - combo_1.addModifyListener(comboModifyListener); - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; + +public class SoundActionComposite extends Composite { + + private static final String[] soundFileExtensions = new String[] { "*.wav", "*.mid", "*.au", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "*.aiff" }; //$NON-NLS-1$ + + private Combo combo_1; + private ModifyListener comboModifyListener = null; + private File selectedSoundFile = null; + private SoundActionPage soundActionPage; + private Label soundFilePathLabel; + private Button tryItButton; + + /** + * Create the composite + * + * @param parent + * @param style + * @param page + */ + public SoundActionComposite(Composite parent, int style, SoundActionPage page) { + super(parent, style); + soundActionPage = page; + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + setLayout(gridLayout); + + final Label playSoundLabel = new Label(this, SWT.NONE); + playSoundLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); + playSoundLabel.setText(Messages.getString("SoundActionComposite.4")); //$NON-NLS-1$ + + combo_1 = new Combo(this, SWT.READ_ONLY); + final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + combo_1.setLayoutData(gridData); + + comboModifyListener = new ModifyListener() { + public void modifyText(ModifyEvent e) { + if (combo_1.getText().length() > 0) { + setSoundFile(combo_1.getText()); + } + } + }; + rebuildRecentSoundsCombo(); + combo_1.addModifyListener(comboModifyListener); + + final String mediaPath = page.getMediaPath(); + + final Button browseButton = new Button(this, SWT.NONE); + browseButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell(), SWT.NONE); + dialog.setText(Messages.getString("SoundActionComposite.5")); //$NON-NLS-1$ + dialog.setFilterExtensions(soundFileExtensions); + if (mediaPath.length() > 0) + dialog.setFilterPath(mediaPath); + + String res = dialog.open(); + if (res != null) { + setSoundFile(res); + } + } + }); + browseButton.setText(Messages.getString("SoundActionComposite.6")); //$NON-NLS-1$ + + tryItButton = new Button(this, SWT.NONE); + tryItButton.setLayoutData(new GridData()); + tryItButton.setText(Messages.getString("SoundActionComposite.7")); //$NON-NLS-1$ + tryItButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + File soundFile = new File(soundFilePathLabel.getText()); + playSoundFile(soundFile); + } + }); + + soundFilePathLabel = new Label(this, SWT.NONE); + final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL); + gridData_1.horizontalSpan = 2; + soundFilePathLabel.setLayoutData(gridData_1); + soundFilePathLabel.setText(""); //$NON-NLS-1$ + + // + if (soundActionPage.getSoundAction().getSoundFile() != null) + setSoundFile(soundActionPage.getSoundAction().getSoundFile().getAbsolutePath()); + } + + private void addRecentSound(File soundFile) { + soundActionPage.addRecentSound(soundFile); + rebuildRecentSoundsCombo(); + } + + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + public void dispose() { + super.dispose(); + } + + public File getSoundFile() { + return selectedSoundFile; + } + + protected void playSoundFile(File soundFile) { + SoundAction.playSoundFile(soundFile); + } + + private void rebuildRecentSoundsCombo() { + combo_1.removeAll(); + + ArrayList sortedSounds = new ArrayList(soundActionPage.getRecentSounds()); + Collections.sort(sortedSounds); + + for (Iterator iter = sortedSounds.iterator(); iter.hasNext();) { + File element = (File) iter.next(); + combo_1.add(element.getAbsolutePath()); + } + } + + private void setSoundFile(String filePath) { + combo_1.removeModifyListener(comboModifyListener); + File soundFile = new File(filePath); + if (soundFile.exists()) { + addRecentSound(soundFile); + combo_1.setText(soundFile.getAbsolutePath()); + soundFilePathLabel.setText(filePath); + tryItButton.setEnabled(true); + selectedSoundFile = soundFile; + } else { + soundFilePathLabel.setText(Messages.getString("SoundActionComposite.9")); //$NON-NLS-1$ + tryItButton.setEnabled(false); + } + combo_1.addModifyListener(comboModifyListener); + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,237 +1,237 @@ -/******************************************************************************* - * Copyright (c) 2007 Nokia and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.breakpointactions; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Iterator; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.swt.widgets.Composite; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.helpers.DefaultHandler; - -public class SoundActionPage extends PlatformObject implements IBreakpointActionPage { - - private static final String SOUND_ACTION_RECENT = "SoundBehaviorDialog.recentSounds"; //$NON-NLS-1$ - - private static boolean isWindows() { - String os = System.getProperty("os.name"); //$NON-NLS-1$ - return (os != null && os.toLowerCase().startsWith("win")); //$NON-NLS-1$ - } - - private static boolean isMacOS() { - String os = System.getProperty("os.name"); //$NON-NLS-1$ - return (os != null && os.toLowerCase().startsWith("mac")); //$NON-NLS-1$ - } - - private SoundActionComposite editor = null; - private String mediaPath = ""; //$NON-NLS-1$ - - private ArrayList recentSounds = new ArrayList(); - - private SoundAction soundAction; - - public SoundActionPage() { - if (isWindows()) - mediaPath = "C:\\WINNT\\Media\\"; //$NON-NLS-1$ - if (isMacOS()) - mediaPath = "/System/Library/Sounds"; //$NON-NLS-1$ - - loadRecentSounds(); - } - - public void actionDialogCanceled() { - } - - public void actionDialogOK() { - saveRecentSounds(); - soundAction.setSoundFile(editor.getSoundFile()); - } - - public void addRecentSound(File soundFile) { - String soundFilePath = soundFile.getAbsolutePath(); - int removeIndex = -1; - int fileCount = 0; - for (Iterator iter = recentSounds.iterator(); iter.hasNext() && removeIndex < 0;) { - File element = (File) iter.next(); - if (element.getAbsolutePath().equals(soundFilePath)) - removeIndex = fileCount; - fileCount++; - } - if (removeIndex >= 0) - recentSounds.remove(removeIndex); - recentSounds.add(soundFile); - if (recentSounds.size() > 10) - recentSounds.remove(0); - - } - - public Composite createComposite(IBreakpointAction action, Composite composite, int style) { - this.soundAction = (SoundAction) action; - loadRecentSounds(); - if (soundAction.getSoundFile() == null && recentSounds.size() > 0) - soundAction.setSoundFile((File) recentSounds.get(0)); - editor = new SoundActionComposite(composite, style, this); - return editor; - } - - public String getMediaPath() { - return mediaPath; - } - - public ArrayList getRecentSounds() { - return recentSounds; - } - - public String getSummary() { - if (soundAction.getSoundFile() == null) - return new String(""); //$NON-NLS-1$ - return soundAction.getSoundFile().getAbsolutePath(); - } - - private void initializeRecentSounds() { - - if (isWindows()) { - String defaultSounds[] = { "chimes.wav", "chord.wav", "ding.wav", "notify.wav", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "tada.wav" }; //$NON-NLS-1$ - - for (int i = 0; i < defaultSounds.length; i++) { - File soundFile = new File(mediaPath + defaultSounds[i]); - if (soundFile.exists()) - recentSounds.add(soundFile); - } - } - if (isMacOS()) { - File macSounds = new File(mediaPath); - File[] soundFiles = macSounds.listFiles(); - - for (int i = 0; i < soundFiles.length; i++) { - String fileExtension = new Path(soundFiles[i].getAbsolutePath()).getFileExtension(); - if (fileExtension.equalsIgnoreCase("aiff") || fileExtension.equalsIgnoreCase("wav")) //$NON-NLS-1$ //$NON-NLS-2$ - recentSounds.add(soundFiles[i]); - - } - } - saveRecentSounds(); - - } - - private void loadRecentSounds() { - String recentSoundData = CDebugUIPlugin.getDefault().getPreferenceStore().getString(SOUND_ACTION_RECENT); - - if (recentSoundData == null || recentSoundData.length() == 0) { - initializeRecentSounds(); - return; - } - - recentSounds = new ArrayList(); - - Element root = null; - DocumentBuilder parser; - try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - parser.setErrorHandler(new DefaultHandler()); - root = parser.parse(new InputSource(new StringReader(recentSoundData))).getDocumentElement(); - - NodeList nodeList = root.getChildNodes(); - int entryCount = nodeList.getLength(); - - for (int i = 0; i < entryCount; i++) { - Node node = nodeList.item(i); - short type = node.getNodeType(); - if (type == Node.ELEMENT_NODE) { - Element subElement = (Element) node; - String nodeName = subElement.getNodeName(); - if (nodeName.equalsIgnoreCase("soundFileName")) { //$NON-NLS-1$ - String value = subElement.getAttribute("name"); //$NON-NLS-1$ - if (value == null) - throw new Exception(); - - File soundFile = new File(value); - if (soundFile.exists()) { - recentSounds.add(soundFile); - } - } - } - } - - } catch (Exception e) { - e.printStackTrace(); - } - - if (recentSounds.size() == 0) - initializeRecentSounds(); - } - - public void saveRecentSounds() { - String recentSoundData = new String(""); //$NON-NLS-1$ - - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; - try { - docBuilder = dfactory.newDocumentBuilder(); - Document doc = docBuilder.newDocument(); - - Element rootElement = doc.createElement("recentSounds"); //$NON-NLS-1$ - doc.appendChild(rootElement); - - for (Iterator iter = recentSounds.iterator(); iter.hasNext();) { - File soundFile = (File) iter.next(); - - Element element = doc.createElement("soundFileName"); //$NON-NLS-1$ - element.setAttribute("name", soundFile.getAbsolutePath()); //$NON-NLS-1$ - rootElement.appendChild(element); - - } - - ByteArrayOutputStream s = new ByteArrayOutputStream(); - - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ - - DOMSource source = new DOMSource(doc); - StreamResult outputTarget = new StreamResult(s); - transformer.transform(source, outputTarget); - - recentSoundData = s.toString("UTF8"); //$NON-NLS-1$ - - } catch (Exception e) { - e.printStackTrace(); - } - - CDebugUIPlugin.getDefault().getPreferenceStore().setValue(SOUND_ACTION_RECENT, recentSoundData); - } - - public SoundAction getSoundAction() { - return soundAction; - } - -} +/******************************************************************************* + * Copyright (c) 2007 Nokia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpointactions; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Iterator; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.swt.widgets.Composite; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.helpers.DefaultHandler; + +public class SoundActionPage extends PlatformObject implements IBreakpointActionPage { + + private static final String SOUND_ACTION_RECENT = "SoundBehaviorDialog.recentSounds"; //$NON-NLS-1$ + + private static boolean isWindows() { + String os = System.getProperty("os.name"); //$NON-NLS-1$ + return (os != null && os.toLowerCase().startsWith("win")); //$NON-NLS-1$ + } + + private static boolean isMacOS() { + String os = System.getProperty("os.name"); //$NON-NLS-1$ + return (os != null && os.toLowerCase().startsWith("mac")); //$NON-NLS-1$ + } + + private SoundActionComposite editor = null; + private String mediaPath = ""; //$NON-NLS-1$ + + private ArrayList recentSounds = new ArrayList(); + + private SoundAction soundAction; + + public SoundActionPage() { + if (isWindows()) + mediaPath = "C:\\WINNT\\Media\\"; //$NON-NLS-1$ + if (isMacOS()) + mediaPath = "/System/Library/Sounds"; //$NON-NLS-1$ + + loadRecentSounds(); + } + + public void actionDialogCanceled() { + } + + public void actionDialogOK() { + saveRecentSounds(); + soundAction.setSoundFile(editor.getSoundFile()); + } + + public void addRecentSound(File soundFile) { + String soundFilePath = soundFile.getAbsolutePath(); + int removeIndex = -1; + int fileCount = 0; + for (Iterator iter = recentSounds.iterator(); iter.hasNext() && removeIndex < 0;) { + File element = (File) iter.next(); + if (element.getAbsolutePath().equals(soundFilePath)) + removeIndex = fileCount; + fileCount++; + } + if (removeIndex >= 0) + recentSounds.remove(removeIndex); + recentSounds.add(soundFile); + if (recentSounds.size() > 10) + recentSounds.remove(0); + + } + + public Composite createComposite(IBreakpointAction action, Composite composite, int style) { + this.soundAction = (SoundAction) action; + loadRecentSounds(); + if (soundAction.getSoundFile() == null && recentSounds.size() > 0) + soundAction.setSoundFile((File) recentSounds.get(0)); + editor = new SoundActionComposite(composite, style, this); + return editor; + } + + public String getMediaPath() { + return mediaPath; + } + + public ArrayList getRecentSounds() { + return recentSounds; + } + + public String getSummary() { + if (soundAction.getSoundFile() == null) + return new String(""); //$NON-NLS-1$ + return soundAction.getSoundFile().getAbsolutePath(); + } + + private void initializeRecentSounds() { + + if (isWindows()) { + String defaultSounds[] = { "chimes.wav", "chord.wav", "ding.wav", "notify.wav", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "tada.wav" }; //$NON-NLS-1$ + + for (int i = 0; i < defaultSounds.length; i++) { + File soundFile = new File(mediaPath + defaultSounds[i]); + if (soundFile.exists()) + recentSounds.add(soundFile); + } + } + if (isMacOS()) { + File macSounds = new File(mediaPath); + File[] soundFiles = macSounds.listFiles(); + + for (int i = 0; i < soundFiles.length; i++) { + String fileExtension = new Path(soundFiles[i].getAbsolutePath()).getFileExtension(); + if (fileExtension.equalsIgnoreCase("aiff") || fileExtension.equalsIgnoreCase("wav")) //$NON-NLS-1$ //$NON-NLS-2$ + recentSounds.add(soundFiles[i]); + + } + } + saveRecentSounds(); + + } + + private void loadRecentSounds() { + String recentSoundData = CDebugUIPlugin.getDefault().getPreferenceStore().getString(SOUND_ACTION_RECENT); + + if (recentSoundData == null || recentSoundData.length() == 0) { + initializeRecentSounds(); + return; + } + + recentSounds = new ArrayList(); + + Element root = null; + DocumentBuilder parser; + try { + parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser.setErrorHandler(new DefaultHandler()); + root = parser.parse(new InputSource(new StringReader(recentSoundData))).getDocumentElement(); + + NodeList nodeList = root.getChildNodes(); + int entryCount = nodeList.getLength(); + + for (int i = 0; i < entryCount; i++) { + Node node = nodeList.item(i); + short type = node.getNodeType(); + if (type == Node.ELEMENT_NODE) { + Element subElement = (Element) node; + String nodeName = subElement.getNodeName(); + if (nodeName.equalsIgnoreCase("soundFileName")) { //$NON-NLS-1$ + String value = subElement.getAttribute("name"); //$NON-NLS-1$ + if (value == null) + throw new Exception(); + + File soundFile = new File(value); + if (soundFile.exists()) { + recentSounds.add(soundFile); + } + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + + if (recentSounds.size() == 0) + initializeRecentSounds(); + } + + public void saveRecentSounds() { + String recentSoundData = new String(""); //$NON-NLS-1$ + + DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = null; + try { + docBuilder = dfactory.newDocumentBuilder(); + Document doc = docBuilder.newDocument(); + + Element rootElement = doc.createElement("recentSounds"); //$NON-NLS-1$ + doc.appendChild(rootElement); + + for (Iterator iter = recentSounds.iterator(); iter.hasNext();) { + File soundFile = (File) iter.next(); + + Element element = doc.createElement("soundFileName"); //$NON-NLS-1$ + element.setAttribute("name", soundFile.getAbsolutePath()); //$NON-NLS-1$ + rootElement.appendChild(element); + + } + + ByteArrayOutputStream s = new ByteArrayOutputStream(); + + TransformerFactory factory = TransformerFactory.newInstance(); + Transformer transformer = factory.newTransformer(); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + + DOMSource source = new DOMSource(doc); + StreamResult outputTarget = new StreamResult(s); + transformer.transform(source, outputTarget); + + recentSoundData = s.toString("UTF8"); //$NON-NLS-1$ + + } catch (Exception e) { + e.printStackTrace(); + } + + CDebugUIPlugin.getDefault().getPreferenceStore().setValue(SOUND_ACTION_RECENT, recentSoundData); + } + + public SoundAction getSoundAction() { + return soundAction; + } + +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.isv/cdtconvert.txt diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.isv/reference/.cvsignore --- a/cdt/cdt_6_0_x/org.eclipse.cdt.doc.isv/reference/.cvsignore Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -api diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.isv/reference/extension-points/.cvsignore --- a/cdt/cdt_6_0_x/org.eclipse.cdt.doc.isv/reference/extension-points/.cvsignore Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -org_eclipse_cdt_make_core_ScannerConfigurationDiscoveryProfile.html -org_eclipse_cdt_ui_cPropertyTab.html -org_eclipse_cdt_ui_DocCommentOwner.html -org_eclipse_cdt_core_projectConverter.html -org_eclipse_cdt_core_templateAssociations.html -org_eclipse_cdt_ui_textHovers.html -org_eclipse_cdt_ui_CHelpProvider.html -org_eclipse_cdt_core_templates.html -org_eclipse_cdt_core_templateProcessTypes.html -org_eclipse_cdt_ui_completionProposalComputer.html -org_eclipse_cdt_debug_core_CDebugger.html -org_eclipse_cdt_managedbuilder_core_ManagedBuildInfo.html -org_eclipse_cdt_ui_workingSetConfigurations.html -org_eclipse_cdt_core_CProject.html -org_eclipse_cdt_core_externalSettingsProvider.html -org_eclipse_cdt_debug_core_BreakpointExtension.html -org_eclipse_cdt_make_ui_DiscoveryProfilePage.html -org_eclipse_cdt_managedbuilder_core_tcModificationInfo.html -org_eclipse_cdt_ui_quickAssistProcessors.html -org_eclipse_cdt_core_PathEntryContainerInitializer.html -org_eclipse_cdt_core_language.html -org_eclipse_cdt_managedbuilder_core_buildDefinitions.html -org_eclipse_cdt_ui_ConfigManager.html -org_eclipse_cdt_core_CBuildConsole.html -org_eclipse_cdt_managedbuilder_core_buildProperties.html -org_eclipse_cdt_ui_ProposalFilter.html -org_eclipse_cdt_ui_IndexerPage.html -org_eclipse_cdt_ui_newCfgDialog.html -org_eclipse_cdt_make_core_MakeTargetBuilder.html -org_eclipse_cdt_core_CIndexer.html -org_eclipse_cdt_ui_HelpInfo.html -org_eclipse_cdt_core_CIndex.html -org_eclipse_cdt_ui_quickFixProcessors.html -org_eclipse_cdt_ui_CDTWizard.html -org_eclipse_cdt_managedbuilder_core_projectConverter.html -org_eclipse_cdt_debug_core_BreakpointActionType.html -org_eclipse_cdt_managedbuilder_ui_newWizardPages.html -org_eclipse_cdt_core_CProjectDescriptionStorage.html -org_eclipse_cdt_ui_PathContainerPage.html -org_eclipse_cdt_ui_foldingStructureProviders.html -org_eclipse_cdt_core_CConfigurationDataProvider.html -org_eclipse_cdt_core_ProcessList.html -org_eclipse_cdt_core_CodeFormatter.html diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/book.css --- a/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/book.css Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/book.css Wed Aug 05 17:35:39 2009 -0500 @@ -1,51 +1,51 @@ -/* following font face declarations need to be removed for DBCS */ - - -body, h1, h2, h3, h4, p, table, td, caption, th, ul, ol, dl, li, dd, dt {font-family: Arial, sans-serif; color: #000000} -pre { font-family: Courier, monospace} - -/* end font face declarations */ - -/* following font size declarations should be OK for DBCS */ -body, h1, h2, h3, h4, p, table, td, caption, th, ul, ol, dl, li, dd, dt {font-size: 10pt; } -pre { font-size: 10pt} - -/* end font size declarations */ - -body { background: #FFFFFF} -h1 { font-size: 18pt; margin-top: 5; margin-bottom: 1 } -h2 { font-size: 14pt; margin-top: 25; margin-bottom: 3 } -h3 { font-size: 11pt; margin-top: 20; margin-bottom: 3 } -h4 { font-size: 10pt; margin-top: 20; margin-bottom: 3; font-style: italic } -p { font-size: 10pt; } -pre { margin-left: 6; font-size: 9pt } - -a:link { color: #006699 } -a:visited { color: #996699 } -a:hover { color: #006699 } - -ul { margin-top: 0; margin-bottom: 10 } -li { margin-top: 0; margin-bottom: 0 } -li p { margin-top: 0; margin-bottom: 0 } -ol { margin-top: 0; margin-bottom: 10 } -dl { margin-top: 0; margin-bottom: 10 } -dt { margin-top: 0; margin-bottom: 0; font-weight: bold } -dd { margin-top: 0; margin-bottom: 0 } -strong { font-weight: bold} -em { font-style: italic} -var { font-style: italic} -div.revision { border-left-style: solid; border-left-width: thin; - border-left-color: #7B68EE; padding-left:5 } -th { font-weight: bold } - -/* Mike Behm's addition to the style sheet */ -.userinput { font-family: monospace; } -.guitab, .important, .guibutton, .selectblue, .guimenu, .guilabel, -.notetitle { - color: #000000; - font-family: helvetica, arial, sans-serif; - font-weight: bold; - } -div.linux {display:none;} -.firsterm {font-style:italic;} - +/* following font face declarations need to be removed for DBCS */ + + +body, h1, h2, h3, h4, p, table, td, caption, th, ul, ol, dl, li, dd, dt {font-family: Arial, sans-serif; color: #000000} +pre { font-family: Courier, monospace} + +/* end font face declarations */ + +/* following font size declarations should be OK for DBCS */ +body, h1, h2, h3, h4, p, table, td, caption, th, ul, ol, dl, li, dd, dt {font-size: 10pt; } +pre { font-size: 10pt} + +/* end font size declarations */ + +body { background: #FFFFFF} +h1 { font-size: 18pt; margin-top: 5; margin-bottom: 1 } +h2 { font-size: 14pt; margin-top: 25; margin-bottom: 3 } +h3 { font-size: 11pt; margin-top: 20; margin-bottom: 3 } +h4 { font-size: 10pt; margin-top: 20; margin-bottom: 3; font-style: italic } +p { font-size: 10pt; } +pre { margin-left: 6; font-size: 9pt } + +a:link { color: #006699 } +a:visited { color: #996699 } +a:hover { color: #006699 } + +ul { margin-top: 0; margin-bottom: 10 } +li { margin-top: 0; margin-bottom: 0 } +li p { margin-top: 0; margin-bottom: 0 } +ol { margin-top: 0; margin-bottom: 10 } +dl { margin-top: 0; margin-bottom: 10 } +dt { margin-top: 0; margin-bottom: 0; font-weight: bold } +dd { margin-top: 0; margin-bottom: 0 } +strong { font-weight: bold} +em { font-style: italic} +var { font-style: italic} +div.revision { border-left-style: solid; border-left-width: thin; + border-left-color: #7B68EE; padding-left:5 } +th { font-weight: bold } + +/* Mike Behm's addition to the style sheet */ +.userinput { font-family: monospace; } +.guitab, .important, .guibutton, .selectblue, .guimenu, .guilabel, +.notetitle { + color: #000000; + font-family: helvetica, arial, sans-serif; + font-weight: bold; + } +div.linux {display:none;} +.firsterm {font-style:italic;} + diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer.htm --- a/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer.htm Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer.htm Wed Aug 05 17:35:39 2009 -0500 @@ -39,6 +39,8 @@

Related concepts
C/C++ search
+C/C++ Indexer Opening or Closing +a project
C/C++ Indexer Progress Bar

Related tasks
diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer_fullindexer.htm --- a/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer_fullindexer.htm Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer_fullindexer.htm Wed Aug 05 17:35:39 2009 -0500 @@ -22,6 +22,8 @@ width="143" height="21">
C/C++ Indexer
C/C++ search
+C/C++ Indexer Opening or Closing +a project
C/C++ Indexer Progress Bar

Related tasks
diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer_open_close.htm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer_open_close.htm Wed Aug 05 17:35:39 2009 -0500 @@ -0,0 +1,38 @@ + + + + + + C/C++ Indexer Opening or Closing a project + + + +

C/C++ Indexer Opening or Closing a project

+

The user opening a previously closed project results in the entire +project being re-indexed.

+

Closing a project results in the index being deleted. Search +features will not report any results for closed projects.

+

Related concepts +
+C/C++ search
+C/C++ Indexer
+C/C++ Indexer Progress Bar

+

Related tasks
+Selection Searching for C/C++ +elements
+Setting Source Folders
+

+

Related reference +
+C/C++ search page, Search +dialog box +
+C/C++ Project Properties, Indexer +

+

 

+IBM Copyright Statement + + diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer_prog_bar.htm --- a/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer_prog_bar.htm Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_c_indexer_prog_bar.htm Wed Aug 05 17:35:39 2009 -0500 @@ -24,6 +24,8 @@
C/C++ search
C/C++ Indexer
+C/C++ Indexer Opening or Closing +a project

Related tasks
Selection Searching for C/C++ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_o_concepts.htm --- a/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_o_concepts.htm Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/concepts/cdt_o_concepts.htm Wed Aug 05 17:35:39 2009 -0500 @@ -51,6 +51,7 @@ --> C/C++ search
C/C++ Indexer
+ C/C++ Indexer Opening or Closing a project
C/C++ Indexer Progress Bar

IBM Corporation Statement

diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/tasks/cdt_t_set_src_fold.htm --- a/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/tasks/cdt_t_set_src_fold.htm Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.doc.user/tasks/cdt_t_set_src_fold.htm Wed Aug 05 17:35:39 2009 -0500 @@ -43,6 +43,8 @@
C/C++ search
C/C++ Indexer
+C/C++ Indexer +Opening or Closing a project
C/C++ Indexer Progress Bar

Related tasks + \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF Wed Aug 05 17:35:39 2009 -0500 @@ -3,7 +3,7 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.0.0.qualifier Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,40 +1,40 @@ -/******************************************************************************* - * Copyright (c) 2009 Ericsson and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ericsson - initial implementation - *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb; - -import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; - - - -/** - * @noimplement This interface is not intended to be implemented by clients. - * @since 2.0 - */ -public interface IGdbDebugPreferenceConstants { - - /** - * Boolean preference whether to enable GDB traces. Default is true. - */ - public static final String PREF_TRACES_ENABLE = "tracesEnable"; //$NON-NLS-1$ - - /** - * Boolean preference whether to automatically terminate GDB when the inferior exists. Default is true. - */ - public static final String PREF_AUTO_TERMINATE_GDB = "autoTerminateGdb"; //$NON-NLS-1$ - - /** - * Help prefixes. - */ - public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$ - - public static final String PREFERENCE_PAGE= PREFIX + "preference_page_context"; //$NON-NLS-1$ -} - +/******************************************************************************* + * Copyright (c) 2009 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - initial implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb; + +import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; + + + +/** + * @noimplement This interface is not intended to be implemented by clients. + * @since 2.0 + */ +public interface IGdbDebugPreferenceConstants { + + /** + * Boolean preference whether to enable GDB traces. Default is true. + */ + public static final String PREF_TRACES_ENABLE = "tracesEnable"; //$NON-NLS-1$ + + /** + * Boolean preference whether to automatically terminate GDB when the inferior exists. Default is true. + */ + public static final String PREF_AUTO_TERMINATE_GDB = "autoTerminateGdb"; //$NON-NLS-1$ + + /** + * Help prefixes. + */ + public static final String PREFIX = GdbPlugin.PLUGIN_ID + "."; //$NON-NLS-1$ + + public static final String PREFERENCE_PAGE= PREFIX + "preference_page_context"; //$NON-NLS-1$ +} + diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java Wed Aug 05 17:35:39 2009 -0500 @@ -38,11 +38,10 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetArgs; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetAutoSolib; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetNonStop; -import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetPagination; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSolibSearchPath; -import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetTargetAsync; import org.eclipse.cdt.dsf.mi.service.command.commands.MITargetSelect; import org.eclipse.cdt.dsf.mi.service.command.commands.MITargetSelectCore; +import org.eclipse.cdt.dsf.mi.service.command.commands.RawCommand; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.core.runtime.CoreException; @@ -222,12 +221,12 @@ if (isNonStop) { // The raw commands should not be necessary in the official GDB release fCommandControl.queueCommand( - new MIGDBSetTargetAsync(fCommandControl.getContext(), true), + new RawCommand(fCommandControl.getContext(), "set target-async on"), //$NON-NLS-1$ new DataRequestMonitor(getExecutor(), requestMonitor) { @Override protected void handleSuccess() { fCommandControl.queueCommand( - new MIGDBSetPagination(fCommandControl.getContext(), false), + new RawCommand(fCommandControl.getContext(), "set pagination off"), //$NON-NLS-1$ new DataRequestMonitor(getExecutor(), requestMonitor) { @Override protected void handleSuccess() { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0.java Wed Aug 05 17:35:39 2009 -0500 @@ -34,7 +34,6 @@ import org.eclipse.cdt.dsf.mi.service.IMIRunControl; import org.eclipse.cdt.dsf.mi.service.MIRunControl; import org.eclipse.cdt.dsf.mi.service.MIStack; -import org.eclipse.cdt.dsf.mi.service.command.commands.CLIRecord; import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakDelete; import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakInsert; import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand; @@ -45,6 +44,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecReverseStep; import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecReverseStepInstruction; import org.eclipse.cdt.dsf.mi.service.command.commands.MIExecUncall; +import org.eclipse.cdt.dsf.mi.service.command.commands.RawCommand; import org.eclipse.cdt.dsf.mi.service.command.events.MIBreakpointHitEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIInferiorExitEvent; import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; @@ -424,15 +424,27 @@ return; } - getConnection().queueCommand( - new CLIRecord(context, enable), - new DataRequestMonitor(getExecutor(), rm) { - @Override - public void handleSuccess() { - setReverseModeEnabled(enable); - rm.done(); - } - }); + if (enable) { + getConnection().queueCommand( + new RawCommand(context, "record"), //$NON-NLS-1$ + new DataRequestMonitor(getExecutor(), rm) { + @Override + public void handleSuccess() { + setReverseModeEnabled(true); + rm.done(); + } + }); + } else { + getConnection().queueCommand( + new RawCommand(context, "record stop"), //$NON-NLS-1$ + new DataRequestMonitor(getExecutor(), rm) { + @Override + public void handleSuccess() { + setReverseModeEnabled(false); + rm.done(); + } + }); + } } /** @since 2.0 */ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java Wed Aug 05 17:35:39 2009 -0500 @@ -44,7 +44,6 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand; import org.eclipse.cdt.dsf.mi.service.command.commands.MIStackSelectFrame; import org.eclipse.cdt.dsf.mi.service.command.commands.MIThreadSelect; -import org.eclipse.cdt.dsf.mi.service.command.commands.RawCommand; import org.eclipse.cdt.dsf.mi.service.command.output.MIConst; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIList; @@ -68,8 +67,6 @@ public abstract class AbstractMIControl extends AbstractDsfService implements ICommandControlService { - private static final String MI_TRACE_IDENTIFIER = " [MI] "; //$NON-NLS-1$ - /* * Thread control variables for the transmit and receive threads. */ @@ -320,12 +317,7 @@ } } - if (!(handle.getCommand() instanceof RawCommand)) { - // Only generate a token id if the command is not a RawCommand - // RawCommands are sent to GDB without an answer expected, so we don't - // need a token id. In fact, GDB will fail if we send one in this case. - handle.generateTokenId(); - } + handle.generateTokenId(); fTxCommands.add(handle); } } @@ -536,10 +528,7 @@ /* * We note that this is an outstanding request at this point. */ - if (!(commandHandle.getCommand() instanceof RawCommand)) { - // RawCommands will not get an answer, so we cannot put them in the receive queue. - fRxCommands.put(commandHandle.getTokenId(), commandHandle); - } + fRxCommands.put(commandHandle.getTokenId(), commandHandle); } /* @@ -551,9 +540,6 @@ if (fUseThreadAndFrameOptions && commandHandle.getCommand().supportsThreadAndFrameOptions()) { str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand(commandHandle.getThreadId(), commandHandle.getStackFrameId()); - } else if (commandHandle.getCommand() instanceof RawCommand) { - // RawCommands CANNOT have a token id: GDB would read it as part of the RawCommand! - str = commandHandle.getCommand().constructCommand(); } else { str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand(); } @@ -563,7 +549,7 @@ fOutputStream.write(str.getBytes()); fOutputStream.flush(); - GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + str); + GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + str); //$NON-NLS-1$ getExecutor().execute(new DsfRunnable() { public void run() { if (getMITracingStream() != null) { @@ -615,7 +601,7 @@ String line; while ((line = reader.readLine()) != null) { if (line.length() != 0) { - GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + line + "\n"); //$NON-NLS-1$ + GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + line +"\n"); //$NON-NLS-1$ //$NON-NLS-2$ final String finalLine = line; getExecutor().execute(new DsfRunnable() { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIRecord.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIRecord.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Ericsson and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ericsson - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.dsf.mi.service.command.commands; - -import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; -import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; - -/** - * This command turns on on off the recording of "Process Record and Replay". - * - * @since 2.1 - */ -public class CLIRecord extends CLICommand { - public CLIRecord(ICommandControlDMContext ctx, boolean enable) { - super(ctx, enable ? "record" : "record stop"); //$NON-NLS-1$ //$NON-NLS-2$ - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaCommand.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaCommand.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaCommand.java Wed Aug 05 17:35:39 2009 -0500 @@ -10,9 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.commands; -import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.IDMContext; -import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommand; import org.eclipse.cdt.dsf.debug.service.command.ICommandResult; @@ -54,13 +52,7 @@ @Override public String toString() { - IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(fCtx, IExpressionDMContext.class); - if (exprDmc != null) { - return getClass().getSimpleName() + "(\"" + //$NON-NLS-1$ - exprDmc.getExpression() + "\")"; //$NON-NLS-1$ - } else { - return getClass().getName() + (fCtx == null ? "null" : fCtx.toString()); //$NON-NLS-1$ - } + return getClass().getName() + (fCtx == null ? "null" : fCtx.toString()); //$NON-NLS-1$ } public String getCommandControlFilter() { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaGetValue.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaGetValue.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaGetValue.java Wed Aug 05 17:35:39 2009 -0500 @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.commands; -import org.eclipse.cdt.dsf.datamodel.DMContexts; -import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext; import org.eclipse.cdt.dsf.mi.service.command.output.ExprMetaGetValueInfo; @@ -20,16 +18,4 @@ public ExprMetaGetValue(FormattedValueDMContext ctx) { super(ctx); } - - @Override - public String toString() { - IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getContext(), IExpressionDMContext.class); - if (exprDmc != null) { - return getClass().getSimpleName() + "(\"" + //$NON-NLS-1$ - exprDmc.getExpression() + "\", " + //$NON-NLS-1$ - ((FormattedValueDMContext)getContext()).getFormatID() + ")"; //$NON-NLS-1$ - } else { - return super.toString(); - } - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIExecContinue.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIExecContinue.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIExecContinue.java Wed Aug 05 17:35:39 2009 -0500 @@ -37,8 +37,8 @@ } /** - * @since 2.1 - */ + * @since 2.0 + */ public MIExecContinue(IExecutionDMContext dmc, String groupId) { this(dmc, false, groupId); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIExecInterrupt.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIExecInterrupt.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIExecInterrupt.java Wed Aug 05 17:35:39 2009 -0500 @@ -42,8 +42,8 @@ } /** - * @since 2.1 - */ + * @since 2.0 + */ public MIExecInterrupt(IExecutionDMContext dmc, String groupId) { this(dmc, false, groupId); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetPagination.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetPagination.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Ericsson and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ericsson - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.dsf.mi.service.command.commands; - -import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; - -/** - * - * -gdb-set pagination [on | off] - * - * @since 2.1 - */ -public class MIGDBSetPagination extends MIGDBSet -{ - public MIGDBSetPagination(ICommandControlDMContext ctx, boolean isSet) { - super(ctx, new String[] {"pagination", isSet ? "on" : "off"});//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetTargetAsync.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetTargetAsync.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Ericsson and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ericsson - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.dsf.mi.service.command.commands; - -import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; - -/** - * - * -gdb-set target-async [on | off] - * - * @since 2.1 - */ -public class MIGDBSetTargetAsync extends MIGDBSet -{ - public MIGDBSetTargetAsync(ICommandControlDMContext ctx, boolean isSet) { - super(ctx, new String[] {"target-async", isSet ? "on" : "off"});//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetAttributesInfo.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetAttributesInfo.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetAttributesInfo.java Wed Aug 05 17:35:39 2009 -0500 @@ -26,9 +26,4 @@ public V getSubsetResult(ICommand command) { return null; } - - @Override - public String toString() { - return getClass().getSimpleName() + " (" + getEditable() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } } \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildCountInfo.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildCountInfo.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildCountInfo.java Wed Aug 05 17:35:39 2009 -0500 @@ -26,9 +26,4 @@ public V getSubsetResult(ICommand command) { return null; } - - @Override - public String toString() { - return getClass().getSimpleName() + " (" + getChildNum() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } } \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildrenInfo.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildrenInfo.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildrenInfo.java Wed Aug 05 17:35:39 2009 -0500 @@ -27,11 +27,4 @@ public V getSubsetResult(ICommand command) { return null; } - - @Override - public String toString() { - return getClass().getSimpleName() + " [Array of " + //$NON-NLS-1$ - (getChildrenExpressions() == null ? 0 : getChildrenExpressions().length) + - " children]"; //$NON-NLS-1$ - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetValueInfo.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetValueInfo.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetValueInfo.java Wed Aug 05 17:35:39 2009 -0500 @@ -26,9 +26,4 @@ public V getSubsetResult(ICommand command) { return null; } - - @Override - public String toString() { - return getClass().getSimpleName() + " (" + getValue() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } } \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java Wed Aug 05 17:35:39 2009 -0500 @@ -35,11 +35,4 @@ public V getSubsetResult(ICommand command) { return null; } - - @Override - public String toString() { - return getClass().getSimpleName() + " (" + //$NON-NLS-1$ - getExpr() + ", " + getNumChildren() + ", " + //$NON-NLS-1$ //$NON-NLS-2$ - getType() + ", " + getEditable() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/META-INF/MANIFEST.MF Wed Aug 05 17:35:39 2009 -0500 @@ -3,7 +3,7 @@ Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.cdt.dsf.ui;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.0.1.qualifier Bundle-Activator: org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/memory/RefreshAction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/memory/RefreshAction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/memory/RefreshAction.java Wed Aug 05 17:35:39 2009 -0500 @@ -15,9 +15,9 @@ import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.IDebugEventSetListener; import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.internal.ui.views.memory.MemoryView; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; +import org.eclipse.debug.ui.memory.IMemoryRenderingSite; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; @@ -33,10 +33,10 @@ private IMemoryBlock fMemoryBlock = null; - private MemoryView fView; + private IMemoryRenderingSite fsite; public void init(IViewPart view) { - fView = (MemoryView) view; + fsite = (IMemoryRenderingSite) view; } public void run(IAction action) { @@ -44,7 +44,7 @@ if(fMemoryBlock instanceof IMemoryBlockUpdatePolicyProvider) { ((IMemoryBlockUpdatePolicyProvider) fMemoryBlock).clearCache(); - IMemoryRenderingContainer containers[] = fView.getMemoryRenderingContainers(); + IMemoryRenderingContainer containers[] = fsite.getMemoryRenderingContainers(); for(int i = 0; i < containers.length; i++) { IMemoryRendering renderings[] = containers[i].getRenderings(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf/.options --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/.options Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/.options Wed Aug 05 17:35:39 2009 -0500 @@ -1,4 +1,3 @@ org.eclipse.cdt.dsf/debug = false org.eclipse.cdt.dsf/debug/executor = false org.eclipse.cdt.dsf/debug/executorName = -org.eclipse.cdt.dsf/debugCache = false diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DsfExecutable.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DsfExecutable.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/DsfExecutable.java Wed Aug 05 17:35:39 2009 -0500 @@ -26,7 +26,7 @@ * * @since 1.0 */ -@ThreadSafe +@Immutable public class DsfExecutable { /** * Flag indicating that tracing of the DSF executor is enabled. It enables diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/Sequence.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/Sequence.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/concurrent/Sequence.java Wed Aug 05 17:35:39 2009 -0500 @@ -40,13 +40,13 @@ *
2. the method is executed by a subsystem *
3. when the method is finished it calls another method and passes * the original callback to it - *
4. steps 2-3 are repeated a number of times + *
4. steps 2-3 are repeated number of times *
5. when the last method in a chain is executed, it submits the original * RequestMonitor callback * *

* This pattern is very useful in itself, but it proves very difficult to follow - * because the methods can be scattered across many classes and systems. Also + * because the methods can be scattered accross many classes and systems. Also * if progress reporting, cancellability, and roll-back ability is required, it * has to be re-implemented every time. The Sequence class tries to address * this problem by containing this pattern in a single class. diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/command/CommandCache.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/command/CommandCache.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/command/CommandCache.java Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,6 @@ import org.eclipse.cdt.dsf.internal.DsfPlugin; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; /** @@ -159,56 +158,6 @@ private ArrayList fPendingQWaitingForCoalescedCompletion = new ArrayList(); - private static boolean DEBUG = false; - private static final String CACHE_TRACE_IDENTIFIER = " [CHE]"; //$NON-NLS-1$ - private static String BLANK_CACHE_TRACE_IDENTIFIER = ""; //$NON-NLS-1$ - static { - DEBUG = "true".equals(Platform.getDebugOption("org.eclipse.cdt.dsf/debugCache")); //$NON-NLS-1$//$NON-NLS-2$ - for (int i=0; i 100) { - String partial = message.substring(0, 100) + "\\"; //$NON-NLS-1$ - message = message.substring(100); - System.out.println(partial); - } - System.out.println(message); - } - } - } - public CommandCache(DsfSession session, ICommandControl control) { fSession = session; fCommandControl = control; @@ -307,15 +256,12 @@ */ if(fCachedContexts.get(context) != null && fCachedContexts.get(context).containsKey(cachedCmd)){ CommandResultInfo result = fCachedContexts.get(context).get(cachedCmd); - debug(command.toString().trim()); if (result.getStatus().getSeverity() <= IStatus.INFO) { @SuppressWarnings("unchecked") V v = (V)result.getData(); rm.setData(v); - debug(v.toString()); } else { rm.setStatus(result.getStatus()); - debug(result.getStatus().toString()); } rm.done(); return; @@ -325,8 +271,6 @@ * Return an error if the target is available anymore. */ if (!isTargetAvailable(command.getContext())) { - debug(command.toString().trim(), "[N/A]"); //$NON-NLS-1$ - rm.setStatus(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Target not available.", null)); //$NON-NLS-1$ rm.done(); return; @@ -339,14 +283,12 @@ for ( CommandInfo sentCommand : fPendingQCommandsSent ) { if ( sentCommand.equals( cachedCmd )) { sentCommand.getRequestMonitorList().add(genericDone); - debug(command.toString().trim(), "[SNT]"); //$NON-NLS-1$ return; } } for ( CommandInfo notYetSentCommand : fPendingQCommandsNotYetSent ) { if ( notYetSentCommand.equals( cachedCmd )) { notYetSentCommand.getRequestMonitorList().add(genericDone); - debug(command.toString().trim(), "[SND]"); //$NON-NLS-1$ return; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/.cvsignore --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/.cvsignore Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -bin diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAAdapterFactory.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAAdapterFactory.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAAdapterFactory.java Wed Aug 05 17:35:39 2009 -0500 @@ -10,14 +10,43 @@ *******************************************************************************/ package org.eclipse.cdt.examples.dsf.pda.ui; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.WeakHashMap; + +import org.eclipse.cdt.dsf.concurrent.Immutable; import org.eclipse.cdt.dsf.concurrent.ThreadSafe; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfResumeCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepIntoCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepOverCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepReturnCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfSuspendCommand; +import org.eclipse.cdt.dsf.debug.ui.sourcelookup.DsfSourceDisplayAdapter; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.DefaultDsfModelSelectionPolicyFactory; import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.examples.dsf.pda.PDAPlugin; import org.eclipse.cdt.examples.dsf.pda.launch.PDALaunch; +import org.eclipse.cdt.examples.dsf.pda.ui.actions.PDATerminateCommand; +import org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.PDAVMAdapter; import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchesListener2; +import org.eclipse.debug.core.commands.IResumeHandler; +import org.eclipse.debug.core.commands.IStepIntoHandler; +import org.eclipse.debug.core.commands.IStepOverHandler; +import org.eclipse.debug.core.commands.IStepReturnHandler; +import org.eclipse.debug.core.commands.ISuspendHandler; +import org.eclipse.debug.core.commands.ITerminateHandler; +import org.eclipse.debug.core.model.IDebugModelProvider; +import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory; -import org.eclipse.debug.ui.contexts.ISuspendTrigger; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory; +import org.eclipse.debug.ui.sourcelookup.ISourceDisplay; /** * The adapter factory is the central point of control of view model and other @@ -32,8 +61,146 @@ */ @ThreadSafe @SuppressWarnings({"restriction"}) -public class PDAAdapterFactory implements IAdapterFactory +public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2 { + /** + * Contains the set of adapters that are created for each launch instance. + */ + @Immutable + private static class LaunchAdapterSet { + // View Model adapter + final PDAVMAdapter fViewModelAdapter; + + // Source lookup and positioning adapter + final DsfSourceDisplayAdapter fSourceDisplayAdapter; + + // Command adapters + final DsfStepIntoCommand fStepIntoCommand; + final DsfStepOverCommand fStepOverCommand; + final DsfStepReturnCommand fStepReturnCommand; + final DsfSuspendCommand fSuspendCommand; + final DsfResumeCommand fResumeCommand; + final PDATerminateCommand fTerminateCommand; + + // Adapters for integration with other UI actions + final IDebugModelProvider fDebugModelProvider; + final PDALaunch fLaunch; + + final SteppingController fSteppingController; + + private IModelSelectionPolicyFactory fModelSelectionPolicyFactory; + + LaunchAdapterSet(PDALaunch launch) { + // Initialize launch and session. + fLaunch = launch; + DsfSession session = launch.getSession(); + + // register stepping controller + fSteppingController = new SteppingController(session); + session.registerModelAdapter(SteppingController.class, fSteppingController); + + // Initialize VM + fViewModelAdapter = new PDAVMAdapter(session, fSteppingController); + + // Initialize source lookup + fSourceDisplayAdapter = new DsfSourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator(), fSteppingController); + session.registerModelAdapter(ISourceDisplay.class, fSourceDisplayAdapter); + + // Default selection policy + fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory(); + session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory); + + // Initialize retargetable command handler. + fStepIntoCommand = new DsfStepIntoCommand(session, null); + fStepOverCommand = new DsfStepOverCommand(session, null); + fStepReturnCommand = new DsfStepReturnCommand(session); + fSuspendCommand = new DsfSuspendCommand(session); + fResumeCommand = new DsfResumeCommand(session); + fTerminateCommand = new PDATerminateCommand(session); + session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand); + session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand); + session.registerModelAdapter(IStepReturnHandler.class, fStepReturnCommand); + session.registerModelAdapter(ISuspendHandler.class, fSuspendCommand); + session.registerModelAdapter(IResumeHandler.class, fResumeCommand); + session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand); + + // Initialize debug model provider + fDebugModelProvider = new IDebugModelProvider() { + public String[] getModelIdentifiers() { + return new String[] { PDAPlugin.ID_PDA_DEBUG_MODEL }; + } + }; + session.registerModelAdapter(IDebugModelProvider.class, fDebugModelProvider); + + // Register the launch as an adapter This ensures that the launch, + // and debug model ID will be associated with all DMContexts from this + // session. + session.registerModelAdapter(ILaunch.class, fLaunch); + } + + void dispose() { + DsfSession session = fLaunch.getSession(); + + fViewModelAdapter.dispose(); + + session.unregisterModelAdapter(ISourceDisplay.class); + if (fSourceDisplayAdapter != null) fSourceDisplayAdapter.dispose(); + + session.unregisterModelAdapter(SteppingController.class); + fSteppingController.dispose(); + + session.unregisterModelAdapter(IModelSelectionPolicyFactory.class); + + session.unregisterModelAdapter(IStepIntoHandler.class); + session.unregisterModelAdapter(IStepOverHandler.class); + session.unregisterModelAdapter(IStepReturnHandler.class); + session.unregisterModelAdapter(ISuspendHandler.class); + session.unregisterModelAdapter(IResumeHandler.class); + session.unregisterModelAdapter(ITerminateHandler.class); + fStepIntoCommand.dispose(); + fStepOverCommand.dispose(); + fStepReturnCommand.dispose(); + fSuspendCommand.dispose(); + fResumeCommand.dispose(); + fTerminateCommand.dispose(); + } + } + + /** + * Active adapter sets. They are accessed using the launch instance + * which owns the debug services session. + */ + private static Map fgLaunchAdapterSets = + Collections.synchronizedMap(new HashMap()); + + /** + * Map of launches for which adapter sets have already been disposed. + * This map (used as a set) is maintained in order to avoid re-creating an + * adapter set after the launch was removed from the launch manager, but + * while the launch is still being held by other classes which may + * request its adapters. A weak map is used to avoid leaking + * memory once the launches are no longer referenced. + *

+ * Access to this map is synchronized using the fgLaunchAdapterSets + * instance. + *

+ */ + private static Map fgDisposedLaunchAdapterSets = + new WeakHashMap(); + + static void disposeAdapterSet(ILaunch launch) { + synchronized(fgLaunchAdapterSets) { + if ( fgLaunchAdapterSets.containsKey(launch) ) { + fgLaunchAdapterSets.remove(launch).dispose(); + fgDisposedLaunchAdapterSets.put(launch, null); + } + } + } + + public PDAAdapterFactory() { + DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); + } + // This IAdapterFactory method returns adapters for the PDA launch object only. @SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3 public Object getAdapter(Object adaptableObject, Class adapterType) { @@ -48,12 +215,26 @@ DsfSession session = launch.getSession(); if (session == null) return null; - SessionAdapterSet adapterSet = PDAUIPlugin.getDefault().getAdapterSet(launch); + // Find the correct set of adapters based on the launch. If not found + // it means that we have a new launch, and we have to create a + // new set of adapters. + LaunchAdapterSet adapterSet; + synchronized(fgLaunchAdapterSets) { + // The adapter set for the given launch was already disposed. + // Return a null adapter. + if (fgDisposedLaunchAdapterSets.containsKey(launch)) { + return null; + } + adapterSet = fgLaunchAdapterSets.get(launch); + if (adapterSet == null) { + adapterSet = new LaunchAdapterSet(launch); + fgLaunchAdapterSets.put(launch, adapterSet); + } + } // Returns the adapter type for the launch object. if (adapterType.equals(IElementContentProvider.class)) return adapterSet.fViewModelAdapter; else if (adapterType.equals(IModelProxyFactory.class)) return adapterSet.fViewModelAdapter; - else if (adapterType.equals(ISuspendTrigger.class)) return adapterSet.fSuspendTrigger; else return null; } @@ -62,4 +243,24 @@ return new Class[] { IElementContentProvider.class, IModelProxyFactory.class, IColumnPresentationFactory.class }; } + public void launchesRemoved(ILaunch[] launches) { + // Dispose the set of adapters for a launch only after the launch is + // removed from the view. If the launch is terminated, the adapters + // are still needed to populate the contents of the view. + for (ILaunch launch : launches) { + if (launch instanceof PDALaunch) { + disposeAdapterSet(launch); + } + } + } + + public void launchesTerminated(ILaunch[] launches) { + } + + public void launchesAdded(ILaunch[] launches) { + } + + public void launchesChanged(ILaunch[] launches) { + } + } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAUIPlugin.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAUIPlugin.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAUIPlugin.java Wed Aug 05 17:35:39 2009 -0500 @@ -13,16 +13,12 @@ package org.eclipse.cdt.examples.dsf.pda.ui; import java.net.URL; -import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.WeakHashMap; -import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.examples.dsf.pda.launch.PDALaunch; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchesListener2; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Color; @@ -35,7 +31,7 @@ /** * The main plugin class to be used in the desktop. */ -public class PDAUIPlugin extends AbstractUIPlugin implements ILaunchesListener2{ +public class PDAUIPlugin extends AbstractUIPlugin { public static String PLUGIN_ID = "org.eclipse.cdt.examples.dsf.pda.ui "; @@ -63,38 +59,6 @@ */ private Map fColors = new HashMap(); - /** - * Active adapter sets. They are accessed using the DSF session ID - * which owns the debug services. - */ - private Map fSessionAdapterSets = - Collections.synchronizedMap(new HashMap()); - - /** - * Map of launches for which adapter sets have already been disposed. - * This map (used as a set) is maintained in order to avoid re-creating an - * adapter set after the launch was removed from the launch manager, but - * while the launch is still being held by other classes which may - * request its adapters. A weak map is used to avoid leaking - * memory once the launches are no longer referenced. - *

- * Access to this map is synchronized using the fSessionAdapterSets - * instance. - *

- */ - private Map fDisposedSessionAdapterSets = - new WeakHashMap(); - - private void disposeAdapterSet(PDALaunch launch) { - String sessionId = launch.getSession().getId(); - synchronized(fSessionAdapterSets) { - if ( fSessionAdapterSets.containsKey(sessionId) ) { - fSessionAdapterSets.remove(sessionId).dispose(); - fDisposedSessionAdapterSets.put(launch, null); - } - } - } - /** * The constructor. */ @@ -110,7 +74,10 @@ public void start(BundleContext context) throws Exception { fContext = context; super.start(context); - DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); +// Toggles single threaded adapter example +// IAdapterManager adapterManager = Platform.getAdapterManager(); +// IAdapterFactory factory = new AdapterFactory(); +// adapterManager.registerAdapters(factory, PDADebugTarget.class); } /** @@ -118,7 +85,6 @@ */ @Override public void stop(BundleContext context) throws Exception { - DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); disposeAdapterSets(); super.stop(context); plugin = null; @@ -175,66 +141,15 @@ return color; } - SessionAdapterSet getAdapterSet(PDALaunch launch) { - // Find the correct set of adapters based on the launch. If not found - // it means that we have a new launch, and we have to create a - // new set of adapters. - SessionAdapterSet adapterSet; - synchronized(fSessionAdapterSets) { - // The adapter set for the given launch was already disposed. - // Return a null adapter. - if (fDisposedSessionAdapterSets.containsKey(launch)) { - return null; - } - String sessionId = launch.getSession().getId(); - adapterSet = fSessionAdapterSets.get(sessionId); - if (adapterSet == null) { - adapterSet = new SessionAdapterSet(launch); - fSessionAdapterSets.put(sessionId, adapterSet); - } - } - return adapterSet; - } - - SessionAdapterSet getAdapterSet(String sessionId) { - DsfSession session = DsfSession.getSession(sessionId); - ILaunch launch = (ILaunch)session.getModelAdapter(ILaunch.class); - if (launch instanceof PDALaunch) { - return getAdapterSet((PDALaunch)launch); - } - return null; - } - /** * Dispose adapter sets for all launches. */ private void disposeAdapterSets() { for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) { if (launch instanceof PDALaunch) { - disposeAdapterSet((PDALaunch)launch); + PDAAdapterFactory.disposeAdapterSet(launch); } } } - public void launchesRemoved(ILaunch[] launches) { - // Dispose the set of adapters for a launch only after the launch is - // removed from the view. If the launch is terminated, the adapters - // are still needed to populate the contents of the view. - for (ILaunch launch : launches) { - if (launch instanceof PDALaunch) { - disposeAdapterSet((PDALaunch)launch); - } - } - } - - public void launchesTerminated(ILaunch[] launches) { - } - - public void launchesAdded(ILaunch[] launches) { - } - - public void launchesChanged(ILaunch[] launches) { - } - -} - + } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/SessionAdapterSet.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/SessionAdapterSet.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.pda.ui; - -import org.eclipse.cdt.dsf.datamodel.IDMContext; -import org.eclipse.cdt.dsf.debug.ui.actions.DsfResumeCommand; -import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepIntoCommand; -import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepOverCommand; -import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepReturnCommand; -import org.eclipse.cdt.dsf.debug.ui.actions.DsfSuspendCommand; -import org.eclipse.cdt.dsf.debug.ui.contexts.DsfSuspendTrigger; -import org.eclipse.cdt.dsf.debug.ui.sourcelookup.DsfSourceDisplayAdapter; -import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController; -import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.DefaultDsfModelSelectionPolicyFactory; -import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.DefaultDsfSelectionPolicy; -import org.eclipse.cdt.dsf.service.DsfSession; -import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; -import org.eclipse.cdt.examples.dsf.pda.PDAPlugin; -import org.eclipse.cdt.examples.dsf.pda.launch.PDALaunch; -import org.eclipse.cdt.examples.dsf.pda.ui.actions.PDATerminateCommand; -import org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.PDAVMAdapter; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.commands.IResumeHandler; -import org.eclipse.debug.core.commands.IStepIntoHandler; -import org.eclipse.debug.core.commands.IStepOverHandler; -import org.eclipse.debug.core.commands.IStepReturnHandler; -import org.eclipse.debug.core.commands.ISuspendHandler; -import org.eclipse.debug.core.commands.ITerminateHandler; -import org.eclipse.debug.core.model.IDebugModelProvider; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.sourcelookup.ISourceDisplay; - -/** - * Contains the set of adapters that are created for each session instance. - */ -class SessionAdapterSet { - // View Model adapter - final PDAVMAdapter fViewModelAdapter; - - // Source lookup and positioning adapter - final DsfSourceDisplayAdapter fSourceDisplayAdapter; - - // Command adapters - final DsfStepIntoCommand fStepIntoCommand; - final DsfStepOverCommand fStepOverCommand; - final DsfStepReturnCommand fStepReturnCommand; - final DsfSuspendCommand fSuspendCommand; - final DsfResumeCommand fResumeCommand; - final PDATerminateCommand fTerminateCommand; - final DsfSuspendTrigger fSuspendTrigger; - - // Adapters for integration with other UI actions - final IDebugModelProvider fDebugModelProvider; - final PDALaunch fLaunch; - - final SteppingController fSteppingController; - - final IModelSelectionPolicyFactory fModelSelectionPolicyFactory; - - SessionAdapterSet(PDALaunch launch) { - // Initialize launch and session. - fLaunch = launch; - DsfSession session = launch.getSession(); - - // register stepping controller - fSteppingController = new SteppingController(session); - session.registerModelAdapter(SteppingController.class, fSteppingController); - - // Initialize VM - fViewModelAdapter = new PDAVMAdapter(session, fSteppingController); - - // Initialize source lookup - fSourceDisplayAdapter = new DsfSourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator(), fSteppingController); - session.registerModelAdapter(ISourceDisplay.class, fSourceDisplayAdapter); - - // Default selection policy - fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory(); - session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory); - - // Initialize retargetable command handler. - fStepIntoCommand = new DsfStepIntoCommand(session, null); - fStepOverCommand = new DsfStepOverCommand(session, null); - fStepReturnCommand = new DsfStepReturnCommand(session); - fSuspendCommand = new DsfSuspendCommand(session); - fResumeCommand = new DsfResumeCommand(session); - fTerminateCommand = new PDATerminateCommand(session); - fSuspendTrigger = new DsfSuspendTrigger(session, fLaunch); - - session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand); - session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand); - session.registerModelAdapter(IStepReturnHandler.class, fStepReturnCommand); - session.registerModelAdapter(ISuspendHandler.class, fSuspendCommand); - session.registerModelAdapter(IResumeHandler.class, fResumeCommand); - session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand); - - // Initialize debug model provider - fDebugModelProvider = new IDebugModelProvider() { - public String[] getModelIdentifiers() { - return new String[] { PDAPlugin.ID_PDA_DEBUG_MODEL }; - } - }; - session.registerModelAdapter(IDebugModelProvider.class, fDebugModelProvider); - } - - void dispose() { - DsfSession session = fLaunch.getSession(); - - fViewModelAdapter.dispose(); - - session.unregisterModelAdapter(ISourceDisplay.class); - if (fSourceDisplayAdapter != null) fSourceDisplayAdapter.dispose(); - - session.unregisterModelAdapter(SteppingController.class); - fSteppingController.dispose(); - - session.unregisterModelAdapter(IModelSelectionPolicyFactory.class); - - session.unregisterModelAdapter(IStepIntoHandler.class); - session.unregisterModelAdapter(IStepOverHandler.class); - session.unregisterModelAdapter(IStepReturnHandler.class); - session.unregisterModelAdapter(ISuspendHandler.class); - session.unregisterModelAdapter(IResumeHandler.class); - session.unregisterModelAdapter(ITerminateHandler.class); - fStepIntoCommand.dispose(); - fStepOverCommand.dispose(); - fStepReturnCommand.dispose(); - fSuspendCommand.dispose(); - fResumeCommand.dispose(); - fTerminateCommand.dispose(); - fSuspendTrigger.dispose(); - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDALaunch.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDALaunch.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/launch/PDALaunch.java Wed Aug 05 17:35:39 2009 -0500 @@ -24,7 +24,6 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.Launch; import org.eclipse.debug.core.model.ISourceLocator; @@ -74,11 +73,6 @@ dsfExecutor.prestartCoreThread(); fExecutor = dsfExecutor; fSession = DsfSession.startSession(fExecutor, PDAPlugin.ID_PDA_DEBUG_MODEL); - - // Register the launch as an adapter This ensures that the launch, - // and debug model ID will be associated with all DMContexts from this - // session. - fSession.registerModelAdapter(ILaunch.class, this); } /** diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDACommandControl.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDACommandControl.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDACommandControl.java Wed Aug 05 17:35:39 2009 -0500 @@ -155,11 +155,7 @@ // Register the service with OSGi as the last step in initialization of // the service. register( - new String[] { - ICommandControl.class.getName(), - ICommandControlService.class.getName(), - PDACommandControl.class.getName() - }, + new String[]{ ICommandControl.class.getName(), PDACommandControl.class.getName() }, new Hashtable()); rm.done(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDARunControl.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDARunControl.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf.pda/src/org/eclipse/cdt/examples/dsf/pda/service/PDARunControl.java Wed Aug 05 17:35:39 2009 -0500 @@ -34,7 +34,6 @@ import org.eclipse.cdt.examples.dsf.pda.service.commands.PDAResumeCommand; import org.eclipse.cdt.examples.dsf.pda.service.commands.PDAStepCommand; import org.eclipse.cdt.examples.dsf.pda.service.commands.PDAStepReturnCommand; -import org.eclipse.cdt.examples.dsf.pda.service.commands.PDASuspendCommand; import org.eclipse.cdt.examples.dsf.pda.service.commands.PDAVMResumeCommand; import org.eclipse.cdt.examples.dsf.pda.service.commands.PDAVMSuspendCommand; import org.osgi.framework.BundleContext; @@ -555,7 +554,7 @@ final PDAThreadDMContext threadCtx = (PDAThreadDMContext)context; fThreads.get(threadCtx.getID()).fSuspendPending = true; fCommandControl.queueCommand( - new PDASuspendCommand(threadCtx), + new PDAVMSuspendCommand(fDMContext), new DataRequestMonitor(getExecutor(), rm) { @Override protected void handleFailure() { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/AsyncDataViewer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/AsyncDataViewer.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor; -import org.eclipse.cdt.dsf.concurrent.ThreadSafe; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.DsfExecutor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.Query; -import org.eclipse.cdt.dsf.ui.concurrent.DisplayDsfExecutor; -import org.eclipse.jface.viewers.ILazyContentProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; - -/** - * Data viewer based on a table, which reads data using asynchronous methods. - *

- * This viewer implements the {@link ILazyContentProvider} interface - * which is used by the JFace TableViewer class to populate a Table. This - * interface contains separate asynchronous methods for requesting the count - * and values for individual indexes, which neatly correspond to the methods - * in {@link IDataGenerator}. As an added optimization, this viewer - * implementation checks for the range of visible items in the view upon each - * request, and it cancels old requests which scroll out of view but have not - * been completed yet. However, it is up to the data generator implementation - * to check the canceled state of the requests and ignore them. - *

- */ -@ConfinedToDsfExecutor("fDisplayExecutor") -public class AsyncDataViewer - implements ILazyContentProvider, IDataGenerator.Listener -{ - // Executor to use instead of Display.asyncExec(). - @ThreadSafe - final private DsfExecutor fDisplayExecutor; - - // The viewer and generator that this content provider using. - final private TableViewer fViewer; - final private IDataGenerator fDataGenerator; - - // Fields used in request cancellation logic. - private List fItemDataRequestMonitors = new LinkedList(); - private Set fIndexesToCancel = new HashSet(); - private int fCancelCallsPending = 0; - - public AsyncDataViewer(TableViewer viewer, IDataGenerator generator) { - fViewer = viewer; - fDisplayExecutor = DisplayDsfExecutor.getDisplayDsfExecutor(fViewer.getTable().getDisplay()); - fDataGenerator = generator; - fDataGenerator.addListener(this); - } - - public void dispose() { - fDataGenerator.removeListener(this); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // Set the initial count to the viewer after the input is set. - queryItemCount(); - } - - public void updateElement(final int index) { - // Calculate the visible index range. - final int topIdx = fViewer.getTable().getTopIndex(); - final int botIdx = topIdx + getVisibleItemCount(topIdx); - - // Request the item for the given index. - queryValue(index); - - // Invoke a cancel task with a delay. The delay allows multiple cancel - // calls to be combined together improving performance of the viewer. - fCancelCallsPending++; - fDisplayExecutor.schedule( - new Runnable() { public void run() { - cancelStaleRequests(topIdx, botIdx); - }}, - 1, TimeUnit.MILLISECONDS); - } - - private int getVisibleItemCount(int top) { - Table table = fViewer.getTable(); - int itemCount = table.getItemCount(); - return Math.min((table.getBounds().height / table.getItemHeight()) + 2, itemCount - top); - } - - @ThreadSafe - public void countChanged() { - queryItemCount(); - } - - @ThreadSafe - public void valuesChanged(final Set indexes) { - // Mark the changed items in table viewer as dirty, this will - // trigger update requests for these indexes if they are - // visible in the viewer. - final TableViewer tableViewer = fViewer; - fDisplayExecutor.execute( new Runnable() { - public void run() { - if (!fViewer.getTable().isDisposed()) { - for (Integer index : indexes) { - tableViewer.clear(index); - } - } - }}); - } - - - private void queryItemCount() { - // Request count from data provider. When the count is returned, we - // have to re-dispatch into the display thread to avoid calling - // the table widget on the DSF dispatch thread. - fIndexesToCancel.clear(); - fDataGenerator.getCount( - // Use the display executor to construct the request monitor, this - // will cause the handleCompleted() method to be automatically - // called on the display thread. - new DataRequestMonitor(fDisplayExecutor, null) { - @Override - protected void handleCompleted() { - if (!fViewer.getTable().isDisposed()) { - fViewer.setItemCount(getData()); - fViewer.getTable().clearAll(); - } - } - }); - - } - - - // Dedicated class for data item requests. This class holds the index - // argument so it can be examined when canceling stale requests. - private class ValueDataRequestMonitor extends DataRequestMonitor { - - /** Index is used when canceling stale requests. */ - int fIndex; - - ValueDataRequestMonitor(int index) { - super(fDisplayExecutor, null); - fIndex = index; - } - - @Override - protected void handleCompleted() { - fItemDataRequestMonitors.remove(this); - - // Check if the request completed successfully, otherwise ignore it. - if (isSuccess()) { - if (!fViewer.getTable().isDisposed()) { - fViewer.replace(getData(), fIndex); - } - } - } - } - - private void queryValue(final int index) { - ValueDataRequestMonitor rm = new ValueDataRequestMonitor(index); - fItemDataRequestMonitors.add(rm); - fDataGenerator.getValue(index, rm); - } - - private void cancelStaleRequests(int topIdx, int botIdx) { - // Decrement the count of outstanding cancel calls. - fCancelCallsPending--; - - // Must check again, in case disposed while re-dispatching. - if (fDataGenerator == null || fViewer.getTable().isDisposed()) return; - - // Go through the outstanding requests and cancel any that - // are not visible anymore. - for (Iterator itr = fItemDataRequestMonitors.iterator(); itr.hasNext();) { - ValueDataRequestMonitor item = itr.next(); - if (item.fIndex < topIdx || item.fIndex > botIdx) { - // Set the item to canceled status, so that the data provider - // will ignore it. - item.cancel(); - - // Add the item index to list of indexes that were canceled, - // which will be sent to the table widget. - fIndexesToCancel.add(item.fIndex); - - // Remove the item from the outstanding cancel requests. - itr.remove(); - } - } - if (!fIndexesToCancel.isEmpty() && fCancelCallsPending == 0) { - Set canceledIdxs = fIndexesToCancel; - fIndexesToCancel = new HashSet(); - - // Clear the indexes of the canceled request, so that the - // viewer knows to request them again when needed. - // Note: clearing using TableViewer.clear(int) seems very - // inefficient, it's better to use Table.clear(int[]). - int[] canceledIdxsArray = new int[canceledIdxs.size()]; - int i = 0; - for (Integer index : canceledIdxs) { - canceledIdxsArray[i++] = index; - } - fViewer.getTable().clear(canceledIdxsArray); - } - } - - - public static void main(String[] args) { - // Create the shell to hold the viewer. - Display display = new Display(); - Shell shell = new Shell(display, SWT.SHELL_TRIM); - shell.setLayout(new GridLayout()); - GridData data = new GridData(GridData.FILL_BOTH); - shell.setLayoutData(data); - Font font = new Font(display, "Courier", 10, SWT.NORMAL); - - // Create the table viewer. - TableViewer tableViewer = new TableViewer(shell, SWT.BORDER | SWT.VIRTUAL); - tableViewer.getControl().setLayoutData(data); - - // Create the data generator. - final IDataGenerator generator = new DataGeneratorWithExecutor(); - - // Create the content provider which will populate the viewer. - AsyncDataViewer contentProvider = new AsyncDataViewer(tableViewer, generator); - tableViewer.setContentProvider(contentProvider); - tableViewer.setInput(new Object()); - - // Open the shell and service the display dispatch loop until user - // closes the shell. - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - - // The IDataGenerator.shutdown() method is asynchronous, this requires - // using a query again in order to wait for its completion. - Query shutdownQuery = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - generator.shutdown(rm); - } - }; - ImmediateExecutor.getInstance().execute(shutdownQuery); - try { - shutdownQuery.get(); - } catch (Exception e) {} - - // Shut down the display. - font.dispose(); - display.dispose(); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,336 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer; - -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.TimeUnit; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor; -import org.eclipse.cdt.dsf.concurrent.DsfExecutor; -import org.eclipse.cdt.dsf.concurrent.DsfRunnable; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; -import org.eclipse.cdt.examples.dsf.DsfExamplesPlugin; - -/** - * DSF Executor-based implementation of the data generator. - *

- * This generator uses a queue of client requests and processes these - * requests periodically using a DSF executor. The main feature of this - * generator is that it uses the executor as its only synchronization object. - * This means that all the fields with the exception of the executor can only - * be accessed while running in the executor thread. - *

- */ -//TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) -//indicating allowed thread access to this class/method/member -public class DataGeneratorWithExecutor implements IDataGenerator { - - // Request objects are used to serialize the interface calls into objects - // which can then be pushed into a queue. - // TODO Ecercise 4 - Add an annotationindicating allowed concurrency access - // Hint: Request and its subclasses have all their fields declared as final. - abstract class Request { - final RequestMonitor fRequestMonitor; - - Request(RequestMonitor rm) { - fRequestMonitor = rm; - } - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - class CountRequest extends Request { - CountRequest(DataRequestMonitor rm) { - super(rm); - } - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - class ItemRequest extends Request { - final int fIndex; - ItemRequest(int index, DataRequestMonitor rm) { - super(rm); - fIndex = index; - } - } - - // The executor used to access all internal data of the generator. - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - // Hint: If a member does not have an annotation, the programmer can assume - // that the concurrency rule that applies to the class also applies to this - // member. - private DsfExecutor fExecutor; - - // Main request queue of the data generator. The getValue(), getCount(), - // and shutdown() methods write into the queue, while the serviceQueue() - // method reads from it. - // The executor used to access all internal data of the generator. - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private List fQueue = new LinkedList(); - - // List of listeners is not synchronized, it also has to be accessed - // using the executor. - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private List fListeners = new LinkedList(); - - // Current number of elements in this generator. - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private int fCount = MIN_COUNT; - - // Counter used to determine when to reset the element count. - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private int fCountResetTrigger = 0; - - // Elements which were modified since the last reset. - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private Set fChangedIndexes = new HashSet(); - - // Flag used to ensure that requests are processed sequentially. - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private boolean fServiceQueueInProgress = false; - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - public DataGeneratorWithExecutor() { - // Create the executor - fExecutor = new DefaultDsfExecutor("Supplier Executor"); - - // Schedule a runnable to make the random changes. - fExecutor.scheduleAtFixedRate( - new DsfRunnable() { - public void run() { - randomChanges(); - } - }, - RANDOM_CHANGE_INTERVAL, - RANDOM_CHANGE_INTERVAL, - TimeUnit.MILLISECONDS); - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - public void shutdown(final RequestMonitor rm) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - // Empty the queue of requests and fail them. - for (Request request : fQueue) { - request.fRequestMonitor.setStatus( - new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - request.fRequestMonitor.done(); - } - fQueue.clear(); - - // Kill executor. - fExecutor.shutdown(); - rm.done(); - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - public void getCount(final DataRequestMonitor rm) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - fQueue.add(new CountRequest(rm)); - serviceQueue(); - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - public void getValue(final int index, final DataRequestMonitor rm) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - fQueue.add(new ItemRequest(index, rm)); - serviceQueue(); - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - public void addListener(final Listener listener) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - fListeners.add(listener); - } - }); - } catch (RejectedExecutionException e) {} - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - public void removeListener(final Listener listener) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - fListeners.remove(listener); - } - }); - } catch (RejectedExecutionException e) {} - } - - // Main processing function of this generator. - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private void serviceQueue() { - - // TODO Exercise 3 - Add logic to discard cancelled requests from queue. - // Hint: Since serviceQueue() is called using the executor, and the - // fQueue list can only be modified when running in the executor - // thread. This method can safely iterate and modify fQueue without - // risk of race conditions or concurrent modification exceptions. - - // If a queue servicing is already scheduled, do nothing. - if (fServiceQueueInProgress) { - return; - } - - if (fQueue.size() != 0) { - // If there are requests to service, remove one from the queue and - // schedule a runnable to process the request after a processing - // delay. - fServiceQueueInProgress = true; - final Request request = fQueue.remove(0); - fExecutor.schedule( - new DsfRunnable() { - public void run() { - if (request instanceof CountRequest) { - processCountRequest((CountRequest)request); - } else if (request instanceof ItemRequest) { - processItemRequest((ItemRequest)request); - } - - // Reset the processing flag and process next - // request. - fServiceQueueInProgress = false; - serviceQueue(); - } - }, - PROCESSING_DELAY, TimeUnit.MILLISECONDS); - } - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private void processCountRequest(CountRequest request) { - @SuppressWarnings("unchecked") // Suppress warning about lost type info. - DataRequestMonitor rm = (DataRequestMonitor)request.fRequestMonitor; - - rm.setData(fCount); - rm.done(); - } - - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private void processItemRequest(ItemRequest request) { - @SuppressWarnings("unchecked") // Suppress warning about lost type info. - DataRequestMonitor rm = (DataRequestMonitor)request.fRequestMonitor; - - if (fChangedIndexes.contains(request.fIndex)) { - rm.setData("Changed: " + request.fIndex); - } else { - rm.setData(Integer.toString(request.fIndex)); - } - rm.done(); - } - - /** - * This method simulates changes in the supplier's data set. - */ - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private void randomChanges() { - // Once every number of changes, reset the count, the rest of the - // times just change certain values. - if (++fCountResetTrigger % RANDOM_COUNT_CHANGE_INTERVALS == 0){ - randomCountReset(); - } else { - randomDataChange(); - } - } - - /** - * Calculates new size for provider's data set. - */ - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private void randomCountReset() { - // Calculate the new count. - Random random = new java.util.Random(); - fCount = MIN_COUNT + Math.abs(random.nextInt()) % (MAX_COUNT - MIN_COUNT); - - // Reset the changed values. - fChangedIndexes.clear(); - - // Notify listeners - for (Listener listener : fListeners) { - listener.countChanged(); - } - } - - /** - * Invalidates a random range of indexes. - */ - // TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) - // indicating allowed thread access to this class/method/member - private void randomDataChange() { - // Calculate the indexes to change. - Random random = new java.util.Random(); - Set set = new HashSet(); - for (int i = 0; i < fCount * RANDOM_CHANGE_SET_PERCENTAGE / 100; i++) { - set.add( new Integer(Math.abs(random.nextInt()) % fCount) ); - } - - // Add the indexes to an overall set of changed indexes. - fChangedIndexes.addAll(set); - - // Notify listeners - for (Listener listener : fListeners) { - listener.valuesChanged(set); - } - } -} - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.Status; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; -import org.eclipse.cdt.examples.dsf.DsfExamplesPlugin; - -/** - * Thread-based implementation of the data generator. - *

- * This generator is based around a queue of client requests and a thread which - * reads the requests from the queue and processes them. The distinguishing - * feature of this generator is that it uses a a blocking queue as the main - * synchronization object. However, fListeners, fShutdown, and fChangedIndexes - * fields also need to be thread-safe and so they implement their own - * synchronization. - *

- */ -public class DataGeneratorWithThread extends Thread implements IDataGenerator { - - // Request objects are used to serialize the interface calls into objects - // which can then be pushed into a queue. - abstract class Request { - final RequestMonitor fRequestMonitor; - - Request(RequestMonitor rm) { - fRequestMonitor = rm; - } - } - - class CountRequest extends Request { - CountRequest(DataRequestMonitor rm) { - super(rm); - } - } - - class ItemRequest extends Request { - final int fIndex; - ItemRequest(int index, DataRequestMonitor rm) { - super(rm); - fIndex = index; - } - } - - class ShutdownRequest extends Request { - ShutdownRequest(RequestMonitor rm) { - super(rm); - } - } - - // Main request queue of the data generator. The getValue(), getCount(), - // and shutdown() methods write into the queue, while the run() method - // reads from it. - private final BlockingQueue fQueue = new LinkedBlockingQueue(); - - // ListenerList class provides thread safety. - private ListenerList fListeners = new ListenerList(); - - // Current number of elements in this generator. - private int fCount = MIN_COUNT; - - // Counter used to determine when to reset the element count. - private int fCountResetTrigger = 0; - - // Elements which were modified since the last reset. - private Set fChangedIndexes = Collections.synchronizedSet(new HashSet()); - - // Used to determine when to make changes in data. - private long fLastChangeTime = System.currentTimeMillis(); - - // Flag indicating when the generator has been shut down. - private AtomicBoolean fShutdown = new AtomicBoolean(false); - - public DataGeneratorWithThread() { - // Immediately kick off the request processing thread. - start(); - } - - public void shutdown(RequestMonitor rm) { - // Mark the generator as shut down. After the fShutdown flag is set, - // all new requests should be shut down. - if (!fShutdown.getAndSet(true)) { - fQueue.add(new ShutdownRequest(rm)); - } else { - // - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void getCount(DataRequestMonitor rm) { - if (!fShutdown.get()) { - fQueue.add(new CountRequest(rm)); - } else { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void getValue(int index, DataRequestMonitor rm) { - if (!fShutdown.get()) { - fQueue.add(new ItemRequest(index, rm)); - } else { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void addListener(Listener listener) { - fListeners.add(listener); - } - - public void removeListener(Listener listener) { - fListeners.remove(listener); - } - - @Override - public void run() { - try { - while(true) { - // Get the next request from the queue. The time-out - // ensures that that the random changes get processed. - final Request request = fQueue.poll(100, TimeUnit.MILLISECONDS); - - // If a request was dequeued, process it. - if (request != null) { - // Simulate a processing delay. - Thread.sleep(PROCESSING_DELAY); - - if (request instanceof CountRequest) { - processCountRequest((CountRequest)request); - } else if (request instanceof ItemRequest) { - processItemRequest((ItemRequest)request); - } else if (request instanceof ShutdownRequest) { - // If shutting down, just break out of the while(true) - // loop and thread will exit. - request.fRequestMonitor.done(); - break; - } - } - - // Simulate data changes. - randomChanges(); - } - } - catch (InterruptedException x) {} - } - - private void processCountRequest(CountRequest request) { - @SuppressWarnings("unchecked") // Suppress warning about lost type info. - DataRequestMonitor rm = (DataRequestMonitor)request.fRequestMonitor; - - rm.setData(fCount); - rm.done(); - } - - private void processItemRequest(ItemRequest request) { - @SuppressWarnings("unchecked") // Suppress warning about lost type info. - DataRequestMonitor rm = (DataRequestMonitor)request.fRequestMonitor; - - if (fChangedIndexes.contains(request.fIndex)) { - rm.setData("Changed: " + request.fIndex); - } else { - rm.setData(Integer.toString(request.fIndex)); - } - rm.done(); - } - - - private void randomChanges() { - // Check if enough time is elapsed. - if (System.currentTimeMillis() > fLastChangeTime + RANDOM_CHANGE_INTERVAL) { - fLastChangeTime = System.currentTimeMillis(); - - // Once every number of changes, reset the count, the rest of the - // times just change certain values. - if (++fCountResetTrigger % RANDOM_COUNT_CHANGE_INTERVALS == 0){ - randomCountReset(); - } else { - randomDataChange(); - } - } - } - - private void randomCountReset() { - // Calculate the new count. - Random random = new java.util.Random(); - fCount = MIN_COUNT + Math.abs(random.nextInt()) % (MAX_COUNT - MIN_COUNT); - - // Reset the changed values. - fChangedIndexes.clear(); - - // Notify listeners - for (Object listener : fListeners.getListeners()) { - ((Listener)listener).countChanged(); - } - } - - private void randomDataChange() { - // Calculate the indexes to change. - Random random = new java.util.Random(); - Set set = new HashSet(); - for (int i = 0; i < fCount * RANDOM_CHANGE_SET_PERCENTAGE / 100; i++) { - set.add( new Integer(Math.abs(random.nextInt()) % fCount) ); - } - - // Add the indexes to an overall set of changed indexes. - fChangedIndexes.addAll(set); - - // Notify listeners - for (Object listener : fListeners.getListeners()) { - ((Listener)listener).valuesChanged(set); - } - } -} - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/IDataGenerator.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/IDataGenerator.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer; - -import java.util.Set; - -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; - -/** - * Data generator is simple source of data used to populate the example table - * view. It contains two asynchronous methods for retrieving the data - * parameters: the count and the value for a given index. It also allows the - * view to receive events indicating when the data supplied by the generator - * is changed. - */ -// TODO Exercise 4 - Add an annotation (ThreadSafe/ConfinedToDsfExecutor) -// indicating allowed thread access to this class/method/member -public interface IDataGenerator { - - // Constants which control the data generator behavior. - // Changing the count range can stress the scalability of the system, while - // changing of the process delay and random change interval can stress - // its performance. - final static int MIN_COUNT = 100; - final static int MAX_COUNT = 200; - final static int PROCESSING_DELAY = 10; - final static int RANDOM_CHANGE_INTERVAL = 10000; - final static int RANDOM_COUNT_CHANGE_INTERVALS = 3; - final static int RANDOM_CHANGE_SET_PERCENTAGE = 10; - - - // Listener interface that the view needs to implement to react - // to the changes in data. - public interface Listener { - void countChanged(); - void valuesChanged(Set indexes); - } - - // Data access methods. - void getCount(DataRequestMonitor rm); - void getValue(int index, DataRequestMonitor rm); - - // Method used to shutdown the data generator including any threads that - // it may use. - void shutdown(RequestMonitor rm); - - // Methods for registering change listeners. - void addListener(Listener listener); - void removeListener(Listener listener); -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/SyncDataViewer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/SyncDataViewer.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer; - -import java.util.Set; - -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.Query; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * Data viewer based on a table, which reads data using synchronous methods. - *

- * This viewer implements the {@link IStructuredContentProvider} interface - * which is used by the JFace TableViewer class to populate a Table. This - * interface contains one principal methods for reading data {@link #getElements(Object)}, - * which synchronously returns an array of elements. In order to implement this - * method using the asynchronous data generator, this provider uses the - * {@link Query} object. - *

- */ -public class SyncDataViewer - implements IStructuredContentProvider, IDataGenerator.Listener -{ - // The viewer and generator that this content provider using. - final private TableViewer fViewer; - final private IDataGenerator fDataGenerator; - - public SyncDataViewer(TableViewer viewer, IDataGenerator generator) { - fViewer = viewer; - fDataGenerator = generator; - fDataGenerator.addListener(this); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // Not used - } - - - public Object[] getElements(Object inputElement) { - - // Create the query object for reading data count. - Query countQuery = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - fDataGenerator.getCount(rm); - } - }; - - // Submit the query to be executed. A query implements a runnable - // interface and it has to be executed in order to do its work. - ImmediateExecutor.getInstance().execute(countQuery); - int count = 0; - - // Block until the query completes, which will happen when the request - // monitor of the execute() method is marked done. - try { - count = countQuery.get(); - } catch (Exception e) { - // InterruptedException and ExecutionException can be thrown here. - // ExecutionException containing a CoreException will be thrown - // if an error status is set to the Query's request monitor. - return new Object[0]; - } - - // Create the array that will be filled with elements. - // For each index in the array execute a query to get the element at - // that index. - final Object[] elements = new Object[count]; - - for (int i = 0; i < count; i++) { - final int index = i; - Query valueQuery = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - fDataGenerator.getValue(index, rm); - } - }; - ImmediateExecutor.getInstance().execute(valueQuery); - try { - elements[i] = valueQuery.get(); - } catch (Exception e) { - elements[i] = "error"; - } - } - return elements; - } - - public void dispose() { - fDataGenerator.removeListener(this); - } - - public void countChanged() { - // For any event from the generator, refresh the whole viewer. - refreshViewer(); - } - - public void valuesChanged(Set indexes) { - // For any event from the generator, refresh the whole viewer. - refreshViewer(); - } - - private void refreshViewer() { - // TODO Exercise 5 - Add a call to getElements() to force a deadlock. - - // This method may be called on any thread, switch to the display - // thread before calling the viewer. - Display display = fViewer.getControl().getDisplay(); - display.asyncExec( new Runnable() { - public void run() { - if (!fViewer.getControl().isDisposed()) { - fViewer.refresh(); - } - } - }); - } - - public static void main(String[] args) { - // Create the shell to hold the viewer. - Display display = new Display(); - Shell shell = new Shell(display, SWT.SHELL_TRIM); - shell.setLayout(new GridLayout()); - GridData data = new GridData(GridData.FILL_BOTH); - shell.setLayoutData(data); - Font font = new Font(display, "Courier", 10, SWT.NORMAL); - - // Create the table viewer. - TableViewer tableViewer = new TableViewer(shell, SWT.BORDER); - tableViewer.getControl().setLayoutData(data); - - // Create the data generator. - // TODO Exercise 5 - Use the DataGeneratorWithExecutor() instead. - final IDataGenerator generator = new DataGeneratorWithThread(); - - // Create the content provider which will populate the viewer. - SyncDataViewer contentProvider = new SyncDataViewer(tableViewer, generator); - tableViewer.setContentProvider(contentProvider); - tableViewer.setInput(new Object()); - - // Open the shell and service the display dispatch loop until user - // closes the shell. - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - - // The IDataGenerator.shutdown() method is asynchronous, this requires - // using a query again in order to wait for its completion. - Query shutdownQuery = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - generator.shutdown(rm); - } - }; - ImmediateExecutor.getInstance().execute(shutdownQuery); - try { - shutdownQuery.get(); - } catch (Exception e) {} - - // Shut down the display. - font.dispose(); - display.dispose(); - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/AsyncDataViewer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/AsyncDataViewer.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer.answers; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor; -import org.eclipse.cdt.dsf.concurrent.ThreadSafe; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.DsfExecutor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.Query; -import org.eclipse.cdt.dsf.ui.concurrent.DisplayDsfExecutor; -import org.eclipse.jface.viewers.ILazyContentProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; - -/** - * Data viewer based on a table, which reads data using asynchronous methods. - *

- * This viewer implements the {@link ILazyContentProvider} interface - * which is used by the JFace TableViewer class to populate a Table. This - * interface contains separate asynchronous methods for requesting the count - * and values for individual indexes, which neatly correspond to the methods - * in {@link IDataGenerator}. As an added optimization, this viewer - * implementation checks for the range of visible items in the view upon each - * request, and it cancels old requests which scroll out of view but have not - * been completed yet. However, it is up to the data generator implementation - * to check the canceled state of the requests and ignore them. - *

- */ -@ConfinedToDsfExecutor("fDisplayExecutor") -public class AsyncDataViewer - implements ILazyContentProvider, IDataGenerator.Listener -{ - // Executor to use instead of Display.asyncExec(). - @ThreadSafe - final private DsfExecutor fDisplayExecutor; - - // The viewer and generator that this content provider using. - final private TableViewer fViewer; - final private IDataGenerator fDataGenerator; - - // Fields used in request cancellation logic. - private List fItemDataRequestMonitors = new LinkedList(); - private Set fIndexesToCancel = new HashSet(); - private int fCancelCallsPending = 0; - - public AsyncDataViewer(TableViewer viewer, IDataGenerator generator) { - fViewer = viewer; - fDisplayExecutor = DisplayDsfExecutor.getDisplayDsfExecutor(fViewer.getTable().getDisplay()); - fDataGenerator = generator; - fDataGenerator.addListener(this); - } - - public void dispose() { - fDataGenerator.removeListener(this); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // Set the initial count to the viewer after the input is set. - queryItemCount(); - } - - public void updateElement(final int index) { - // Calculate the visible index range. - final int topIdx = fViewer.getTable().getTopIndex(); - final int botIdx = topIdx + getVisibleItemCount(topIdx); - - // Request the item for the given index. - queryValue(index); - - // Invoke a cancel task with a delay. The delay allows multiple cancel - // calls to be combined together improving performance of the viewer. - fCancelCallsPending++; - fDisplayExecutor.schedule( - new Runnable() { public void run() { - cancelStaleRequests(topIdx, botIdx); - }}, - 1, TimeUnit.MILLISECONDS); - } - - private int getVisibleItemCount(int top) { - Table table = fViewer.getTable(); - int itemCount = table.getItemCount(); - return Math.min((table.getBounds().height / table.getItemHeight()) + 2, itemCount - top); - } - - @ThreadSafe - public void countChanged() { - queryItemCount(); - } - - @ThreadSafe - public void valuesChanged(final Set indexes) { - // Mark the changed items in table viewer as dirty, this will - // trigger update requests for these indexes if they are - // visible in the viewer. - final TableViewer tableViewer = fViewer; - fDisplayExecutor.execute( new Runnable() { - public void run() { - if (!fViewer.getTable().isDisposed()) { - for (Integer index : indexes) { - tableViewer.clear(index); - } - } - }}); - } - - - private void queryItemCount() { - // Request count from data provider. When the count is returned, we - // have to re-dispatch into the display thread to avoid calling - // the table widget on the DSF dispatch thread. - fIndexesToCancel.clear(); - fDataGenerator.getCount( - // Use the display executor to construct the request monitor, this - // will cause the handleCompleted() method to be automatically - // called on the display thread. - new DataRequestMonitor(fDisplayExecutor, null) { - @Override - protected void handleCompleted() { - if (!fViewer.getTable().isDisposed()) { - fViewer.setItemCount(getData()); - fViewer.getTable().clearAll(); - } - } - }); - - } - - - // Dedicated class for data item requests. This class holds the index - // argument so it can be examined when canceling stale requests. - private class ValueDataRequestMonitor extends DataRequestMonitor { - - /** Index is used when canceling stale requests. */ - int fIndex; - - ValueDataRequestMonitor(int index) { - super(fDisplayExecutor, null); - fIndex = index; - } - - @Override - protected void handleCompleted() { - fItemDataRequestMonitors.remove(this); - - // Check if the request completed successfully, otherwise ignore it. - if (isSuccess()) { - if (!fViewer.getTable().isDisposed()) { - fViewer.replace(getData(), fIndex); - } - } - } - } - - private void queryValue(final int index) { - ValueDataRequestMonitor rm = new ValueDataRequestMonitor(index); - fItemDataRequestMonitors.add(rm); - fDataGenerator.getValue(index, rm); - } - - private void cancelStaleRequests(int topIdx, int botIdx) { - // Decrement the count of outstanding cancel calls. - fCancelCallsPending--; - - // Must check again, in case disposed while re-dispatching. - if (fDataGenerator == null || fViewer.getTable().isDisposed()) return; - - // Go through the outstanding requests and cancel any that - // are not visible anymore. - for (Iterator itr = fItemDataRequestMonitors.iterator(); itr.hasNext();) { - ValueDataRequestMonitor item = itr.next(); - if (item.fIndex < topIdx || item.fIndex > botIdx) { - // Set the item to canceled status, so that the data provider - // will ignore it. - item.cancel(); - - // Add the item index to list of indexes that were canceled, - // which will be sent to the table widget. - fIndexesToCancel.add(item.fIndex); - - // Remove the item from the outstanding cancel requests. - itr.remove(); - } - } - if (!fIndexesToCancel.isEmpty() && fCancelCallsPending == 0) { - Set canceledIdxs = fIndexesToCancel; - fIndexesToCancel = new HashSet(); - - // Clear the indexes of the canceled request, so that the - // viewer knows to request them again when needed. - // Note: clearing using TableViewer.clear(int) seems very - // inefficient, it's better to use Table.clear(int[]). - int[] canceledIdxsArray = new int[canceledIdxs.size()]; - int i = 0; - for (Integer index : canceledIdxs) { - canceledIdxsArray[i++] = index; - } - fViewer.getTable().clear(canceledIdxsArray); - } - } - - - public static void main(String[] args) { - // Create the shell to hold the viewer. - Display display = new Display(); - Shell shell = new Shell(display, SWT.SHELL_TRIM); - shell.setLayout(new GridLayout()); - GridData data = new GridData(GridData.FILL_BOTH); - shell.setLayoutData(data); - Font font = new Font(display, "Courier", 10, SWT.NORMAL); - - // Create the table viewer. - TableViewer tableViewer = new TableViewer(shell, SWT.BORDER | SWT.VIRTUAL); - tableViewer.getControl().setLayoutData(data); - - // Create the data generator. - final IDataGenerator generator = new DataGeneratorWithExecutor(); - - // Create the content provider which will populate the viewer. - AsyncDataViewer contentProvider = new AsyncDataViewer(tableViewer, generator); - tableViewer.setContentProvider(contentProvider); - tableViewer.setInput(new Object()); - - // Open the shell and service the display dispatch loop until user - // closes the shell. - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - - // The IDataGenerator.shutdown() method is asynchronous, this requires - // using a query again in order to wait for its completion. - Query shutdownQuery = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - generator.shutdown(rm); - } - }; - ImmediateExecutor.getInstance().execute(shutdownQuery); - try { - shutdownQuery.get(); - } catch (Exception e) {} - - // Shut down the display. - font.dispose(); - display.dispose(); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/DataGeneratorWithExecutor.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/DataGeneratorWithExecutor.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,311 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer.answers; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.TimeUnit; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor; -import org.eclipse.cdt.dsf.concurrent.Immutable; -import org.eclipse.cdt.dsf.concurrent.ThreadSafe; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor; -import org.eclipse.cdt.dsf.concurrent.DsfExecutor; -import org.eclipse.cdt.dsf.concurrent.DsfRunnable; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; -import org.eclipse.cdt.examples.dsf.DsfExamplesPlugin; - -/** - * DSF Executor-based implementation of the data generator. - *

- * This generator uses a queue of client requests and processes these - * requests periodically using a DSF executor. The main feature of this - * generator is that it uses the executor as its only synchronization object. - * This means that all the fields with the exception of the executor can only - * be accessed while running in the executor thread. - *

- */ -@ThreadSafe -public class DataGeneratorWithExecutor implements IDataGenerator { - - // Request objects are used to serialize the interface calls into objects - // which can then be pushed into a queue. - @Immutable - abstract class Request { - final RequestMonitor fRequestMonitor; - - Request(RequestMonitor rm) { - fRequestMonitor = rm; - } - } - - @Immutable - class CountRequest extends Request { - CountRequest(DataRequestMonitor rm) { - super(rm); - } - } - - @Immutable - class ItemRequest extends Request { - final int fIndex; - ItemRequest(int index, DataRequestMonitor rm) { - super(rm); - fIndex = index; - } - } - - // The executor used to access all internal data of the generator. - private DsfExecutor fExecutor; - - // Main request queue of the data generator. The getValue(), getCount(), - // and shutdown() methods write into the queue, while the serviceQueue() - // method reads from it. - // The executor used to access all internal data of the generator. - @ConfinedToDsfExecutor("fExecutor") - private List fQueue = new LinkedList(); - - // List of listeners is not synchronized, it also has to be accessed - // using the executor. - @ConfinedToDsfExecutor("fExecutor") - private List fListeners = new LinkedList(); - - // Current number of elements in this generator. - @ConfinedToDsfExecutor("fExecutor") - private int fCount = MIN_COUNT; - - // Counter used to determine when to reset the element count. - @ConfinedToDsfExecutor("fExecutor") - private int fCountResetTrigger = 0; - - // Elements which were modified since the last reset. - @ConfinedToDsfExecutor("fExecutor") - private Set fChangedIndexes = new HashSet(); - - // Flag used to ensure that requests are processed sequentially. - @ConfinedToDsfExecutor("fExecutor") - private boolean fServiceQueueInProgress = false; - - public DataGeneratorWithExecutor() { - // Create the executor - fExecutor = new DefaultDsfExecutor("Supplier Executor"); - - // Schedule a runnable to make the random changes. - fExecutor.scheduleAtFixedRate( - new DsfRunnable() { - public void run() { - randomChanges(); - } - }, - RANDOM_CHANGE_INTERVAL, - RANDOM_CHANGE_INTERVAL, - TimeUnit.MILLISECONDS); - } - - public void shutdown(final RequestMonitor rm) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - // Empty the queue of requests and fail them. - for (Request request : fQueue) { - request.fRequestMonitor.setStatus( - new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - request.fRequestMonitor.done(); - } - fQueue.clear(); - - // Kill executor. - fExecutor.shutdown(); - rm.done(); - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void getCount(final DataRequestMonitor rm) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - fQueue.add(new CountRequest(rm)); - serviceQueue(); - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void getValue(final int index, final DataRequestMonitor rm) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - fQueue.add(new ItemRequest(index, rm)); - serviceQueue(); - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void addListener(final Listener listener) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - fListeners.add(listener); - } - }); - } catch (RejectedExecutionException e) {} - } - - public void removeListener(final Listener listener) { - try { - fExecutor.execute( new DsfRunnable() { - public void run() { - fListeners.remove(listener); - } - }); - } catch (RejectedExecutionException e) {} - } - - // Main processing function of this generator. - @ConfinedToDsfExecutor("fExecutor") - private void serviceQueue() { - - for (Iterator requestItr = fQueue.iterator(); requestItr.hasNext();) { - Request request = requestItr.next(); - if (request.fRequestMonitor.isCanceled()) { - request.fRequestMonitor.setStatus( - new Status(IStatus.CANCEL, DsfExamplesPlugin.PLUGIN_ID, "Request canceled")); - request.fRequestMonitor.done(); - requestItr.remove(); - } - } - - // If a queue servicing is already scheduled, do nothing. - if (fServiceQueueInProgress) { - return; - } - - if (fQueue.size() != 0) { - // If there are requests to service, remove one from the queue and - // schedule a runnable to process the request after a processing - // delay. - fServiceQueueInProgress = true; - final Request request = fQueue.remove(0); - fExecutor.schedule( - new DsfRunnable() { - public void run() { - if (request instanceof CountRequest) { - processCountRequest((CountRequest)request); - } else if (request instanceof ItemRequest) { - processItemRequest((ItemRequest)request); - } - - // Reset the processing flag and process next - // request. - fServiceQueueInProgress = false; - serviceQueue(); - } - }, - PROCESSING_DELAY, TimeUnit.MILLISECONDS); - } - } - - @ConfinedToDsfExecutor("fExecutor") - private void processCountRequest(CountRequest request) { - @SuppressWarnings("unchecked") // Suppress warning about lost type info. - DataRequestMonitor rm = (DataRequestMonitor)request.fRequestMonitor; - - rm.setData(fCount); - rm.done(); - } - - @ConfinedToDsfExecutor("fExecutor") - private void processItemRequest(ItemRequest request) { - @SuppressWarnings("unchecked") // Suppress warning about lost type info. - DataRequestMonitor rm = (DataRequestMonitor)request.fRequestMonitor; - - if (fChangedIndexes.contains(request.fIndex)) { - rm.setData("Changed: " + request.fIndex); - } else { - rm.setData(Integer.toString(request.fIndex)); - } - rm.done(); - } - - /** - * This method simulates changes in the supplier's data set. - */ - @ConfinedToDsfExecutor("fExecutor") - private void randomChanges() { - // Once every number of changes, reset the count, the rest of the - // times just change certain values. - if (++fCountResetTrigger % RANDOM_COUNT_CHANGE_INTERVALS == 0){ - randomCountReset(); - } else { - randomDataChange(); - } - } - - /** - * Calculates new size for provider's data set. - */ - @ConfinedToDsfExecutor("fExecutor") - private void randomCountReset() { - // Calculate the new count. - Random random = new java.util.Random(); - fCount = MIN_COUNT + Math.abs(random.nextInt()) % (MAX_COUNT - MIN_COUNT); - - // Reset the changed values. - fChangedIndexes.clear(); - - // Notify listeners - for (Listener listener : fListeners) { - listener.countChanged(); - } - } - - /** - * Invalidates a random range of indexes. - */ - @ConfinedToDsfExecutor("fExecutor") - private void randomDataChange() { - // Calculate the indexes to change. - Random random = new java.util.Random(); - Set set = new HashSet(); - for (int i = 0; i < fCount * RANDOM_CHANGE_SET_PERCENTAGE / 100; i++) { - set.add( new Integer(Math.abs(random.nextInt()) % fCount) ); - } - - // Add the indexes to an overall set of changed indexes. - fChangedIndexes.addAll(set); - - // Notify listeners - for (Listener listener : fListeners) { - listener.valuesChanged(set); - } - } -} - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/DataGeneratorWithThread.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/DataGeneratorWithThread.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer.answers; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.Status; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; -import org.eclipse.cdt.examples.dsf.DsfExamplesPlugin; - -/** - * Thread-based implementation of the data generator. - *

- * This generator is based around a queue of client requests and a thread which - * reads the requests from the queue and processes them. The distinguishing - * feature of this generator is that it uses a a blocking queue as the main - * synchronization object. However, fListeners, fShutdown, and fChangedIndexes - * fields also need to be thread-safe and so they implement their own - * synchronization. - *

- */ -public class DataGeneratorWithThread extends Thread implements IDataGenerator { - - // Request objects are used to serialize the interface calls into objects - // which can then be pushed into a queue. - abstract class Request { - final RequestMonitor fRequestMonitor; - - Request(RequestMonitor rm) { - fRequestMonitor = rm; - } - } - - class CountRequest extends Request { - CountRequest(DataRequestMonitor rm) { - super(rm); - } - } - - class ItemRequest extends Request { - final int fIndex; - ItemRequest(int index, DataRequestMonitor rm) { - super(rm); - fIndex = index; - } - } - - class ShutdownRequest extends Request { - ShutdownRequest(RequestMonitor rm) { - super(rm); - } - } - - // Main request queue of the data generator. The getValue(), getCount(), - // and shutdown() methods write into the queue, while the run() method - // reads from it. - private final BlockingQueue fQueue = new LinkedBlockingQueue(); - - // ListenerList class provides thread safety. - private ListenerList fListeners = new ListenerList(); - - // Current number of elements in this generator. - private int fCount = MIN_COUNT; - - // Counter used to determine when to reset the element count. - private int fCountResetTrigger = 0; - - // Elements which were modified since the last reset. - private Set fChangedIndexes = Collections.synchronizedSet(new HashSet()); - - // Used to determine when to make changes in data. - private long fLastChangeTime = System.currentTimeMillis(); - - // Flag indicating when the generator has been shut down. - private AtomicBoolean fShutdown = new AtomicBoolean(false); - - public DataGeneratorWithThread() { - // Immediately kick off the request processing thread. - start(); - } - - public void shutdown(RequestMonitor rm) { - // Mark the generator as shut down. After the fShutdown flag is set, - // all new requests should be shut down. - if (!fShutdown.getAndSet(true)) { - fQueue.add(new ShutdownRequest(rm)); - } else { - // - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void getCount(DataRequestMonitor rm) { - if (!fShutdown.get()) { - fQueue.add(new CountRequest(rm)); - } else { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void getValue(int index, DataRequestMonitor rm) { - if (!fShutdown.get()) { - fQueue.add(new ItemRequest(index, rm)); - } else { - rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, "Supplier shut down")); - rm.done(); - } - } - - public void addListener(Listener listener) { - fListeners.add(listener); - } - - public void removeListener(Listener listener) { - fListeners.remove(listener); - } - - @Override - public void run() { - try { - while(true) { - // Get the next request from the queue. The time-out - // ensures that that the random changes get processed. - final Request request = fQueue.poll(100, TimeUnit.MILLISECONDS); - - // If a request was dequeued, process it. - if (request != null) { - // Simulate a processing delay. - Thread.sleep(PROCESSING_DELAY); - - if (request instanceof CountRequest) { - processCountRequest((CountRequest)request); - } else if (request instanceof ItemRequest) { - processItemRequest((ItemRequest)request); - } else if (request instanceof ShutdownRequest) { - // If shutting down, just break out of the while(true) - // loop and thread will exit. - request.fRequestMonitor.done(); - break; - } - } - - // Simulate data changes. - randomChanges(); - } - } - catch (InterruptedException x) {} - } - - private void processCountRequest(CountRequest request) { - @SuppressWarnings("unchecked") // Suppress warning about lost type info. - DataRequestMonitor rm = (DataRequestMonitor)request.fRequestMonitor; - - rm.setData(fCount); - rm.done(); - } - - private void processItemRequest(ItemRequest request) { - @SuppressWarnings("unchecked") // Suppress warning about lost type info. - DataRequestMonitor rm = (DataRequestMonitor)request.fRequestMonitor; - - if (fChangedIndexes.contains(request.fIndex)) { - rm.setData("Changed: " + request.fIndex); - } else { - rm.setData(Integer.toString(request.fIndex)); - } - rm.done(); - } - - - private void randomChanges() { - // Check if enough time is elapsed. - if (System.currentTimeMillis() > fLastChangeTime + RANDOM_CHANGE_INTERVAL) { - fLastChangeTime = System.currentTimeMillis(); - - // Once every number of changes, reset the count, the rest of the - // times just change certain values. - if (++fCountResetTrigger % RANDOM_COUNT_CHANGE_INTERVALS == 0){ - randomCountReset(); - } else { - randomDataChange(); - } - } - } - - private void randomCountReset() { - // Calculate the new count. - Random random = new java.util.Random(); - fCount = MIN_COUNT + Math.abs(random.nextInt()) % (MAX_COUNT - MIN_COUNT); - - // Reset the changed values. - fChangedIndexes.clear(); - - // Notify listeners - for (Object listener : fListeners.getListeners()) { - ((Listener)listener).countChanged(); - } - } - - private void randomDataChange() { - // Calculate the indexes to change. - Random random = new java.util.Random(); - Set set = new HashSet(); - for (int i = 0; i < fCount * RANDOM_CHANGE_SET_PERCENTAGE / 100; i++) { - set.add( new Integer(Math.abs(random.nextInt()) % fCount) ); - } - - // Add the indexes to an overall set of changed indexes. - fChangedIndexes.addAll(set); - - // Notify listeners - for (Object listener : fListeners.getListeners()) { - ((Listener)listener).valuesChanged(set); - } - } -} - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/IDataGenerator.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/IDataGenerator.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer.answers; - -import java.util.Set; - -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; -import org.eclipse.cdt.dsf.concurrent.ThreadSafe; - -/** - * Data generator is simple source of data used to populate the example table - * view. It contains two asynchronous methods for retrieving the data - * parameters: the count and the value for a given index. It also allows the - * view to receive events indicating when the data supplied by the generator - * is changed. - */ -@ThreadSafe -public interface IDataGenerator { - - // Constants which control the data generator behavior. - // Changing the count range can stress the scalability of the system, while - // changing of the process delay and random change interval can stress - // its performance. - final static int MIN_COUNT = 100; - final static int MAX_COUNT = 200; - final static int PROCESSING_DELAY = 10; - final static int RANDOM_CHANGE_INTERVAL = 10000; - final static int RANDOM_COUNT_CHANGE_INTERVALS = 3; - final static int RANDOM_CHANGE_SET_PERCENTAGE = 10; - - - // Listener interface that the view needs to implement to react - // to the changes in data. - public interface Listener { - void countChanged(); - void valuesChanged(Set indexes); - } - - // Data access methods. - void getCount(DataRequestMonitor rm); - void getValue(int index, DataRequestMonitor rm); - - // Method used to shutdown the data generator including any threads that - // it may use. - void shutdown(RequestMonitor rm); - - // Methods for registering change listeners. - void addListener(Listener listener); - void removeListener(Listener listener); -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/SyncDataViewer.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/dataviewer/answers/SyncDataViewer.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.dataviewer.answers; - -import java.util.Set; - -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.Query; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * Data viewer based on a table, which reads data using synchronous methods. - *

- * This viewer implements the {@link IStructuredContentProvider} interface - * which is used by the JFace TableViewer class to populate a Table. This - * interface contains one principal methods for reading data {@link #getElements(Object)}, - * which synchronously returns an array of elements. In order to implement this - * method using the asynchronous data generator, this provider uses the - * {@link Query} object. - *

- */ -public class SyncDataViewer - implements IStructuredContentProvider, IDataGenerator.Listener -{ - // The viewer and generator that this content provider using. - final private TableViewer fViewer; - final private IDataGenerator fDataGenerator; - - public SyncDataViewer(TableViewer viewer, IDataGenerator generator) { - fViewer = viewer; - fDataGenerator = generator; - fDataGenerator.addListener(this); - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // Not used - } - - - public Object[] getElements(Object inputElement) { - - // Create the query object for reading data count. - Query countQuery = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - fDataGenerator.getCount(rm); - } - }; - - // Submit the query to be executed. A query implements a runnable - // interface and it has to be executed in order to do its work. - ImmediateExecutor.getInstance().execute(countQuery); - int count = 0; - - // Block until the query completes, which will happen when the request - // monitor of the execute() method is marked done. - try { - count = countQuery.get(); - } catch (Exception e) { - // InterruptedException and ExecutionException can be thrown here. - // ExecutionException containing a CoreException will be thrown - // if an error status is set to the Query's request monitor. - return new Object[0]; - } - - // Create the array that will be filled with elements. - // For each index in the array execute a query to get the element at - // that index. - final Object[] elements = new Object[count]; - - for (int i = 0; i < count; i++) { - final int index = i; - Query valueQuery = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - fDataGenerator.getValue(index, rm); - } - }; - ImmediateExecutor.getInstance().execute(valueQuery); - try { - elements[i] = valueQuery.get(); - } catch (Exception e) { - elements[i] = "error"; - } - } - return elements; - } - - public void dispose() { - fDataGenerator.removeListener(this); - } - - public void countChanged() { - // For any event from the generator, refresh the whole viewer. - refreshViewer(); - } - - public void valuesChanged(Set indexes) { - // For any event from the generator, refresh the whole viewer. - refreshViewer(); - } - - private void refreshViewer() { - getElements(null); - - // This method may be called on any thread, switch to the display - // thread before calling the viewer. - Display display = fViewer.getControl().getDisplay(); - display.asyncExec( new Runnable() { - public void run() { - if (!fViewer.getControl().isDisposed()) { - fViewer.refresh(); - } - } - }); - } - - public static void main(String[] args) { - // Create the shell to hold the viewer. - Display display = new Display(); - Shell shell = new Shell(display, SWT.SHELL_TRIM); - shell.setLayout(new GridLayout()); - GridData data = new GridData(GridData.FILL_BOTH); - shell.setLayoutData(data); - Font font = new Font(display, "Courier", 10, SWT.NORMAL); - - // Create the table viewer. - TableViewer tableViewer = new TableViewer(shell, SWT.BORDER); - tableViewer.getControl().setLayoutData(data); - - // Create the data generator. - final IDataGenerator generator = new DataGeneratorWithExecutor(); - - // Create the content provider which will populate the viewer. - SyncDataViewer contentProvider = new SyncDataViewer(tableViewer, generator); - tableViewer.setContentProvider(contentProvider); - tableViewer.setInput(new Object()); - - // Open the shell and service the display dispatch loop until user - // closes the shell. - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - - // The IDataGenerator.shutdown() method is asynchronous, this requires - // using a query again in order to wait for its completion. - Query shutdownQuery = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - generator.shutdown(rm); - } - }; - ImmediateExecutor.getInstance().execute(shutdownQuery); - try { - shutdownQuery.get(); - } catch (Exception e) {} - - // Shut down the display. - font.dispose(); - display.dispose(); - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/Async2Plus2.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/Async2Plus2.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.requestmonitor; - -import java.util.concurrent.Executor; - -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; - -/** - * Example of using a DataRequestMonitor to retrieve a result from an - * asynchronous method. - */ -public class Async2Plus2 { - - public static void main(String[] args) { - Executor executor = ImmediateExecutor.getInstance(); - DataRequestMonitor rm = - new DataRequestMonitor(executor, null) { - @Override - protected void handleCompleted() { - System.out.println("2 + 2 = " + getData()); - } - }; - asyncAdd(2, 2, rm); - } - - static void asyncAdd(int value1, int value2, DataRequestMonitor rm) { - rm.setData(value1 + value2); - rm.done(); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/AsyncHelloWorld.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/AsyncHelloWorld.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.requestmonitor; - -import java.util.concurrent.Executor; - -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; - -/** - * "Hello world" example which uses an asynchronous method to print out - * the result. - *

- * The main method uses an immediate executor, which executes runnables - * as soon as they are submitted, in creating its request monitor. - * - */ -public class AsyncHelloWorld { - - public static void main(String[] args) { - Executor executor = ImmediateExecutor.getInstance(); - RequestMonitor rm = new RequestMonitor(executor, null); - asyncHelloWorld(rm); - } - - static void asyncHelloWorld(RequestMonitor rm) { - System.out.println("Hello world"); - // TODO Exercise 1: - Call the second async. "Hello world 2" method. - // Hint: Calling an asynchronous method requires passing to it a - // request monitor. A new request monitor can be constructed with - // a parent RequestMonitor as an argument argument. The parent gets - // completed automatically when the lower level request monitor is - // completed. - rm.done(); - } - - // TODO: Exercise 1 - Add a second async. "Hello world 2" method. -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/AsyncQuicksort.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/AsyncQuicksort.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.requestmonitor; - -import java.util.Arrays; -import java.util.concurrent.Executor; - -import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; - -/** - * Example of using a CountingRequestMonitor to wait for multiple - * asynchronous calls to complete. - */ -public class AsyncQuicksort { - - static Executor fgExecutor = ImmediateExecutor.getInstance(); - - public static void main(String[] args) { - final int[] array = {5, 7, 8, 3, 2, 1, 9, 5, 4}; - - System.out.println("To sort: " + Arrays.toString(array)); - asyncQuicksort( - array, 0, array.length - 1, - new RequestMonitor(fgExecutor, null) { - @Override - protected void handleCompleted() { - System.out.println("Sorted: " + Arrays.toString(array)); - } - }); - } - - static void asyncQuicksort(final int[] array, final int left, - final int right, final RequestMonitor rm) - { - if (right > left) { - int pivot = left; - // TODO: Exercise 2 - Convert the call to partition into an - // asynchronous call to asyncPartition(). - // Hint: The rest of the code below should be executed inside - // the DataRequestMonitor.handleCompleted() overriding method. - int newPivot = partition(array, left, right, pivot); - printArray(array, left, right, newPivot); - - CountingRequestMonitor countingRm = new CountingRequestMonitor(fgExecutor, rm); - asyncQuicksort(array, left, newPivot - 1, countingRm); - asyncQuicksort(array, newPivot + 1, right, countingRm); - countingRm.setDoneCount(2); - } else { - rm.done(); - } - } - - // TODO Exercise 2 - Convert partition to an asynchronous method. - // Hint: a DataRequestMonitor should be used to carry the - // return value to the caller. - static int partition(int[] array, int left, int right, int pivot) - { - int pivotValue = array[pivot]; - array[pivot] = array[right]; - array[right] = pivotValue; - int store = left; - for (int i = left; i < right; i++) { - if (array[i] <= pivotValue) { - int tmp = array[store]; - array[store] = array[i]; - array[i] = tmp; - store++; - } - } - array[right] = array[store]; - array[store] = pivotValue; - - // TODO: Request Monitors Exercise 2 - Return the data to caller using - // a request monitor. - return store; - } - - static void printArray(int[] array, int left, int right, int pivot) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < array.length; i++ ) { - if (i == left) { - buffer.append('>'); - } else if (i == pivot) { - buffer.append('-'); - } else { - buffer.append(' '); - } - buffer.append(array[i]); - - if (i == right) { - buffer.append('<'); - } else if (i == pivot) { - buffer.append('-'); - } else { - buffer.append(' '); - } - } - - System.out.println(buffer); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/answers/Async2Plus2.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/answers/Async2Plus2.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.requestmonitor.answers; - -import java.util.concurrent.Executor; - -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; - -/** - * Example of using a DataRequestMonitor to retrieve a result from an - * asynchronous method. - */ -public class Async2Plus2 { - - public static void main(String[] args) { - Executor executor = ImmediateExecutor.getInstance(); - DataRequestMonitor rm = - new DataRequestMonitor(executor, null) { - @Override - protected void handleCompleted() { - System.out.println("2 + 2 = " + getData()); - } - }; - asyncAdd(2, 2, rm); - } - - static void asyncAdd(int value1, int value2, DataRequestMonitor rm) { - rm.setData(value1 + value2); - rm.done(); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/answers/AsyncHelloWorld.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/answers/AsyncHelloWorld.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.requestmonitor.answers; - -import java.util.concurrent.Executor; - -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; - -/** - * "Hello world" example which uses an asynchronous method to print out - * the result. - *

- * The main method uses an immediate executor, which executes runnables - * as soon as they are submitted, in creating its request monitor. - * - */ -public class AsyncHelloWorld { - - public static void main(String[] args) { - Executor executor = ImmediateExecutor.getInstance(); - RequestMonitor rm = new RequestMonitor(executor, null); - asyncHelloWorld(rm); - } - - static void asyncHelloWorld(RequestMonitor rm) { - System.out.println("Hello world"); - RequestMonitor rm2 = new RequestMonitor(ImmediateExecutor.getInstance(), rm); - asyncHelloWorld2(rm2); - } - - static void asyncHelloWorld2(RequestMonitor rm) { - System.out.println("Hello world 2"); - rm.done(); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/answers/AsyncQuicksort.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/requestmonitor/answers/AsyncQuicksort.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.examples.dsf.requestmonitor.answers; - -import java.util.Arrays; -import java.util.concurrent.Executor; - -import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; -import org.eclipse.cdt.dsf.concurrent.RequestMonitor; - -/** - * Example of using a CountingRequestMonitor to wait for multiple - * asynchronous calls to complete. - */ -public class AsyncQuicksort { - - static Executor fgExecutor = ImmediateExecutor.getInstance(); - - public static void main(String[] args) { - final int[] array = {5, 7, 8, 3, 2, 1, 9, 5, 4}; - - System.out.println("To sort: " + Arrays.toString(array)); - asyncQuicksort( - array, 0, array.length - 1, - new RequestMonitor(fgExecutor, null) { - @Override - protected void handleCompleted() { - System.out.println("Sorted: " + Arrays.toString(array)); - } - }); - } - - static void asyncQuicksort(final int[] array, final int left, - final int right, final RequestMonitor rm) - { - if (right > left) { - int pivot = left; - asyncPartition( - array, left, right, pivot, - new DataRequestMonitor(fgExecutor, rm) { - @Override - protected void handleCompleted() { - int newPivot = getData(); - printArray(array, left, right, newPivot); - - CountingRequestMonitor countingRm = new CountingRequestMonitor(fgExecutor, rm); - asyncQuicksort(array, left, newPivot - 1, countingRm); - asyncQuicksort(array, newPivot + 1, right, countingRm); - countingRm.setDoneCount(2); - } - }); - } else { - rm.done(); - } - } - - static void asyncPartition(int[] array, int left, int right, int pivot, DataRequestMonitor rm) - { - int pivotValue = array[pivot]; - array[pivot] = array[right]; - array[right] = pivotValue; - int store = left; - for (int i = left; i < right; i++) { - if (array[i] <= pivotValue) { - int tmp = array[store]; - array[store] = array[i]; - array[i] = tmp; - store++; - } - } - array[right] = array[store]; - array[store] = pivotValue; - - // Java 5 automatically converts the int type of the store variable - // to an Integer object. - rm.setData(store); - rm.done(); - } - - static void printArray(int[] array, int left, int right, int pivot) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < array.length; i++ ) { - if (i == left) { - buffer.append('>'); - } else if (i == pivot) { - buffer.append('-'); - } else { - buffer.append(' '); - } - buffer.append(array[i]); - - if (i == right) { - buffer.append('<'); - } else if (i == pivot) { - buffer.append('-'); - } else { - buffer.append(' '); - } - } - - System.out.println(buffer); - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/ServicesShutdownSequence.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/ServicesShutdownSequence.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/ServicesShutdownSequence.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems and others. + * Copyright (c) 2006, 2008 Wind River Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,7 +25,7 @@ */ public class ServicesShutdownSequence extends Sequence { - // Session that the services are running in. + // Session to that the services are running in. final private DsfSession fSession; // DSF Services is created as the first step of the sequence. It diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/TimersVMProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/TimersVMProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/TimersVMProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -42,55 +42,12 @@ /** Enumeration of possible layouts for the timers view model */ public enum ViewLayout { TRIGGERS_AT_TOP, TIMERS_AT_TOP } - /** Have we registered ourselves as a listener for DM events? */ - private boolean fRegisteredEventListener; - public TimersVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) { super(adapter, presentationContext, session); - - // Add ourselves as listener for DM events events. - try { - session.getExecutor().execute(new Runnable() { - public void run() { - if (DsfSession.isSessionActive(getSession().getId())) { - getSession().addServiceEventListener(TimersVMProvider.this, null); - fRegisteredEventListener = true; - } - } - }); - } catch (RejectedExecutionException e) { - // Session shut down, not much we can do but wait to be disposed. - } - // Set the initial view layout. setViewLayout(ViewLayout.TIMERS_AT_TOP); } - /* (non-Javadoc) - * @see org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMProvider#dispose() - */ - @Override - public void dispose() { - // Remove ourselves as listener for DM events events. In practice, we - // get called after the session has shut down, so we'll end up with a - // RejectedExecutionException. We put this here all the same for - // completeness sake. - try { - getSession().getExecutor().execute(new Runnable() { - public void run() { - if (fRegisteredEventListener && DsfSession.isSessionActive(getSession().getId())) { - getSession().removeServiceEventListener(TimersVMProvider.this); - fRegisteredEventListener = false; - } - } - }); - } catch (RejectedExecutionException e) { - // Session shut down, not much we can do but wait to be disposed. - } - - super.dispose(); - } - /** * Configures a new layout for the timers view model. * @param layout New layout to use. diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.gnu.dsf-feature/feature.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt.gnu.dsf-feature/feature.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.gnu.dsf-feature/feature.xml Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java Wed Aug 05 17:35:39 2009 -0500 @@ -136,10 +136,6 @@ private List orderedProjects; private String preLaunchBuildConfiguration; - /** - * Used in conjunction with build before launch settings in the main tab. - */ - private boolean buildForLaunchCalled; abstract public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException; @@ -595,24 +591,11 @@ * @return whether the debug platform should perform an incremental * workspace build before the launch * @throws CoreException - * if an exception occurs while building + * if an exception occurrs while building */ @Override public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { - - buildForLaunchCalled = true; - - // check the build before launch setting and honor it - int buildBeforeLaunchValue = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, - ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING); - - // we shouldn't be getting called if the workspace setting is disabled, so assume we need to - // build unless the user explicitly disabled it in the main tab of the launch. - if (buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED) { - return false; - } - - //This matches the old code, but I don't know that it is the right behavior. + //This matches the old code, but I don't know that it is the right behaviour. //We should be building the local project as well, not just the ordered projects if(orderedProjects == null) { return false; @@ -683,26 +666,6 @@ */ @Override public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { - - if (!buildForLaunchCalled) { - // buildForLaunch was not called which means that the workspace pref is disabled. see if the user enabled the - // launch specific setting in the main tab. if so, we do call buildBeforeLaunch here. - if (ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED == configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, - ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING)) { - - IProgressMonitor buildMonitor = new SubProgressMonitor(monitor, 10, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); - buildMonitor.beginTask(LaunchMessages.getString("AbstractCLaunchDelegate.BuildBeforeLaunch"), 10); //$NON-NLS-1$ - buildMonitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.PerformingBuild")); //$NON-NLS-1$ - if (buildForLaunch(configuration, mode, new SubProgressMonitor(buildMonitor, 7))) { - buildMonitor.subTask(LaunchMessages.getString("AbstractCLaunchDelegate.PerformingIncrementalBuild")); //$NON-NLS-1$ - ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(buildMonitor, 3)); - } - else { - buildMonitor.worked(3); /* No incremental build required */ - } - } - } - boolean continueLaunch = true; if(orderedProjects == null) { return continueLaunch; @@ -807,8 +770,6 @@ monitor = new NullProgressMonitor(); } - buildForLaunchCalled = false; - int scale = 1000; int totalWork = 2 * scale; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties Wed Aug 05 17:35:39 2009 -0500 @@ -30,9 +30,6 @@ AbstractCLaunchDelegate.searching_for_errors_in=Searching for compile errors in AbstractCLaunchDelegate.20=Building prerequisite project list AbstractCLaunchDelegate.Program_is_not_a_recongnized_executable=Program is not a recognized executable. -AbstractCLaunchDelegate.BuildBeforeLaunch=Build before launch - -AbstractCLaunchDelegate.PerformingBuild=Performing required build... -AbstractCLaunchDelegate.PerformingIncrementalBuild=Performing incremental workspace build... LocalRunLaunchDelegate.Launching_Local_C_Application=Launching Local C/C++ Application LocalRunLaunchDelegate.Failed_setting_runtime_option_though_debugger=Failed to set program arguments, environment or working directory. @@ -89,15 +86,6 @@ CMainTab.Use_Active=Use Active #For CMainTab.Configuration_name: {0} - project name; {1} - configuration name CMainTab.Configuration_name={0} {1} -CMainTab.Build_options=Build (if required) before launching -CMainTab.Disable_build_button_label=Disable auto build -CMainTab.Disable_build_button_tooltip=Requires manually building project before launching (this may improve launch performance) -CMainTab.Enable_build_button_label=Enable auto build -CMainTab.Enable_build_button_tooltip=Always build project before launching (this may impact launch performance) -CMainTab.Workspace_settings_button_label=Use workspace settings -CMainTab.Workspace_settings_button_tooltip=Use workspace settings -CMainTab.Workspace_settings_link_label=Configure Workspace Settings... -CMainTab.Workspace_settings_page_id=org.eclipse.debug.ui.LaunchingPreferencePage CDebuggerTab.Advanced_Options_Dialog_Title=Advanced Options CDebuggerTab.Stop_at_main_on_startup=Stop on startup at: diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java Wed Aug 05 17:35:39 2009 -0500 @@ -66,12 +66,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.ElementListSelectionDialog; -import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.dialogs.TwoPaneElementSelector; /** @@ -117,11 +114,6 @@ * @since 6.0 */ protected Combo fBuildConfigCombo; - // Build option UI widgets - protected Button fDisableBuildButton; - protected Button fEnableBuildButton; - protected Button fWorkspaceSettingsButton; - protected Link fWorkpsaceSettingsLink; private final boolean fWantsTerminalOption; protected Button fTerminalButton; @@ -172,7 +164,6 @@ createVerticalSpacer(comp, 1); createProjectGroup(comp, 1); createBuildConfigCombo(comp, 1); - createBuildOptionGroup(comp, 1); createExeFileGroup(comp, 1); createVerticalSpacer(comp, 1); if (fSpecifyCoreFile) { @@ -329,65 +320,6 @@ }); } - protected void createBuildOptionGroup(final Composite parent, int colSpan) { - Group buildGroup = new Group(parent, SWT.NONE); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = colSpan; - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - gridLayout.marginHeight = 5; - gridLayout.marginWidth = 5; - gridLayout.makeColumnsEqualWidth= true; - buildGroup.setLayoutData(gridData); - buildGroup.setLayout(gridLayout); - buildGroup.setText("Build (if required) before launching"); //$NON-NLS-1$ - - fDisableBuildButton = new Button(buildGroup, SWT.RADIO); - fDisableBuildButton.setText(LaunchMessages.getString("CMainTab.Disable_build_button_label")); //$NON-NLS-1$ - fDisableBuildButton.setToolTipText(LaunchMessages.getString("CMainTab.Disable_build_button_tooltip")); //$NON-NLS-1$ - fDisableBuildButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - - new Label(buildGroup, SWT.NONE); - - fEnableBuildButton = new Button(buildGroup, SWT.RADIO); - fEnableBuildButton.setText(LaunchMessages.getString("CMainTab.Enable_build_button_label")); //$NON-NLS-1$ - fEnableBuildButton.setToolTipText(LaunchMessages.getString("CMainTab.Enable_build_button_tooltip")); //$NON-NLS-1$ - fEnableBuildButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - - new Label(buildGroup, SWT.NONE); - - fWorkspaceSettingsButton = new Button(buildGroup, SWT.RADIO); - fWorkspaceSettingsButton.setText(LaunchMessages.getString("CMainTab.Workspace_settings_button_label")); //$NON-NLS-1$ - fWorkspaceSettingsButton.setToolTipText(LaunchMessages.getString("CMainTab.Workspace_settings_button_tooltip")); //$NON-NLS-1$ - fWorkspaceSettingsButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - - fWorkpsaceSettingsLink = new Link(buildGroup, SWT.NONE); //$NON-NLS-1$ - fWorkpsaceSettingsLink.setText(LaunchMessages.getString("CMainTab.Workspace_settings_link_label")); //$NON-NLS-1$ - fWorkpsaceSettingsLink.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - PreferencesUtil.createPreferenceDialogOn( - parent.getShell(), - LaunchMessages.getString("CMainTab.Workspace_settings_page_id"), //$NON-NLS-1$ - null, - null).open(); - } - }); - } /** @since 6.0 */ protected void createCoreFileGroup(Composite parent, int colSpan) { Composite coreComp = new Composite(parent, SWT.NONE); @@ -463,7 +395,6 @@ updateProjectFromConfig(config); updateProgramFromConfig(config); updateCoreFromConfig(config); - updateBuildOptionFromConfig(config); updateTerminalFromConfig(config); } @@ -493,16 +424,13 @@ } protected void updateProgramFromConfig(ILaunchConfiguration config) { - if (fProgText != null) - { - String programName = EMPTY_STRING; - try { - programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING); - } catch (CoreException ce) { - LaunchUIPlugin.log(ce); - } - fProgText.setText(programName); + String programName = EMPTY_STRING; + try { + programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING); + } catch (CoreException ce) { + LaunchUIPlugin.log(ce); } + fProgText.setText(programName); } /** @since 6.0 */ @@ -514,23 +442,10 @@ } catch (CoreException ce) { LaunchUIPlugin.log(ce); } - fProgText.setText(coreName); + fCoreText.setText(coreName); } } - - protected void updateBuildOptionFromConfig(ILaunchConfiguration config) { - int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING; - try { - buildBeforeLaunchValue = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue); - } catch (CoreException e) { - LaunchUIPlugin.log(e); - } - - fDisableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED); - fEnableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED); - fWorkspaceSettingsButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING); - } - + /* * (non-Javadoc) * @@ -549,28 +464,14 @@ config.setMappedResources(null); } config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText()); - if (fBuildConfigCombo != null) { - config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, (String)fBuildConfigCombo.getData(Integer.toString(fBuildConfigCombo.getSelectionIndex()))); - } - if (fProgText != null) { - config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText()); - } + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, (String)fBuildConfigCombo.getData(Integer.toString(fBuildConfigCombo.getSelectionIndex()))); + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText()); if (fCoreText != null) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, fCoreText.getText()); } if (fTerminalButton != null) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, fTerminalButton.getSelection()); } - - if (fDisableBuildButton != null) { - int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING; - if (fDisableBuildButton.getSelection()) { - buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED; - } else if (fEnableBuildButton.getSelection()) { - buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED; - } - config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue); - } } /** diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF --- a/cdt/cdt_6_0_x/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.make.ui; singleton:=true -Bundle-Version: 6.1.0.qualifier +Bundle-Version: 6.0.1.qualifier Bundle-Activator: org.eclipse.cdt.make.internal.ui.MakeUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java Wed Aug 05 17:35:39 2009 -0500 @@ -59,6 +59,8 @@ import org.eclipse.swt.dnd.FileTransfer; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Shell; @@ -124,7 +126,18 @@ handleSelectionChanged(event); } }); + fViewer.getControl().addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent event) { + if (event.character == SWT.DEL && event.stateMask == 0) { + handleDeleteKeyPressed(); + } + } + }); + + fViewer.setContentProvider(new MakeContentProvider()); + fViewer.setLabelProvider(new MakeLabelProvider()); fViewer.setSorter(new ViewerSorter() { @Override @@ -332,6 +345,10 @@ // manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } + protected void handleDeleteKeyPressed() { + deleteTargetAction.run(); + } + protected void handleDoubleClick(DoubleClickEvent event) { buildTargetAction.run(); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/makefile --- a/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/makefile Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/makefile Wed Aug 05 17:35:39 2009 -0500 @@ -1,43 +1,43 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -ROOT := .. - --include $(ROOT)/makefile.init - -RM := rm -rf - -# All of the sources participating in the build are defined here --include sources.mk --include $(SUBDIRS:%=%/subdir.mk) --include objects.mk -ifneq ($(strip $(DEPS)),) --include $(DEPS) -endif - --include $(ROOT)/makefile.defs - -# Add inputs and outputs from these tool invocations to the build variables - -# All Target -all: lib.a - -# Tool invocations -lib.a: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: MBS30.archiver.gnu' - @echo ar -r lib.a $(OBJS) $(USER_OBJS) $(LIBS) - @ar -r lib.a $(OBJS) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' - -# Other Targets -clean: - -$(RM) $(OBJS)$(ARCHIVES)$(DEPS) lib.a - -@echo ' ' - -.PHONY: all clean dependents -.SECONDARY: - --include $(ROOT)/makefile.targets +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +ROOT := .. + +-include $(ROOT)/makefile.init + +RM := rm -rf + +# All of the sources participating in the build are defined here +-include sources.mk +-include $(SUBDIRS:%=%/subdir.mk) +-include objects.mk +ifneq ($(strip $(DEPS)),) +-include $(DEPS) +endif + +-include $(ROOT)/makefile.defs + +# Add inputs and outputs from these tool invocations to the build variables + +# All Target +all: lib.a + +# Tool invocations +lib.a: $(OBJS) $(USER_OBJS) + @echo 'Building target: $@' + @echo 'Invoking: MBS30.archiver.gnu' + @echo ar -r lib.a $(OBJS) $(USER_OBJS) $(LIBS) + @ar -r lib.a $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Finished building target: $@' + @echo ' ' + +# Other Targets +clean: + -$(RM) $(OBJS)$(ARCHIVES)$(DEPS) lib.a + -@echo ' ' + +.PHONY: all clean dependents +.SECONDARY: + +-include $(ROOT)/makefile.targets diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/objects.mk --- a/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/objects.mk Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/objects.mk Wed Aug 05 17:35:39 2009 -0500 @@ -1,7 +1,7 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -LIBS := - +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +LIBS := + USER_OBJS := \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/sources.mk --- a/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/sources.mk Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/sources.mk Wed Aug 05 17:35:39 2009 -0500 @@ -1,14 +1,14 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -C_SRCS := -O_SRCS := -OBJS := -ARCHIVES := -DEPS := - -# Every subdirectory with source files must be described here -SUBDIRS := \ -. \ - +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +C_SRCS := +O_SRCS := +OBJS := +ARCHIVES := +DEPS := + +# Every subdirectory with source files must be described here +SUBDIRS := \ +. \ + diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/subdir.mk --- a/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/subdir.mk Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core.tests/resources/test30Projects/linkedFolder/Benchmarks/subdir.mk Wed Aug 05 17:35:39 2009 -0500 @@ -1,34 +1,34 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -# Add inputs and outputs from these tool invocations to the build variables -C_SRCS += \ -$(ROOT)/f1.c \ -$(ROOT)/f2.c - -OBJS += \ -${addprefix ./, \ -f1.o \ -f2.o \ -} - -DEPS += \ -${addprefix ./, \ -f1.d \ -f2.d \ -} - - -# Each subdirectory must supply rules for building sources it contributes -%.o: $(ROOT)/%.c - @echo 'Building file: $<' - @echo 'Invoking: MBS30.compiler.gnu.c' - @echo gcc -O0 -g3 -Wall -c -fmessage-length=0 -o$@ $< - @gcc -O0 -g3 -Wall -c -fmessage-length=0 -o$@ $< && \ - echo -n $(@:%.o=%.d) $(dir $@) > $(@:%.o=%.d) && \ - gcc -MM -MG -P -w -O0 -g3 -Wall -c -fmessage-length=0 $< >> $(@:%.o=%.d) - @echo 'Finished building: $<' - @echo ' ' - - +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +$(ROOT)/f1.c \ +$(ROOT)/f2.c + +OBJS += \ +${addprefix ./, \ +f1.o \ +f2.o \ +} + +DEPS += \ +${addprefix ./, \ +f1.d \ +f2.d \ +} + + +# Each subdirectory must supply rules for building sources it contributes +%.o: $(ROOT)/%.c + @echo 'Building file: $<' + @echo 'Invoking: MBS30.compiler.gnu.c' + @echo gcc -O0 -g3 -Wall -c -fmessage-length=0 -o$@ $< + @gcc -O0 -g3 -Wall -c -fmessage-length=0 -o$@ $< && \ + echo -n $(@:%.o=%.d) $(dir $@) > $(@:%.o=%.d) && \ + gcc -MM -MG -P -w -O0 -g3 -Wall -c -fmessage-length=0 $< >> $(@:%.o=%.d) + @echo 'Finished building: $<' + @echo ' ' + + diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedOptionValueHandler.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedOptionValueHandler.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedOptionValueHandler.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 Symbian Ltd and others. + * Copyright (c) 2005, 2007 Symbian Ltd and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,121 +11,104 @@ package org.eclipse.cdt.managedbuilder.core; /** - * This interface represents an option value handler in the managed build + * This interface represents an option value handler in the managed build * system. It is used to enable a tool integrator to use the MBS configuration * GUI, while linking to an alternative back-end. * * @since 3.0 */ -public interface IManagedOptionValueHandler { - - /** - * The option is opened, i.e. its UI element is created. The valueHandler - * can override the value of the option. If it does not, the last persisted - * value is used. - */ - public final int EVENT_OPEN = 1; - - /** - * The option is closed. i.e. its value has been destroyed when a - * configuration/resource gets deleted. The value handler can do various - * things associated with destroying the option such as freeing the memory - * associated with this option callback, if needed. - */ - public final int EVENT_CLOSE = 2; +public interface IManagedOptionValueHandler{ - /** - * The default value option::defaultValue has been set. The handleValue - * callback is called afterwards to give the handler a chance to override - * the value or to update the value in its back-end. Typically this event - * will be called when the Restore Defaults button is pressed. - */ - public final int EVENT_SETDEFAULT = 3; - - /** - * The option has been set by pressing the Apply button (or the OK button). - * The valueHandler can transfer the value of the option to its own - * back-end. - */ - public final int EVENT_APPLY = 4; - - /** - * Posted when the managed build extensions (defined in the manifest files) - * are loaded. The handler is allowed to adjust the extension elements - */ - public final int EVENT_LOAD = 5; + public final int EVENT_OPEN = 1; /** The option is opened, i.e. its UI element + * is created. The valueHandler can override + * the value of the option. If it does not, + * the last persisted value is used. */ + public final int EVENT_CLOSE = 2; /** The option is closed. i.e. its value has been + * destroyed when a configuration/resource gets deleted. + * The valuehandler can do various things assocaited with + * destroying the option such as freeing the memory + * associated with this option callback, if needed. */ + public final int EVENT_SETDEFAULT = 3; /** The default value option::defaultValue has + * been set. The handleValue callback is called + * afterwards to give the handler a chance to + * override the value or to update the value in + * its back-end. Typically this event will be called + * when the Restore Defaults button is pressed. */ + public final int EVENT_APPLY = 4; /** The option has been set by pressing the Apply + * button (or the OK button). The valueHandler can + * transfer the value of the option to its own + * back-end. */ + public final int EVENT_LOAD = 5; /** Posted when the managed build extensions (defined in the manifest files) + * are loadded. + * The handler is allowed to adjust the extension elements + */ + +/** + * Handles transfer between values between UI element and + * back-end in different circumstances. + * + * @param configuration build configuration of option + * (may be IConfiguration or IResourceConfiguration) + * @param holder contains the holder of the option + * @param option the option that is handled + * @param extraArgument extra argument for handler + * @param event event to be handled + * + * @return True when the event was handled, false otherwise. + * This enables default event handling can take place. + */ +boolean handleValue(IBuildObject configuration, + IHoldsOptions holder, + IOption option, + String extraArgument, + int event); - /** - * Handles transfer between values between UI element and back-end in - * different circumstances. - * - * @param configuration - * build configuration of option (may be IConfiguration or - * IResourceConfiguration) - * @param holder - * contains the holder of the option - * @param option - * the option that is handled - * @param extraArgument - * extra argument for handler - * @param event - * event to be handled - * - * @return True when the event was handled, false otherwise. This enables - * default event handling can take place. - */ - boolean handleValue(IBuildObject configuration, IHoldsOptions holder, - IOption option, String extraArgument, int event); +/** + * Checks whether the value of an option is its default value. + * + * @param configuration build configuration of option + * (may be IConfiguration or IResourceConfiguration) + * @param holder contains the holder of the option + * @param option the option that is handled + * @param extraArgument extra argument for handler + * + * The additional options besides configuration are supplied to + * provide enough information for querying the default value from + * a potential data storage back-end. + * + * @return True if the options value is its default value and + * False otherwise. This enables that default event handling can + * take place. + */ +boolean isDefaultValue(IBuildObject configuration, + IHoldsOptions holder, + IOption option, + String extraArgument); - /** - * Checks whether the value of an option is its default value. - * - * @param configuration - * build configuration of option (may be IConfiguration or - * IResourceConfiguration) - * @param holder - * contains the holder of the option - * @param option - * the option that is handled - * @param extraArgument - * extra argument for handler - * - * The additional options besides configuration are supplied to - * provide enough information for querying the default value from - * a potential data storage back-end. - * - * @return True if the options value is its default value and False - * otherwise. This enables that default event handling can take - * place. - */ - boolean isDefaultValue(IBuildObject configuration, IHoldsOptions holder, - IOption option, String extraArgument); - - /** - * Checks whether an enumeration value of an option is currently a valid - * choice. The use-case for this method is the case, where the set of valid - * enumerations in the plugin.xml file changes. The UI will remove entries - * from selection lists if the value returns false. - * - * @param configuration - * build configuration of option (may be IConfiguration or - * IResourceConfiguration) - * @param holder - * contains the holder of the option - * @param option - * the option that is handled - * @param extraArgument - * extra argument for handler - * @param enumValue - * enumeration value that is to be checked - * - * The additional options besides configuration are supplied to - * provide enough information for querying information from a a - * potential data storage back-end. - * - * @return True if the enumeration value is valid and False otherwise. - */ - boolean isEnumValueAppropriate(IBuildObject configuration, - IHoldsOptions holder, IOption option, String extraArgument, - String enumValue); +/** + * Checks whether an enumeration value of an option is currently a + * valid choice. The use-case for this method is the case, where + * the set of valid enumerations in the plugin.xml file changes. + * The UI will remove entries from selection lists if the value + * returns false. + * + * @param configuration build configuration of option + * (may be IConfiguration or IResourceConfiguration) + * @param holder contains the holder of the option + * @param option the option that is handled + * @param extraArgument extra argument for handler + * @param enumValue enumeration value that is to be checked + * + * The additional options besides configuration are supplied to + * provide enough information for querying information from a + * a potential data storage back-end. + * + * @return True if the enumeration value is valid and False + * otherwise. + */ +boolean isEnumValueAppropriate(IBuildObject configuration, + IHoldsOptions holder, + IOption option, + String extraArgument, + String enumValue); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java Wed Aug 05 17:35:39 2009 -0500 @@ -4691,11 +4691,8 @@ " ", //$NON-NLS-1$ IBuildMacroProvider.CONTEXT_CONFIGURATION, builder); - if (resolved!=null) { - resolved = resolved.trim(); - if(resolved.length() > 0) - buildTargetName = resolved; - } + if((resolved = resolved.trim()).length() > 0) + buildTargetName = resolved; } catch (BuildMacroException e){ } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.master/feature.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt.master/feature.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.master/feature.xml Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.platform-feature/feature.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt.platform-feature/feature.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.platform-feature/feature.xml Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/build.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/build.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/build.xml Wed Aug 05 17:35:39 2009 -0500 @@ -17,7 +17,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -300,9 +300,8 @@ ]]> - -

  • @buildId@
  • ]]> - + @buildId@ + ]]> diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/buildsite.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/buildsite.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/buildsite.xml Wed Aug 05 17:35:39 2009 -0500 @@ -3,10 +3,10 @@ - + - + @@ -45,10 +45,10 @@ - + - + diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/c99/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/c99/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/c99/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/crossgcc/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/crossgcc/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/crossgcc/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/dsfgdb/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/dsfgdb/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/dsfgdb/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/gdbjtag/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/gdbjtag/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/gdbjtag/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/launch.remote/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/launch.remote/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/launch.remote/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/lrparser.sdk/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/lrparser.sdk/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/lrparser.sdk/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/lrparser/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/lrparser/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/lrparser/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/master/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/master/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/master/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -34,7 +34,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/memory/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/memory/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/memory/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/mylyn/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/mylyn/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/mylyn/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -27,7 +27,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/p2/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/p2/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/p2/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/platform/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/platform/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/platform/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -27,7 +27,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/sdk/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/sdk/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/sdk/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -27,7 +27,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/testing/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/testing/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/testing/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/upc.sdk/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/upc.sdk/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/upc.sdk/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/upc/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/upc/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/upc/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/util/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/util/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/util/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -27,7 +27,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/windows/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/windows/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/windows/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/xlc.sdk/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/xlc.sdk/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/xlc.sdk/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -27,7 +27,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.releng/xlc/build.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.releng/xlc/build.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.releng/xlc/build.properties Wed Aug 05 17:35:39 2009 -0500 @@ -28,7 +28,7 @@ # for example, when doing a nightly build out of HEAD # fetchTag=HEAD -cdtTag=HEAD +cdtTag=cdt_6_0 ############## BUILD / GENERATION CONTROL ################ # The directory into which the build elements will be fetched and where diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.sdk-feature/feature.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt.sdk-feature/feature.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.sdk-feature/feature.xml Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.sdk/META-INF/MANIFEST.MF --- a/cdt/cdt_6_0_x/org.eclipse.cdt.sdk/META-INF/MANIFEST.MF Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.sdk/META-INF/MANIFEST.MF Wed Aug 05 17:35:39 2009 -0500 @@ -2,6 +2,6 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.sdk;singleton:=true -Bundle-Version: 6.1.0.qualifier +Bundle-Version: 5.1.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstantHistory.rts --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstantHistory.rts Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,232 +0,0 @@ -//!ExtractConstantInt -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - void bar(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - void bar(); - static const int theAnswer = 42; -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} - -int A::foo() -{ - return 42; //Hallo -} - -void A::bar() -{ - int a = 42; - int b = 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} - -int A::foo() -{ - return theAnswer; //Hallo -} - -void A::bar() -{ - int a = theAnswer; - int b = theAnswer; -} - -//@refScript.xml - - - - - - -//!replaceNumberProtected -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); -protected: - static const int theAnswer = 42; -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} - -int A::foo() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} - -int A::foo() -{ - return theAnswer; -} - -//@refScript.xml - - - - - -//!replaceNumberPrivate -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); -private: - static const int theAnswer = 42; -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} - -int A::foo() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} - -int A::foo() -{ - return theAnswer; -} - -//@refScript.xml - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariableHistory.rts --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariableHistory.rts Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -//!extract local variable from for loop -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@main.cpp -void foo(){ - for(int n = 5 + 2; n < 10; ++n); -} - -//= -void foo(){ - int i = 5 + 2; - for(int n = i; n < 10; ++n); -} - -//@refScript.xml - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodDuplicates.rts --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodDuplicates.rts Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1075 +0,0 @@ -//!ExtractFunctionRefactoringTest with duplicates -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - void exp(int & i); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - ++i; - help(); -}int A::foo() -{ - int i = 2; - /*$*/++i; - help();/*$$*/ - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - exp(i); -}void A::exp(int & i) -{ - ++i; - help(); -} - -int A::foo() -{ - int i = 2; - exp(i); - return i; -} - -int A::help() -{ - return 42; -} - -//!ExtractFunctionRefactoringTest duplicates with different Names -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - void exp(int & i); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int oo = 99; - ++oo; - help(); -}int A::foo() -{ - int i = 2; - /*$*/++i; - help();/*$$*/ - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int oo = 99; - exp(oo); -}void A::exp(int & i) -{ - ++i; - help(); -} - -int A::foo() -{ - int i = 2; - exp(i); - return i; -} - -int A::help() -{ - return 42; -} - -//!ExtractFunctionRefactoringTest dublicate with field -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -returnvalue=true -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - void foo(); - int i; - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - void foo(); - int i; - -private: - int help(); - int exp(int j, int & a); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int j = 0; - i++; - j++; - help(); -}void A::foo() -{ - int j = 0; - int a = 1; - /*$*/j++; - a++; - help();/*$$*/ - a++; - j++; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int j = 0; - i = exp(i, j); -}int A::exp(int j, int & a) -{ - j++; - a++; - help(); - return j; -} - -void A::foo() -{ - int j = 0; - int a = 1; - j = exp(j, a); - a++; - j++; -} - -int A::help() -{ - return 42; -} - -//!ExtractFunctionRefactoringTest dublicate with field in marked scope -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -returnvalue=true -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - void foo(); - int i; - int field; - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - void foo(); - int i; - int field; - -private: - int help(); - int exp(int j); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int j = 0; - int a = 1; - a++; - j++; - help(); -}void A::foo() -{ - int j = 0; - - /*$*/field++; - j++; - help();/*$$*/ - field++; - j++; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int j = 0; - int a = 1; - a++; - j++; - help(); -}int A::exp(int j) -{ - field++; - j++; - help(); - return j; -} - -void A::foo() -{ - int j = 0; - j = exp(j); - field++; - j++; -} - -int A::help() -{ - return 42; -} - -//!ExtractFunctionRefactoringTest duplicates with different Names and return type -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -returnvalue=true -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - int exp(int i, float & j); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int oo = 99; - float blabla = 0; - ++oo; - blabla += 1; - help(); - blabla += 1; -}int A::foo() -{ - int i = 2; - float j = 8989; - /*$*/++i; - j+=1; - help();/*$$*/ - j++; - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int oo = 99; - float blabla = 0; - oo = exp(oo, blabla); - blabla += 1; -}int A::exp(int i, float & j) -{ - ++i; - j += 1; - help(); - return i; -} - -int A::foo() -{ - int i = 2; - float j = 8989; - i = exp(i, j); - j++; - return i; -} - -int A::help() -{ - return 42; -} - -//!ExtractFunctionRefactoringTest duplicates with a lot of different Names an variable not used afterwards in the duplicate -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - void exp(int & i, float j); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int oo = 99; - float blabla = 0; - ++oo; - blabla += 1; - help(); -}int A::foo() -{ - int i = 2; - float j = 8989; - /*$*/++i; - j+=1; - help();/*$$*/ - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int oo = 99; - float blabla = 0; - exp(oo, blabla); -}void A::exp(int & i, float j) -{ - ++i; - j += 1; - help(); -} - -int A::foo() -{ - int i = 2; - float j = 8989; - exp(i, j); - return i; -} - -int A::help() -{ - return 42; -} - -//!ExtractFunctionRefactoringTest with duplicates name used afterwards in duplicate but not in original selection this is no dublicate -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - void foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - void foo(); - -private: - int help(); - void exp(int i); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - ++i;// No Duplicate - help(); - ++i;// this is the reason -}void A::foo() -{ - int i = 2; - /*$*/++i; - help();/*$$*/ -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - ++i;// No Duplicate - help(); - ++i;// this is the reason -}void A::exp(int i) -{ - ++i; - help(); -} - -void A::foo() -{ - int i = 2; - exp(i); -} - -int A::help() -{ - return 42; -} - -//!ExtractFunctionRefactoringTest with Return Value and a lot Ref Parameter and a method call -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -returnvalue=true -//@A.h -#ifndef A_H_ -#define A_H_ - -#include "B.h" - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -#include "B.h" - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - int exp(int i, B *& b, int & y, float & x); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - float x = i; - B* b = new B(); - int y = x + i; - ++i; - b->hello(y); - i = i + x; - help(); - b->hello(y); - ++x; - i++; -}int A::foo() -{ - int i = 2; - float x = i; - B* b = new B(); - int y = x + i; - /*$*/++i; - b->hello(y); - i = i + x; - help();/*$$*/ - b->hello(y); - ++x; - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - float x = i; - B* b = new B(); - int y = x + i; - i = exp(i, b, y, x); - b->hello(y); - ++x; - i++; -}int A::exp(int i, B *& b, int & y, float & x) -{ - ++i; - b->hello(y); - i = i + x; - help(); - return i; -} - -int A::foo() -{ - int i = 2; - float x = i; - B* b = new B(); - int y = x + i; - i = exp(i, b, y, x); - b->hello(y); - ++x; - return i; -} - -int A::help() -{ - return 42; -} - -//@B.h -#ifndef B_H_ -#define B_H_ - -class B -{ -public: - B(); - virtual ~B(); - void hello(float y); -}; - -#endif /*B_H_*/ - -//!ExtractFunctionRefactoringTest with Return Value and a lot Ref Parameter and a method call, duplicate is not similar -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -returnvalue=true -//@A.h -#ifndef A_H_ -#define A_H_ - -#include "B.h" - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -#include "B.h" - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - int exp(int i, B *& b, int & y, float x); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - float x = i; - B* b = new B(); - int y = x + i; - ++i; - b->hello(y); - i = i + x; - help(); - b->hello(y); - ++x; - i++; -}int A::foo() -{ - int i = 2; - float x = i; - B* b = new B(); - int y = x + i; - /*$*/++i; - b->hello(y); - i = i + x; - help();/*$$*/ - b->hello(y); - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - float x = i; - B* b = new B(); - int y = x + i; - ++i; - b->hello(y); - i = i + x; - help(); - b->hello(y); - ++x; - i++; -}int A::exp(int i, B *& b, int & y, float x) -{ - ++i; - b->hello(y); - i = i + x; - help(); - return i; -} - -int A::foo() -{ - int i = 2; - float x = i; - B* b = new B(); - int y = x + i; - i = exp(i, b, y, x); - b->hello(y); - return i; -} - -int A::help() -{ - return 42; -} - -//@B.h -#ifndef B_H_ -#define B_H_ - -class B -{ -public: - B(); - virtual ~B(); - void hello(float y); -}; - -#endif /*B_H_*/ - -//!ExtractFunctionRefactoringTest with duplicates and comments -//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest -//@.config -replaceduplicates=true -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - void exp(int & i); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - ++i; - help(); -}int A::foo() -{ - int i = 2; - /*$*/++i; - help();/*$$*/ - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int i = 2; - exp(i); -}void A::exp(int & i) -{ - ++i; - help(); -} - -int A::foo() -{ - int i = 2; - exp(i); - return i; -} - -int A::help() -{ - return 42; -} - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodHistory.rts --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodHistory.rts Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,362 +0,0 @@ -//!ExtractFunctionHistoryRefactoringTest variable defined in scope -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - int exp(); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} -int A::foo() -{ - int i = 2; - ++i; - help(); - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} -int A::exp() -{ - int i = 2; - ++i; - help(); - return i; -} - -int A::foo() -{ - int i = exp(); - return i; -} - -int A::help() -{ - return 42; -} - -//@refScript.xml - - - - - - -//!ExtractFunctionHistoryRefactoringTest -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - void exp(int & i); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} -int A::foo() -{ - int i = 2; - //comment - ++i; - help(); - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ -} -void A::exp(int & i) -{ - //comment - ++i; - help(); -} - -int A::foo() -{ - int i = 2; - exp(i); - return i; -} - -int A::help() -{ - return 42; -} - -//@refScript.xml - - - - - -//!Extract Function History first extracted statement with leading comment -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@main.cpp -int main(){ - - int i; - // Comment - i= 7; - return i; -} - -//= -void exp(int & i) -{ - // Comment - i = 7; -} - -int main(){ - - int i; - exp(i); - return i; -} - -//@refScript.xml - - - - - -//!Extract Function History extracted statement with trailling comment -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@main.cpp -int main(){ - - int i; - i= 7; // Comment - return i; -} - -//= -void exp(int & i) -{ - i = 7; // Comment -} - -int main(){ - - int i; - exp(i); - return i; -} - -//@refScript.xml - - - - - -//!ExtractFunctionRefactoringTest duplicates with different Names History Test -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@A.h -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -class A -{ -public: - A(); - virtual ~A(); - int foo(); - -private: - int help(); - void exp(int & i); -}; - -#endif /*A_H_*/ - -//@A.cpp -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int oo = 99; - ++oo; - help(); -}int A::foo() -{ - int i = 2; - ++i; - help(); - return i; -} - -int A::help() -{ - return 42; -} - -//= -#include "A.h" - -A::A() -{ -} - -A::~A() -{ - int oo = 99; - exp(oo); -}void A::exp(int & i) -{ - ++i; - help(); -} - -int A::foo() -{ - int i = 2; - exp(i); - return i; -} - -int A::help() -{ - return 42; -} - -//@refScript.xml - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -//!HideMethodSimple -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A{ -public: - A(); - void method2(); - std::string toString(); -private: - int i; -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A{ -public: - A(); - std::string toString(); -private: - int i; - void method2(); -}; - -#endif /*A_H_*/ - -//@refScript.xml - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringHistoryTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringHistoryTest.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.ui.tests.refactoring; - -import java.io.ByteArrayInputStream; -import java.util.Properties; -import java.util.Vector; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.history.RefactoringHistory; -import org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistoryService; - -import org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; - -/** - * @author Emanuel Graf IFS - * - */ -public class RefactoringHistoryTest extends - ExtractFunctionRefactoringTest { - - private TestSourceFile scriptFile; - - public RefactoringHistoryTest(String name, - Vector files) { - super(name, files); - } - - @Override - protected void configureRefactoring(Properties refactoringProperties) { - scriptFile = fileMap.get(refactoringProperties.getProperty( - "scriptFile", "refScript.xml")); - - } - - @Override - protected void runTest() throws Throwable { - String xmlSource = scriptFile.getSource(); - xmlSource = xmlSource.replaceAll("\\$\\$projectPath\\$\\$", project.getLocation().toOSString()); - RefactoringHistory refHist = RefactoringHistoryService.getInstance() - .readRefactoringHistory( - new ByteArrayInputStream(xmlSource - .getBytes()), 0); - for (RefactoringDescriptorProxy proxy : refHist.getDescriptors()) { - RefactoringStatus status = new RefactoringStatus(); - CRefactoring ref = (CRefactoring) proxy - .requestDescriptor(new NullProgressMonitor()) - .createRefactoring(status); - assertTrue(status.isOK()); - RefactoringStatus checkInitialConditions = ref.checkInitialConditions(NULL_PROGRESS_MONITOR); - - if(fatalError){ - assertConditionsFatalError(checkInitialConditions); - return; - } - else{ - assertConditionsOk(checkInitialConditions); - executeRefactoring(ref); - } - } - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractconstant/ExtractConstantRefactoringTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractconstant/ExtractConstantRefactoringTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractconstant/ExtractConstantRefactoringTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -21,7 +21,6 @@ import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile; -import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; import org.eclipse.cdt.internal.ui.refactoring.extractconstant.ExtractConstantInfo; import org.eclipse.cdt.internal.ui.refactoring.extractconstant.ExtractConstantRefactoring; import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum; @@ -42,16 +41,22 @@ protected void runTest() throws Throwable { IFile refFile = project.getFile(fileName); ExtractConstantInfo info = new ExtractConstantInfo(); - CRefactoring refactoring = new ExtractConstantRefactoring(refFile, selection, info, cproject); - RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR); - assertConditionsOk(checkInitialConditions); - info.setName("theAnswer"); //$NON-NLS-1$ - info.setVisibility(visibility); - Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR); - RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); - assertConditionsOk(finalConditions); - createChange.perform(NULL_PROGRESS_MONITOR); + ExtractConstantRefactoring refactoring = new ExtractConstantRefactoring( refFile, selection, info); + try { + refactoring.lockIndex(); + RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR); + assertConditionsOk(checkInitialConditions); + info.setName("theAnswer"); //$NON-NLS-1$ + info.setVisibility(visibility); + Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR); + RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); + assertConditionsOk(finalConditions); + createChange.perform(NULL_PROGRESS_MONITOR); + }finally { + refactoring.unlockIndex(); + } compareFiles(fileMap); + } @Override diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractconstant/ExtractConstantTestSuite.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractconstant/ExtractConstantTestSuite.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractconstant/ExtractConstantTestSuite.java Wed Aug 05 17:35:39 2009 -0500 @@ -27,8 +27,6 @@ TestSuite suite = new ExtractConstantTestSuite(); suite.addTest(RefactoringTester.suite("ExtractConstantRefactoringTest", "resources/refactoring/ExtractConstant.rts")); - suite.addTest(RefactoringTester.suite("ExtractConstantHistoryRefactoringTest", - "resources/refactoring/ExtractConstantHistory.rts")); return suite; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -40,7 +40,6 @@ protected int returnParameterIndex; protected boolean fatalError; private VisibilityEnum visibility; - private static int nr = 1; /** * @param name @@ -63,28 +62,18 @@ } else{ assertConditionsOk(checkInitialConditions); - setValues(info); - executeRefactoring(refactoring); + executeRefactoring(info, refactoring); } } - protected void executeRefactoring(CRefactoring refactoring) throws CoreException, Exception { - RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); - assertConditionsOk(finalConditions); - Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR); - createChange.perform(NULL_PROGRESS_MONITOR); - compareFiles(fileMap); - } - - private void setValues(ExtractFunctionInformation info) { + private void executeRefactoring(ExtractFunctionInformation info, CRefactoring refactoring) throws CoreException, Exception { info.setMethodName(methodName); info.setReplaceDuplicates(replaceDuplicates); if(info.getInScopeDeclaredVariable() == null){ if(returnValue) { info.setReturnVariable(info.getAllAfterUsedNames().get(returnParameterIndex)); - info.getAllAfterUsedNames().get(returnParameterIndex).setUserSetIsReference(false); } } else { info.setReturnVariable( info.getInScopeDeclaredVariable() ); @@ -96,6 +85,13 @@ name.setUserSetIsReference(name.isReference()); } } + + Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR); + RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); + assertConditionsOk(finalConditions); + createChange.perform(NULL_PROGRESS_MONITOR); + + compareFiles(fileMap); } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionTestSuite.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionTestSuite.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionTestSuite.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -29,8 +29,6 @@ suite.addTest(RefactoringTester.suite("Extract Expression", "resources/refactoring/ExtractExpression.rts")); suite.addTest(RefactoringTester.suite("ExtractMethodPreprocessorRefactoringTests", "resources/refactoring/ExtractMethodPreprocessor.rts")); suite.addTest(RefactoringTester.suite("Extract Function Templates Tests", "resources/refactoring/ExtractFunctionTemplates.rts")); - suite.addTest(RefactoringTester.suite("Extract Method History Test", "resources/refactoring/ExtractMethodHistory.rts")); - suite.addTest(RefactoringTester.suite("Extract Function Dublicates Test", "resources/refactoring/ExtractMethodDuplicates.rts")); return suite; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -43,7 +43,7 @@ IFile refFile = project.getFile(fileName); NameNVisibilityInformation info = new NameNVisibilityInformation(); info.setName(variableName); - CRefactoring refactoring = new ExtractLocalVariableRefactoring( refFile, selection, info, cproject); + CRefactoring refactoring = new ExtractLocalVariableRefactoring( refFile, selection, info); RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR); if(fatalError){ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractlocalvariable/ExtractLocalVariableTestSuite.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractlocalvariable/ExtractLocalVariableTestSuite.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractlocalvariable/ExtractLocalVariableTestSuite.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -28,8 +28,6 @@ TestSuite suite = new ExtractLocalVariableTestSuite(); suite.addTest(RefactoringTester.suite("ExtractLocalVariableRefactoringTests", "resources/refactoring/ExtractLocalVariable.rts")); - suite.addTest(RefactoringTester.suite("ExtractLocalVariableRefactoringHistoryTests", - "resources/refactoring/ExtractLocalVariableHistory.rts")); return suite; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -52,7 +52,7 @@ @Override protected void runTest() throws Throwable { IFile refFile = project.getFile(fileName); - refactoring = new GenerateGettersAndSettersRefactoring(refFile, selection, null, cproject); + refactoring = new GenerateGettersAndSettersRefactoring(refFile, selection, null); RefactoringStatus initialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -40,7 +40,9 @@ protected void runTest() throws Throwable { IFile refFile = project.getFile(fileWithSelection); - CRefactoring refactoring = new HideMethodRefactoring(refFile,selection, null, cproject); + CRefactoring refactoring = new HideMethodRefactoring(refFile,selection, null); + try { + refactoring.lockIndex(); RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR); if(errors > 0) { assertConditionsError(checkInitialConditions, errors); @@ -50,7 +52,7 @@ }else { assertConditionsOk(checkInitialConditions); } - + Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR); RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); if(warnings > 0){ @@ -61,6 +63,10 @@ createChange.perform(NULL_PROGRESS_MONITOR); compareFiles(fileMap); + } + finally { + refactoring.unlockIndex(); + } } @Override diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodTestSuite.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodTestSuite.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodTestSuite.java Wed Aug 05 17:35:39 2009 -0500 @@ -27,8 +27,6 @@ TestSuite suite = new HideMethodTestSuite(); suite.addTest(RefactoringTester.suite("HideMethodRefactoringTests", "resources/refactoring/HideMethod.rts")); - suite.addTest(RefactoringTester.suite("HideMethodRefactoringHistoryTests", - "resources/refactoring/HideMethodHistory.rts")); return suite; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -42,7 +42,7 @@ IFile refFile = project.getFile(fileName); - CRefactoring refactoring = new ImplementMethodRefactoring(refFile, selection, null, cproject); + CRefactoring refactoring = new ImplementMethodRefactoring(refFile, selection, null); try { refactoring.lockIndex(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java Wed Aug 05 17:35:39 2009 -0500 @@ -624,7 +624,7 @@ writer.write( " void v(){i++;} \n" ); //$NON-NLS-1$ writer.write( "}; \n" ); //$NON-NLS-1$ String contents = writer.toString(); - IFile file = importFile( "t45.cpp", contents ); //$NON-NLS-1$ + IFile file = importFile( "t.cpp", contents ); //$NON-NLS-1$ waitForIndexer(); //vp1 implicit virtual method int offset = contents.indexOf( "v/*vp1*/" ) ; //$NON-NLS-1$ diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java Wed Aug 05 17:35:39 2009 -0500 @@ -255,13 +255,14 @@ Object node = nodeElements[0]; if (!(node instanceof IStatus)) node = nodeElements[1]; - if (node instanceof IStatus) { + if (node instanceof IStatus) + { IStatus firstRootNode = (IStatus) node; assertEquals(IStatus.WARNING, firstRootNode.getSeverity()); // can't really verify text in case message is localized... - } else { + } + else fail("can't get status"); - } } } else { // must NOT have the IStatus diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/.settings/org.eclipse.pde.api.tools.prefs --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/.settings/org.eclipse.pde.api.tools.prefs Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/.settings/org.eclipse.pde.api.tools.prefs Wed Aug 05 17:35:39 2009 -0500 @@ -1,4 +1,4 @@ -#Mon Jul 06 14:55:59 CEST 2009 +#Wed Jun 18 09:56:50 CEST 2008 ANNOTATION_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error ANNOTATION_ELEMENT_TYPE_ADDED_FIELD=Error ANNOTATION_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error @@ -15,11 +15,9 @@ ANNOTATION_ELEMENT_TYPE_CHANGED_TO_CLASS=Error ANNOTATION_ELEMENT_TYPE_CHANGED_TO_ENUM=Error ANNOTATION_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error -ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error ANNOTATION_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error ANNOTATION_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error -ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD_WITHOUT_DEFAULT_VALUE=Error ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD_WITH_DEFAULT_VALUE=Error ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error @@ -31,7 +29,6 @@ CLASS_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error CLASS_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error CLASS_ELEMENT_TYPE_ADDED_METHOD=Error -CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error CLASS_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERCLASS_SET=Error @@ -45,14 +42,12 @@ CLASS_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error CLASS_ELEMENT_TYPE_CHANGED_TO_ENUM=Error CLASS_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error -CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error CLASS_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error CLASS_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error CLASS_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error -CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error @@ -80,7 +75,6 @@ ENUM_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error ENUM_ELEMENT_TYPE_CHANGED_TO_CLASS=Error ENUM_ELEMENT_TYPE_CHANGED_TO_INTERFACE=Error -ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error @@ -93,7 +87,6 @@ FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error -FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENTS=Error FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error ILLEGAL_EXTEND=Warning @@ -106,8 +99,6 @@ INTERFACE_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error INTERFACE_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error -INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error -INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error INTERFACE_ELEMENT_TYPE_ADDED_TYPE_MEMBER=Error INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETERS=Error @@ -119,16 +110,13 @@ INTERFACE_ELEMENT_TYPE_CHANGED_TO_ANNOTATION=Error INTERFACE_ELEMENT_TYPE_CHANGED_TO_CLASS=Error INTERFACE_ELEMENT_TYPE_CHANGED_TO_ENUM=Error -INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error INTERFACE_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error INTERFACE_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error INTERFACE_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error -INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error INVALID_JAVADOC_TAG=Ignore -INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Error LEAK_EXTEND=Warning LEAK_FIELD_DECL=Warning LEAK_IMPLEMENT=Warning @@ -137,7 +125,6 @@ METHOD_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error METHOD_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error METHOD_ELEMENT_TYPE_ADDED_INTERFACE_BOUNDS=Error -METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error METHOD_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error @@ -154,13 +141,6 @@ METHOD_ELEMENT_TYPE_REMOVED_INTERFACE_BOUNDS=Error METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETERS=Error -TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error -TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error -TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error -TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error -TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error -TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error -UNUSED_PROBLEM_FILTERS=Warning eclipse.preferences.version=1 incompatible_api_component_version=Error incompatible_api_component_version_include_major_without_breaking_change=Disabled @@ -168,5 +148,3 @@ invalid_since_tag_version=Error malformed_since_tag=Error missing_since_tag=Error -report_api_breakage_when_major_version_incremented=Disabled -report_resolution_errors_api_component=Warning diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/META-INF/MANIFEST.MF --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/META-INF/MANIFEST.MF Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/META-INF/MANIFEST.MF Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true -Bundle-Version: 5.2.0.qualifier +Bundle-Version: 5.1.1.qualifier Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/plugin.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/plugin.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/plugin.properties Wed Aug 05 17:35:39 2009 -0500 @@ -536,7 +536,4 @@ preferenceKeywords.templates=editor templates snippet macros preferenceKeywords.folding=editor folding section comment header function method statement preprocessor preferenceKeywords.markoccurrences=editor occurrence mark highlight -preferenceKeywords.smarttyping=editor typing type close comment tabs indentation indent imports wrap escape semicolons braces brackets parenthesis parentheses strings literals paste pasting tabulator automatically -historyAction.label = History... -createScriptAction.label = Create Script... -applyScriptAction.label = Apply Script... \ No newline at end of file +preferenceKeywords.smarttyping=editor typing type close comment tabs indentation indent imports wrap escape semicolons braces brackets parenthesis parentheses strings literals paste pasting tabulator automatically \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/plugin.xml --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/plugin.xml Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/plugin.xml Wed Aug 05 17:35:39 2009 -0500 @@ -1221,10 +1221,7 @@ - - - + - - - - - - - - - - - - - - - - diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.ui; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,7 +26,6 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.ui.model.IWorkbenchAdapter; -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.IArchive; @@ -398,12 +396,8 @@ ICElement[] c2 = ((ISourceRoot)child).getChildren(); for (int k = 0; k < c2.length; ++k) list.add(c2[k]); - } else if (CCorePlugin.showSourceRootsAtTopOfProject()) { + } else list.add(child); - } else if (child instanceof ISourceRoot && - child.getResource().getParent().equals(cproject.getProject())) { - list.add(child); - } } Object[] objects = list.toArray(); @@ -519,11 +513,7 @@ protected Object[] getCResources(ICContainer container) throws CModelException { Object[] objects = null; - ICElement[] children = container.getChildren(); - List missingElements = Collections.emptyList(); - if (!CCorePlugin.showSourceRootsAtTopOfProject()) { - missingElements = getMissingElements(container, children); - } + Object[] children = container.getChildren(); try { objects = container.getNonCResources(); if (objects.length > 0) { @@ -534,38 +524,7 @@ if (objects == null || objects.length == 0) { return children; } - Object[] result = concatenate(children, objects); - return concatenate(result, missingElements.toArray()); - } - - private List getMissingElements(ICContainer container, ICElement[] elements) { - // nested source roots may be filtered out below the project root, - // we need to find them to add them back in - List missingElements = new ArrayList(); - try { - List missingContainers = new ArrayList(); - IResource[] allChildren = ((IContainer) container.getResource()).members(); - for (IResource child : allChildren) { - if (!(child instanceof IContainer)) - continue; - boolean found = false; - for (ICElement element : elements) { - if (element.getResource().equals(child)) { - found = true; - break; - } - } - if (!found) - missingContainers.add(child); - } - for (IResource resource : missingContainers) { - ICElement element = container.getCProject().findElement(resource.getFullPath()); - if (element != null) - missingElements.add(element); - } - } catch (CoreException e1) { - } - return missingElements; + return concatenate(children, objects); } protected Object[] getResources(IProject project) { @@ -617,19 +576,16 @@ // folder we have to exclude it as a normal child. if (o instanceof IFolder) { IFolder folder = (IFolder)o; - ISourceRoot root = null; + boolean found = false; for (int j = 0; j < roots.length; j++) { if (roots[j].getPath().equals(folder.getFullPath())) { - root = roots[j]; + found = true; break; } } // it is a sourceRoot skip it. - if (root != null) { - if (CCorePlugin.showSourceRootsAtTopOfProject()) - continue; - else - o = root; + if (found) { + continue; } } else if (o instanceof IFile){ boolean found = false; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java Wed Aug 05 17:35:39 2009 -0500 @@ -98,7 +98,6 @@ public static final String IMG_OBJS_TUNIT_RESOURCE_H= NAME_PREFIX + "ch_resource_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_TUNIT_RESOURCE_A= NAME_PREFIX + "asm_resource_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_SOURCE_ROOT= NAME_PREFIX + "sroot_obj.gif"; // $NON-NLS-1$ //$NON-NLS-1$ - public static final String IMG_OBJS_SOURCE2_ROOT= NAME_PREFIX + "sroot2_obj.gif"; // $NON-NLS-1$ //$NON-NLS-1$ public static final String IMG_OBJS_CFOLDER= NAME_PREFIX + "cfolder_obj.gif"; // $NON-NLS-1$ //$NON-NLS-1$ public static final String IMG_OBJS_CONFIG = NAME_PREFIX + "config.gif"; // $NON-NLS-1$ //$NON-NLS-1$ public static final String IMG_OBJS_ARCHIVE= NAME_PREFIX + "ar_obj.gif"; //$NON-NLS-1$ @@ -181,7 +180,6 @@ public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_H= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_H); public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_A= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_A); public static final ImageDescriptor DESC_OBJS_SOURCE_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE_ROOT); - public static final ImageDescriptor DESC_OBJS_SOURCE2_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE2_ROOT); public static final ImageDescriptor DESC_OBJS_CFOLDER= createManaged(T_OBJ, IMG_OBJS_CFOLDER); public static final ImageDescriptor DESC_OBJS_CONFIG = createManaged(T_OBJ, IMG_OBJS_CONFIG); public static final ImageDescriptor DESC_OBJS_ARCHIVE= createManaged(T_OBJ, IMG_OBJS_ARCHIVE); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java Wed Aug 05 17:35:39 2009 -0500 @@ -154,5 +154,6 @@ if ((shell != null) && !shell.isDisposed()) shell.setImage(fImage); } + } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java Wed Aug 05 17:35:39 2009 -0500 @@ -559,7 +559,8 @@ return identifier.length() > 0 && (Character.isUpperCase(identifier.charAt(0)) || angularIntroducers.contains(identifier) - || identifier.endsWith("_ptr")); //$NON-NLS-1$ + || identifier.endsWith("_ptr") //$NON-NLS-1$ + || identifier.endsWith("_cast")); //$NON-NLS-1$ } /* diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java Wed Aug 05 17:35:39 2009 -0500 @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.ui.preferences; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -29,8 +28,6 @@ import org.eclipse.ui.PlatformUI; import org.osgi.service.prefs.BackingStoreException; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.CCorePreferenceConstants; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; @@ -50,7 +47,6 @@ private SelectionButtonDialogField fCViewGroupIncludes; private SelectionButtonDialogField fCViewSeparateHeaderAndSource; private SelectionButtonDialogField fOutlineGroupMembers; - private SelectionButtonDialogField fShowSourceRootsAtTopOfProject; public AppearancePreferencePage() { setPreferenceStore(PreferenceConstants.getPreferenceStore()); @@ -85,12 +81,6 @@ fCViewSeparateHeaderAndSource= new SelectionButtonDialogField(SWT.CHECK); fCViewSeparateHeaderAndSource.setDialogFieldListener(listener); fCViewSeparateHeaderAndSource.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewSeparateHeaderAndSource_label); - - fShowSourceRootsAtTopOfProject= new SelectionButtonDialogField(SWT.CHECK); - fShowSourceRootsAtTopOfProject.setDialogFieldListener(listener); - fShowSourceRootsAtTopOfProject.setLabelText(PreferencesMessages.AppearancePreferencePage_showSourceRootsAtTopOfProject_label); - - } private void initFields() { @@ -101,8 +91,6 @@ fOutlineGroupIncludes.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES)); fOutlineGroupNamespaces.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES)); fOutlineGroupMembers.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS)); - boolean showSourceRootsAtTopOfProject = CCorePlugin.showSourceRootsAtTopOfProject(); - fShowSourceRootsAtTopOfProject.setSelection(showSourceRootsAtTopOfProject); } /* @@ -146,10 +134,6 @@ gd.horizontalSpan= 2; noteControl.setLayoutData(gd); - - new Separator().doFillIntoGrid(result, nColumns); - fShowSourceRootsAtTopOfProject.doFillIntoGrid(result, nColumns); - initFields(); Dialog.applyDialogFont(result); @@ -192,8 +176,6 @@ } catch (BackingStoreException exc) { CUIPlugin.log(exc); } - CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, fShowSourceRootsAtTopOfProject.isSelected()); - CCorePlugin.getDefault().savePluginPreferences(); return super.performOk(); } @@ -209,8 +191,6 @@ fOutlineGroupIncludes.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES)); fOutlineGroupNamespaces.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES)); fOutlineGroupMembers.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS)); - Preferences corePrefs = CCorePlugin.getDefault().getPluginPreferences(); - fShowSourceRootsAtTopOfProject.setSelection(corePrefs.getDefaultBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT)); super.performDefaults(); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java Wed Aug 05 17:35:39 2009 -0500 @@ -138,7 +138,6 @@ public static String AppearancePreferencePage_outlineGroupNamespaces_label; public static String AppearancePreferencePage_note; public static String AppearancePreferencePage_preferenceOnlyForNewViews; - public static String AppearancePreferencePage_showSourceRootsAtTopOfProject_label; public static String CEditorPreferencePage_folding_title; public static String FoldingConfigurationBlock_enable; public static String FoldingConfigurationBlock_combo_caption; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties Wed Aug 05 17:35:39 2009 -0500 @@ -157,7 +157,6 @@ AppearancePreferencePage_outlineGroupNamespaces_label= Group namespaces in the Outline view AppearancePreferencePage_note=Note: AppearancePreferencePage_preferenceOnlyForNewViews=This preference does not affect open views -AppearancePreferencePage_showSourceRootsAtTopOfProject_label=Show source roots at top of project #Folding CEditorPreferencePage_folding_title= &Folding diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CCompositeChange.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CCompositeChange.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring; - -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.ChangeDescriptor; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor; - -/** - * @author Emanuel Graf IFS - * - */ -public class CCompositeChange extends CompositeChange { - - private RefactoringChangeDescriptor desc; - - public CCompositeChange(String name, Change[] children) { - super(name, children); - } - - public CCompositeChange(String name) { - super(name); - } - - public void setDescription(RefactoringChangeDescriptor descriptor) { - desc = descriptor; - } - - @Override - public ChangeDescriptor getDescriptor() { - if(desc == null) { - return super.getDescriptor(); - }else { - return desc; - } - } - - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -23,8 +23,6 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.Refactoring; -import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.cdt.core.CCorePlugin; @@ -70,10 +68,7 @@ protected IASTTranslationUnit unit; private IIndex fIndex; - protected ICProject project; - - public CRefactoring(IFile file, ISelection selection, ICElement element, ICProject proj) { - project = proj; + public CRefactoring(IFile file, ISelection selection, ICElement element) { if (element instanceof ISourceReference) { ISourceReference sourceRef= (ISourceReference) element; ITranslationUnit tu= sourceRef.getTranslationUnit(); @@ -212,13 +207,9 @@ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { ModificationCollector collector = new ModificationCollector(); collectModifications(pm, collector); - CCompositeChange finalChange = collector.createFinalChange(); - finalChange.setDescription(new RefactoringChangeDescriptor(getRefactoringDescriptor())); - return finalChange; + return collector.createFinalChange(); } - abstract protected RefactoringDescriptor getRefactoringDescriptor(); - abstract protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) throws CoreException, OperationCanceledException; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring; - -import java.util.Map; - -import org.eclipse.ltk.core.refactoring.RefactoringContribution; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; - -/** - * @author Emanuel Graf IFS - * - */ -public abstract class CRefactoringContribution extends RefactoringContribution { - - public CRefactoringContribution() { - super(); - } - - @SuppressWarnings("unchecked") - @Override - public Map retrieveArgumentMap(RefactoringDescriptor descriptor) { - if (descriptor instanceof CRefactoringDescription) { - CRefactoringDescription refDesc = (CRefactoringDescription) descriptor; - return refDesc.getParameterMap(); - }else { - return super.retrieveArgumentMap(descriptor); - } - } - -} \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescription.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescription.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; - -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.ui.CUIPlugin; - -/** - * @author Emanuel Graf IFS - * - */ -public abstract class CRefactoringDescription extends RefactoringDescriptor { - - public static final String FILE_NAME = "fileName"; //$NON-NLS-1$ - public static final String SELECTION = "selection"; //$NON-NLS-1$ - protected Map arguments; - - public CRefactoringDescription(String id, String project, String description, String comment, int flags, Map arguments) { - super(id, project, description, comment, flags); - this.arguments = arguments; - } - - public Map getParameterMap() { - return arguments; - } - - protected ISelection getSelection() throws CoreException { - ISelection selection; - String selectStrings[] = arguments.get(SELECTION).split(","); //$NON-NLS-1$ - if(selectStrings.length >= 2) { - int offset = Integer.parseInt(selectStrings[0]); - int length = Integer.parseInt(selectStrings[1]); - selection = new TextSelection(offset,length); - }else { - throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Illegal Selection")); //$NON-NLS-1$ - } - return selection; - } - - protected ICProject getCProject() throws CoreException { - ICProject proj; - IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(getProject()); - proj = CoreModel.getDefault().create(iProject); - if(proj == null) { - throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Unknown Project")); //$NON-NLS-1$ - } - return proj; - } - - protected IFile getFile() throws CoreException { - IFile file; - try { - file = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new URI(arguments.get(FILE_NAME)))[0]; - } catch (URISyntaxException e) { - throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, e.getMessage(), e)); - } - return file; - } - -} \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -18,6 +18,7 @@ import java.util.Map; import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.CompositeChange; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; @@ -51,9 +52,9 @@ changes.add(change); } - public CCompositeChange createFinalChange() { + public CompositeChange createFinalChange() { // Synthetic changes aren't displayed and therefore don't need a name - CCompositeChange result = new CCompositeChange(""); //$NON-NLS-1$ + CompositeChange result = new CompositeChange(""); //$NON-NLS-1$ result.markAsSynthetic(); if(changes != null) diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -16,7 +16,6 @@ import org.eclipse.jface.window.IShellProvider; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; /** * Base class for all refactoring runners. @@ -30,14 +29,12 @@ protected ISelection selection; protected ICElement celement; protected IShellProvider shellProvider; - protected ICProject project; - public RefactoringRunner(IFile file, ISelection selection, ICElement element, IShellProvider shellProvider, ICProject cProject) { + public RefactoringRunner(IFile file, ISelection selection, ICElement element, IShellProvider shellProvider) { this.file = file; this.selection = selection; this.celement= element; this.shellProvider= shellProvider; - this.project = cProject; } public abstract void run(); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,8 +13,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; -import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; @@ -26,7 +24,6 @@ import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.text.Region; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.text.edits.TextEditGroup; @@ -49,7 +46,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; -import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; @@ -63,7 +59,6 @@ import org.eclipse.cdt.internal.ui.refactoring.AddDeclarationNodeToClassChange; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription; import org.eclipse.cdt.internal.ui.refactoring.MethodContext; import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector; import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper; @@ -79,67 +74,52 @@ */ public class ExtractConstantRefactoring extends CRefactoring { - public static final String ID = "org.eclipse.cdt.ui.refactoring.extractconstant.ExtractConstantRefactoring"; //$NON-NLS-1$ - private IASTLiteralExpression target = null; private final ArrayList literalsToReplace = new ArrayList(); private final ExtractConstantInfo info; - - public ExtractConstantRefactoring(IFile file, ISelection selection, ExtractConstantInfo info, ICProject proj){ - super(file,selection, null, proj); + public ExtractConstantRefactoring(IFile file, ISelection selection, ExtractConstantInfo info){ + super(file,selection, null); this.info = info; - this.project = proj; name = Messages.ExtractConstantRefactoring_ExtractConst; } @Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { SubMonitor sm = SubMonitor.convert(pm, 9); - try { - lockIndex(); - try { - super.checkInitialConditions(sm.newChild(6)); - - Collection literalExpressionCollection = findAllLiterals(); - if(literalExpressionCollection.isEmpty()){ - initStatus.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); - return initStatus; - } - sm.worked(1); - if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; + super.checkInitialConditions(sm.newChild(6)); - boolean oneMarked = region != null && isOneMarked(literalExpressionCollection, region); - if(!oneMarked){ - //No or more than one marked - if(target == null){ - //No Selection found; - initStatus.addFatalError(Messages.ExtractConstantRefactoring_NoLiteralSelected); - } else { - //To many selection found - initStatus.addFatalError(Messages.ExtractConstantRefactoring_TooManyLiteralSelected); - } - return initStatus; - } - sm.worked(1); - - if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; + Collection literalExpressionCollection = findAllLiterals(); + if(literalExpressionCollection.isEmpty()){ + initStatus.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); + return initStatus; + } + + sm.worked(1); + if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; + + boolean oneMarked = region != null && isOneMarked(literalExpressionCollection, region); + if(!oneMarked){ + //No or more than one marked + if(target == null){ + //No Selection found; + initStatus.addFatalError(Messages.ExtractConstantRefactoring_NoLiteralSelected); + } else { + //To many selection found + initStatus.addFatalError(Messages.ExtractConstantRefactoring_TooManyLiteralSelected); + } + return initStatus; + } + sm.worked(1); - findAllNodesForReplacement(literalExpressionCollection); - - info.addNamesToUsedNames(findAllDeclaredNames()); - if(info.getName().length() == 0) { - info.setName(getDefaultName(target)); - } - info.setMContext(NodeHelper.findMethodContext(target, getIndex())); - sm.done(); - } - finally { - unlockIndex(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } + if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; + + findAllNodesForReplacement(literalExpressionCollection); + + info.addNamesToUsedNames(findAllDeclaredNames()); + info.setName(getDefaultName(target)); + info.setMContext(NodeHelper.findMethodContext(target, getIndex())); + sm.done(); return initStatus; } @@ -271,78 +251,53 @@ @Override protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) - throws CoreException, OperationCanceledException{ - try { - lockIndex(); - try { - MethodContext context = info.getMContext(); - Collection locLiteralsToReplace = new ArrayList(); - - if(context.getType() == MethodContext.ContextType.METHOD){ + throws CoreException, OperationCanceledException{ + + MethodContext context = info.getMContext(); + Collection locLiteralsToReplace = new ArrayList(); - for (IASTExpression expression : literalsToReplace) { - MethodContext exprContext = NodeHelper.findMethodContext(expression, getIndex()); - if(exprContext.getType() == MethodContext.ContextType.METHOD){ - if(context.getMethodQName() != null) { - if( MethodContext.isSameClass(exprContext.getMethodQName(), context.getMethodQName())){ - locLiteralsToReplace.add(expression); - } - }else { - if( MethodContext.isSameClass(exprContext.getMethodDeclarationName(), context.getMethodDeclarationName())){ - locLiteralsToReplace.add(expression); - } - } + if(context.getType() == MethodContext.ContextType.METHOD){ + + for (IASTExpression expression : literalsToReplace) { + MethodContext exprContext = NodeHelper.findMethodContext(expression, getIndex()); + if(exprContext.getType() == MethodContext.ContextType.METHOD){ + if(context.getMethodQName() != null) { + if( MethodContext.isSameClass(exprContext.getMethodQName(), context.getMethodQName())){ + locLiteralsToReplace.add(expression); } - } - - } else { - - for (IASTExpression expression : literalsToReplace) { - IPath path = new Path(expression.getContainingFilename()); - IFile expressionFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); - //expressionFile may be null if the file is NOT in the workspace - if( expressionFile != null && expressionFile.equals(file) ){ + }else { + if( MethodContext.isSameClass(exprContext.getMethodDeclarationName(), context.getMethodDeclarationName())){ locLiteralsToReplace.add(expression); } } - } - - //Create all Changes for literals - String constName = info.getName(); - createLiteralToConstantChanges(constName, locLiteralsToReplace, collector); - - if(context.getType() == MethodContext.ContextType.METHOD) { - ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) context.getMethodDeclaration().getParent(); - AddDeclarationNodeToClassChange.createChange(classDefinition, info.getVisibility(), getConstNodesClass(constName), true, collector); - } else { - IASTDeclaration nodes = getConstNodesGlobal(constName); - ASTRewrite rewriter = collector.rewriterForTranslationUnit(unit); - rewriter.insertBefore(unit, TranslationUnitHelper.getFirstNode(unit), nodes, new TextEditGroup(Messages.ExtractConstantRefactoring_CreateConstant)); + } + + } else { + + for (IASTExpression expression : literalsToReplace) { + IPath path = new Path(expression.getContainingFilename()); + IFile expressionFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); + //expressionFile may be null if the file is NOT in the workspace + if( expressionFile != null && expressionFile.equals(file) ){ + locLiteralsToReplace.add(expression); } } - finally { - unlockIndex(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); + } - } - - @Override - protected RefactoringDescriptor getRefactoringDescriptor() { - Map arguments = getArgumentMap(); - RefactoringDescriptor desc = new ExtractConstantRefactoringDescription( project.getProject().getName(), "Extract Constant Refactoring", "Create constant for " + target.getRawSignature(), arguments); //$NON-NLS-1$//$NON-NLS-2$ - return desc; - } - - private Map getArgumentMap() { - Map arguments = new HashMap(); - arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString()); - arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$ - arguments.put(ExtractConstantRefactoringDescription.NAME, info.getName()); - arguments.put(ExtractConstantRefactoringDescription.VISIBILITY, info.getVisibility().toString()); - return arguments; + + //Create all Changes for literals + String constName = info.getName(); + createLiteralToConstantChanges(constName, locLiteralsToReplace, collector); + + if(context.getType() == MethodContext.ContextType.METHOD) { + ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) context.getMethodDeclaration().getParent(); + AddDeclarationNodeToClassChange.createChange(classDefinition, info.getVisibility(), getConstNodesClass(constName), true, collector); + } else { + IASTDeclaration nodes = getConstNodesGlobal(constName); + ASTRewrite rewriter = collector.rewriterForTranslationUnit(unit); + rewriter.insertBefore(unit, TranslationUnitHelper.getFirstNode(unit), nodes, new TextEditGroup(Messages.ExtractConstantRefactoring_CreateConstant)); + } } private void createLiteralToConstantChanges(String constName, Iterable literals, ModificationCollector collector) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.extractconstant; - -import java.util.Map; - -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution; - -/** - * @author Emanuel Graf IFS - * - */ -public class ExtractConstantRefactoringContribution extends - CRefactoringContribution { - - @SuppressWarnings("unchecked") - @Override - public RefactoringDescriptor createDescriptor(String id, String project, - String description, String comment, Map arguments, int flags) - throws IllegalArgumentException { - if(id.equals(ExtractConstantRefactoring.ID)) { - return new ExtractConstantRefactoringDescription(project, description, comment, arguments); - }else { - return null; - } - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescription.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescription.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.extractconstant; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.Refactoring; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - -import org.eclipse.cdt.core.model.ICProject; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription; -import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum; - -/** - * @author Emanuel Graf IFS - * - */ -public class ExtractConstantRefactoringDescription extends - CRefactoringDescription { - protected static final String NAME = "name"; //$NON-NLS-1$ - protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$ - - protected ExtractConstantRefactoringDescription(String project, - String description, String comment, Map arguments) { - super(ExtractConstantRefactoring.ID, project, description, comment, RefactoringDescriptor.MULTI_CHANGE, arguments); - } - - @Override - public Refactoring createRefactoring(RefactoringStatus status) - throws CoreException { - IFile file; - ExtractConstantInfo info = new ExtractConstantInfo(); - ICProject proj; - - info.setName(arguments.get(NAME)); - info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY))); - - proj = getCProject(); - - file = getFile(); - - ISelection selection = getSelection(); - return new ExtractConstantRefactoring(file, selection, info, proj); - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,11 +12,12 @@ package org.eclipse.cdt.internal.ui.refactoring.extractconstant; import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.window.IShellProvider; import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; -import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner; @@ -27,22 +28,29 @@ */ public class ExtractConstantRefactoringRunner extends RefactoringRunner { - public ExtractConstantRefactoringRunner(IFile file, ISelection selection, IShellProvider shellProvider, ICProject cProject) { - super(file, selection, null, shellProvider, cProject); + public ExtractConstantRefactoringRunner(IFile file, ISelection selection, IShellProvider shellProvider) { + super(file, selection, null, shellProvider); } @Override public void run() { ExtractConstantInfo info = new ExtractConstantInfo(); - CRefactoring refactoring = new ExtractConstantRefactoring(file,selection,info, project); + CRefactoring refactoring = new ExtractConstantRefactoring(file,selection,info); ExtractConstantRefactoringWizard wizard = new ExtractConstantRefactoringWizard(refactoring, info); RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard); - + try { - operator.run(shellProvider.getShell(), refactoring.getName()); - + refactoring.lockIndex(); + try { + operator.run(shellProvider.getShell(), refactoring.getName()); + } + finally { + refactoring.unlockIndex(); + } } catch (InterruptedException e) { Thread.currentThread().interrupt(); - } + } catch (CoreException e) { + CUIPlugin.log(e); + } } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java Wed Aug 05 17:35:39 2009 -0500 @@ -54,6 +54,7 @@ boolean hasNoPredefinedReturnValue = true; if (info.getInScopeDeclaredVariable() != null) { + info.getInScopeDeclaredVariable().setUserSetIsReturnValue(true); hasNoPredefinedReturnValue = false; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionComposite.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionComposite.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionComposite.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -40,13 +40,15 @@ Group returnGroup = createReturnGroup(nameVisiComp); createReturnValueChooser(returnGroup, info, ip); - createReplaceCheckBox(nameVisiComp); + // Disabled for now + //createReplaceCheckBox(nameVisiComp); if (info.getMethodContext().getType() == MethodContext.ContextType.METHOD) { visibilityPanelSetVisible(true); }else { visibilityPanelSetVisible(false); } + layout(); } @@ -104,13 +106,13 @@ } - private void createReplaceCheckBox(Composite parent) { - replaceSimilar = new Button(parent, SWT.CHECK | SWT.LEFT); - GridData buttonLayoutData = new GridData(SWT.None); - buttonLayoutData.verticalIndent = 5; - replaceSimilar.setLayoutData(buttonLayoutData); - replaceSimilar.setText(Messages.ExtractFunctionComposite_ReplaceDuplicates); - } +// private void createReplaceCheckBox(Composite parent) { +// replaceSimilar = new Button(parent, SWT.CHECK | SWT.LEFT); +// GridData buttonLayoutData = new GridData(SWT.None); +// buttonLayoutData.verticalIndent = 5; +// replaceSimilar.setLayoutData(buttonLayoutData); +// replaceSimilar.setText(Messages.ExtractFunctionComposite_ReplaceDuplicates); +// } public ChooserComposite getReturnChooser() { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -17,8 +17,6 @@ import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -67,7 +65,9 @@ }); } - comp.getReplaceSimilarButton().addSelectionListener(new SelectionListener(){ + /* Disable until it works again. + * + * comp.getReplaceSimilarButton().addSelectionListener(new SelectionListener(){ public void widgetDefaultSelected(SelectionEvent e) { info.setReplaceDuplicates(comp.getReplaceSimilarButton().isEnabled()); @@ -77,7 +77,7 @@ widgetDefaultSelected(e); } - }); + });*/ setControl(comp); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java Wed Aug 05 17:35:39 2009 -0500 @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Vector; @@ -31,14 +30,12 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.text.edits.TextEditGroup; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; -import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -51,8 +48,8 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTIdExpression; import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression; +import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; @@ -67,15 +64,11 @@ import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; @@ -94,6 +87,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTInitializerExpression; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement; @@ -106,7 +100,6 @@ import org.eclipse.cdt.internal.ui.refactoring.AddDeclarationNodeToClassChange; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription; import org.eclipse.cdt.internal.ui.refactoring.Container; import org.eclipse.cdt.internal.ui.refactoring.MethodContext; import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector; @@ -114,13 +107,10 @@ import org.eclipse.cdt.internal.ui.refactoring.MethodContext.ContextType; import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation; import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper; -import org.eclipse.cdt.internal.ui.refactoring.utils.CPPASTAllVisitor; import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper; import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper; public class ExtractFunctionRefactoring extends CRefactoring { - - public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"; //$NON-NLS-1$ static final Integer NULL_INTEGER = Integer.valueOf(0); static final char[] ZERO= "0".toCharArray(); //$NON-NLS-1$ @@ -135,16 +125,18 @@ private final Container returnNumber; protected boolean hasNameResolvingForSimilarError = false; + protected ICProject project; HashMap nameTrail; private ExtractedFunctionConstructionHelper extractedFunctionConstructionHelper; - private final INodeFactory factory = CPPNodeFactory.getDefault(); + private INodeFactory factory = CPPNodeFactory.getDefault(); public ExtractFunctionRefactoring(IFile file, ISelection selection, ExtractFunctionInformation info, ICProject project) { - super(file, selection, null, project); + super(file, selection, null); this.info = info; + this.project = project; name = Messages.ExtractFunctionRefactoring_ExtractFunction; names = new HashMap(); namesCounter = new Container(NULL_INTEGER); @@ -181,13 +173,15 @@ info.setAllUsedNames(container.getUsedNamesUnique()); if (container.size() < 1) { - status.addFatalError(Messages.ExtractFunctionRefactoring_NoStmtSelected); + status + .addFatalError(Messages.ExtractFunctionRefactoring_NoStmtSelected); sm.done(); return status; } if (container.getAllDeclaredInScope().size() > 1) { - status.addFatalError(Messages.ExtractFunctionRefactoring_TooManySelected); + status + .addFatalError(Messages.ExtractFunctionRefactoring_TooManySelected); } else if (container.getAllDeclaredInScope().size() == 1) { info.setInScopeDeclaredVariable(container.getAllDeclaredInScope().get(0)); } @@ -202,21 +196,10 @@ MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0), getIndex()); info.setMethodContext(context); - if (info.getInScopeDeclaredVariable() != null) { - info.getInScopeDeclaredVariable().setUserSetIsReturnValue(true); - } - for (int i = 0; i < info.getAllUsedNames().size(); i++) { - if (!info.getAllUsedNames().get(i).isDeclarationInScope()) { - NameInformation name = info.getAllUsedNames().get(i); - if(!name.isReturnValue()) { - name.setUserSetIsReference(name.isReference()); - } - } - } if(unit != null) { IIndex index = CCorePlugin.getIndexManager().getIndex(project); unit.setIndex(index); - } + } sm.done(); return status; @@ -242,10 +225,12 @@ for (IASTNode node : cont.getNodesToWrite()) { node.accept(vis); if (vis.containsContinue()) { - initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Continue); + initStatus + .addFatalError(Messages.ExtractFunctionRefactoring_Error_Continue); break; } else if (vis.containsBreak()) { - initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Break); + initStatus + .addFatalError(Messages.ExtractFunctionRefactoring_Error_Break); break; } } @@ -254,7 +239,8 @@ for (IASTNode node : cont.getNodesToWrite()) { node.accept(rFinder); if (rFinder.containsReturn()) { - initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Return); + initStatus + .addFatalError(Messages.ExtractFunctionRefactoring_Error_Return); break; } } @@ -354,11 +340,6 @@ methodCall = declarationStatement; } insertCallintoTree(methodCall, container.getNodesToWrite(), rewriter, editGroup); - - if (info.isReplaceDuplicates()) { - replaceSimilar(collector, astMethodName, implementationFile, context.getType()); - } - for (IASTNode node : container.getNodesToWrite()) { if (node != firstNodeToWrite) { rewriter.remove(node, editGroup); @@ -375,12 +356,14 @@ IASTExpression leftSubTree = parent.getOperand1(); int op = parent.getOperator(); IASTBinaryExpression newParentNode = new CPPASTBinaryExpression(); + CPPASTLiteralExpression placeholder = new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, ZERO); IASTBinaryExpression rootBinExp = getRootBinExp(parent, list); newParentNode.setParent(rootBinExp.getParent()); - newParentNode.setOperand1(leftSubTree.copy()); + newParentNode.setOperand1(placeholder); newParentNode.setOperator(op); - newParentNode.setOperand2((IASTExpression) methodCall); - rewriter.replace(rootBinExp, newParentNode, editGroup); + newParentNode.setOperand2((IASTExpression) methodCall); // TODO check + ASTRewrite callRewrite = rewriter.replace(rootBinExp, newParentNode, editGroup); + callRewrite.replace(placeholder, leftSubTree, editGroup); }else { rewriter.replace(firstNode, methodCall, editGroup); } @@ -423,158 +406,6 @@ } - private void replaceSimilar(ModificationCollector collector, final IASTName astMethodName, - final IFile implementationFile, - final ContextType contextType) { - // Find similar code - final List nodesToRewriteWithoutComments = new LinkedList(); - - for (IASTNode node : container.getNodesToWrite()) { - if (!(node instanceof IASTComment)) { - nodesToRewriteWithoutComments.add(node); - } - } - - final Vector initTrail = getTrail(nodesToRewriteWithoutComments); - final String title; - if (contextType == MethodContext.ContextType.METHOD) { - title = Messages.ExtractFunctionRefactoring_CreateMethodCall; - } else { - title = Messages.ExtractFunctionRefactoring_CreateFunctionCall; - } - - if (!hasNameResolvingForSimilarError) { - unit.accept(new SimilarFinderVisitor(this, collector, initTrail, implementationFile, - astMethodName, nodesToRewriteWithoutComments, title)); - } - } - - protected Vector getTrail(List stmts) { - final Vector trail = new Vector(); - - nameTrail = new HashMap(); - final Container trailCounter = new Container(NULL_INTEGER); - - for (IASTNode node : stmts) { - node.accept(new CPPASTAllVisitor() { - @Override - public int visitAll(IASTNode node) { - - if (node instanceof IASTComment) { - // Visit Comment, but don't add them to the trail - return super.visitAll(node); - } else if (node instanceof IASTNamedTypeSpecifier) { - // Skip if somewhere is a named Type Specifier - trail.add(node); - return PROCESS_SKIP; - } else if (node instanceof IASTName) { - if (node instanceof ICPPASTConversionName && node instanceof ICPPASTOperatorName - && node instanceof ICPPASTTemplateId) { - trail.add(node); - return super.visitAll(node); - } else { - // Save Name Sequenz Number - IASTName name = (IASTName) node; - TrailName trailName = new TrailName(); - int actCount = trailCounter.getObject().intValue(); - if (nameTrail.containsKey(name.getRawSignature())) { - Integer value = nameTrail.get(name.getRawSignature()); - actCount = value.intValue(); - } else { - trailCounter.setObject(Integer.valueOf(++actCount)); - nameTrail.put(name.getRawSignature(), trailCounter.getObject()); - } - trailName.setNameNumber(actCount); - trailName.setRealName(name); - - if (info.getReturnVariable() != null - && info.getReturnVariable().getName().getRawSignature().equals( - name.getRawSignature())) { - returnNumber.setObject(Integer.valueOf(actCount)); - } - - // Save type informations for the name - IBinding bind = name.resolveBinding(); - IASTName[] declNames = name.getTranslationUnit().getDeclarationsInAST(bind); - if (declNames.length > 0) { - IASTNode tmpNode = ASTHelper.getDeclarationForNode(declNames[0]); - - IBinding declbind = declNames[0].resolveBinding(); - if (declbind instanceof ICPPBinding) { - ICPPBinding cppBind = (ICPPBinding) declbind; - try { - trailName.setGloballyQualified(cppBind.isGloballyQualified()); - } catch (DOMException e) { - ILog logger = CUIPlugin.getDefault().getLog(); - IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, - IStatus.OK, e.getMessage(), e); - - logger.log(status); - } - } - - if (tmpNode != null) { - trailName.setDeclaration(tmpNode); - } else { - hasNameResolvingForSimilarError = true; - } - } - - trail.add(trailName); - return PROCESS_SKIP; - } - } else { - trail.add(node); - return super.visitAll(node); - } - } - }); - - } - - return trail; - } - - protected boolean isStatementInTrail(IASTStatement stmt, final Vector trail) { - final Container same = new Container(Boolean.TRUE); - final TrailNodeEqualityChecker equalityChecker = new TrailNodeEqualityChecker(names, namesCounter); - - stmt.accept(new CPPASTAllVisitor() { - @Override - public int visitAll(IASTNode node) { - - int pos = trailPos.getObject().intValue(); - - if (trail.size() <= 0 || pos >= trail.size()) { - same.setObject(Boolean.FALSE); - return PROCESS_ABORT; - } - - if (node instanceof IASTComment) { - // Visit Comment, but they are not in the trail - return super.visitAll(node); - } - - IASTNode trailNode = trail.get(pos); - trailPos.setObject(Integer.valueOf(pos + 1)); - - if (equalityChecker.isEquals(trailNode, node)) { - if (node instanceof ICPPASTQualifiedName || node instanceof IASTNamedTypeSpecifier) { - return PROCESS_SKIP; - } else { - return super.visitAll(node); - } - - } else { - same.setObject(new Boolean(false)); - return PROCESS_ABORT; - } - } - }); - - return same.getObject().booleanValue(); - } - private boolean isMethodAllreadyDefined( IASTSimpleDeclaration methodDeclaration, ICPPASTCompositeTypeSpecifier classDeclaration) { @@ -935,21 +766,4 @@ } } - @Override - protected RefactoringDescriptor getRefactoringDescriptor() { - Map arguments = getArgumentMap(); - RefactoringDescriptor desc = new ExtractFunctionRefactoringDescription( project.getProject().getName(), "Extract Method Refactoring", "Create method " + info.getMethodName(), arguments); //$NON-NLS-1$//$NON-NLS-2$ - return desc; - } - - private Map getArgumentMap() { - Map arguments = new HashMap(); - arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString()); - arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$ - arguments.put(ExtractFunctionRefactoringDescription.NAME, info.getMethodName()); - arguments.put(ExtractFunctionRefactoringDescription.VISIBILITY, info.getVisibility().toString()); - arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUBLICATES, Boolean.toString(info.isReplaceDuplicates())); - return arguments; - } - } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.extractfunction; - -import java.util.Map; - -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution; - -/** - * @author Emanuel Graf IFS - * - */ -public class ExtractFunctionRefactoringContribution extends CRefactoringContribution { - - @SuppressWarnings("unchecked") - @Override - public RefactoringDescriptor createDescriptor(String id, String project, String description, - String comment, Map arguments, int flags) throws IllegalArgumentException { - if(id.equals(ExtractFunctionRefactoring.ID)) { - return new ExtractFunctionRefactoringDescription(project, description, comment, arguments); - }else { - return null; - } - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.extractfunction; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.Refactoring; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - -import org.eclipse.cdt.core.model.ICProject; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription; -import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum; - -/** - * @author Emanuel Graf IFS - * - */ -public class ExtractFunctionRefactoringDescription extends CRefactoringDescription { - protected static final String NAME = "name"; //$NON-NLS-1$ - protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$ - protected static final String REPLACE_DUBLICATES = "replaceDuplicates"; //$NON-NLS-1$ - - public ExtractFunctionRefactoringDescription(String project, String description, - String comment, Map arguments) { - super(ExtractFunctionRefactoring.ID, project, description, comment, RefactoringDescriptor.MULTI_CHANGE, arguments); - } - - @Override - public Refactoring createRefactoring(RefactoringStatus status) throws CoreException { - IFile file; - ExtractFunctionInformation info = new ExtractFunctionInformation(); - ICProject proj; - - info.setMethodName(arguments.get(NAME)); - info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY))); - info.setReplaceDuplicates(Boolean.parseBoolean(arguments.get(REPLACE_DUBLICATES))); - - proj = getCProject(); - file = getFile(); - - ISelection selection = getSelection(); - return new ExtractFunctionRefactoring(file, selection, info, proj); - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java Wed Aug 05 17:35:39 2009 -0500 @@ -26,9 +26,12 @@ * */ public class ExtractFunctionRefactoringRunner extends RefactoringRunner { + + private ICProject project; - public ExtractFunctionRefactoringRunner(IFile file, ISelection selection, IShellProvider shellProvider, ICProject cProject) { - super(file, selection, null, shellProvider, cProject); + public ExtractFunctionRefactoringRunner(IFile file, ISelection selection, IShellProvider shellProvider, ICProject project) { + super(file, selection, null, shellProvider); + this.project = project; } @Override diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java Wed Aug 05 17:35:39 2009 -0500 @@ -34,7 +34,7 @@ public static String ExtractFunctionComposite_ReturnValue; public static String ExtractFunctionRefactoring_CreateMethodDef; public static String ExtractFunctionRefactoring_CreateFunctionDef; - public static String ExtractFunctionComposite_ReplaceDuplicates; +// public static String ExtractFunctionComposite_ReplaceDuplicates; public static String ExtractFunctionRefactoring_CreateMethodCall; public static String ExtractFunctionRefactoring_CreateFunctionCall; public static String ChooserComposite_Return; @@ -46,7 +46,6 @@ public static String ExtractFunctionRefactoring_Error_Return; public static String ExtractFunctionRefactoring_Error_Continue; public static String ExtractFunctionRefactoring_Error_Break; - public static String SimilarFinderVisitor_replaceDuplicateCode; static { NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.extractfunction; - -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; -import java.util.Map.Entry; - -import org.eclipse.core.resources.IFile; -import org.eclipse.text.edits.TextEditGroup; - -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTStatement; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; -import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; - -import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector; -import org.eclipse.cdt.internal.ui.refactoring.NodeContainer; -import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation; - -final class SimilarFinderVisitor extends CPPASTVisitor { - - private final ExtractFunctionRefactoring refactoring; - - private final Vector trail; - private final IASTName name; - private final List stmts; - private int i = 0; - private NodeContainer similarContainer; - private final List stmtToReplace = new ArrayList(); - - private final ModificationCollector collector; - - SimilarFinderVisitor(ExtractFunctionRefactoring refactoring, - ModificationCollector collector, Vector trail, IFile file, IASTName name, - List stmts, String title) { - this.refactoring = refactoring; - this.trail = trail; - this.name = name; - this.stmts = stmts; - this.collector = collector; - this.similarContainer = new NodeContainer(); - } - - { - shouldVisitStatements = true; - } - - @Override - public int visit(IASTStatement stmt) { - - boolean isAllreadyInMainRefactoring = isInSelection(stmt); - - if( (!isAllreadyInMainRefactoring) - && this.refactoring.isStatementInTrail(stmt, trail)){ - stmtToReplace.add(stmt); - similarContainer.add(stmt); - ++i; - - if(i==stmts.size()){ - //found similar code - - boolean similarOnReturnWays = true; - for (NameInformation nameInfo : similarContainer.getAllAfterUsedNames()) { - if(this.refactoring.names.containsKey(nameInfo.getDeclaration().getRawSignature())){ - Integer nameOrderNumber = this.refactoring.names.get(nameInfo.getDeclaration().getRawSignature()); - if(this.refactoring.nameTrail.containsValue(nameOrderNumber)){ - String orgName = null; - boolean found = false; - for (Entry entry : this.refactoring.nameTrail.entrySet()) { - if(entry.getValue().equals(nameOrderNumber)){ - orgName = entry.getKey(); - } - } - if(orgName != null){ - for (NameInformation orgNameInfo : this.refactoring.container.getAllAfterUsedNamesChoosenByUser()) { - if( orgName.equals(orgNameInfo.getDeclaration().getRawSignature()) ){ - found = true; - } - } - } - - if(!found){ - similarOnReturnWays = false; - } - } - } - } - - if(similarOnReturnWays){ - System.out.println(6); - IASTNode call = refactoring.getMethodCall(name, - this.refactoring.nameTrail, this.refactoring.names, - this.refactoring.container, similarContainer); - ASTRewrite rewrite = collector.rewriterForTranslationUnit(stmtToReplace.get(0) - .getTranslationUnit()); - TextEditGroup editGroup = new TextEditGroup(Messages.SimilarFinderVisitor_replaceDuplicateCode); - rewrite.replace(stmtToReplace.get(0), call, editGroup); - if (stmtToReplace.size() > 1) { - for (int i = 1; i < stmtToReplace.size(); ++i) { - rewrite.remove(stmtToReplace.get(i), editGroup); - } - } - } - - clear(); - } - - return PROCESS_SKIP; - } else { - clear(); - return super.visit(stmt); - } - - } - - private boolean isInSelection(IASTStatement stmt) { - Listnodes = this.refactoring.container.getNodesToWrite(); - for (IASTNode node : nodes) { - if(node.equals(stmt)) { - return true; - } - } - return false; - } - - private void clear() { - i = 0; - this.refactoring.names.clear(); - similarContainer = new NodeContainer(); - this.refactoring.namesCounter.setObject(ExtractFunctionRefactoring.NULL_INTEGER); - this.refactoring.trailPos.setObject(ExtractFunctionRefactoring.NULL_INTEGER); - stmtToReplace.clear(); - } - } \ No newline at end of file diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/messages.properties --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/messages.properties Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/messages.properties Wed Aug 05 17:35:39 2009 -0500 @@ -22,7 +22,7 @@ ExtractFunctionComposite_ReturnValue=Return value: ExtractFunctionRefactoring_CreateMethodDef=Create Method Definition ExtractFunctionRefactoring_CreateFunctionDef=Create Function Definition -ExtractFunctionComposite_ReplaceDuplicates=Replace all occurrences of statements with method. +#ExtractFunctionComposite_ReplaceDuplicates=Replace all occurrences of statements with method. ExtractFunctionRefactoring_CreateMethodCall=Create Method Call ExtractFunctionRefactoring_CreateFunctionCall=Create Function Call ChooserComposite_Return=Return @@ -34,4 +34,3 @@ ExtractFunctionRefactoring_Error_Return=Extracting return statements is not supported ExtractFunctionRefactoring_Error_Continue=Extracting cotinue statements without the surrounding loop is not possible. Please adjust your selection. ExtractFunctionRefactoring_Error_Break=Extracting break statements without the surrounding loop is not possible. Please adjust your selection. -SimilarFinderVisitor_replaceDuplicateCode=Replace Duplicated Code diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Google and others. All rights reserved. This program and + * Copyright (c) 2008 Google and others. All rights reserved. This program and * the accompanying materials are made available under the terms of the Eclipse * Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html @@ -11,9 +11,7 @@ package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; @@ -22,7 +20,6 @@ import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.text.Region; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.text.edits.TextEditGroup; @@ -48,7 +45,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; -import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; @@ -60,7 +56,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription; import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector; import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation; import org.eclipse.cdt.internal.ui.refactoring.NodeContainer; @@ -76,73 +71,61 @@ * @author Tom Ball */ public class ExtractLocalVariableRefactoring extends CRefactoring { - - public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocalVariableRefactoring"; //$NON-NLS-1$ - private IASTExpression target = null; private final NameNVisibilityInformation info; private NodeContainer container; public ExtractLocalVariableRefactoring(IFile file, ISelection selection, - NameNVisibilityInformation info, ICProject project) { - super(file, selection, null, project); + NameNVisibilityInformation info) { + super(file, selection, null); this.info = info; name = Messages.ExtractLocalVariable; } @Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) - throws CoreException, OperationCanceledException { + throws CoreException, OperationCanceledException { SubMonitor sm = SubMonitor.convert(pm, 9); - try { - lockIndex(); - try { - super.checkInitialConditions(sm.newChild(6)); + super.checkInitialConditions(sm.newChild(6)); - container = findAllExpressions(); - if (container.size() < 1) { - initStatus.addFatalError(Messages.ExpressionMustBeSelected); - return initStatus; - } + container = findAllExpressions(); + if (container.size() < 1) { + initStatus.addFatalError(Messages.ExpressionMustBeSelected); + return initStatus; + } - sm.worked(1); - if (isProgressMonitorCanceld(sm, initStatus)) - return initStatus; + sm.worked(1); + if (isProgressMonitorCanceld(sm, initStatus)) + return initStatus; - boolean oneMarked = region != null + boolean oneMarked = region != null && isOneMarked(container.getNodesToWrite(), region); - if (!oneMarked) { - if (target == null) { - initStatus.addFatalError(Messages.NoExpressionSelected); - } else { - initStatus.addFatalError(Messages.TooManyExpressionsSelected); - } - return initStatus; - } - sm.worked(1); + if (!oneMarked) { + if (target == null) { + initStatus.addFatalError(Messages.NoExpressionSelected); + } else { + initStatus.addFatalError(Messages.TooManyExpressionsSelected); + } + return initStatus; + } + sm.worked(1); - if (isProgressMonitorCanceld(sm, initStatus)) - return initStatus; - - container.findAllNames(); - sm.worked(1); + if (isProgressMonitorCanceld(sm, initStatus)) + return initStatus; - container.getAllAfterUsedNames(); - info.addNamesToUsedNames(findAllDeclaredNames()); - sm.worked(1); + container.findAllNames(); + sm.worked(1); - NodeHelper.findMethodContext(container.getNodesToWrite().get(0), - getIndex()); - sm.worked(1); + container.getAllAfterUsedNames(); + info.addNamesToUsedNames(findAllDeclaredNames()); + sm.worked(1); - info.setName(guessTempName()); - sm.done(); - }finally { - unlockIndex(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } + NodeHelper.findMethodContext(container.getNodesToWrite().get(0), + getIndex()); + sm.worked(1); + + info.setName(guessTempName()); + sm.done(); return initStatus; } @@ -257,31 +240,22 @@ protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) throws CoreException, OperationCanceledException { - try { - lockIndex(); - try { - String variableName = info.getName(); - TextEditGroup editGroup = new TextEditGroup( - Messages.CreateLocalVariable); + String variableName = info.getName(); + TextEditGroup editGroup = new TextEditGroup( + Messages.CreateLocalVariable); - // Define temporary variable declaration and insert it - IASTStatement declInsertPoint = getParentStatement(target); - IASTDeclarationStatement declaration = getVariableNodes(variableName); - declaration.setParent(declInsertPoint.getParent()); - ASTRewrite rewriter = collector.rewriterForTranslationUnit(unit); - rewriter.insertBefore(declInsertPoint.getParent(), declInsertPoint, - declaration, editGroup); + // Define temporary variable declaration and insert it + IASTStatement declInsertPoint = getParentStatement(target); + IASTDeclarationStatement declaration = getVariableNodes(variableName); + declaration.setParent(declInsertPoint.getParent()); + ASTRewrite rewriter = collector.rewriterForTranslationUnit(unit); + rewriter.insertBefore(declInsertPoint.getParent(), declInsertPoint, + declaration, editGroup); - // Replace target with reference to temporary variable - CPPASTIdExpression idExpression = new CPPASTIdExpression( - new CPPASTName(variableName.toCharArray())); - rewriter.replace(target, idExpression, editGroup); - }finally { - unlockIndex(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } + // Replace target with reference to temporary variable + CPPASTIdExpression idExpression = new CPPASTIdExpression( + new CPPASTName(variableName.toCharArray())); + rewriter.replace(target, idExpression, editGroup); } private IASTStatement getParentStatement(IASTNode node) { @@ -456,19 +430,4 @@ } return null; } - - @Override - protected RefactoringDescriptor getRefactoringDescriptor() { - Map arguments = getArgumentMap(); - RefactoringDescriptor desc = new ExtractLocalVariableRefactoringDescription(project.getProject().getName(), "Extract Local Variable Refactoring", "Extract " + target.getRawSignature(), arguments); //$NON-NLS-1$//$NON-NLS-2$ - return desc; - } - - private Map getArgumentMap() { - Map arguments = new HashMap(); - arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString()); - arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$ - arguments.put(ExtractLocalVariableRefactoringDescription.NAME, info.getName()); - return arguments; - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable; - -import java.util.Map; - -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution; - -/** - * @author Emanuel Graf IFS - * - */ -public class ExtractLocalVariableRefactoringContribution extends CRefactoringContribution { - - @SuppressWarnings("unchecked") - @Override - public RefactoringDescriptor createDescriptor(String id, String project, String description, - String comment, Map arguments, int flags) throws IllegalArgumentException { - if(id.equals(ExtractLocalVariableRefactoring.ID)) { - return new ExtractLocalVariableRefactoringDescription(project, description, comment, arguments); - }else { - return null; - } - } -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescription.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescription.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.Refactoring; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - -import org.eclipse.cdt.core.model.ICProject; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription; -import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation; - -/** - * @author Emanuel Graf IFS - * - */ -public class ExtractLocalVariableRefactoringDescription extends CRefactoringDescription { - - static protected final String NAME = "name"; //$NON-NLS-1$ - - public ExtractLocalVariableRefactoringDescription(String project, String description, - String comment, Map arguments) { - super(ExtractLocalVariableRefactoring.ID, project, description, comment, CRefactoringDescription.MULTI_CHANGE, arguments); - } - - @Override - public Refactoring createRefactoring(RefactoringStatus status) throws CoreException { - IFile file; - NameNVisibilityInformation info = new NameNVisibilityInformation(); - ICProject proj; - - info.setName(arguments.get(NAME)); - - proj = getCProject(); - - file = getFile(); - - ISelection selection = getSelection(); - return new ExtractLocalVariableRefactoring(file, selection, info, proj); - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -16,8 +16,6 @@ import org.eclipse.jface.window.IShellProvider; import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; -import org.eclipse.cdt.core.model.ICProject; - import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation; import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner; @@ -30,15 +28,15 @@ public class ExtractLocalVariableRefactoringRunner extends RefactoringRunner { public ExtractLocalVariableRefactoringRunner(IFile file, - ISelection selection, IShellProvider shellProvider, ICProject cProject) { - super(file, selection, null, shellProvider, cProject); + ISelection selection, IShellProvider shellProvider) { + super(file, selection, null, shellProvider); } @Override public void run() { NameNVisibilityInformation info = new NameNVisibilityInformation(); CRefactoring refactoring = new ExtractLocalVariableRefactoring(file, - selection, info, project); + selection, info); ExtractLocalVariableRefactoringWizard wizard = new ExtractLocalVariableRefactoringWizard( refactoring, info); RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -20,7 +20,6 @@ import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.text.Region; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; @@ -38,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.ui.refactoring.AddDeclarationNodeToClassChange; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; @@ -83,8 +81,8 @@ private static final String MEMBER_DECLARATION = "MEMBER_DECLARATION"; //$NON-NLS-1$ private final GetterAndSetterContext context = new GetterAndSetterContext(); - public GenerateGettersAndSettersRefactoring(IFile file, ISelection selection, ICElement element, ICProject project) { - super(file, selection, element, project); + public GenerateGettersAndSettersRefactoring(IFile file, ISelection selection, ICElement element) { + super(file, selection, element); } @Override @@ -197,11 +195,5 @@ public Region getRegion() { return region; - } - - @Override - protected RefactoringDescriptor getRefactoringDescriptor() { - // TODO egraf add Descriptor - return null; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -19,7 +19,6 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner; @@ -29,14 +28,14 @@ */ public class GenerateGettersAndSettersRefactoringRunner extends RefactoringRunner { - public GenerateGettersAndSettersRefactoringRunner(IFile file, ISelection selection, ICElement elem, IShellProvider shellProvider, ICProject cProject) { - super(file, selection, elem, shellProvider, cProject); + public GenerateGettersAndSettersRefactoringRunner(IFile file, ISelection selection, ICElement elem, IShellProvider shellProvider) { + super(file, selection, elem, shellProvider); } @Override public void run() { if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() instanceof ITextEditor) { - GenerateGettersAndSettersRefactoring refactoring = new GenerateGettersAndSettersRefactoring(file, selection, celement, project); + GenerateGettersAndSettersRefactoring refactoring = new GenerateGettersAndSettersRefactoring(file, selection, celement); GenerateGettersAndSettersRefactoringWizard wizard = new GenerateGettersAndSettersRefactoringWizard(refactoring); RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.ui.refactoring.hidemethod; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; @@ -21,7 +19,6 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.text.edits.TextEditGroup; @@ -41,14 +38,12 @@ import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; import org.eclipse.cdt.internal.ui.refactoring.AddDeclarationNodeToClassChange; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription; import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector; import org.eclipse.cdt.internal.ui.refactoring.utils.DeclarationFinder; import org.eclipse.cdt.internal.ui.refactoring.utils.DeclarationFinderDO; @@ -62,102 +57,90 @@ * */ public class HideMethodRefactoring extends CRefactoring { - - public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoring"; //$NON-NLS-1$ private IASTName methodToHide; private IASTDeclaration methodToHideDecl; private DeclarationFinderDO declData; - public HideMethodRefactoring(IFile file, ISelection selection, ICElement element, ICProject project) { - super(file, selection, element, project); + public HideMethodRefactoring(IFile file, ISelection selection, ICElement element) { + super(file, selection, element); name = Messages.HideMethodRefactoring_HIDE_METHOD; } @Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { SubMonitor sm = SubMonitor.convert(pm, 10); - try { - lockIndex(); - try { - super.checkInitialConditions(sm.newChild(6)); - - if(initStatus.hasFatalError()){ - return initStatus; - } - - if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; + super.checkInitialConditions(sm.newChild(6)); + + if(initStatus.hasFatalError()){ + return initStatus; + } + + if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; + + IASTName name; + ArrayList names = findAllMarkedNames(); + if (names.size() < 1) { + initStatus.addFatalError(Messages.HideMethodRefactoring_NoNameSelected); + return initStatus; + } + name = names.get(names.size()-1); + sm.worked(1); + if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; + + declData = DeclarationFinder.getDeclaration(name, getIndex()); + + if(declData == null || declData.name == null) { + initStatus.addFatalError(Messages.HideMethodRefactoring_NoMethodNameSelected); + return initStatus; + } + + methodToHide = declData.name; + sm.worked(1); + methodToHideDecl = NodeHelper.findSimpleDeclarationInParents(methodToHide); + if(methodToHideDecl == null) { + initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); + return initStatus; + } + if(!(methodToHideDecl.getParent() instanceof ICPPASTCompositeTypeSpecifier)) { + methodToHideDecl = NodeHelper.findFunctionDefinitionInAncestors(methodToHide); + } - IASTName name; - ArrayList names = findAllMarkedNames(); - if (names.size() < 1) { - initStatus.addFatalError(Messages.HideMethodRefactoring_NoNameSelected); - return initStatus; - } - name = names.get(names.size()-1); - sm.worked(1); - if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; - - declData = DeclarationFinder.getDeclaration(name, getIndex()); - - if(declData == null || declData.name == null) { - initStatus.addFatalError(Messages.HideMethodRefactoring_NoMethodNameSelected); - return initStatus; - } - - methodToHide = declData.name; - sm.worked(1); - methodToHideDecl = NodeHelper.findSimpleDeclarationInParents(methodToHide); - if(methodToHideDecl == null) { + if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; + sm.worked(1); + if(methodToHideDecl instanceof IASTFunctionDefinition) { + IASTDeclarator declarator = ((IASTFunctionDefinition)methodToHideDecl).getDeclarator(); + if(CPPVisitor.findInnermostDeclarator(declarator).getName().getRawSignature().equals(name.getRawSignature())) { + if (!(declarator instanceof IASTFunctionDeclarator)) { initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); return initStatus; } - if(!(methodToHideDecl.getParent() instanceof ICPPASTCompositeTypeSpecifier)) { - methodToHideDecl = NodeHelper.findFunctionDefinitionInAncestors(methodToHide); - } - - if(isProgressMonitorCanceld(sm, initStatus)) return initStatus; - sm.worked(1); - if(methodToHideDecl instanceof IASTFunctionDefinition) { - IASTDeclarator declarator = ((IASTFunctionDefinition)methodToHideDecl).getDeclarator(); - if(CPPVisitor.findInnermostDeclarator(declarator).getName().getRawSignature().equals(name.getRawSignature())) { - if (!(declarator instanceof IASTFunctionDeclarator)) { - initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); - return initStatus; - } + } + }else if (methodToHideDecl instanceof IASTSimpleDeclaration) { + for(IASTDeclarator declarator : ((IASTSimpleDeclaration) methodToHideDecl).getDeclarators()) { + if(declarator.getName().getRawSignature().equals(name.getRawSignature())) { + if (!(declarator instanceof IASTFunctionDeclarator)) { + initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); + return initStatus; } - }else if (methodToHideDecl instanceof IASTSimpleDeclaration) { - for(IASTDeclarator declarator : ((IASTSimpleDeclaration) methodToHideDecl).getDeclarators()) { - if(declarator.getName().getRawSignature().equals(name.getRawSignature())) { - if (!(declarator instanceof IASTFunctionDeclarator)) { - initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); - return initStatus; - } - } - } - }else { - initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); - return initStatus; } - - sm.worked(1); + } + }else { + initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); + return initStatus; + } + + sm.worked(1); - IASTCompositeTypeSpecifier classNode = NodeHelper.findClassInAncestors(methodToHide); - if(classNode == null) { - initStatus.addError(Messages.HideMethodRefactoring_EnclosingClassNotFound); - } - - if(checkIfPrivate(classNode, methodToHideDecl)) { - initStatus.addError(Messages.HideMethodRefactoring_IsAlreadyPrivate); - } - sm.done(); - } - finally { - unlockIndex(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); + IASTCompositeTypeSpecifier classNode = NodeHelper.findClassInAncestors(methodToHide); + if(classNode == null) { + initStatus.addError(Messages.HideMethodRefactoring_EnclosingClassNotFound); } + + if(checkIfPrivate(classNode, methodToHideDecl)) { + initStatus.addError(Messages.HideMethodRefactoring_IsAlreadyPrivate); + } + sm.done(); return initStatus; } @@ -187,54 +170,41 @@ @Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { - RefactoringStatus finalConditions = null; - try { - lockIndex(); - try { - finalConditions = super.checkFinalConditions(pm); - - for(IIndexName pdomref : declData.allNamesPDom) { - declData.filename = pdomref.getFileLocation().getFileName(); + RefactoringStatus finalConditions = super.checkFinalConditions(pm); - if(pdomref instanceof PDOMName) { - PDOMName pdomName = (PDOMName)pdomref; - if(pdomName.isDeclaration()) { - continue; - } - if(pdomName.isDefinition()) { - continue; - } - } - - IASTTranslationUnit transUtmp = TranslationUnitHelper.loadTranslationUnit(declData.filename, false); - IASTName expName = ExpressionFinder.findExpressionInTranslationUnit(transUtmp, pdomref); + for(IIndexName pdomref : declData.allNamesPDom) { + declData.filename = pdomref.getFileLocation().getFileName(); - IASTFunctionDeclarator funcDec = findEnclosingFunction(expName); - IASTCompositeTypeSpecifier encClass2; - if(funcDec == null) { - encClass2 = NodeHelper.findClassInAncestors(expName); - } - else { - encClass2 = NodeHelper.findClassInAncestors(funcDec); - } - - IASTCompositeTypeSpecifier encClass = NodeHelper.findClassInAncestors(methodToHide); + if(pdomref instanceof PDOMName) { + PDOMName pdomName = (PDOMName)pdomref; + if(pdomName.isDeclaration()) { + continue; + } + if(pdomName.isDefinition()) { + continue; + } + } + + IASTTranslationUnit transUtmp = TranslationUnitHelper.loadTranslationUnit(declData.filename, false); + IASTName expName = ExpressionFinder.findExpressionInTranslationUnit(transUtmp, pdomref); + + IASTFunctionDeclarator funcDec = findEnclosingFunction(expName); + IASTCompositeTypeSpecifier encClass2; + if(funcDec == null) { + encClass2 = NodeHelper.findClassInAncestors(expName); + } + else { + encClass2 = NodeHelper.findClassInAncestors(funcDec); + } + + IASTCompositeTypeSpecifier encClass = NodeHelper.findClassInAncestors(methodToHide); - if(!NodeHelper.isSameNode(encClass, encClass2)) { - finalConditions.addWarning(Messages.HideMethodRefactoring_HasExternalReferences); - break; - } - } - - return finalConditions; + if(!NodeHelper.isSameNode(encClass, encClass2)) { + finalConditions.addWarning(Messages.HideMethodRefactoring_HasExternalReferences); + break; } - finally { - unlockIndex(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); } - return finalConditions; + return finalConditions; } private IASTFunctionDeclarator findEnclosingFunction(IASTNode node) throws CoreException { @@ -275,36 +245,12 @@ @Override protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) throws CoreException, OperationCanceledException { - try { - lockIndex(); - try { - ASTRewrite rewriter = collector.rewriterForTranslationUnit(declData.transUnit); - TextEditGroup editGroup = new TextEditGroup(Messages.HideMethodRefactoring_FILE_CHANGE_TEXT+ methodToHide.getRawSignature()); - - ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) methodToHideDecl.getParent(); - AddDeclarationNodeToClassChange.createChange(classDefinition, VisibilityEnum.v_private, methodToHideDecl, false, collector); + ASTRewrite rewriter = collector.rewriterForTranslationUnit(declData.transUnit); + TextEditGroup editGroup = new TextEditGroup(Messages.HideMethodRefactoring_FILE_CHANGE_TEXT+ methodToHide.getRawSignature()); + + ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) methodToHideDecl.getParent(); + AddDeclarationNodeToClassChange.createChange(classDefinition, VisibilityEnum.v_private, methodToHideDecl, false, collector); - rewriter.remove(methodToHideDecl, editGroup); - } - finally { - unlockIndex(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - - @Override - protected RefactoringDescriptor getRefactoringDescriptor() { - Map arguments = getArgumentMap(); - RefactoringDescriptor desc = new HideMethodRefactoringDescription( project.getProject().getName(), "Hide Method Refactoring", "Hide Method " + methodToHide.getRawSignature(), arguments); //$NON-NLS-1$//$NON-NLS-2$ - return desc; - } - - private Map getArgumentMap() { - Map arguments = new HashMap(); - arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString()); - arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$ - return arguments; + rewriter.remove(methodToHideDecl, editGroup); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.hidemethod; - -import java.util.Map; - -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution; - -/** - * @author Emanuel Graf IFS - * - */ -public class HideMethodRefactoringContribution extends CRefactoringContribution { - - @SuppressWarnings("unchecked") - @Override - public RefactoringDescriptor createDescriptor(String id, String project, String description, - String comment, Map arguments, int flags) throws IllegalArgumentException { - if(id.equals(HideMethodRefactoring.ID)) { - return new HideMethodRefactoringDescription(project, description, comment, arguments); - }else { - return null; - } - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescription.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescription.java Tue Aug 04 14:00:13 2009 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Institute for Software (IFS)- initial API and implementation - ******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.hidemethod; - -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.Refactoring; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - -import org.eclipse.cdt.core.model.ICProject; - -import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription; - -/** - * @author Emanuel Graf IFS - * - */ -public class HideMethodRefactoringDescription extends CRefactoringDescription { - - public HideMethodRefactoringDescription(String project, String description, String comment, - Map arguments) { - super(HideMethodRefactoring.ID, project, description, comment, RefactoringDescriptor.STRUCTURAL_CHANGE, arguments); - } - - @Override - public Refactoring createRefactoring(RefactoringStatus status) throws CoreException { - IFile file; - ICProject proj; - - proj = getCProject(); - file = getFile(); - ISelection selection = getSelection(); - return new HideMethodRefactoring(file, selection, null, proj); - } - -} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,12 +12,13 @@ package org.eclipse.cdt.internal.ui.refactoring.hidemethod; import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.window.IShellProvider; import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner; @@ -28,20 +29,29 @@ */ public class HideMethodRefactoringRunner extends RefactoringRunner { - public HideMethodRefactoringRunner(IFile file, ISelection selection, ICElement element, IShellProvider shellProvider, ICProject cProject) { - super(file, selection, element, shellProvider, cProject); + public HideMethodRefactoringRunner(IFile file, ISelection selection, ICElement element, IShellProvider shellProvider) { + super(file, selection, element, shellProvider); } @Override public void run() { - CRefactoring refactoring= new HideMethodRefactoring(file, selection, celement, project); + CRefactoring refactoring= new HideMethodRefactoring(file, selection, celement); HideMethodRefactoringWizard wizard = new HideMethodRefactoringWizard(refactoring); RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard); + try { - operator.run(shellProvider.getShell(), refactoring.getName()); + refactoring.lockIndex(); + try { + operator.run(shellProvider.getShell(), refactoring.getName()); + } + finally { + refactoring.unlockIndex(); + } } catch (InterruptedException e) { Thread.currentThread().interrupt(); - } + } catch (CoreException e) { + CUIPlugin.log(e); + } } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java Wed Aug 05 17:35:39 2009 -0500 @@ -21,7 +21,6 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.cdt.core.dom.ast.ASTVisitor; @@ -41,7 +40,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator; @@ -68,8 +66,8 @@ private CPPASTFunctionDeclarator createdMethodDeclarator; private ImplementMethodData data; - public ImplementMethodRefactoring(IFile file, ISelection selection, ICElement element, ICProject project) { - super(file, selection, element, project); + public ImplementMethodRefactoring(IFile file, ISelection selection, ICElement element) { + super(file, selection, element); data = new ImplementMethodData(); } @@ -248,10 +246,4 @@ public ImplementMethodData getRefactoringData() { return data; } - - @Override - protected RefactoringDescriptor getRefactoringDescriptor() { - // TODO egraf add Descriptor - return null; - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -18,7 +18,6 @@ import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner; @@ -29,13 +28,13 @@ */ public class ImplementMethodRefactoringRunner extends RefactoringRunner { - public ImplementMethodRefactoringRunner(IFile file, ISelection selection, ICElement element, IShellProvider shellProvider, ICProject cProject) { - super(file, selection, element, shellProvider, cProject); + public ImplementMethodRefactoringRunner(IFile file, ISelection selection, ICElement element, IShellProvider shellProvider) { + super(file, selection, element, shellProvider); } @Override public void run() { - ImplementMethodRefactoring refactoring = new ImplementMethodRefactoring(file, selection, celement, project); + ImplementMethodRefactoring refactoring = new ImplementMethodRefactoring(file, selection, celement); ImplementMethodRefactoringWizard wizard = new ImplementMethodRefactoringWizard(refactoring); RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard); diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2005, 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -615,7 +615,10 @@ private static IType getRealType(IType t) { while(t instanceof ITypedef) { - t= ((ITypedef) t).getType(); + try { + t= ((ITypedef) t).getType(); + } catch (DOMException e) { + } } return t; } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,251 +1,251 @@ -/******************************************************************************* - * Copyright (c) 2009 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andrey Eremchenko, kamre@ngs.ru - 222495 C/C++ search should show line matches and line numbers - * - *******************************************************************************/ -package org.eclipse.cdt.internal.ui.search; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; - -import org.eclipse.cdt.core.index.IIndexFileLocation; -import org.eclipse.cdt.core.parser.CodeReader; -import org.eclipse.cdt.ui.CUIPlugin; - -/** - * Element representing a line with one ore more matches. - * - */ -public class LineSearchElement extends PDOMSearchElement { - public static final class Match { - private final int fOffset; - private final int fLength; - private final boolean fIsPolymorphicCall; - - public Match(int offset, int length, boolean isPolymorphicCall) { - fOffset = offset; - fLength = length; - fIsPolymorphicCall = isPolymorphicCall; - } - - public int getOffset() { - return fOffset; - } - - public int getLength() { - return fLength; - } - - public boolean isPolymorphicCall() { - return fIsPolymorphicCall; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Match)) - return false; - Match m = (Match) obj; - return (fOffset == m.fOffset) && (fLength == m.fLength); - } - - @Override - public int hashCode() { - return 31 * fOffset + fLength; - } - } - - private static final class MatchesComparator implements Comparator { - public int compare(Match m1, Match m2) { - return m1.getOffset() - m2.getOffset(); - } - } - - private final int fOffset; - private final int fNumber; - private final String fContent; - private final Match[] fMatches; - private final static MatchesComparator MATCHES_COMPARATOR = new MatchesComparator(); - - private LineSearchElement(IIndexFileLocation file, Match[] matches, int number, String content, int offset) { - super(file); - fMatches = matches; - fNumber = number; - // skip whitespace at the beginning - int index = 0; - int length = content.length(); - int firstMatchOffset = matches[0].getOffset(); - while (offset < firstMatchOffset && length > 0) { - if (content.charAt(index) != ' ') - break; - index++; - offset++; - length--; - } - fOffset = offset; - fContent = content.substring(index); - } - - public int getOffset() { - return fOffset; - } - - public int getLineNumber() { - return fNumber; - } - - public String getContent() { - return fContent; - } - - public Match[] getMatches() { - return fMatches; - } - - @Override - public String toString() { - return fNumber + ": " + fContent; //$NON-NLS-1$ - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof LineSearchElement)) - return false; - LineSearchElement other = (LineSearchElement) obj; - return (fOffset == other.fOffset) && (super.equals(obj)) && (fMatches.equals(other.fMatches)); - } - - @Override - public int hashCode() { - return fOffset + 31 * (super.hashCode() + 31 * fMatches.hashCode()); - } - - public static LineSearchElement[] createElements(IIndexFileLocation fileLocation, Match[] matches) { - // sort matches according to their offsets - Arrays.sort(matches, MATCHES_COMPARATOR); - LineSearchElement[] result = {}; - try { - String path = fileLocation.getURI().getPath(); - // read the content of file - CodeReader reader = new CodeReader(path); - result = collectLineElements(reader.buffer, matches, fileLocation); - } catch (IOException e) { - CUIPlugin.log(e); - } - return result; - } - - public static LineSearchElement[] createElements(IIndexFileLocation fileLocation, Match[] matches, - IDocument document) { - // sort matches according to their offsets - Arrays.sort(matches, MATCHES_COMPARATOR); - // group all matches by lines and create LineSearchElements - List result = new ArrayList(); - int firstMatch = 0; - while (firstMatch < matches.length) { - try { - int lineNumber = document.getLineOfOffset(matches[firstMatch].getOffset()); - int lineOffset = document.getLineOffset(lineNumber); - int lineLength = document.getLineLength(lineNumber); - int nextlineOffset = lineOffset + lineLength; - int nextMatch = firstMatch; - int nextMatchOffset = matches[nextMatch].getOffset(); - while (nextMatch < matches.length && nextMatchOffset < nextlineOffset) { - nextMatch++; - if (nextMatch < matches.length) - nextMatchOffset = matches[nextMatch].getOffset(); - } - int lineMatchesCount = nextMatch - firstMatch; - Match[] lineMatches = new Match[lineMatchesCount]; - System.arraycopy(matches, firstMatch, lineMatches, 0, lineMatchesCount); - String content = document.get(lineOffset, lineLength); - result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber + 1, content, lineOffset)); - firstMatch = nextMatch; - } catch (BadLocationException e) { - CUIPlugin.log(e); - } - } - return result.toArray(new LineSearchElement[result.size()]); - } - - private static LineSearchElement[] collectLineElements(char[] buffer, Match[] matches, - IIndexFileLocation fileLocation) { - List result = new ArrayList(); - boolean skipLF = false; - int lineNumber = 1; - int lineOffset = 0; - int lineFirstMatch = -1; // not matched - int nextMatch = 0; - int nextMatchOffset = matches[nextMatch].getOffset(); - for (int pos = 0; pos < buffer.length; pos++) { - char c = buffer[pos]; - // consider '\n' and '\r' - if (skipLF) { - skipLF = false; - if (c == '\n') { - lineOffset = pos + 1; - continue; - } - } - if (c == '\n' || c == '\r') { - // create new LineElement if there were matches - if (lineFirstMatch != -1) { - int lineLength = pos - lineOffset; - int lineMatchesCount = nextMatch - lineFirstMatch; - Match[] lineMatches = new Match[lineMatchesCount]; - System.arraycopy(matches, lineFirstMatch, lineMatches, 0, lineMatchesCount); - String lineContent = new String(buffer, lineOffset, lineLength); - result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent, - lineOffset)); - lineFirstMatch = -1; - if (nextMatch >= matches.length) - break; - if (matches[nextMatch].getOffset() < pos) - lineFirstMatch = nextMatch; - } - lineNumber++; - lineOffset = pos + 1; - if (c == '\r') - skipLF = true; - continue; - } - // compare offset of next match with current position - if (nextMatchOffset > pos) - continue; - // next match was reached - // check if this match is the first for current line - if (lineFirstMatch == -1) - lineFirstMatch = nextMatch; - // goto to next match - nextMatch++; - if (nextMatch < matches.length) { - // update offset of next match - nextMatchOffset = matches[nextMatch].getOffset(); - } else { - // no more matches - nextMatchOffset = buffer.length; - } - } - // check if there were matches on the last line - if (lineFirstMatch != -1) { - int lineLength = buffer.length - lineOffset; - int lineMatchesCount = nextMatch - lineFirstMatch; - Match[] lineMatches = new Match[lineMatchesCount]; - System.arraycopy(matches, lineFirstMatch, lineMatches, 0, lineMatchesCount); - String lineContent = new String(buffer, lineOffset, lineLength); - result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent, lineOffset)); - } - return result.toArray(new LineSearchElement[result.size()]); - } -} +/******************************************************************************* + * Copyright (c) 2009 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrey Eremchenko, kamre@ngs.ru - 222495 C/C++ search should show line matches and line numbers + * + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.search; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; + +import org.eclipse.cdt.core.index.IIndexFileLocation; +import org.eclipse.cdt.core.parser.CodeReader; +import org.eclipse.cdt.ui.CUIPlugin; + +/** + * Element representing a line with one ore more matches. + * + */ +public class LineSearchElement extends PDOMSearchElement { + public static final class Match { + private final int fOffset; + private final int fLength; + private final boolean fIsPolymorphicCall; + + public Match(int offset, int length, boolean isPolymorphicCall) { + fOffset = offset; + fLength = length; + fIsPolymorphicCall = isPolymorphicCall; + } + + public int getOffset() { + return fOffset; + } + + public int getLength() { + return fLength; + } + + public boolean isPolymorphicCall() { + return fIsPolymorphicCall; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Match)) + return false; + Match m = (Match) obj; + return (fOffset == m.fOffset) && (fLength == m.fLength); + } + + @Override + public int hashCode() { + return 31 * fOffset + fLength; + } + } + + private static final class MatchesComparator implements Comparator { + public int compare(Match m1, Match m2) { + return m1.getOffset() - m2.getOffset(); + } + } + + private final int fOffset; + private final int fNumber; + private final String fContent; + private final Match[] fMatches; + private final static MatchesComparator MATCHES_COMPARATOR = new MatchesComparator(); + + private LineSearchElement(IIndexFileLocation file, Match[] matches, int number, String content, int offset) { + super(file); + fMatches = matches; + fNumber = number; + // skip whitespace at the beginning + int index = 0; + int length = content.length(); + int firstMatchOffset = matches[0].getOffset(); + while (offset < firstMatchOffset && length > 0) { + if (content.charAt(index) != ' ') + break; + index++; + offset++; + length--; + } + fOffset = offset; + fContent = content.substring(index); + } + + public int getOffset() { + return fOffset; + } + + public int getLineNumber() { + return fNumber; + } + + public String getContent() { + return fContent; + } + + public Match[] getMatches() { + return fMatches; + } + + @Override + public String toString() { + return fNumber + ": " + fContent; //$NON-NLS-1$ + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof LineSearchElement)) + return false; + LineSearchElement other = (LineSearchElement) obj; + return (fOffset == other.fOffset) && (super.equals(obj)) && (fMatches.equals(other.fMatches)); + } + + @Override + public int hashCode() { + return fOffset + 31 * (super.hashCode() + 31 * fMatches.hashCode()); + } + + public static LineSearchElement[] createElements(IIndexFileLocation fileLocation, Match[] matches) { + // sort matches according to their offsets + Arrays.sort(matches, MATCHES_COMPARATOR); + LineSearchElement[] result = {}; + try { + String path = fileLocation.getURI().getPath(); + // read the content of file + CodeReader reader = new CodeReader(path); + result = collectLineElements(reader.buffer, matches, fileLocation); + } catch (IOException e) { + CUIPlugin.log(e); + } + return result; + } + + public static LineSearchElement[] createElements(IIndexFileLocation fileLocation, Match[] matches, + IDocument document) { + // sort matches according to their offsets + Arrays.sort(matches, MATCHES_COMPARATOR); + // group all matches by lines and create LineSearchElements + List result = new ArrayList(); + int firstMatch = 0; + while (firstMatch < matches.length) { + try { + int lineNumber = document.getLineOfOffset(matches[firstMatch].getOffset()); + int lineOffset = document.getLineOffset(lineNumber); + int lineLength = document.getLineLength(lineNumber); + int nextlineOffset = lineOffset + lineLength; + int nextMatch = firstMatch; + int nextMatchOffset = matches[nextMatch].getOffset(); + while (nextMatch < matches.length && nextMatchOffset < nextlineOffset) { + nextMatch++; + if (nextMatch < matches.length) + nextMatchOffset = matches[nextMatch].getOffset(); + } + int lineMatchesCount = nextMatch - firstMatch; + Match[] lineMatches = new Match[lineMatchesCount]; + System.arraycopy(matches, firstMatch, lineMatches, 0, lineMatchesCount); + String content = document.get(lineOffset, lineLength); + result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber + 1, content, lineOffset)); + firstMatch = nextMatch; + } catch (BadLocationException e) { + CUIPlugin.log(e); + } + } + return result.toArray(new LineSearchElement[result.size()]); + } + + private static LineSearchElement[] collectLineElements(char[] buffer, Match[] matches, + IIndexFileLocation fileLocation) { + List result = new ArrayList(); + boolean skipLF = false; + int lineNumber = 1; + int lineOffset = 0; + int lineFirstMatch = -1; // not matched + int nextMatch = 0; + int nextMatchOffset = matches[nextMatch].getOffset(); + for (int pos = 0; pos < buffer.length; pos++) { + char c = buffer[pos]; + // consider '\n' and '\r' + if (skipLF) { + skipLF = false; + if (c == '\n') { + lineOffset = pos + 1; + continue; + } + } + if (c == '\n' || c == '\r') { + // create new LineElement if there were matches + if (lineFirstMatch != -1) { + int lineLength = pos - lineOffset; + int lineMatchesCount = nextMatch - lineFirstMatch; + Match[] lineMatches = new Match[lineMatchesCount]; + System.arraycopy(matches, lineFirstMatch, lineMatches, 0, lineMatchesCount); + String lineContent = new String(buffer, lineOffset, lineLength); + result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent, + lineOffset)); + lineFirstMatch = -1; + if (nextMatch >= matches.length) + break; + if (matches[nextMatch].getOffset() < pos) + lineFirstMatch = nextMatch; + } + lineNumber++; + lineOffset = pos + 1; + if (c == '\r') + skipLF = true; + continue; + } + // compare offset of next match with current position + if (nextMatchOffset > pos) + continue; + // next match was reached + // check if this match is the first for current line + if (lineFirstMatch == -1) + lineFirstMatch = nextMatch; + // goto to next match + nextMatch++; + if (nextMatch < matches.length) { + // update offset of next match + nextMatchOffset = matches[nextMatch].getOffset(); + } else { + // no more matches + nextMatchOffset = buffer.length; + } + } + // check if there were matches on the last line + if (lineFirstMatch != -1) { + int lineLength = buffer.length - lineOffset; + int lineMatchesCount = nextMatch - lineFirstMatch; + Match[] lineMatches = new Match[lineMatchesCount]; + System.arraycopy(matches, lineFirstMatch, lineMatches, 0, lineMatchesCount); + String lineContent = new String(buffer, lineOffset, lineLength); + result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent, lineOffset)); + } + return result.toArray(new LineSearchElement[result.size()]); + } +} diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -109,7 +109,7 @@ if (element instanceof LineSearchElement) { return element.toString(); } - + if (element instanceof TypeInfoSearchElement) { return fTypeInfoLabelProvider.getText(((TypeInfoSearchElement)element).getTypeInfo()); } @@ -167,4 +167,5 @@ } return styled; } + } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -55,7 +55,7 @@ return text; } - + @Override public StyledString getStyledText(Object element) { if (!(element instanceof LineSearchElement)) diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java Wed Aug 05 17:35:39 2009 -0500 @@ -110,7 +110,8 @@ } } - if (buff.length() > 0) { + if (buff.length() > 0) + { if (isCaseSensitive) patternList.add(Pattern.compile(buff.toString())); else @@ -137,7 +138,8 @@ boolean matches= false; if ((flags & FIND_ALL_TYPES) == FIND_ALL_TYPES) { matches= true; - } else if (pdomBinding instanceof ICompositeType) { + } + else if (pdomBinding instanceof ICompositeType) { ICompositeType ct= (ICompositeType) pdomBinding; switch (ct.getKey()) { case ICompositeType.k_struct: @@ -148,21 +150,29 @@ matches= (flags & FIND_UNION) != 0; break; } - } else if (pdomBinding instanceof IEnumeration) { + } + else if (pdomBinding instanceof IEnumeration) { matches= (flags & FIND_ENUM) != 0; - } else if (pdomBinding instanceof IEnumerator) { + } + else if (pdomBinding instanceof IEnumerator) { matches= (flags & FIND_ENUMERATOR) != 0; - } else if (pdomBinding instanceof IField) { + } + else if (pdomBinding instanceof IField) { matches= (flags & FIND_FIELD) != 0; - } else if (pdomBinding instanceof ICPPMethod) { + } + else if (pdomBinding instanceof ICPPMethod) { matches= (flags & FIND_METHOD) != 0; - } else if (pdomBinding instanceof IVariable) { + } + else if (pdomBinding instanceof IVariable) { matches= (flags & FIND_VARIABLE) != 0; - } else if (pdomBinding instanceof IFunction) { + } + else if (pdomBinding instanceof IFunction) { matches= (flags & FIND_FUNCTION) != 0; - } else if (pdomBinding instanceof ICPPNamespace || pdomBinding instanceof ICPPNamespaceAlias) { + } + else if (pdomBinding instanceof ICPPNamespace || pdomBinding instanceof ICPPNamespaceAlias) { matches= (flags & FIND_NAMESPACE) != 0; - } else if (pdomBinding instanceof ITypedef) { + } + else if (pdomBinding instanceof ITypedef) { matches= (flags & FIND_TYPEDEF) != 0; } if (matches) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java Wed Aug 05 17:35:39 2009 -0500 @@ -304,14 +304,14 @@ if (localMatches.isEmpty()) return; // Search for dirty editor - ITextEditor dirtyTextEditor = null; + ITextEditor dirtyTextEditor = null; String fullPath = ast.getFilePath(); for (IEditorPart editorPart : CUIPlugin.getDirtyEditors()) { if (editorPart instanceof ITextEditor) { - ITextEditor textEditor = (ITextEditor) editorPart; + ITextEditor textEditor = (ITextEditor)editorPart; IEditorInput editorInput = editorPart.getEditorInput(); if (editorInput instanceof IPathEditorInput) { - IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput; + IPathEditorInput pathEditorInput = (IPathEditorInput)editorInput; IPath path = pathEditorInput.getPath(); if (fullPath.equals(path.toOSString())) { dirtyTextEditor = textEditor; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -39,7 +39,7 @@ return text + " " //$NON-NLS-1$ + Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count)); } - + @Override public StyledString getStyledText(Object element) { if (element instanceof TranslationUnit) { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java Wed Aug 05 17:35:39 2009 -0500 @@ -51,6 +51,8 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.IWorkingCopyManager; +import org.eclipse.cdt.internal.core.index.IndexChangeEvent; + /** * A single strategy C reconciler. * @@ -266,7 +268,8 @@ */ public void indexChanged(IIndexChangeEvent event) { if (!fIndexChanged && isRelevantProject(event.getAffectedProject())) { - if (!fIgnoreChanges || event.isCleared() || event.isReloaded() || event.hasNewFile()) { + if (!fIgnoreChanges || event.isCleared() || event.isReloaded() || + ((event instanceof IndexChangeEvent) && ((IndexChangeEvent)event).hasNewFile())) { fIndexChanged= true; } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java Wed Aug 05 17:35:39 2009 -0500 @@ -243,6 +243,7 @@ String desc= CUIPlugin.getResourceString("Editorutility.closedproject.description"); //$NON-NLS-1$ errorMsg.setMessage(MessageFormat.format(desc, new Object[]{project.getName()})); errorMsg.open(); + } private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException { diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java Wed Aug 05 17:35:39 2009 -0500 @@ -14,10 +14,8 @@ package org.eclipse.cdt.internal.ui.viewsupport; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; @@ -25,14 +23,12 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.model.IWorkbenchAdapter; -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.IArchiveContainer; import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinaryContainer; import org.eclipse.cdt.core.model.IBinaryModule; -import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IContributedCElement; @@ -50,8 +46,6 @@ import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.internal.core.model.CModelManager; - import org.eclipse.cdt.internal.ui.CPluginImages; @@ -126,11 +120,7 @@ public Image getImageLabel(Object element, int flags) { ImageDescriptor descriptor= null; if (element instanceof ICElement) { - if (!CCorePlugin.showSourceRootsAtTopOfProject() && - element instanceof ICContainer && isParentOfSourceRoot(element)) - descriptor = CPluginImages.DESC_OBJS_SOURCE2_ROOT; - else - descriptor= getCImageDescriptor((ICElement) element, flags); + descriptor= getCImageDescriptor((ICElement) element, flags); } else if (element instanceof IFile) { // Check for Non Translation Unit. IFile file = (IFile)element; @@ -148,9 +138,6 @@ Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE; descriptor = new CElementImageDescriptor(descriptor, 0, size); } - } else if (!CCorePlugin.showSourceRootsAtTopOfProject() && - element instanceof IFolder && isParentOfSourceRoot(element)) { - descriptor = CPluginImages.DESC_OBJS_SOURCE2_ROOT; } if (descriptor == null && element instanceof IAdaptable) { descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags); @@ -161,34 +148,6 @@ return null; } - private boolean isParentOfSourceRoot(Object element) { - // we want to return true for parents of source roots which are not themselves source roots - // so we can distinguish the two and return the source root icon or the parent of source root icon - IFolder folder = null; - if (element instanceof ICContainer && !(element instanceof ISourceRoot)) - folder = (IFolder) ((ICContainer) element).getResource(); - else if (element instanceof IFolder) - folder = (IFolder) element; - if (folder == null) - return false; - - ICProject cproject = CModelManager.getDefault().getCModel().findCProject(folder.getProject()); - if (cproject != null) { - try { - IPath folderPath = folder.getFullPath(); - for (ICElement sourceRoot : cproject.getSourceRoots()) { - IPath sourceRootPath = sourceRoot.getPath(); - if (folderPath.isPrefixOf(sourceRootPath)) { - return true; - } - } - } catch (CModelException e) { - } - } - - return false; - } - public static ImageDescriptor getImageDescriptor(int type) { switch (type) { case ICElement.C_VCONTAINER: diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java Wed Aug 05 17:35:39 2009 -0500 @@ -193,6 +193,7 @@ } + // ------ adapter communication private void buttonPressed(int index) { @@ -238,7 +239,7 @@ Control list= getListControl(parent); gd= new GridData(); gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; + gd.grabExcessHorizontalSpace= false; gd.verticalAlignment= GridData.FILL; gd.grabExcessVerticalSpace= true; gd.horizontalSpan= nColumns - 2; @@ -644,6 +645,7 @@ dialogFieldChanged(); } + /** * Adds an element at a position. */ @@ -690,6 +692,7 @@ public int getSize() { return fElements.size(); } + public void selectElements(ISelection selection) { fSelectionWhenEnabled= selection; @@ -715,6 +718,7 @@ selectElements(new StructuredSelection(element)); } } + public void postSetSelection(final ISelection selection) { if (isOkToUse(fTableControl)) { @@ -783,6 +787,7 @@ return reverse; } + private void remove() { removeElements(getSelectedElements()); } @@ -867,8 +872,10 @@ public void doubleClick(DoubleClickEvent event) { doDoubleClick(event); } + } + protected void doListSelected(SelectionChangedEvent event) { updateButtonState(); if (fListAdapter != null) { @@ -881,4 +888,7 @@ fListAdapter.doubleClicked(this); } } + + + } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Intel Corporation and others. + * Copyright (c) 2007, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -700,14 +700,4 @@ public void setHelpContextId(String id) { helpId = PREFIX + id; } - - /** - * Allows subclasses to inform the container about changes relevant to the indexer. - * The tab will be asked before the apply is performed. As a consequence of returning - * true the user will be asked whether she wants to rebuild the index. - * @since 5.2 - */ - protected boolean isIndexerAffected() { - return false; - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java Wed Aug 05 17:35:39 2009 -0500 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Intel Corporation and others. + * Copyright (c) 2007, 2008 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -90,17 +90,9 @@ protected ICLanguageSetting [] ls; // all languages known private boolean fHadSomeModification; - private static final int BUTTON_INDEX_ADD = 0; - private static final int BUTTON_INDEX_EDIT = 1; - private static final int BUTTON_INDEX_DELETE = 2; - private static final int BUTTON_INDEX_EXPORT = 3; - // there is a separator instead of button #4 - private static final int BUTTON_INDEX_MOVEUP = 5; - private static final int BUTTON_INDEX_MOVEDOWN = 6; - protected final static String[] BUTTONS = {ADD_STR, EDIT_STR, DEL_STR, UIMessages.getString("AbstractLangsListTab.2"), //$NON-NLS-1$ - null, MOVEUP_STR, MOVEDOWN_STR }; + null, MOVEUP_STR, MOVEDOWN_STR }; protected final static String[] BUTTSYM = {ADD_STR, EDIT_STR, DEL_STR, UIMessages.getString("AbstractLangsListTab.2")}; //$NON-NLS-1$ @@ -129,14 +121,14 @@ sashForm.setLayout(layout); addTree(sashForm).setLayoutData(new GridData(GridData.FILL_VERTICAL)); - table = new Table(sashForm, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION); - gd = new GridData(GridData.FILL_BOTH); - gd.widthHint = 150; - table.setLayoutData(gd); - table.setHeaderVisible(isHeaderVisible()); - table.setLinesVisible(true); + table = new Table(sashForm, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION); + gd = new GridData(GridData.FILL_BOTH); + gd.widthHint = 150; + table.setLayoutData(gd); + table.setHeaderVisible(isHeaderVisible()); + table.setLinesVisible(true); - sashForm.setWeights(DEFAULT_SASH_WEIGHTS); + sashForm.setWeights(DEFAULT_SASH_WEIGHTS); sashForm.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { @@ -159,7 +151,7 @@ } }); - tv = new TableViewer(table); + tv = new TableViewer(table); tv.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { @@ -168,77 +160,73 @@ public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }); - - tv.setLabelProvider(new RichLabelProvider()); - - table.addSelectionListener(new SelectionAdapter() { - @Override + + tv.setLabelProvider(new RichLabelProvider()); + + table.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - - @Override + updateButtons(); + } + @Override public void widgetDefaultSelected(SelectionEvent e) { - if (buttonIsEnabled(1) && table.getSelectionIndex() != -1) - buttonPressed(1); - } - }); - - table.addControlListener(new ControlListener() { + if (buttonIsEnabled(1) && table.getSelectionIndex() != -1) + buttonPressed(1); + } + }); + + table.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { setColumnToFit(); } public void controlResized(ControlEvent e) { setColumnToFit(); }}); - - setupLabel(usercomp, EMPTY_STR, 1, 0); - - lb1 = new Label(usercomp, SWT.BORDER | SWT.CENTER); - lb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - lb1.setToolTipText(UIMessages.getString("EnvironmentTab.15")); //$NON-NLS-1$ - lb1.addMouseListener(new MouseAdapter() { + + setupLabel(usercomp, EMPTY_STR, 1, 0); + + lb1 = new Label(usercomp, SWT.BORDER | SWT.CENTER); + lb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + lb1.setToolTipText(UIMessages.getString("EnvironmentTab.15")); //$NON-NLS-1$ + lb1.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { CDTPrefUtil.spinDMode(); update(); - } - }); + }}); - showBIButton = setupCheck(usercomp, - UIMessages.getString("AbstractLangsListTab.0"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$ - showBIButton.addSelectionListener(new SelectionAdapter() { - @Override + showBIButton = setupCheck(usercomp, UIMessages.getString("AbstractLangsListTab.0"), 1, GridData.FILL_HORIZONTAL); //$NON-NLS-1$ + showBIButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - update(); - } - }); - - lb2 = new Label(usercomp, SWT.BORDER | SWT.CENTER); - lb2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - lb2.setToolTipText(UIMessages.getString("EnvironmentTab.23")); //$NON-NLS-1$ - lb2.addMouseListener(new MouseAdapter() { + update(); + } + }); + + lb2 = new Label(usercomp, SWT.BORDER | SWT.CENTER); + lb2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + lb2.setToolTipText(UIMessages.getString("EnvironmentTab.23")); //$NON-NLS-1$ + lb2.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { CDTPrefUtil.spinWMode(); updateLbs(null, lb2); - } - }); + }}); - additionalTableSet(); - initButtons((getKind() == ICSettingEntry.MACRO) ? BUTTSYM : BUTTONS); - updateData(getResDesc()); + additionalTableSet(); + initButtons((getKind() == ICSettingEntry.MACRO) ? BUTTSYM : BUTTONS); + updateData(getResDesc()); } - /** - * Updates state for all buttons - * Called when table selection changes. - */ - @Override + /** + * Updates state for all buttons + * Called when table selection changes. + */ + @Override protected void updateButtons() { - int index = table.getSelectionIndex(); - int[] ids = table.getSelectionIndices(); - boolean canAdd = langTree.getItemCount() > 0; + int index = table.getSelectionIndex(); + int[] ids = table.getSelectionIndices(); + boolean canAdd = langTree.getItemCount() > 0; boolean canExport = index != -1; boolean canEdit = canExport && ids.length == 1; boolean canDelete = canExport; @@ -248,11 +236,11 @@ if (ent.isReadOnly()) canEdit = false; if (ent.isReadOnly()) canDelete = false; if (exported.contains(ent)) - buttonSetText(BUTTON_INDEX_EXPORT, UIMessages.getString("AbstractLangsListTab.4")); //$NON-NLS-1$ + buttonSetText(3, UIMessages.getString("AbstractLangsListTab.4")); //$NON-NLS-1$ else - buttonSetText(BUTTON_INDEX_EXPORT, UIMessages.getString("AbstractLangsListTab.2")); //$NON-NLS-1$ + buttonSetText(3, UIMessages.getString("AbstractLangsListTab.2")); //$NON-NLS-1$ } else { - buttonSetText(BUTTON_INDEX_EXPORT, UIMessages.getString("AbstractLangsListTab.2")); //$NON-NLS-1$ + buttonSetText(3, UIMessages.getString("AbstractLangsListTab.2")); //$NON-NLS-1$ } boolean canMoveUp = false; boolean canMoveDown = false; @@ -260,54 +248,55 @@ canMoveUp = canEdit && index > 0 && !ent.isBuiltIn(); canMoveDown = canEdit && (index < table.getItemCount() - 1) && !ent.isBuiltIn(); } - if (canMoveDown && showBIButton.getSelection()) { - ent = (ICLanguageSettingEntry)(table.getItem(index+1).getData()); - if (ent.isBuiltIn()) canMoveDown = false; // cannot exchange with built in - } - buttonSetEnabled(BUTTON_INDEX_ADD, canAdd); - buttonSetEnabled(BUTTON_INDEX_EDIT, canEdit); - buttonSetEnabled(BUTTON_INDEX_DELETE, canDelete); - buttonSetEnabled(BUTTON_INDEX_EXPORT, canExport && !page.isMultiCfg()); - buttonSetEnabled(BUTTON_INDEX_MOVEUP, canMoveUp && !page.isMultiCfg()); - buttonSetEnabled(BUTTON_INDEX_MOVEDOWN, canMoveDown && !page.isMultiCfg()); - } + if (canMoveDown && showBIButton.getSelection()) { + ent = (ICLanguageSettingEntry)(table.getItem(index+1).getData()); + if (ent.isBuiltIn()) canMoveDown = false; // cannot exchange with built in + } + buttonSetEnabled(0, canAdd); // add + buttonSetEnabled(1, canEdit); // edit + buttonSetEnabled(2, canDelete); // delete + buttonSetEnabled(3, canExport && !page.isMultiCfg()); // export + // there is a separator instead of button #4 + buttonSetEnabled(5, canMoveUp && !page.isMultiCfg()); // up + buttonSetEnabled(6, canMoveDown && !page.isMultiCfg()); // down + } private Tree addTree(Composite comp) { langTree = new Tree(comp, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL); langTree.setLayoutData(new GridData(GridData.FILL_VERTICAL)); langTree.setHeaderVisible(true); - + langTree.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TreeItem[] items = langTree.getSelection(); if (items.length > 0) { - ICLanguageSetting ls = (ICLanguageSetting) items[0].getData(); + ICLanguageSetting ls = (ICLanguageSetting)items[0].getData(); if (ls != null) { lang = ls; update(); } } - } - }); + }}); langTree.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { int x = langTree.getBounds().width - 5; if (langCol.getWidth() != x) langCol.setWidth(x); - } - }); - + }}); + langCol = new TreeColumn(langTree, SWT.NONE); langCol.setText(UIMessages.getString("AbstractLangsListTab.1")); //$NON-NLS-1$ langCol.setWidth(200); langCol.setResizable(false); - langTree.getAccessible().addAccessibleListener(new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = UIMessages.getString("AbstractLangsListTab.1"); //$NON-NLS-1$ - } - }); + langTree.getAccessible().addAccessibleListener( + new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = UIMessages.getString("AbstractLangsListTab.1"); //$NON-NLS-1$ + } + } + ); return langTree; } @@ -317,7 +306,7 @@ public abstract int getKind(); public abstract ICLanguageSettingEntry doAdd(); public abstract ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent); - public void additionalTableSet() {} // may be not overwritten + public void additionalTableSet() {} // may be not overwritten /** * Called when language changed or item added/edited/removed. @@ -326,7 +315,7 @@ * Note, this method is rewritten in Symbols tab. */ public void update() { update(0); } - + public void update(int shift) { if (lang != null) { int x = table.getSelectionIndex(); @@ -374,10 +363,10 @@ ls = getLangSetting(cfg); if (ls != null) { Arrays.sort(ls, CDTListComparator.getInstance()); - for (ICLanguageSetting element : ls) { - if ((element.getSupportedEntryKinds() & getKind()) != 0) { + for (int i=0; i=0; x--) { old = (ICLanguageSettingEntry)(table.getItem(ids[x]).getData()); @@ -547,12 +535,13 @@ updateExport(); update(); break; - case BUTTON_INDEX_MOVEUP: - case BUTTON_INDEX_MOVEDOWN: + // there is a separator instead of button #4 + case 5: // move up + case 6: // move down old = (ICLanguageSettingEntry)(table.getItem(n).getData()); int x = shownEntries.indexOf(old); if (x < 0) break; - if (i == BUTTON_INDEX_MOVEDOWN) x++; // "down" simply means "up underlying item" + if (i == 6) x++; // "down" simply means "up underlying item" old = shownEntries.get(x); ICLanguageSettingEntry old2 = shownEntries.get(x - 1); shownEntries.remove(x); @@ -561,7 +550,7 @@ shownEntries.add(x, old2); setSettingEntries(getKind(), shownEntries, false); - update(i == BUTTON_INDEX_MOVEUP ? -1 : 1); + update(i == 5 ? -1 : 1); break; default: break; @@ -574,8 +563,8 @@ ICConfigurationDescription cfg = getResDesc().getConfiguration(); ICExternalSetting[] vals = cfg.getExternalSettings(); if (!(vals == null || vals.length == 0)) { - for (ICExternalSetting val : vals) { - ICSettingEntry[] ents = val.getEntries(getKind()); + for (int i=0; i)null); } @@ -740,10 +729,10 @@ lsets = new ICLanguageSetting[fs.length]; for (int i=0; i list = new ArrayList(ls.length); - for (ICLanguageSetting[] element : ls) { - int x = Arrays.binarySearch(element, fs[i], comp); + for (int j=0; j= 0) - list.add(element[x]); + list.add(ls[j][x]); } if (list.size() == 1) lsets[i] = list.get(0); @@ -759,8 +748,8 @@ if (getResDesc() == null) return true; ICLanguageSetting [] ls = getLangSetting(getResDesc()); if (ls == null) return false; - for (ICLanguageSetting element : ls) { - if ((element.getSupportedEntryKinds() & getKind()) != 0) + for (int i=0; i clazz= tabtab.getClass(); + Method meth = clazz.getDeclaredMethod("isIndexerAffected"); //$NON-NLS-1$ + if (meth != null) { + Object result = meth.invoke(tabtab); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) + return true; + } + } catch (SecurityException e) { + } catch (NoSuchMethodException e) { + } catch (IllegalArgumentException e) { + } catch (IllegalAccessException e) { + } catch (InvocationTargetException e) { + // the method was called and has thrown an exception. + CUIPlugin.log(e); + } } } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java Wed Aug 05 17:35:39 2009 -0500 @@ -45,12 +45,9 @@ private Label message; private static ICConfigurationDescription[] result = null; - /** - * @since 5.2 - */ - public static ICConfigurationDescription[] select(ICConfigurationDescription[] _cfgds, Shell parentShell) { + public static ICConfigurationDescription[] select(ICConfigurationDescription[] _cfgds) { cfgds = _cfgds; - ConfigMultiSelectionDialog d = new ConfigMultiSelectionDialog(parentShell); + ConfigMultiSelectionDialog d = new ConfigMultiSelectionDialog(CUIPlugin.getActiveWorkbenchShell()); if (d.open() == OK) return result; return null; @@ -136,22 +133,7 @@ }}); tv.setInput(cfgds); table.setFocus(); - return composite; + return composite; } - - /** - * @deprecated (in org.eclipse.cdt.ui 5.2.0) - * - * This call is deprecated in plugin org.eclipse.cdt.ui 5.2.0 and intended to be removed - * on occasion when the plugin increases major version (Bug 285033). - * Use {@link #select(ICConfigurationDescription[], Shell)} to properly set focus. - */ - @Deprecated - public static ICConfigurationDescription[] select(ICConfigurationDescription[] _cfgds) { - cfgds = _cfgds; - ConfigMultiSelectionDialog d = new ConfigMultiSelectionDialog(CUIPlugin.getActiveWorkbenchShell()); - if (d.open() == OK) - return result; - return null; - } + } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java Wed Aug 05 17:35:39 2009 -0500 @@ -29,8 +29,6 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -60,6 +58,21 @@ */ public class ExPatternDialog extends StatusDialog { + private static class ExPatternLabelProvider extends LabelProvider { + + @Override + public Image getImage(Object element) { + ImageDescriptorRegistry registry= CUIPlugin.getImageDescriptorRegistry(); + return registry.get(CPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB); + } + + @Override + public String getText(Object element) { + return (String) element; + } + + } + private ListDialogField fExclusionPatternList; private IProject fCurrProject; private IPath[] pattern; @@ -70,6 +83,7 @@ private static final int IDX_ADD_MULTIPLE= 1; private static final int IDX_EDIT= 2; private static final int IDX_REMOVE= 4; + public ExPatternDialog(Shell parent, IPath[] _data, IPath _path, IProject proj) { super(parent); @@ -78,8 +92,7 @@ path = _path; setTitle(CPathEntryMessages.ExclusionPatternDialog_title); - String label= NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label, - path.makeRelative().toString()); + String label= NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label, path.makeRelative().toString()); String[] buttonLabels= new String[] { CPathEntryMessages.ExclusionPatternDialog_pattern_add, @@ -110,16 +123,17 @@ fExclusionPatternList.selectFirstElement(); fExclusionPatternList.enableButton(IDX_ADD_MULTIPLE, fCurrSourceFolder != null); } - + + @Override protected Control createDialogArea(Composite parent) { - Composite composite= (Composite) super.createDialogArea(parent); + Composite composite= (Composite)super.createDialogArea(parent); Composite inner= new Composite(composite, SWT.NONE); - inner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - GridLayout layout= new GridLayout(2, false); + GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; + layout.numColumns= 2; inner.setLayout(layout); fExclusionPatternList.doFillIntoGrid(inner, 3); @@ -173,12 +187,35 @@ fExclusionPatternList.addElement(dialog.getExclusionPattern()); } } + + + // -------- ExclusionPatternAdapter -------- + + private class ExclusionPatternAdapter implements IListAdapter, IDialogFieldListener { + public void customButtonPressed(ListDialogField field, int index) { + doCustomButtonPressed(field, index); + } + + public void selectionChanged(ListDialogField field) { + doSelectionChanged(field); + } + + public void doubleClicked(ListDialogField field) { + doDoubleClicked(field); + } + + public void dialogFieldChanged(DialogField field) { + } + + } + protected void doStatusLineUpdate() { } protected void checkIfPatternValid() { } + public IPath[] getExclusionPattern() { IPath[] res= new IPath[fExclusionPatternList.getSize()]; @@ -197,12 +234,7 @@ super.configureShell(newShell); // WorkbenchHelp.setHelp(newShell, ICHelpContextIds.EXCLUSION_PATTERN_DIALOG); } - - @Override - protected boolean isResizable() { - return true; - } - + private void addMultipleEntries() { Class[] acceptedClasses= new Class[] { IFolder.class, IFile.class }; ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, true); @@ -240,34 +272,4 @@ } } - private static class ExPatternLabelProvider extends LabelProvider { - - @Override - public Image getImage(Object element) { - ImageDescriptorRegistry registry= CUIPlugin.getImageDescriptorRegistry(); - return registry.get(CPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB); - } - - @Override - public String getText(Object element) { - return (String) element; - } - } - - private class ExclusionPatternAdapter implements IListAdapter, IDialogFieldListener { - public void customButtonPressed(ListDialogField field, int index) { - doCustomButtonPressed(field, index); - } - - public void selectionChanged(ListDialogField field) { - doSelectionChanged(field); - } - - public void doubleClicked(ListDialogField field) { - doDoubleClicked(field); - } - - public void dialogFieldChanged(DialogField field) { - } - } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java Wed Aug 05 17:35:39 2009 -0500 @@ -41,7 +41,7 @@ public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection selection) { IResource res= wc.getResource(); if (res instanceof IFile) { - new ExtractConstantRefactoringRunner((IFile) res, selection, shellProvider, wc.getCProject()).run(); + new ExtractConstantRefactoringRunner((IFile) res, selection, shellProvider).run(); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java Wed Aug 05 17:35:39 2009 -0500 @@ -40,7 +40,7 @@ public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection selection) { IResource res= wc.getResource(); if (res instanceof IFile) { - new ExtractLocalVariableRefactoringRunner((IFile) res, selection, shellProvider, wc.getCProject()).run(); + new ExtractLocalVariableRefactoringRunner((IFile) res, selection, shellProvider).run(); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java Wed Aug 05 17:35:39 2009 -0500 @@ -45,14 +45,14 @@ @Override public void run(IShellProvider shellProvider, ICElement elem) { - new GenerateGettersAndSettersRefactoringRunner(null, null, elem, shellProvider, elem.getCProject()).run(); + new GenerateGettersAndSettersRefactoringRunner(null, null, elem, shellProvider).run(); } @Override public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s) { IResource res= wc.getResource(); if (res instanceof IFile) { - new GenerateGettersAndSettersRefactoringRunner((IFile) res, s, null, shellProvider, wc.getCProject()).run(); + new GenerateGettersAndSettersRefactoringRunner((IFile) res, s, null, shellProvider).run(); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java Wed Aug 05 17:35:39 2009 -0500 @@ -38,7 +38,7 @@ @Override public void run(IShellProvider shellProvider, ICElement elem) { if (elem instanceof ISourceReference) { - new HideMethodRefactoringRunner(null, null, elem, shellProvider, elem.getCProject()).run(); + new HideMethodRefactoringRunner(null, null, elem, shellProvider).run(); } } @@ -48,7 +48,7 @@ if (res instanceof IFile) { new HideMethodRefactoringRunner((IFile) res, fEditor.getSelectionProvider().getSelection(), null, - fEditor.getSite().getWorkbenchWindow(), wc.getCProject()).run(); + fEditor.getSite().getWorkbenchWindow()).run(); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java Wed Aug 05 17:35:39 2009 -0500 @@ -48,14 +48,14 @@ @Override public void run(IShellProvider shellProvider, ICElement elem) { - new ImplementMethodRefactoringRunner(null, null, elem, shellProvider, elem.getCProject()).run(); + new ImplementMethodRefactoringRunner(null, null, elem, shellProvider).run(); } @Override public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection selection) { IResource res = wc.getResource(); if (res instanceof IFile) { - new ImplementMethodRefactoringRunner((IFile) res, selection, null, shellProvider, wc.getCProject()).run(); + new ImplementMethodRefactoringRunner((IFile) res, selection, null, shellProvider).run(); } } diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISelectWidget.java --- a/cdt/cdt_6_0_x/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISelectWidget.java Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt.ui/templateengine/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISelectWidget.java Wed Aug 05 17:35:39 2009 -0500 @@ -142,8 +142,7 @@ @Override public boolean isValid() { boolean retVal = true; - if(Boolean.parseBoolean(uiAttributes.get(InputUIElement.MANDATORY)) - && ! InputUIElement.SELECTTYPE.equals(uiAttributes.get(InputUIElement.TYPE)) ) { + if(Boolean.parseBoolean(uiAttributes.get(InputUIElement.MANDATORY))) { retVal= currentValue!= null && currentValue.trim().length()>0; } return retVal; diff -r fcb77f9783d2 -r 49c226a8748e cdt/cdt_6_0_x/org.eclipse.cdt/META-INF/MANIFEST.MF --- a/cdt/cdt_6_0_x/org.eclipse.cdt/META-INF/MANIFEST.MF Tue Aug 04 14:00:13 2009 -0500 +++ b/cdt/cdt_6_0_x/org.eclipse.cdt/META-INF/MANIFEST.MF Wed Aug 05 17:35:39 2009 -0500 @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt; singleton:=true -Bundle-Version: 6.1.0.qualifier +Bundle-Version: 5.1.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui.intro;bundle-version="[3.2.0,4.0.0)",