1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-05-24 05:35:45 -04:00
commit 11e878448a
243 changed files with 3073 additions and 2698 deletions

View file

@ -2975,6 +2975,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
@Override
public ITreeRoot getTreeRoot() throws BuildException {
if (getValueType() != TREE) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
if (treeRoot == null) {
if (superClass != null) {
return superClass.getTreeRoot();
@ -2982,9 +2985,6 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
return null;
}
}
if (getValueType() != TREE) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
return treeRoot;
}

View file

@ -271,6 +271,29 @@ public class MBSWizardHandler extends CWizardHandler {
return out;
}
/**
* Get a map from toolchain names to actual toolchains.
* This list should mirror the list displayed in the wizard.
* Bug #363612
*
* @since 8.1
* @return the map
*/
public SortedMap<String, IToolChain> getToolChains() {
Set<String> toolChainNames = this.tc_filter();
SortedMap<String, IToolChain> toolChainMap = new TreeMap<String, IToolChain>();
for (String toolChainName : toolChainNames) {
IToolChain tc = tcs.get(toolChainName);
if (tc == null) {
toolChainMap.put(toolChainName, null);
} else {
toolChainMap.put(tc.getUniqueRealName(), tc);
}
}
return toolChainMap;
}
/**
* Checks whether given toolchain can be displayed
*
@ -708,6 +731,30 @@ public class MBSWizardHandler extends CWizardHandler {
else
return entryInfo.tc_filter().size();
}
/**
* Get a map from toolchain names to actual toolchains.
* Bug #363612
*
* @since 8.1
* @return the map
*/
public SortedMap<String, IToolChain> getToolChains() {
if (entryInfo == null)
return full_tcs;
else
return entryInfo.getToolChains();
}
/**
* Get the table that is displayed in the left pane.
* This allow for changes after handler creation.
* Bug #363612
*
* @since 8.1
* @return the table
*/
public Table getToolChainsTable() {
return table;
}
public String getPropertyId() {
return propertyId;
}

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
@ -43,6 +44,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
@ -171,9 +174,13 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
Set<IField> actualConstructorFields = constructorsStack.peek();
if (!actualConstructorFields.isEmpty()) {
IBinding binding = name.resolveBinding();
if (actualConstructorFields.contains(binding)) {
if ((CPPVariableReadWriteFlags.getReadWriteFlags(name) & PDOMName.WRITE_ACCESS) != 0) {
actualConstructorFields.remove(binding);
if (binding != null && !(binding instanceof IProblemBinding)) {
IField equivalentFieldBinding = getContainedEquivalentBinding(
actualConstructorFields, binding, name.getTranslationUnit().getIndex());
if (equivalentFieldBinding != null) {
if ((CPPVariableReadWriteFlags.getReadWriteFlags(name) & PDOMName.WRITE_ACCESS) != 0) {
actualConstructorFields.remove(equivalentFieldBinding);
}
}
}
}
@ -181,6 +188,36 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
return PROCESS_CONTINUE;
}
private IField getContainedEquivalentBinding(Iterable<IField> fields, IBinding binding, IIndex index) {
for (IField field : fields) {
if (areEquivalentBindings(binding, field, index)) {
return field;
}
}
return null;
}
private boolean areEquivalentBindings(IBinding binding1, IBinding binding2, IIndex index) {
if (binding1.equals(binding2)) {
return true;
}
if ((binding1 instanceof IIndexBinding) != (binding2 instanceof IIndexBinding) && index != null) {
if (binding1 instanceof IIndexBinding) {
binding2 = index.adaptBinding(binding2);
} else {
binding1 = index.adaptBinding(binding1);
}
if (binding1 == null || binding2 == null) {
return false;
}
if (binding1.equals(binding2)) {
return true;
}
}
return false;
}
/** Checks whether class member of the specified type should be initialized
*
* @param type Type to check

View file

@ -543,4 +543,28 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
//@file:test.h
//template <typename>
//struct B;
//@file:test.cpp
//#include "test.h"
//
//template <typename>
//struct A {
//};
//
//template <typename valueT>
//struct B<A<valueT> > {
// const A<valueT>& obj;
// B(const A<valueT>& o) : obj(o) {}
//};
public void testBug368611_templatePartialSpecialization() throws Exception {
CharSequence[] code = getContents(2);
loadcode(code[0].toString());
loadcode(code[1].toString());
runOnProject();
checkNoErrors();
}
}

View file

@ -53,7 +53,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public AST2CPPSpecTest(String name) {
super(name);
}
public static TestSuite suite() {
return suite(AST2CPPSpecTest.class);
}
@ -121,7 +121,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// C& operator=(const C& x) { s = x.s; return *this; }
// ~C() { }
// };
//
//
public void test3_1s4b() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
@ -141,10 +141,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// X::X(int = 0) { }
// class D: public X { };
// D d2; // X(int) called by D()
public void test3_2s5_a() throws Exception {
public void test3_2s5_a() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// // translation unit 2:
// struct X {
// X(int);
@ -154,7 +154,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// class D: public X { }; // X(int, int) called by D();
// // D()'s implicit definition
// // violates the ODR
public void test3_2s5_b() throws Exception {
public void test3_2s5_b() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -291,7 +291,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test3_4_3s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 1);
}
// namespace NS {
// class T { };
// void f(T);
@ -391,8 +391,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// // resolution chooses Z::h(double)
// }
public void test3_4_3_2s2() throws Exception {
String[] problems= {"AB::x", "x", "AB::i", "i"};
parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4
String[] problems= {"AB::x", "x", "AB::i", "i"};
parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4
}
// namespace A {
@ -423,7 +423,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// {
// BD::a++; //OK: S is { A::a, A::a }
// }
public void test3_4_3_2s3() throws Exception {
public void test3_4_3_2s3() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -506,7 +506,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// // cannot introduce a qualified type (7.1.5.3)
// friend struct Glob; // OK: Refers to (as yet) undeclared Glob
// // at global scope.
//
//
// };
// struct Base {
// struct Data; // OK: Declares nested Data
@ -524,7 +524,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// struct Base::Datum; // error: Datum undefined
// struct Base::Data* pBase; // OK: refers to nested Data
public void test3_4_4s3() throws Exception {
String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"};
String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"};
parse(getAboveComment(), ParserLanguage.CPP, problems);
}
@ -687,7 +687,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// arrpp++; //OK: sizeof UNKA* is known
// }
// struct X {
// int i;
// int i;
// }; // now X is a complete type
// int arr[10]; // now the type of arr is complete
// X x;
@ -756,7 +756,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// class D { // ...
// class D { // ...
// };
// D d1;
// const D d2;
@ -799,7 +799,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
IASTExpression expr= getExpressionOfStatement(fdef, 0);
assertInstance(expr, ICPPASTNewExpression.class);
ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
IASTTypeId typeid= newExpr.getTypeId();
@ -815,7 +815,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// };
public void test5_3_4s12() throws Exception {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
IASTFunctionDefinition fdef= getDeclaration(tu, 1);
@ -826,7 +826,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
// new(2,f) T;
expr= getExpressionOfStatement(fdef, 1);
assertInstance(expr, ICPPASTNewExpression.class);
@ -920,7 +920,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// int x=0;
// if (x)
// int i;
//
//
// if (x) {
// int i;
// }
@ -937,7 +937,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// int x; // illformed,redeclaration of x
// }
// }
public void test6_4s3() throws Exception {
public void test6_4s3() throws Exception {
// raised bug 90618
// gcc does not report an error, either, so leave it as it is.
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
@ -962,7 +962,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// ~A() { }
// operator bool() { return val != 0; }
// };
//
//
// int foo() {
// int i = 1;
// while (A a = i) {
@ -997,7 +997,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// goto ly; // OK, jump implies destructor
// // call for a followed by construction
// // again immediately following label ly
// }
// }
public void test6_7s3() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 1);
}
@ -1077,13 +1077,20 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// thread_local int e;
// static thread_local int f;
// extern thread_local int g;
public void test7_1_1s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// static char* f(); // f() has internal linkage
// char* f() // f() still has internal linkage
// { //
// }
// char* g(); // g() has external linkage
// static char* g() // error: inconsistent linkage
// { //
// { //
// }
// void h();
// inline void h(); // external linkage
@ -1138,12 +1145,12 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// typedef int I;
// typedef int I;
// typedef I I;
public void test7_1_3s2() throws Exception {
public void test7_1_3s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// class complex { //
// class complex { //
// };
// typedef int complex; // error: redefinition
public void test7_1_3s3a() throws Exception {
@ -1151,7 +1158,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
}
// typedef int complex;
// class complex { //
// class complex { //
// }; // error: redefinition
public void test7_1_3s3b() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
@ -1184,6 +1191,24 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
assertInstance(d, IASTProblemDeclaration.class);
}
// constexpr int square(int x);
// constexpr int bufsz = 1024;
// struct pixel {
// int x;
// int y;
// constexpr pixel(int);
// };
// constexpr pixel::pixel(int a)
// : x(square(a)), y(square(a))
// { }
// constexpr int square(int x) {
// return x * x;
// }
// constexpr pixel large(4);
public void test7_1_5s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// int foo() {
// const int ci = 3; // cvqualified (initialized as required)
// ci = 4; // illformed: attempt to modify const
@ -1212,7 +1237,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// X x;
// Y();
// };
//
//
// int foo() {
// const Y y;
// y.x.i++; //wellformed: mutable member can be modified
@ -1560,7 +1585,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// }
public void test7_3_3s11() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
}
// struct A { int x(); };
// struct B : A { };
@ -1822,10 +1847,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 1);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
assertInstance(col.getName(4), ICPPASTTemplateId.class);
assertInstance(((ICPPASTTemplateId)col.getName(4)).getTemplateArguments()[0], IASTTypeId.class);
final IASTName S_int_1 = col.getName(7);
assertInstance(S_int_1, ICPPASTTemplateId.class);
assertInstance(((ICPPASTTemplateId)S_int_1).getTemplateArguments()[0], IASTExpression.class);
@ -1861,7 +1886,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test8_2s7a() throws Exception { // TODO raised bug 90633
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 1);
BindingAssertionHelper ba= new BindingAssertionHelper(code, true);
IFunction f= ba.assertNonProblem("f", 1, IFunction.class);
isTypeEqual(f.getType(), "void (int (*)(C))");
@ -1896,7 +1921,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// const int ci = 10, *pc = &ci, *const cpc = pc, **ppc;
// int i, *p, *const cp = &i;
//
//
// int f() {
// i = ci;
// *cp = ci;
@ -1978,7 +2003,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// int a;
// };
// class Y;
//
//
// void f() {
// int X::* pmi = &X::a;
// void (X::* pmf)(int) = &X::f;
@ -2314,7 +2339,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
}
// char msg[] = "Syntax error on line %s";
public void test8_5_2s1() throws Exception {
public void test8_5_2s1() throws Exception {
// raised bug 90647
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -2527,7 +2552,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// int g() { return a++; }
// };
// int s::f() const { return a; }
//
//
// void k(s& x, const s& y)
// {
// x.f();
@ -2540,8 +2565,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
final String code = getAboveComment();
IASTTranslationUnit tu= parse(code, ParserLanguage.CPP, problems);
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
bh.assertNonProblem("g();", 1);
bh.assertProblem("g(); //error", 1);
bh.assertNonProblem("g();", 1);
bh.assertProblem("g(); //error", 1);
}
// class process {
@ -2588,7 +2613,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// p = "Jennifer";
// // ...
// }
public void test9_5s2() throws Exception {
public void test9_5s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -2733,7 +2758,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// class B : public L { };
// class C : public A, public B { void f(); }; // wellformed
// class D : public A, public L { void f(); }; // wellformed
//
//
public void test10_1s3b() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -3560,7 +3585,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(code, ParserLanguage.CPP, false, 0);
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
ICPPFunction dtor= bh.assertNonProblem("~B() {", 2);
ICPPFunction d= bh.assertNonProblem("~B(); //1", 2);
assertSame(dtor, d);
d= bh.assertNonProblem("~B(); //2", 2);
@ -3569,7 +3594,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
assertSame(dtor, d);
d= bh.assertNonProblem("~B(); //4", 2);
assertSame(dtor, d);
bh.assertProblem("~B_alias(); //5", 8);
}
@ -3910,7 +3935,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// void h(int (*)()); // redeclaration of h(int())
// void h(int x()) { } // definition of h(int())
// void h(int (*x)()) { } // illformed: redefinition of h(int())
public void test12_8s3d() throws Exception {
public void test12_8s3d() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 1);
}
@ -4456,7 +4481,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// // ...
// };
// Array<int> v1(20);
// typedef complex<double> dcomplex;
// typedef complex<double> dcomplex;
// Array<dcomplex> v2(30);
// Array<dcomplex> v3(40);
// void bar() {
@ -4659,7 +4684,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// static T s;
// };
// template<class T> T X<T>::s = 0;
public void test14_5_1_3s1() throws Exception {
public void test14_5_1_3s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -4675,7 +4700,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// template<class P> friend class frd;
// // ...
// };
public void test14_5_4s1() throws Exception {
public void test14_5_4s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -4773,7 +4798,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// template<class T1, class T2, int I> class A<T1*, T2, I> { }; // #3
// template<class T> class A<int, T*, 5> { }; // #4
// template<class T1, class T2, int I> class A<T1, T2*, I> { }; // #5
// A<int*, int*, 2> a5; // ambiguous: matches #3 and #5 : expect problem
// A<int*, int*, 2> a5; // ambiguous: matches #3 and #5 : expect problem
public void test14_5_5_1s2b() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 1);
}
@ -4824,12 +4849,12 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// // file1.c
// // file1.c
// template<class T>
// void f(T*);
// void g(int* p) {
// f(p); // call
// // f<int>(int*)
// void g(int* p) {
// f(p); // call
// // f<int>(int*)
// }
public void test14_5_6_1s1a() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
@ -4891,7 +4916,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
ICPPSpecialization templateSpecialization = (ICPPSpecialization) inst.getTemplateDefinition();
assertSame(op1, templateSpecialization.getSpecializedBinding());
}
// template<class T> struct A { A(); };
// template<class T> void f(T);
// template<class T> void f(T*);
@ -5097,7 +5122,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// template<class C> void N::B<C>::f(C) {
// C b; // C is the template parameter, not N::C
// }
public void test14_6_1s6() throws Exception {
public void test14_6_1s6() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -5139,7 +5164,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// template<class T> struct X : B<T> {
// A a; // a has type double
// };
public void test14_6_2s3() throws Exception {
public void test14_6_2s3() throws Exception {
final String content= getAboveComment();
IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
@ -5218,7 +5243,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// template<class T> T X<T>::s = 0;
// X<int> aa;
// X<char*> bb;
public void test14_7s6() throws Exception {
public void test14_7s6() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -5312,7 +5337,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// int i = m.get("Nicholas");
// // ...
// }
public void test14_7_1s10() throws Exception {
public void test14_7_1s10() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -5385,7 +5410,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// template<class T> class Array { };
// template<class T> void sort(Array<T>& v) { }
// template<> void sort<char*>(Array<char*>&) ;
public void test14_7_3s1() throws Exception {
public void test14_7_3s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -5669,7 +5694,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
inst= bh.assertNonProblem("f<int,char>()", -2);
assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
// struct X { };
// struct Y {
// Y(X){}
@ -5680,8 +5705,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// X x3 = f(x1, x2); // deduction fails on #1 (cannot add X+X), calls #2
public void test14_8_2s8a() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
}
// template <class T> int f(T[5]);
// int I = f<int>(0);
// int j = f<void>(0); // invalid array // also no error with gcc
@ -5750,7 +5775,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
bh.assertProblem("f<X>", 0);
}
// template <class T, T*> int f(int);
// int i2 = f<int,1>(0); // can't conv 1 to int*
public void test14_8_2s8g() throws Exception {
@ -5778,14 +5803,14 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_8_2_1s1a() throws Exception {
final String code= getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
ICPPTemplateInstance inst;
inst= bh.assertNonProblem("f({1,2,3})", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
bh.assertProblem("f({1,\"asdf\"})", 1);
bh.assertProblem("g({1,2,3})", 1);
}
// template<class ... Types> void f(Types& ...);
// template<class T1, class ... Types> void g(T1, Types ...);
// void h(int x, float& y) {
@ -5796,14 +5821,14 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_8_2_1s1b() throws Exception {
final String code= getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
ICPPTemplateInstance inst;
inst= bh.assertNonProblem("f(x, y, z)", 1);
assertEquals("<int,float,const int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
inst= bh.assertNonProblem("g(x, y, z)", 1);
assertEquals("<int,float,int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
// template <class T> int f(T&&);
// template <class T> int g(const T&&);
// int i;
@ -5835,7 +5860,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
inst= bh.assertNonProblem("f(g)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
// // Ambiguous deduction causes the second function parameter to be a
// // non-deduced context.
// template <class T> int f(T, T (*p)(T));
@ -5863,7 +5888,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
inst= bh.assertNonProblem("f(1, g)", 1);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
// struct A {
// template <class T> operator T***();
// };
@ -5874,7 +5899,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_8_2_3s7() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// template <class T> T f(int); // #1
// template <class T, class U> T f(U); // #2
// void g() {
@ -5883,7 +5908,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_8_2_4s11() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// template<typename...> struct Tuple { };
// template<typename... Types> void g(Tuple<Types...>); // #1
// template<typename T1, typename... Types> void g(Tuple<T1, Types...>); // #2
@ -5892,17 +5917,17 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// g(Tuple<>()); // calls #1
// g(Tuple<int, float>()); // calls #2
// g(Tuple<int, float&>()); // calls #3
// g(Tuple<int>()); // calls #3
// g(Tuple<int>()); // calls #3
// }
public void test14_8_2_4s12() throws Exception {
final String code= getAboveComment();
parse(code, ParserLanguage.CPP, true, 0);
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
ICPPFunction g1= bh.assertNonProblem("g(Tuple<Types...>)", 1);
ICPPFunction g2= bh.assertNonProblem("g(Tuple<T1, Types...>)", 1);
ICPPFunction g3= bh.assertNonProblem("g(Tuple<T1, Types&...>)", 1);
ICPPTemplateInstance x= bh.assertNonProblem("g(Tuple<>())", 1);
assertSame(g1, x.getTemplateDefinition());
x= bh.assertNonProblem("g(Tuple<int, float>())", 1);
@ -5911,8 +5936,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
assertSame(g3, x.getTemplateDefinition());
x= bh.assertNonProblem("g(Tuple<int>())", 1);
assertSame(g3, x.getTemplateDefinition());
}
}
// template<class T> void g(T);
// void test() {
// g({1,2,3}); // error: no argument deduced for T
@ -5981,7 +6006,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_8_2_5s7d() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// template <class T> void f(T&&);
// template <> void f(int&) { } // #1
// template <> void f(int&&) { } // #2
@ -6058,7 +6083,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
inst= bh.assertNonProblem("f(a1, a2)", 1);
assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
// template<typename T> class A {
// public:
// typedef int X;
@ -6082,7 +6107,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// template<int i> class A {};
// template<short s> void f(A<s>);
// void k1() {
@ -6144,7 +6169,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
inst= bh.assertNonProblem("f<int>()", -2);
assertEquals("<int>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true));
}
// template <template <class T> class X> struct A { };
// template <template <class T> class X> void f(A<X>) { }
// template<class T> struct B { };
@ -6172,7 +6197,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_8_2_4s21() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// template<class ... Args> void f(Args ... args); // #1
// template<class T1, class ... Args> void f(T1 a1, Args ... args); // #2
// template<class T1, class T2> void f(T1 a1, T2 a2); // #3
@ -6188,7 +6213,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
ICPPFunctionTemplate f1= bh.assertNonProblem("f(Args ... args)", 1);
ICPPFunctionTemplate f2= bh.assertNonProblem("f(T1 a1, Args ... args)", 1);
ICPPFunctionTemplate f3= bh.assertNonProblem("f(T1 a1, T2 a2)", 1);
ICPPTemplateInstance inst;
inst= bh.assertNonProblem("f()", 1);
assertSame(f1, inst.getTemplateDefinition());
@ -6246,10 +6271,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// template<class T> void f(T); // declaration
// void g() {
// f("Annemarie"); // call of f<const char*>
// }
// template<class T> void f(T); // declaration
// void g() {
// f("Annemarie"); // call of f<const char*>
// }
public void test14_8_3s6() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -6261,7 +6286,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// int t2;
// if (1)
// goto lab;
// } catch(...) { // handler 2
// } catch(...) { // handler 2
// }
// } catch(...) { // handler 1
// }
@ -6752,7 +6777,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// template <int I, int J> A<I+J> f/*1*/(A<I>, A<J>); // #1
// template <int K, int L> A<K+L> f/*2*/(A<K>, A<L>); // same as #1
// template <int I, int J> A<I-J> f/*3*/(A<I>, A<J>); // different from #1
public void test14_5_6_1s5() throws Exception {
public void test14_5_6_1s5() throws Exception {
final String content= getAboveComment();
IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
@ -6766,7 +6791,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// template <int I> class A;
// template <int I, int J> void f/*1*/(A<I+J>); // #1
// template <int K, int L> void f/*2*/(A<K+L>); // same as #1
public void test14_5_6_1s6() throws Exception {
public void test14_5_6_1s6() throws Exception {
final String content= getAboveComment();
IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0);
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
@ -6815,7 +6840,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// this->A::operator=(s); // wellformed
// return *this;
// }
public void test12s1() throws Exception {
public void test12s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -6836,7 +6861,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// // C/B/D/A sublattice is fully constructed
// { }
// };
public void test12_7s2() throws Exception {
public void test12_7s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
@ -6932,7 +6957,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// new (int(*p)) int; // newplacement expression
// new (int(*[x])); // new typeid
// }
public void test8_2s3() throws Exception {
public void test8_2s3() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
@ -6942,7 +6967,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// {
// f<int()>(); // int() is a typeid:call the first f()
// }
public void test14_3s2() throws Exception {
public void test14_3s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
}

View file

@ -45,14 +45,17 @@ import org.eclipse.core.runtime.Path;
/**
* Tests the behavior of the IIndex API when dealing with multiple projects
*/
public class IndexCompositeTests extends BaseTestCase {
public class IndexCompositeTests extends BaseTestCase {
public static Test suite() {
return suite(IndexCompositeTests.class);
}
private static final int NONE = 0, REFS = IIndexManager.ADD_DEPENDENCIES;
private static final int REFD = IIndexManager.ADD_DEPENDENT, BOTH = REFS | REFD;
private static final int NONE = 0;
private static final int REFS = IIndexManager.ADD_DEPENDENCIES;
private static final int REFD = IIndexManager.ADD_DEPENDENT;
private static final int BOTH = REFS | REFD;
private static final IndexFilter FILTER= new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) throws CoreException {
@ -75,15 +78,15 @@ public class IndexCompositeTests extends BaseTestCase {
// class B {};
public void testPairDisjointContent() throws Exception {
CharSequence[] contents = getContentsForTest(2);
List projects = new ArrayList();
List<ICProject> projects = new ArrayList<ICProject>();
try {
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
ProjectBuilder pb = new ProjectBuilder("projB" + System.currentTimeMillis(), true);
pb.addFile("h1.h", contents[0]);
ICProject cprojB = pb.create();
projects.add(cprojB);
pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true);
pb = new ProjectBuilder("projA" + System.currentTimeMillis(), true);
pb.addFile("h2.h", contents[1]).addDependency(cprojB.getProject());
ICProject cprojA = pb.create();
projects.add(cprojA);
@ -98,8 +101,8 @@ public class IndexCompositeTests extends BaseTestCase {
setIndex(cprojA, REFD); assertBCount(1, 1);
setIndex(cprojA, BOTH); assertBCount(2, 2);
} finally {
for (Iterator i = projects.iterator(); i.hasNext();)
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor());
for (ICProject project : projects)
project.getProject().delete(true, true, new NullProgressMonitor());
}
}
@ -122,20 +125,20 @@ public class IndexCompositeTests extends BaseTestCase {
// namespace X { class A2 {}; B2 b; C2 c; }
public void testTripleLinear() throws Exception {
CharSequence[] contents = getContentsForTest(3);
List projects = new ArrayList();
List<ICProject> projects = new ArrayList<ICProject>();
try {
ProjectBuilder pb = new ProjectBuilder("projC"+System.currentTimeMillis(), true);
ProjectBuilder pb = new ProjectBuilder("projC" + System.currentTimeMillis(), true);
pb.addFile("h3.h", contents[0]);
ICProject cprojC = pb.create();
projects.add(cprojC);
pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
pb = new ProjectBuilder("projB" + System.currentTimeMillis(), true);
pb.addFile("h2.h", contents[1]).addDependency(cprojC.getProject());
ICProject cprojB = pb.create();
projects.add(cprojB);
pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true);
pb = new ProjectBuilder("projA" + System.currentTimeMillis(), true);
pb.addFile("h1.h", contents[2]).addDependency(cprojB.getProject());
ICProject cprojA = pb.create();
projects.add(cprojA);
@ -150,8 +153,8 @@ public class IndexCompositeTests extends BaseTestCase {
final int gB= 6, aB= gB + 1;
final int gA= 3, aA= gA + 3;
final int gBC= gB+gC-1, aBC= aB+aC-1;
final int gABC= gA+gBC-1, aABC= aA+aBC-1;
final int gBC= gB + gC - 1, aBC= aB + aC - 1;
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
setIndex(cprojC, NONE);
assertBCount(gC, aC); assertNamespaceXMemberCount(1);
@ -214,8 +217,8 @@ public class IndexCompositeTests extends BaseTestCase {
assertNamespaceXMemberCount(5);
assertFieldCount("C1", 1);
} finally {
for (Iterator i = projects.iterator(); i.hasNext();)
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor());
for (ICProject project : projects)
project.getProject().delete(true, true, new NullProgressMonitor());
}
}
@ -238,20 +241,20 @@ public class IndexCompositeTests extends BaseTestCase {
// void foo(C1 c) {}
public void testTripleUpwardV() throws Exception {
CharSequence[] contents = getContentsForTest(3);
List projects = new ArrayList();
List<ICProject> projects = new ArrayList<ICProject>();
try {
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
ProjectBuilder pb = new ProjectBuilder("projB" + System.currentTimeMillis(), true);
pb.addFile("h2.h", contents[0]);
ICProject cprojB = pb.create();
projects.add(cprojB);
pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true);
pb = new ProjectBuilder("projA" + System.currentTimeMillis(), true);
pb.addFile("h1.h", contents[1]).addDependency(cprojB.getProject());
ICProject cprojA = pb.create();
projects.add(cprojA);
pb = new ProjectBuilder("projC"+System.currentTimeMillis(), true);
pb = new ProjectBuilder("projC" + System.currentTimeMillis(), true);
pb.addFile("h3.h", contents[2]).addDependency(cprojB.getProject());
ICProject cprojC = pb.create();
projects.add(cprojC);
@ -271,9 +274,9 @@ public class IndexCompositeTests extends BaseTestCase {
final int gB= 4, aB= gB + 1;
final int gA= 4, aA= gA + 1;
final int gBC= gB+gC-1, aBC= aB+aC-1;
final int gAB= gA+gB-1, aAB= aA+aB-1;
final int gABC= gA+gBC-1, aABC= aA+aBC-1;
final int gBC= gB + gC - 1, aBC= aB + aC - 1;
final int gAB= gA + gB - 1, aAB= aA + aB - 1;
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
setIndex(cprojC, NONE);
@ -315,8 +318,8 @@ public class IndexCompositeTests extends BaseTestCase {
assertBCount(gABC, aABC);
assertNamespaceXMemberCount(4);
} finally {
for (Iterator i = projects.iterator(); i.hasNext();)
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor());
for (ICProject project : projects)
project.getProject().delete(true, true, new NullProgressMonitor());
}
}
@ -337,20 +340,20 @@ public class IndexCompositeTests extends BaseTestCase {
// namespace X { class A2 {}; }
public void testTripleDownwardV() throws Exception {
CharSequence[] contents = getContentsForTest(3);
List projects = new ArrayList();
List<ICProject> projects = new ArrayList<ICProject>();
try {
ProjectBuilder pb = new ProjectBuilder("projC"+System.currentTimeMillis(), true);
ProjectBuilder pb = new ProjectBuilder("projC" + System.currentTimeMillis(), true);
pb.addFile("h3.h", contents[0]);
ICProject cprojC = pb.create();
projects.add(cprojC);
pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true);
pb = new ProjectBuilder("projA" + System.currentTimeMillis(), true);
pb.addFile("h1.h", contents[2]);
ICProject cprojA = pb.create();
projects.add(cprojA);
pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
pb = new ProjectBuilder("projB" + System.currentTimeMillis(), true);
pb.addFile("h2.h", contents[1]).addDependency(cprojC.getProject()).addDependency(cprojA.getProject());
ICProject cprojB = pb.create();
projects.add(cprojB);
@ -369,9 +372,9 @@ public class IndexCompositeTests extends BaseTestCase {
final int gB= 4, aB= gB + 2;
final int gA= 3, aA= gA + 1;
final int gBC= gB+gC-1, aBC= aB+aC-1;
final int gAB= gA+gB-1, aAB= aA+aB-1;
final int gABC= gA+gBC-1, aABC= aA+aBC-1;
final int gBC= gB + gC - 1, aBC= aB + aC - 1;
final int gAB= gA + gB - 1, aAB= aA + aB - 1;
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
setIndex(cprojC, NONE);
assertBCount(gC, aC);
@ -412,8 +415,8 @@ public class IndexCompositeTests extends BaseTestCase {
assertBCount(gABC, aABC);
assertNamespaceXMemberCount(4);
} finally {
for (Iterator i = projects.iterator(); i.hasNext();)
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor());
for (ICProject project : projects)
project.getProject().delete(true, true, new NullProgressMonitor());
}
}
@ -465,10 +468,11 @@ public class IndexCompositeTests extends BaseTestCase {
* Convenience class for setting up projects.
*/
class ProjectBuilder {
private String name;
private static final int INDEXER_TIMEOUT_SEC = 5;
private final String name;
private final boolean cpp;
private List dependencies = new ArrayList();
private Map path2content = new HashMap();
private boolean cpp;
ProjectBuilder(String name, boolean cpp) {
this.name = name;
@ -503,7 +507,7 @@ class ProjectBuilder {
CCorePlugin.getIndexManager().setIndexerId(result, IPDOMManager.ID_FAST_INDEXER);
if (lastFile != null) {
IIndex index= CCorePlugin.getIndexManager().getIndex(result);
TestSourceReader.waitUntilFileIsIndexed(index, lastFile, 2000);
TestSourceReader.waitUntilFileIsIndexed(index, lastFile, INDEXER_TIMEOUT_SEC * 1000);
}
BaseTestCase.waitForIndexer(result);
return result;

View file

@ -376,7 +376,6 @@ public class CoreModel {
return null;
}
/**
* Return true if project has C nature.
*/

View file

@ -198,13 +198,16 @@ public class BinaryRunner {
}
// check against known content types
// if the file has an extension
String name = proxy.getName();
IContentType contentType = CCorePlugin.getContentType(project, name);
if (contentType != null && textContentType != null) {
if (contentType.isKindOf(textContentType)) {
return true;
} else if (textContentType.isAssociatedWith(name)) {
return true;
if (name.contains(".")) {
IContentType contentType = CCorePlugin.getContentType(project, name);
if (contentType != null && textContentType != null) {
if (contentType.isKindOf(textContentType)) {
return true;
} else if (textContentType.isAssociatedWith(name)) {
return true;
}
}
}

View file

@ -510,7 +510,24 @@ public class ASTSignatureUtil {
}
if (declSpec instanceof ICPPASTDeclSpecifier) {
if (((ICPPASTDeclSpecifier) declSpec).isExplicit()) {
ICPPASTDeclSpecifier cppDeclSpec = (ICPPASTDeclSpecifier) declSpec;
if (cppDeclSpec.isThreadLocal()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.THREAD_LOCAL);
needSpace = true;
}
if (cppDeclSpec.isConstexpr()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.CONSTEXPR);
needSpace = true;
}
if (cppDeclSpec.isExplicit()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@ -518,7 +535,7 @@ public class ASTSignatureUtil {
result.append(Keywords.EXPLICIT);
needSpace = true;
}
if (((ICPPASTDeclSpecifier) declSpec).isFriend()) {
if (cppDeclSpec.isFriend()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
@ -526,7 +543,7 @@ public class ASTSignatureUtil {
result.append(Keywords.FRIEND);
needSpace = true;
}
if (((ICPPASTDeclSpecifier) declSpec).isVirtual()) {
if (cppDeclSpec.isVirtual()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner, IASTDeclarationListOwner {
/**
* <code>TYPE_NAME</code> represents the relationship between an
* <code>IASTCompositeTypeSpecifier</code> and its <code>IASTName</code>.

View file

@ -27,9 +27,7 @@ public interface IASTDeclSpecifier extends IASTNode {
public static final int sc_static = 3;
public static final int sc_auto = 4;
public static final int sc_register = 5;
/**
* @since 5.2
*/
/** @since 5.2 */
public static final int sc_mutable = 6;
/**
@ -40,6 +38,7 @@ public interface IASTDeclSpecifier extends IASTNode {
// Type qualifier
public boolean isConst();
public boolean isVolatile();
/**
* @since 5.2
*/

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/**
* Enumeration.
*/
@ -39,17 +38,16 @@ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTName
public static final int k_last = k_union;
/**
* Get the kind.
* Returns the kind.
*
* @return int (kind).
*/
public int getKind();
/**
* Set the kind.
* Sets the kind.
*
* @param value
* int (kind)
* @param value int (kind)
*/
public void setKind(int value);
@ -61,14 +59,14 @@ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTName
"IASTElaboratedTypeSpecifier.TYPE_NAME - IASTName for IASTElaboratedTypeSpecifier"); //$NON-NLS-1$
/**
* Get the name.
* Returns the name.
*
* @return <code>IASTName</code>
*/
public IASTName getName();
/**
* Set the name.
* Sets the name.
*
* @param name
* <code>IASTName</code>

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* John Camelon (IBM Rational Software) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/**
* This interface represents an enumerator member of an enum specifier.
*
@ -59,14 +58,14 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn
"IASTEnumerator.ENUMERATOR_VALUE - IASTExpression (value) for IASTEnumerator"); //$NON-NLS-1$
/**
* Set enumerator value.
* Sets enumerator value.
*
* @param expression
*/
public void setValue(IASTExpression expression);
/**
* Get enumerator value.
* Returns enumerator value.
*
* @return <code>IASTExpression</code> value
*/
@ -95,7 +94,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn
"IASTEnumerationSpecifier.ENUMERATOR - nested IASTEnumerator for IASTEnumerationSpecifier"); //$NON-NLS-1$
/**
* Add an enumerator.
* Adds an enumerator.
*
* @param enumerator
* <code>IASTEnumerator</code>
@ -103,7 +102,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn
public void addEnumerator(IASTEnumerator enumerator);
/**
* Get enumerators.
* Returns enumerators.
*
* @return <code>IASTEnumerator []</code> array
*/
@ -117,7 +116,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn
"IASTEnumerationSpecifier.ENUMERATION_NAME - IASTName for IASTEnumerationSpecifier"); //$NON-NLS-1$
/**
* Set the enum's name.
* Sets the enum's name.
*
* @param name
*/

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -18,11 +18,9 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/**
* <code>NAME</code> describes the relationship between an
* <code>IASTNamedTypeSpecifier</code> and its nested
* <code>IASTName</code>.
* <code>IASTNamedTypeSpecifier</code> and its nested <code>IASTName</code>.
*/
public static final ASTNodeProperty NAME = new ASTNodeProperty("IASTNamedTypeSpecifier.NAME - IASTName for IASTNamedTypeSpecifier"); //$NON-NLS-1$

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -27,7 +27,6 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
public static final ASTNodeProperty DECLTYPE_EXPRESSION = new ASTNodeProperty(
"IASTSimpleDeclSpecifier.EXPRESSION [IASTExpression]"); //$NON-NLS-1$
/**
* Used for omitted declaration specifiers. E.g. for declaration of constructors,
* or in plain c, where this defaults to an integer.
@ -109,7 +108,7 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
public IASTSimpleDeclSpecifier copy();
/**
* This returns the built-in type for the declaration. The type is then
* Returns the built-in type for the declaration. The type is then
* refined by qualifiers for signed/unsigned and short/long. The type could
* also be unspecified which usually means int.
*/
@ -231,5 +230,4 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
*/
@Deprecated
public static final int t_last = t_double; // used only in subclasses
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c;
@ -20,11 +20,9 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICASTDeclSpecifier extends IASTDeclSpecifier {
/**
* @since 5.1
*/
@Override
public ICASTDeclSpecifier copy();
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -19,6 +19,5 @@ import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTArrayDeclarator extends IASTArrayDeclarator, ICPPASTDeclarator{
public interface ICPPASTArrayDeclarator extends IASTArrayDeclarator, ICPPASTDeclarator {
}

View file

@ -1,13 +1,14 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others.
* Copyright (c) 2004, 2012 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:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -15,64 +16,92 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
/**
* C++ adds additional modifiers and types for decl specifier sequence.
*
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
// A declaration in C++ can be a friend declaration
/**
* Is this a friend declaration?
*
*
* @return boolean
*/
public boolean isFriend();
/**
* Set this to be a friend declaration true/false.
*
* @param value
* boolean
* Sets this to be a friend declaration true/false.
*
* @param value the new value
*/
public void setFriend(boolean value);
/**
* Is this a virtual function?
*
*
* @return boolean
*/
public boolean isVirtual();
/**
* Set this declaration to be virutal.
*
* @param value
* boolean
* Sets this declaration to be virtual.
*
* @param value the new value
*/
public void setVirtual(boolean value);
/**
* Is this an explicit constructor?
*
*
* @return boolean
*/
public boolean isExplicit();
/**
* Set this to be an explicit constructor.
*
* @param value
* boolean
* Sets this to be an explicit constructor.
*
* @param value the new value
*/
public void setExplicit(boolean value);
/**
* Is this a constexpr
*
* @return boolean
* @since 5.4
*/
public boolean isConstexpr();
/**
* Sets this to be constexpr.
*
* @param value the new value
* @since 5.4
*/
public void setConstexpr(boolean value);
/**
* Is this thread_local
*
* @return boolean
* @since 5.4
*/
public boolean isThreadLocal();
/**
* Sets this to be thread_local.
*
* @param value the new value
* @since 5.4
*/
public void setThreadLocal(boolean value);
/**
* @since 5.1
*/
@Override
public ICPPASTDeclSpecifier copy();
/**
* @since 5.3
*/

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -21,15 +21,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
*/
public interface ICPPASTDeclarator extends IASTDeclarator {
/**
* Returns whether the declarator contains an ellipsis, in which case it declares a
* parameter pack.
* Returns whether the declarator contains an ellipsis, in which case it declares
* a parameter pack.
*/
public boolean declaresParameterPack();
/**
* Set whether the declarator contains an ellipsis, denoting a pack expansion.
* Not allowed on frozen AST.
* Not allowed on a frozen AST.
*/
public void setDeclaresParameterPack(boolean val);
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -18,9 +18,7 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
* @noimplement This interface is not intended to be implemented by clients.
*/
@Deprecated
public interface ICPPASTFunctionTryBlockDeclarator extends
ICPPASTFunctionDeclarator {
public interface ICPPASTFunctionTryBlockDeclarator extends ICPPASTFunctionDeclarator {
/**
* A <code>CATCH_HANDLER</code> is the role of an ICPPASTCatchHandler in
* this interface.

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* John Camelon (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
*/
@Deprecated
public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier {
/**
* @since 5.1
*/

View file

@ -1,15 +1,15 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 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
* Copyright (c) 2004, 2011 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:
* IBM - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
* Contributors:
* IBM - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.core.dom.parser;
@ -50,15 +50,15 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
addPreprocessorKeyword(Keywords.cASSERT, IPreprocessorDirective.ppIgnore);
addPreprocessorKeyword(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);
addKeyword(GCCKeywords.cp__ALIGNOF, IGCCToken.t___alignof__ );
addKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
addKeyword(GCCKeywords.cp__ALIGNOF, IGCCToken.t___alignof__);
addKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__);
addKeyword(GCCKeywords.cp__ASM, IToken.t_asm);
addKeyword(GCCKeywords.cp__ASM__, IToken.t_asm);
addKeyword(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__ );
addKeyword(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
addKeyword(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__);
addKeyword(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__);
addKeyword(GCCKeywords.cp__CONST, IToken.t_const);
addKeyword(GCCKeywords.cp__CONST__, IToken.t_const);
addKeyword(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
addKeyword(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec);
addKeyword(GCCKeywords.cp__INLINE, IToken.t_inline);
addKeyword(GCCKeywords.cp__INLINE__, IToken.t_inline);
addKeyword(GCCKeywords.cp__RESTRICT, IToken.t_restrict);
@ -69,7 +69,7 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
addKeyword(GCCKeywords.cp__SIGNED__, IToken.t_signed);
addKeyword(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof);
addKeyword(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
addKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
addKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof);
}
@Override

View file

@ -419,7 +419,7 @@ public interface IIndex {
* Returns an IIndexBinding for this IIndex that is equivalent to the specified binding,
* or null if such a binding does not exist in this index. This is useful for adapting
* bindings obtained from IIndex objects that might have been created for a different scope
* or for IBinding objects obtained direct from the AST.
* or for IBinding objects obtained directly from the AST.
* @param binding
* @return an IIndexBinding for this IIndex that is equivalent to the specified binding
*/

View file

@ -33,21 +33,21 @@ public interface IIndexManager extends IPDOMManager {
* projects referenced by the set of input projects should also be added
* to the resulting index.
*/
public final static int ADD_DEPENDENCIES = 0x1;
public static final int ADD_DEPENDENCIES = 0x1;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates
* projects which reference any of the set of input projects should also be
* added to the resulting index.
*/
public final static int ADD_DEPENDENT = 0x2;
public static final int ADD_DEPENDENT = 0x2;
/**
* @deprecated Extension fragments are now used depending on their configuration.
* Use one of the ADD_EXTENSION_XX flags instead.
*/
@Deprecated
public final static int SKIP_PROVIDED = 0x4;
public static final int SKIP_PROVIDED = 0x4;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -56,7 +56,7 @@ public interface IIndexManager extends IPDOMManager {
*
* @since 5.4
*/
public final static int ADD_EXTENSION_FRAGMENTS_NAVIGATION = 0x8;
public static final int ADD_EXTENSION_FRAGMENTS_NAVIGATION = 0x8;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates that the each index
@ -65,7 +65,7 @@ public interface IIndexManager extends IPDOMManager {
*
* @since 5.4
*/
public final static int ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST = 0x10;
public static final int ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST = 0x10;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -74,7 +74,7 @@ public interface IIndexManager extends IPDOMManager {
*
* @since 5.4
*/
public final static int ADD_EXTENSION_FRAGMENTS_ADD_IMPORT = 0x20;
public static final int ADD_EXTENSION_FRAGMENTS_ADD_IMPORT = 0x20;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -83,7 +83,7 @@ public interface IIndexManager extends IPDOMManager {
*
* @since 5.4
*/
public final static int ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY = 0x40;
public static final int ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY = 0x40;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -92,7 +92,7 @@ public interface IIndexManager extends IPDOMManager {
*
* @since 5.4
*/
public final static int ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY = 0x80;
public static final int ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY = 0x80;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -101,7 +101,7 @@ public interface IIndexManager extends IPDOMManager {
*
* @since 5.4
*/
public final static int ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER = 0x100;
public static final int ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER = 0x100;
/**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -110,29 +110,29 @@ public interface IIndexManager extends IPDOMManager {
*
* @since 5.4
*/
public final static int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200;
public static final int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200;
/**
* Constant for indicating that there is no time out period for joining the indexer job.
* @see IIndexManager#joinIndexer(int, IProgressMonitor)
*/
public final static int FOREVER= -1;
public static final int FOREVER= -1;
/**
* Constant for requesting an update of all translation units.
*/
public final static int UPDATE_ALL= 0x1;
public static final int UPDATE_ALL= 0x1;
/**
* Constant for requesting an update of translation units if theit timestamps have changed.
*/
public final static int UPDATE_CHECK_TIMESTAMPS= 0x2;
public static final int UPDATE_CHECK_TIMESTAMPS= 0x2;
/**
* Constant for requesting an update of translation units if their configurations
* have changed. The flag currently has no effect.
*/
public final static int UPDATE_CHECK_CONFIGURATION= 0x4;
public static final int UPDATE_CHECK_CONFIGURATION= 0x4;
/**
* Constant for requesting to update the external files for a project, also. This flag works
@ -140,7 +140,7 @@ public interface IIndexManager extends IPDOMManager {
* {@link #UPDATE_ALL} or {@link #UPDATE_CHECK_TIMESTAMPS}.
* @since 5.1
*/
public final static int UPDATE_EXTERNAL_FILES_FOR_PROJECT= 0x8;
public static final int UPDATE_EXTERNAL_FILES_FOR_PROJECT= 0x8;
/**
* This flag modifies behavior of UPDATE_CHECK_TIMESTAMPS. Both, the timestamp and the hash
@ -149,7 +149,7 @@ public interface IIndexManager extends IPDOMManager {
* generation since generated files are sometimes recreated with identical contents.
* @since 5.2
*/
public final static int UPDATE_CHECK_CONTENTS_HASH= 0x10;
public static final int UPDATE_CHECK_CONTENTS_HASH= 0x10;
/**
* Include files that are otherwise would be excluded from the index. This flag is sticky
@ -157,7 +157,7 @@ public interface IIndexManager extends IPDOMManager {
* they remain in the index.
* @since 5.3
*/
public final static int FORCE_INDEX_INCLUSION= 0x20;
public static final int FORCE_INDEX_INCLUSION= 0x20;
/**
* Causes files previously included in the index due to FORCE_INDEX_INCLUSION to loose
@ -165,13 +165,13 @@ public interface IIndexManager extends IPDOMManager {
* will be removed from the index.
* @since 5.4
*/
public final static int RESET_INDEX_INCLUSION= 0x40;
public static final int RESET_INDEX_INCLUSION= 0x40;
/**
* Constant for requesting an update of translation units that had unresolved includes.
* @since 5.4
*/
public final static int UPDATE_UNRESOLVED_INCLUDES= 0x80;
public static final int UPDATE_UNRESOLVED_INCLUDES= 0x80;
/**
* Returns the index for the given project.

View file

@ -24,17 +24,17 @@ public interface IToken {
public int getLength();
public int getEndOffset();
public IToken getNext();
public void setNext(IToken t);
public void setType(int i);
// Token types
int FIRST_RESERVED_PREPROCESSOR= -200;
int LAST_RESERVED_PREPROCESSOR= -101;
int FIRST_RESERVED_SCANNER= -100;
int LAST_RESERVED_SCANNER= -1;
/** @since 5.2 */
/** @since 5.2 */
int t_PRAGMA = 5200;
int tIDENTIFIER = 1;
@ -90,11 +90,11 @@ public interface IToken {
int tDIVASSIGN = 51;
int tDIV = 52;
/**
* @see IScanner#setSplitShiftROperator(boolean)
* @since 5.2
* @see IScanner#setSplitShiftROperator(boolean)
* @since 5.2
*/
int tGT_in_SHIFTR= 5201;
/** @deprecated use {@link #tAND} */ @Deprecated int t_and = 54;
/** @deprecated use {@link #tAMPERASSIGN} */ @Deprecated int t_and_eq = 55;
int t_asm = 56;
@ -106,18 +106,19 @@ public interface IToken {
int t_case = 62;
int t_catch = 63;
int t_char = 64;
/** @since 5.2 */
/** @since 5.2 */
int t_char16_t= 5202;
/** @since 5.2 */
/** @since 5.2 */
int t_char32_t= 5203;
int t_class = 65;
/** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int tCOMPL= tBITCOMPLEMENT;
/** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int t_compl = 66;
int t_const = 67;
/** @since 5.4 */ int t_constexpr = 5400;
int t_const_cast = 69;
int t_continue = 70;
/** @since 5.2 */
/** @since 5.2 */
int t_decltype= 5204;
int t_default = 71;
int t_delete = 72;
@ -141,7 +142,8 @@ public interface IToken {
int t_mutable = 90;
int t_namespace = 91;
int t_new = 92;
/** @since 5.4 */ int t_nullptr = 5400;
/** @since 5.4 */ int t_noexcept = 5401;
/** @since 5.4 */ int t_nullptr = 5402;
/** @deprecated use {@link #tNOT} */ @Deprecated int t_not = 93;
/** @deprecated use {@link #tNOTEQUAL} */ @Deprecated int t_not_eq = 94;
int t_operator = 95;
@ -156,7 +158,7 @@ public interface IToken {
int t_short = 104;
int t_sizeof = 105;
int t_static = 106;
/** @since 5.2 */
/** @since 5.2 */
int t_static_assert = 5205;
int t_static_cast = 107;
int t_signed = 108;
@ -164,6 +166,7 @@ public interface IToken {
int t_switch = 110;
int t_template = 111;
int t_this = 112;
/** @since 5.4 */ int t_thread_local = 5403;
int t_throw = 113;
int t_true = 114;
int t_try = 115;
@ -179,24 +182,24 @@ public interface IToken {
int t_wchar_t = 125;
int t_while = 126;
/** @deprecated use {@link #tXOR} */ @Deprecated int t_xor = 127;
/** @deprecated use {@link #tXORASSIGN} */ @Deprecated int t_xor_eq = 128;
/** @deprecated use {@link #tXORASSIGN} */ @Deprecated int t_xor_eq = 128;
int tFLOATINGPT = 129;
int tSTRING = 130;
int tLSTRING = 131;
/** @since 5.1 */ int tUTF16STRING = 5000;
/** @since 5.1 */ int tUTF32STRING = 5001;
int tCHAR = 132;
int tLCHAR = 133;
/** @since 5.1 */ int tUTF16CHAR = 5002;
/** @since 5.1 */ int tUTF32CHAR = 5003;
int t__Bool = 134;
int t__Complex = 135;
int t__Imaginary = 136;
int t_restrict = 137;
/** @deprecated don't use it */ @Deprecated int tMACROEXP = 138;
/** @deprecated don't use it */ @Deprecated int tMACROEXP = 138;
int tPOUND= 138;
int tPOUNDPOUND = 139;
int tCOMPLETION = 140;
@ -207,14 +210,14 @@ public interface IToken {
/** @since 5.1 */ int tINACTIVE_CODE_START= 145;
/** @since 5.1 */ int tINACTIVE_CODE_SEPARATOR= 146;
/** @since 5.1 */ int tINACTIVE_CODE_END = 147;
int FIRST_RESERVED_IGCCToken = 150;
int LAST_RESERVED_IGCCToken = 199;
int FIRST_RESERVED_IExtensionToken = 243;
int LAST_RESERVED_IExtensionToken = 299;
/**
* @noreference This method is not intended to be referenced by clients.
*/

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
* John Camelon (IBM Rational Software) - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.parser;
@ -20,277 +20,292 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
*/
@SuppressWarnings("nls")
public class Keywords {
public static final String CAST = "cast";
/** @since 5.4 */
public static final String ALIGNAS = "alignas";
public static final String ALIGNOF = "alignof";
public static final String TYPEOF = "typeof";
public static final String CAST = "cast";
public static final String ALIGNOF = "alignof";
public static final String TYPEOF = "typeof";
public static final String _BOOL = "_Bool";
public static final String _COMPLEX = "_Complex";
public static final String _IMAGINARY = "_Imaginary";
public static final String AND = "and";
public static final String AND_EQ = "and_eq";
public static final String ASM = "asm";
public static final String AUTO = "auto";
public static final String BITAND = "bitand";
public static final String BITOR = "bitor";
public static final String BOOL = "bool";
public static final String BREAK = "break";
public static final String CASE = "case";
public static final String CATCH = "catch";
public static final String CHAR = "char";
public static final String _BOOL = "_Bool";
public static final String _COMPLEX = "_Complex";
public static final String _IMAGINARY = "_Imaginary";
public static final String AND = "and";
public static final String AND_EQ = "and_eq";
public static final String ASM = "asm";
public static final String AUTO = "auto";
public static final String BITAND = "bitand";
public static final String BITOR = "bitor";
public static final String BOOL = "bool";
public static final String BREAK = "break";
public static final String CASE = "case";
public static final String CATCH = "catch";
public static final String CHAR = "char";
/** @since 5.2 */
public static final String CHAR16_T = "char16_t";
public static final String CHAR16_T = "char16_t";
/** @since 5.2 */
public static final String CHAR32_T = "char32_t";
public static final String CLASS = "class";
public static final String COMPL = "compl";
public static final String CONST = "const";
public static final String CONST_CAST = "const_cast";
public static final String CONTINUE = "continue";
public static final String CHAR32_T = "char32_t";
public static final String CLASS = "class";
public static final String COMPL = "compl";
public static final String CONST = "const";
/** @since 5.4 */
public static final String CONSTEXPR = "constexpr";
public static final String CONST_CAST = "const_cast";
public static final String CONTINUE = "continue";
/** @since 5.2 */
public static final String DECLTYPE = "decltype";
public static final String DEFAULT = "default";
public static final String DELETE = "delete";
public static final String DO = "do";
public static final String DOUBLE = "double";
public static final String DYNAMIC_CAST = "dynamic_cast";
public static final String ELSE = "else";
public static final String ENUM = "enum";
public static final String EXPLICIT = "explicit";
public static final String EXPORT = "export";
public static final String EXTERN = "extern";
public static final String FALSE = "false";
public static final String FLOAT = "float";
public static final String FOR = "for";
public static final String FRIEND = "friend";
public static final String GOTO = "goto";
public static final String IF = "if";
public static final String INLINE = "inline";
public static final String INT = "int";
public static final String LONG = "long";
public static final String LONG_LONG = "long long";
public static final String MUTABLE = "mutable";
public static final String NAMESPACE = "namespace";
public static final String DECLTYPE = "decltype";
public static final String DEFAULT = "default";
public static final String DELETE = "delete";
public static final String DO = "do";
public static final String DOUBLE = "double";
public static final String DYNAMIC_CAST = "dynamic_cast";
public static final String ELSE = "else";
public static final String ENUM = "enum";
public static final String EXPLICIT = "explicit";
public static final String EXPORT = "export";
public static final String EXTERN = "extern";
public static final String FALSE = "false";
public static final String FLOAT = "float";
public static final String FOR = "for";
public static final String FRIEND = "friend";
public static final String GOTO = "goto";
public static final String IF = "if";
public static final String INLINE = "inline";
public static final String INT = "int";
public static final String LONG = "long";
public static final String LONG_LONG = "long long";
public static final String MUTABLE = "mutable";
public static final String NAMESPACE = "namespace";
/** @since 5.4 */
public static final String NULLPTR = "nullptr";
public static final String NEW = "new";
public static final String NOT = "not";
public static final String NOT_EQ = "not_eq";
public static final String OPERATOR = "operator";
public static final String OR = "or";
public static final String OR_EQ = "or_eq";
public static final String PRIVATE = "private";
public static final String PROTECTED = "protected";
public static final String PUBLIC = "public";
public static final String REGISTER = "register";
public static final String REINTERPRET_CAST = "reinterpret_cast";
public static final String RESTRICT = "restrict";
public static final String RETURN = "return";
public static final String SHORT = "short";
public static final String SIGNED = "signed";
public static final String SIZEOF = "sizeof";
public static final String STATIC = "static";
/** @since 5.2 */
public static final String STATIC_ASSERT = "static_assert";
public static final String STATIC_CAST = "static_cast";
public static final String STRUCT = "struct";
public static final String SWITCH = "switch";
public static final String TEMPLATE = "template";
public static final String THIS = "this";
public static final String THROW = "throw";
public static final String TRUE = "true";
public static final String TRY = "try";
public static final String TYPEDEF = "typedef";
public static final String TYPEID = "typeid";
public static final String TYPENAME = "typename";
public static final String UNION = "union";
public static final String UNSIGNED = "unsigned";
public static final String USING = "using";
public static final String VIRTUAL = "virtual";
public static final String VOID = "void";
public static final String VOLATILE = "volatile";
public static final String WCHAR_T = "wchar_t";
public static final String WHILE = "while";
public static final String XOR = "xor";
public static final String XOR_EQ = "xor_eq";
public static final char[] c_BOOL = "_Bool".toCharArray();
public static final char[] c_COMPLEX = "_Complex".toCharArray();
public static final char[] c_IMAGINARY = "_Imaginary".toCharArray();
/** @since 5.3 */
public static final char[] cALIGNOF = "alignof".toCharArray();
public static final char[] cAND = "and".toCharArray();
public static final char[] cAND_EQ = "and_eq".toCharArray();
public static final char[] cASM = "asm".toCharArray();
public static final char[] cAUTO = "auto".toCharArray();
public static final char[] cBITAND = "bitand".toCharArray();
public static final char[] cBITOR = "bitor".toCharArray();
public static final char[] cBOOL = "bool".toCharArray();
public static final char[] cBREAK = "break".toCharArray();
public static final char[] cCASE = "case".toCharArray();
public static final char[] cCATCH = "catch".toCharArray();
public static final char[] cCHAR = "char".toCharArray();
/** @since 5.2 */
public static final char[] cCHAR16_T = CHAR16_T.toCharArray();
/** @since 5.2 */
public static final char[] cCHAR32_T = CHAR32_T.toCharArray();
public static final char[] cCLASS = "class".toCharArray();
public static final char[] cCOMPL = "compl".toCharArray();
public static final char[] cCONST = "const".toCharArray();
public static final char[] cCONST_CAST = "const_cast".toCharArray();
public static final char[] cCONTINUE = "continue".toCharArray();
public static final char[] cDEFAULT = "default".toCharArray();
/** @since 5.2 */
public static final char[] cDECLTYPE = DECLTYPE.toCharArray();
public static final char[] cDELETE = "delete".toCharArray();
public static final char[] cDO = "do".toCharArray();
public static final char[] cDOUBLE = "double".toCharArray();
public static final char[] cDYNAMIC_CAST = "dynamic_cast".toCharArray();
public static final char[] cELSE = "else".toCharArray();
public static final char[] cENUM = "enum".toCharArray();
public static final char[] cEXPLICIT = "explicit".toCharArray();
public static final char[] cEXPORT = "export".toCharArray();
public static final char[] cEXTERN = "extern".toCharArray();
public static final char[] cFALSE = "false".toCharArray();
public static final char[] cFLOAT = "float".toCharArray();
public static final char[] cFOR = "for".toCharArray();
public static final char[] cFRIEND = "friend".toCharArray();
public static final char[] cGOTO = "goto".toCharArray();
public static final char[] cIF = "if".toCharArray();
public static final char[] cINLINE = "inline".toCharArray();
public static final char[] cINT = "int".toCharArray();
public static final char[] cLONG = "long".toCharArray();
public static final char[] cMUTABLE = "mutable".toCharArray();
public static final char[] cNAMESPACE = "namespace".toCharArray();
public static final char[] cNEW = "new".toCharArray();
public static final String NEW = "new";
/** @since 5.4 */
public static final char[] cNULLPTR = NULLPTR.toCharArray();
public static final char[] cNOT = "not".toCharArray();
public static final char[] cNOT_EQ = "not_eq".toCharArray();
public static final char[] cOPERATOR = "operator".toCharArray();
public static final char[] cOR = "or".toCharArray();
public static final char[] cOR_EQ = "or_eq".toCharArray();
public static final char[] cPRIVATE = "private".toCharArray();
public static final char[] cPROTECTED = "protected".toCharArray();
public static final char[] cPUBLIC = "public".toCharArray();
public static final char[] cREGISTER = "register".toCharArray();
public static final char[] cREINTERPRET_CAST = "reinterpret_cast".toCharArray();
public static final char[] cRESTRICT = "restrict".toCharArray();
public static final char[] cRETURN = "return".toCharArray();
public static final char[] cSHORT = "short".toCharArray();
public static final char[] cSIGNED = "signed".toCharArray();
public static final char[] cSIZEOF = "sizeof".toCharArray();
/** @since 5.3 */
public static final char[] cSIZEOFPACK= "sizeof...".toCharArray();
public static final char[] cSTATIC = "static".toCharArray();
public static final String NOEXCEPT = "noexcept";
public static final String NOT = "not";
public static final String NOT_EQ = "not_eq";
public static final String OPERATOR = "operator";
public static final String OR = "or";
public static final String OR_EQ = "or_eq";
public static final String PRIVATE = "private";
public static final String PROTECTED = "protected";
public static final String PUBLIC = "public";
public static final String REGISTER = "register";
public static final String REINTERPRET_CAST = "reinterpret_cast";
public static final String RESTRICT = "restrict";
public static final String RETURN = "return";
public static final String SHORT = "short";
public static final String SIGNED = "signed";
public static final String SIZEOF = "sizeof";
public static final String STATIC = "static";
/** @since 5.2 */
public static final char[] cSTATIC_ASSERT = STATIC_ASSERT.toCharArray();
public static final char[] cSTATIC_CAST = "static_cast".toCharArray();
public static final char[] cSTRUCT = "struct".toCharArray();
public static final char[] cSWITCH = "switch".toCharArray();
public static final char[] cTEMPLATE = "template".toCharArray();
public static final char[] cTHIS = "this".toCharArray();
public static final char[] cTHROW = "throw".toCharArray();
public static final char[] cTRUE = "true".toCharArray();
public static final char[] cTRY = "try".toCharArray();
public static final char[] cTYPEDEF = "typedef".toCharArray();
public static final char[] cTYPEID = "typeid".toCharArray();
public static final char[] cTYPENAME = "typename".toCharArray();
public static final char[] cUNION = "union".toCharArray();
public static final char[] cUNSIGNED = "unsigned".toCharArray();
public static final char[] cUSING = "using".toCharArray();
public static final char[] cVIRTUAL = "virtual".toCharArray();
public static final char[] cVOID = "void".toCharArray();
public static final char[] cVOLATILE = "volatile".toCharArray();
public static final char[] cWCHAR_T = "wchar_t".toCharArray();
public static final char[] cWHILE = "while".toCharArray();
public static final char[] cXOR = "xor".toCharArray();
public static final char[] cXOR_EQ = "xor_eq".toCharArray();
public static final char[] cpCOLONCOLON = "::".toCharArray();
public static final char[] cpCOLON = ":".toCharArray();
public static final char[] cpSEMI = ";".toCharArray();
public static final char[] cpCOMMA = ",".toCharArray();
public static final char[] cpQUESTION = "?".toCharArray();
public static final char[] cpLPAREN = "(".toCharArray();
public static final char[] cpRPAREN = ")".toCharArray();
public static final char[] cpLBRACKET = "[".toCharArray();
public static final char[] cpRBRACKET = "]".toCharArray();
public static final char[] cpLBRACE = "{".toCharArray();
public static final char[] cpRBRACE = "}".toCharArray();
public static final char[] cpPLUSASSIGN = "+=".toCharArray();
public static final char[] cpINCR = "++".toCharArray();
public static final char[] cpPLUS = "+".toCharArray();
public static final char[] cpMINUSASSIGN = "-=".toCharArray();
public static final char[] cpDECR = "--".toCharArray();
public static final char[] cpARROWSTAR = "->*".toCharArray();
public static final char[] cpARROW = "->".toCharArray();
public static final char[] cpMINUS = "-".toCharArray();
public static final char[] cpSTARASSIGN = "*=".toCharArray();
public static final char[] cpSTAR = "*".toCharArray();
public static final char[] cpMODASSIGN = "%=".toCharArray();
public static final char[] cpMOD = "%".toCharArray();
public static final char[] cpXORASSIGN = "^=".toCharArray();
public static final char[] cpXOR = "^".toCharArray();
public static final char[] cpAMPERASSIGN = "&=".toCharArray();
public static final char[] cpAND = "&&".toCharArray();
public static final char[] cpAMPER = "&".toCharArray();
public static final char[] cpBITORASSIGN = "|=".toCharArray();
public static final char[] cpOR = "||".toCharArray();
public static final char[] cpBITOR = "|".toCharArray();
public static final char[] cpCOMPL = "~".toCharArray();
public static final char[] cpNOTEQUAL = "!=".toCharArray();
public static final char[] cpNOT = "!".toCharArray();
public static final char[] cpEQUAL = "==".toCharArray();
public static final char[] cpASSIGN ="=".toCharArray();
public static final char[] cpSHIFTL = "<<".toCharArray();
public static final char[] cpLTEQUAL = "<=".toCharArray();
public static final char[] cpLT = "<".toCharArray();
public static final char[] cpSHIFTRASSIGN = ">>=".toCharArray();
public static final char[] cpSHIFTR = ">>".toCharArray();
public static final char[] cpGTEQUAL = ">=".toCharArray();
public static final char[] cpGT = ">".toCharArray();
public static final char[] cpSHIFTLASSIGN = "<<=".toCharArray();
public static final char[] cpELLIPSIS = "...".toCharArray();
public static final char[] cpDOTSTAR = ".*".toCharArray();
public static final char[] cpDOT = ".".toCharArray();
public static final char[] cpDIVASSIGN = "/=".toCharArray();
public static final char[] cpDIV = "/".toCharArray();
public static final char[] cpPOUND = "#".toCharArray();
public static final char[] cpPOUNDPOUND = "##".toCharArray();
// gcc extensions
public static final char[] cpMIN = "<?".toCharArray();
public static final char[] cpMAX = ">?".toCharArray();
// preprocessor keywords
public static final char[] cIFDEF = "ifdef".toCharArray();
public static final char[] cIFNDEF = "ifndef".toCharArray();
public static final char[] cELIF = "elif".toCharArray();
public static final char[] cENDIF = "endif".toCharArray();
public static final char[] cINCLUDE = "include".toCharArray();
public static final char[] cDEFINE = "define".toCharArray();
public static final char[] cUNDEF = "undef".toCharArray();
public static final char[] cERROR = "error".toCharArray();
public static final char[] cPRAGMA = "pragma".toCharArray();
public static final char[] cLINE = "line".toCharArray();
public static final char[] cDEFINED= "defined".toCharArray();
/** @since 5.2*/
public static final char[] _Pragma= "_Pragma".toCharArray();
public static final char[] cVA_ARGS= "__VA_ARGS__".toCharArray();
public static final String STATIC_ASSERT = "static_assert";
public static final String STATIC_CAST = "static_cast";
public static final String STRUCT = "struct";
public static final String SWITCH = "switch";
public static final String TEMPLATE = "template";
public static final String THIS = "this";
/** @since 5.4 */
public static final String THREAD_LOCAL = "thread_local";
public static final String THROW = "throw";
public static final String TRUE = "true";
public static final String TRY = "try";
public static final String TYPEDEF = "typedef";
public static final String TYPEID = "typeid";
public static final String TYPENAME = "typename";
public static final String UNION = "union";
public static final String UNSIGNED = "unsigned";
public static final String USING = "using";
public static final String VIRTUAL = "virtual";
public static final String VOID = "void";
public static final String VOLATILE = "volatile";
public static final String WCHAR_T = "wchar_t";
public static final String WHILE = "while";
public static final String XOR = "xor";
public static final String XOR_EQ = "xor_eq";
public static final char[] c_BOOL = "_Bool".toCharArray();
public static final char[] c_COMPLEX = "_Complex".toCharArray();
public static final char[] c_IMAGINARY = "_Imaginary".toCharArray();
/** @since 5.4 */
public static final char[] cALIGNAS = "alignas".toCharArray();
/** @since 5.3 */
public static final char[] cALIGNOF = "alignof".toCharArray();
public static final char[] cAND = "and".toCharArray();
public static final char[] cAND_EQ = "and_eq".toCharArray();
public static final char[] cASM = "asm".toCharArray();
public static final char[] cAUTO = "auto".toCharArray();
public static final char[] cBITAND = "bitand".toCharArray();
public static final char[] cBITOR = "bitor".toCharArray();
public static final char[] cBOOL = "bool".toCharArray();
public static final char[] cBREAK = "break".toCharArray();
public static final char[] cCASE = "case".toCharArray();
public static final char[] cCATCH = "catch".toCharArray();
public static final char[] cCHAR = "char".toCharArray();
/** @since 5.2 */
public static final char[] cCHAR16_T = CHAR16_T.toCharArray();
/** @since 5.2 */
public static final char[] cCHAR32_T = CHAR32_T.toCharArray();
public static final char[] cCLASS = "class".toCharArray();
public static final char[] cCOMPL = "compl".toCharArray();
public static final char[] cCONST = "const".toCharArray();
/** @since 5.4 */
public static final char[] cCONSTEXPR = "constexpr".toCharArray();
public static final char[] cCONST_CAST = "const_cast".toCharArray();
public static final char[] cCONTINUE = "continue".toCharArray();
public static final char[] cDEFAULT = "default".toCharArray();
/** @since 5.2 */
public static final char[] cDECLTYPE = DECLTYPE.toCharArray();
public static final char[] cDELETE = "delete".toCharArray();
public static final char[] cDO = "do".toCharArray();
public static final char[] cDOUBLE = "double".toCharArray();
public static final char[] cDYNAMIC_CAST = "dynamic_cast".toCharArray();
public static final char[] cELSE = "else".toCharArray();
public static final char[] cENUM = "enum".toCharArray();
public static final char[] cEXPLICIT = "explicit".toCharArray();
public static final char[] cEXPORT = "export".toCharArray();
public static final char[] cEXTERN = "extern".toCharArray();
public static final char[] cFALSE = "false".toCharArray();
public static final char[] cFLOAT = "float".toCharArray();
public static final char[] cFOR = "for".toCharArray();
public static final char[] cFRIEND = "friend".toCharArray();
public static final char[] cGOTO = "goto".toCharArray();
public static final char[] cIF = "if".toCharArray();
public static final char[] cINLINE = "inline".toCharArray();
public static final char[] cINT = "int".toCharArray();
public static final char[] cLONG = "long".toCharArray();
public static final char[] cMUTABLE = "mutable".toCharArray();
public static final char[] cNAMESPACE = "namespace".toCharArray();
public static final char[] cNEW = "new".toCharArray();
/** @since 5.4 */
public static final char[] cNULLPTR = NULLPTR.toCharArray();
/** @since 5.4 */
public static final char[] cNOEXCEPT = "noexcept".toCharArray();
public static final char[] cNOT = "not".toCharArray();
public static final char[] cNOT_EQ = "not_eq".toCharArray();
public static final char[] cOPERATOR = "operator".toCharArray();
public static final char[] cOR = "or".toCharArray();
public static final char[] cOR_EQ = "or_eq".toCharArray();
public static final char[] cPRIVATE = "private".toCharArray();
public static final char[] cPROTECTED = "protected".toCharArray();
public static final char[] cPUBLIC = "public".toCharArray();
public static final char[] cREGISTER = "register".toCharArray();
public static final char[] cREINTERPRET_CAST = "reinterpret_cast".toCharArray();
public static final char[] cRESTRICT = "restrict".toCharArray();
public static final char[] cRETURN = "return".toCharArray();
public static final char[] cSHORT = "short".toCharArray();
public static final char[] cSIGNED = "signed".toCharArray();
public static final char[] cSIZEOF = "sizeof".toCharArray();
/** @since 5.3 */
public static final char[] cSIZEOFPACK= "sizeof...".toCharArray();
public static final char[] cSTATIC = "static".toCharArray();
/** @since 5.2 */
public static final char[] cSTATIC_ASSERT = STATIC_ASSERT.toCharArray();
public static final char[] cSTATIC_CAST = "static_cast".toCharArray();
public static final char[] cSTRUCT = "struct".toCharArray();
public static final char[] cSWITCH = "switch".toCharArray();
public static final char[] cTEMPLATE = "template".toCharArray();
public static final char[] cTHIS = "this".toCharArray();
/** @since 5.4 */
public static final char[] cTHREAD_LOCAL = "thread_local".toCharArray();
public static final char[] cTHROW = "throw".toCharArray();
public static final char[] cTRUE = "true".toCharArray();
public static final char[] cTRY = "try".toCharArray();
public static final char[] cTYPEDEF = "typedef".toCharArray();
public static final char[] cTYPEID = "typeid".toCharArray();
public static final char[] cTYPENAME = "typename".toCharArray();
public static final char[] cUNION = "union".toCharArray();
public static final char[] cUNSIGNED = "unsigned".toCharArray();
public static final char[] cUSING = "using".toCharArray();
public static final char[] cVIRTUAL = "virtual".toCharArray();
public static final char[] cVOID = "void".toCharArray();
public static final char[] cVOLATILE = "volatile".toCharArray();
public static final char[] cWCHAR_T = "wchar_t".toCharArray();
public static final char[] cWHILE = "while".toCharArray();
public static final char[] cXOR = "xor".toCharArray();
public static final char[] cXOR_EQ = "xor_eq".toCharArray();
public static final char[] cpCOLONCOLON = "::".toCharArray();
public static final char[] cpCOLON = ":".toCharArray();
public static final char[] cpSEMI = ";".toCharArray();
public static final char[] cpCOMMA = ",".toCharArray();
public static final char[] cpQUESTION = "?".toCharArray();
public static final char[] cpLPAREN = "(".toCharArray();
public static final char[] cpRPAREN = ")".toCharArray();
public static final char[] cpLBRACKET = "[".toCharArray();
public static final char[] cpRBRACKET = "]".toCharArray();
public static final char[] cpLBRACE = "{".toCharArray();
public static final char[] cpRBRACE = "}".toCharArray();
public static final char[] cpPLUSASSIGN = "+=".toCharArray();
public static final char[] cpINCR = "++".toCharArray();
public static final char[] cpPLUS = "+".toCharArray();
public static final char[] cpMINUSASSIGN = "-=".toCharArray();
public static final char[] cpDECR = "--".toCharArray();
public static final char[] cpARROWSTAR = "->*".toCharArray();
public static final char[] cpARROW = "->".toCharArray();
public static final char[] cpMINUS = "-".toCharArray();
public static final char[] cpSTARASSIGN = "*=".toCharArray();
public static final char[] cpSTAR = "*".toCharArray();
public static final char[] cpMODASSIGN = "%=".toCharArray();
public static final char[] cpMOD = "%".toCharArray();
public static final char[] cpXORASSIGN = "^=".toCharArray();
public static final char[] cpXOR = "^".toCharArray();
public static final char[] cpAMPERASSIGN = "&=".toCharArray();
public static final char[] cpAND = "&&".toCharArray();
public static final char[] cpAMPER = "&".toCharArray();
public static final char[] cpBITORASSIGN = "|=".toCharArray();
public static final char[] cpOR = "||".toCharArray();
public static final char[] cpBITOR = "|".toCharArray();
public static final char[] cpCOMPL = "~".toCharArray();
public static final char[] cpNOTEQUAL = "!=".toCharArray();
public static final char[] cpNOT = "!".toCharArray();
public static final char[] cpEQUAL = "==".toCharArray();
public static final char[] cpASSIGN ="=".toCharArray();
public static final char[] cpSHIFTL = "<<".toCharArray();
public static final char[] cpLTEQUAL = "<=".toCharArray();
public static final char[] cpLT = "<".toCharArray();
public static final char[] cpSHIFTRASSIGN = ">>=".toCharArray();
public static final char[] cpSHIFTR = ">>".toCharArray();
public static final char[] cpGTEQUAL = ">=".toCharArray();
public static final char[] cpGT = ">".toCharArray();
public static final char[] cpSHIFTLASSIGN = "<<=".toCharArray();
public static final char[] cpELLIPSIS = "...".toCharArray();
public static final char[] cpDOTSTAR = ".*".toCharArray();
public static final char[] cpDOT = ".".toCharArray();
public static final char[] cpDIVASSIGN = "/=".toCharArray();
public static final char[] cpDIV = "/".toCharArray();
public static final char[] cpPOUND = "#".toCharArray();
public static final char[] cpPOUNDPOUND = "##".toCharArray();
// gcc extensions
public static final char[] cpMIN = "<?".toCharArray();
public static final char[] cpMAX = ">?".toCharArray();
// preprocessor keywords
public static final char[] cIFDEF = "ifdef".toCharArray();
public static final char[] cIFNDEF = "ifndef".toCharArray();
public static final char[] cELIF = "elif".toCharArray();
public static final char[] cENDIF = "endif".toCharArray();
public static final char[] cINCLUDE = "include".toCharArray();
public static final char[] cDEFINE = "define".toCharArray();
public static final char[] cUNDEF = "undef".toCharArray();
public static final char[] cERROR = "error".toCharArray();
public static final char[] cPRAGMA = "pragma".toCharArray();
public static final char[] cLINE = "line".toCharArray();
public static final char[] cDEFINED= "defined".toCharArray();
/** @since 5.2*/
public static final char[] _Pragma= "_Pragma".toCharArray();
public static final char[] cVA_ARGS= "__VA_ARGS__".toCharArray();
// preprocessor extensions (supported by GCC)
public static final char[] cINCLUDE_NEXT = "include_next".toCharArray();
public static final char[] cIMPORT = "import".toCharArray();
public static final char[] cIDENT = "ident".toCharArray();
public static final char[] cSCCS = "sccs".toCharArray();
public static final char[] cWARNING = "warning".toCharArray();
public static final char[] cASSERT = "assert".toCharArray();
public static final char[] cUNASSERT = "unassert".toCharArray();
public static final char[] cINCLUDE_NEXT = "include_next".toCharArray();
public static final char[] cIMPORT = "import".toCharArray();
public static final char[] cIDENT = "ident".toCharArray();
public static final char[] cSCCS = "sccs".toCharArray();
public static final char[] cWARNING = "warning".toCharArray();
public static final char[] cASSERT = "assert".toCharArray();
public static final char[] cUNASSERT = "unassert".toCharArray();
public static void addKeywordsC(CharArrayIntMap kw) {
addCommon(kw);
addC(kw);
@ -301,116 +316,118 @@ public class Keywords {
addCpp(kw);
}
private static void addCommon(CharArrayIntMap words) {
words.put(Keywords._Pragma, IToken.t_PRAGMA);
words.put(Keywords.cAUTO, IToken.t_auto);
words.put(Keywords.cBREAK, IToken.t_break);
words.put(Keywords.cCASE, IToken.t_case);
words.put(Keywords.cCHAR, IToken.t_char);
words.put(Keywords.cCONST, IToken.t_const);
words.put(Keywords.cCONTINUE, IToken.t_continue);
words.put(Keywords.cDEFAULT, IToken.t_default);
words.put(Keywords.cDO, IToken.t_do);
words.put(Keywords.cDOUBLE, IToken.t_double);
words.put(Keywords.cELSE, IToken.t_else);
words.put(Keywords.cENUM, IToken.t_enum);
words.put(Keywords.cEXTERN, IToken.t_extern);
words.put(Keywords.cFLOAT, IToken.t_float);
words.put(Keywords.cFOR, IToken.t_for);
words.put(Keywords.cGOTO, IToken.t_goto);
words.put(Keywords.cIF, IToken.t_if);
words.put(Keywords.cINLINE, IToken.t_inline);
words.put(Keywords.cINT, IToken.t_int);
words.put(Keywords.cLONG, IToken.t_long);
words.put(Keywords.cREGISTER, IToken.t_register);
words.put(Keywords.cRETURN, IToken.t_return);
words.put(Keywords.cSHORT, IToken.t_short);
words.put(Keywords.cSIGNED, IToken.t_signed);
words.put(Keywords.cSIZEOF, IToken.t_sizeof);
words.put(Keywords.cSTATIC, IToken.t_static);
words.put(Keywords.cSTRUCT, IToken.t_struct);
words.put(Keywords.cSWITCH, IToken.t_switch);
words.put(Keywords.cTYPEDEF, IToken.t_typedef);
words.put(Keywords.cUNION, IToken.t_union);
words.put(Keywords.cUNSIGNED, IToken.t_unsigned);
words.put(Keywords.cVOID, IToken.t_void);
words.put(Keywords.cVOLATILE, IToken.t_volatile);
words.put(Keywords.cWHILE, IToken.t_while);
words.put(Keywords.cASM, IToken.t_asm);
words.put(Keywords.cCASE, IToken.t_case);
words.put(Keywords.cCHAR, IToken.t_char);
words.put(Keywords.cCONST, IToken.t_const);
words.put(Keywords.cCONTINUE, IToken.t_continue);
words.put(Keywords.cDEFAULT, IToken.t_default);
words.put(Keywords.cDO, IToken.t_do);
words.put(Keywords.cDOUBLE, IToken.t_double);
words.put(Keywords.cELSE, IToken.t_else);
words.put(Keywords.cENUM, IToken.t_enum);
words.put(Keywords.cEXTERN, IToken.t_extern);
words.put(Keywords.cFLOAT, IToken.t_float);
words.put(Keywords.cFOR, IToken.t_for);
words.put(Keywords.cGOTO, IToken.t_goto);
words.put(Keywords.cIF, IToken.t_if);
words.put(Keywords.cINLINE, IToken.t_inline);
words.put(Keywords.cINT, IToken.t_int);
words.put(Keywords.cLONG, IToken.t_long);
words.put(Keywords.cREGISTER, IToken.t_register);
words.put(Keywords.cRETURN, IToken.t_return);
words.put(Keywords.cSHORT, IToken.t_short);
words.put(Keywords.cSIGNED, IToken.t_signed);
words.put(Keywords.cSIZEOF, IToken.t_sizeof);
words.put(Keywords.cSTATIC, IToken.t_static);
words.put(Keywords.cSTRUCT, IToken.t_struct);
words.put(Keywords.cSWITCH, IToken.t_switch);
words.put(Keywords.cTYPEDEF, IToken.t_typedef);
words.put(Keywords.cUNION, IToken.t_union);
words.put(Keywords.cUNSIGNED, IToken.t_unsigned);
words.put(Keywords.cVOID, IToken.t_void);
words.put(Keywords.cVOLATILE, IToken.t_volatile);
words.put(Keywords.cWHILE, IToken.t_while);
words.put(Keywords.cASM, IToken.t_asm);
}
// ANSI C keywords
private static void addC(CharArrayIntMap ckeywords) {
ckeywords.put(Keywords.cRESTRICT, IToken.t_restrict);
ckeywords.put(Keywords.c_BOOL, IToken.t__Bool);
ckeywords.put(Keywords.c_COMPLEX, IToken.t__Complex);
ckeywords.put(Keywords.c_IMAGINARY, IToken.t__Imaginary);
ckeywords.put(Keywords.cRESTRICT, IToken.t_restrict);
ckeywords.put(Keywords.c_BOOL, IToken.t__Bool);
ckeywords.put(Keywords.c_COMPLEX, IToken.t__Complex);
ckeywords.put(Keywords.c_IMAGINARY, IToken.t__Imaginary);
}
private static void addCpp(CharArrayIntMap cppkeywords) {
cppkeywords.put(Keywords.cBOOL, IToken.t_bool);
cppkeywords.put(Keywords.cCATCH, IToken.t_catch);
cppkeywords.put(Keywords.cCHAR16_T, IToken.t_char16_t);
cppkeywords.put(Keywords.cCHAR32_T, IToken.t_char32_t);
cppkeywords.put(Keywords.cCLASS, IToken.t_class);
cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast);
cppkeywords.put(Keywords.cBOOL, IToken.t_bool);
cppkeywords.put(Keywords.cCATCH, IToken.t_catch);
cppkeywords.put(Keywords.cCHAR16_T, IToken.t_char16_t);
cppkeywords.put(Keywords.cCHAR32_T, IToken.t_char32_t);
cppkeywords.put(Keywords.cCLASS, IToken.t_class);
cppkeywords.put(Keywords.cCONSTEXPR, IToken.t_constexpr);
cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast);
cppkeywords.put(Keywords.cDECLTYPE, IToken.t_decltype);
cppkeywords.put(Keywords.cDELETE, IToken.t_delete);
cppkeywords.put(Keywords.cDYNAMIC_CAST, IToken.t_dynamic_cast);
cppkeywords.put(Keywords.cEXPLICIT, IToken.t_explicit);
cppkeywords.put(Keywords.cEXPORT, IToken.t_export);
cppkeywords.put(Keywords.cFALSE, IToken.t_false);
cppkeywords.put(Keywords.cFRIEND, IToken.t_friend);
cppkeywords.put(Keywords.cMUTABLE, IToken.t_mutable);
cppkeywords.put(Keywords.cNAMESPACE, IToken.t_namespace);
cppkeywords.put(Keywords.cNEW, IToken.t_new);
cppkeywords.put(Keywords.cDELETE, IToken.t_delete);
cppkeywords.put(Keywords.cDYNAMIC_CAST, IToken.t_dynamic_cast);
cppkeywords.put(Keywords.cEXPLICIT, IToken.t_explicit);
cppkeywords.put(Keywords.cEXPORT, IToken.t_export);
cppkeywords.put(Keywords.cFALSE, IToken.t_false);
cppkeywords.put(Keywords.cFRIEND, IToken.t_friend);
cppkeywords.put(Keywords.cMUTABLE, IToken.t_mutable);
cppkeywords.put(Keywords.cNAMESPACE, IToken.t_namespace);
cppkeywords.put(Keywords.cNEW, IToken.t_new);
cppkeywords.put(Keywords.cNOEXCEPT, IToken.t_noexcept);
cppkeywords.put(Keywords.cNULLPTR, IToken.t_nullptr);
cppkeywords.put(Keywords.cOPERATOR, IToken.t_operator);
cppkeywords.put(Keywords.cPRIVATE, IToken.t_private);
cppkeywords.put(Keywords.cPROTECTED, IToken.t_protected);
cppkeywords.put(Keywords.cPUBLIC, IToken.t_public);
cppkeywords.put(Keywords.cREINTERPRET_CAST, IToken.t_reinterpret_cast);
cppkeywords.put(Keywords.cOPERATOR, IToken.t_operator);
cppkeywords.put(Keywords.cPRIVATE, IToken.t_private);
cppkeywords.put(Keywords.cPROTECTED, IToken.t_protected);
cppkeywords.put(Keywords.cPUBLIC, IToken.t_public);
cppkeywords.put(Keywords.cREINTERPRET_CAST, IToken.t_reinterpret_cast);
cppkeywords.put(Keywords.cSTATIC_ASSERT, IToken.t_static_assert);
cppkeywords.put(Keywords.cSTATIC_CAST, IToken.t_static_cast);
cppkeywords.put(Keywords.cTEMPLATE, IToken.t_template);
cppkeywords.put(Keywords.cTHIS, IToken.t_this);
cppkeywords.put(Keywords.cTHROW, IToken.t_throw);
cppkeywords.put(Keywords.cTRUE, IToken.t_true);
cppkeywords.put(Keywords.cTRY, IToken.t_try);
cppkeywords.put(Keywords.cTYPEID, IToken.t_typeid);
cppkeywords.put(Keywords.cTYPENAME, IToken.t_typename);
cppkeywords.put(Keywords.cUSING, IToken.t_using);
cppkeywords.put(Keywords.cVIRTUAL, IToken.t_virtual);
cppkeywords.put(Keywords.cWCHAR_T, IToken.t_wchar_t);
cppkeywords.put(Keywords.cSTATIC_CAST, IToken.t_static_cast);
cppkeywords.put(Keywords.cTEMPLATE, IToken.t_template);
cppkeywords.put(Keywords.cTHIS, IToken.t_this);
cppkeywords.put(Keywords.cTHREAD_LOCAL, IToken.t_thread_local);
cppkeywords.put(Keywords.cTHROW, IToken.t_throw);
cppkeywords.put(Keywords.cTRUE, IToken.t_true);
cppkeywords.put(Keywords.cTRY, IToken.t_try);
cppkeywords.put(Keywords.cTYPEID, IToken.t_typeid);
cppkeywords.put(Keywords.cTYPENAME, IToken.t_typename);
cppkeywords.put(Keywords.cUSING, IToken.t_using);
cppkeywords.put(Keywords.cVIRTUAL, IToken.t_virtual);
cppkeywords.put(Keywords.cWCHAR_T, IToken.t_wchar_t);
// C++ operator alternative
cppkeywords.put(Keywords.cAND, IToken.tAND);
cppkeywords.put(Keywords.cAND_EQ, IToken.tAMPERASSIGN);
cppkeywords.put(Keywords.cBITAND, IToken.tAMPER);
cppkeywords.put(Keywords.cBITOR, IToken.tBITOR);
cppkeywords.put(Keywords.cCOMPL, IToken.tBITCOMPLEMENT);
cppkeywords.put(Keywords.cNOT, IToken.tNOT);
cppkeywords.put(Keywords.cNOT_EQ, IToken.tNOTEQUAL);
cppkeywords.put(Keywords.cOR, IToken.tOR);
cppkeywords.put(Keywords.cOR_EQ, IToken.tBITORASSIGN);
cppkeywords.put(Keywords.cXOR, IToken.tXOR);
cppkeywords.put(Keywords.cXOR_EQ, IToken.tXORASSIGN);
cppkeywords.put(Keywords.cAND, IToken.tAND);
cppkeywords.put(Keywords.cAND_EQ, IToken.tAMPERASSIGN);
cppkeywords.put(Keywords.cBITAND, IToken.tAMPER);
cppkeywords.put(Keywords.cBITOR, IToken.tBITOR);
cppkeywords.put(Keywords.cCOMPL, IToken.tBITCOMPLEMENT);
cppkeywords.put(Keywords.cNOT, IToken.tNOT);
cppkeywords.put(Keywords.cNOT_EQ, IToken.tNOTEQUAL);
cppkeywords.put(Keywords.cOR, IToken.tOR);
cppkeywords.put(Keywords.cOR_EQ, IToken.tBITORASSIGN);
cppkeywords.put(Keywords.cXOR, IToken.tXOR);
cppkeywords.put(Keywords.cXOR_EQ, IToken.tXORASSIGN);
}
public static void addKeywordsPreprocessor(CharArrayIntMap ppKeywords) {
// Preprocessor keywords
ppKeywords.put(Keywords.cIF, IPreprocessorDirective.ppIf);
ppKeywords.put(Keywords.cIFDEF, IPreprocessorDirective.ppIfdef);
ppKeywords.put(Keywords.cIFNDEF, IPreprocessorDirective.ppIfndef);
ppKeywords.put(Keywords.cELIF, IPreprocessorDirective.ppElif);
ppKeywords.put(Keywords.cELSE, IPreprocessorDirective.ppElse);
ppKeywords.put(Keywords.cENDIF, IPreprocessorDirective.ppEndif);
ppKeywords.put(Keywords.cINCLUDE, IPreprocessorDirective.ppInclude);
ppKeywords.put(Keywords.cDEFINE, IPreprocessorDirective.ppDefine);
ppKeywords.put(Keywords.cUNDEF, IPreprocessorDirective.ppUndef);
ppKeywords.put(Keywords.cERROR, IPreprocessorDirective.ppError);
ppKeywords.put(Keywords.cPRAGMA, IPreprocessorDirective.ppPragma);
ppKeywords.put(Keywords.cIF, IPreprocessorDirective.ppIf);
ppKeywords.put(Keywords.cIFDEF, IPreprocessorDirective.ppIfdef);
ppKeywords.put(Keywords.cIFNDEF, IPreprocessorDirective.ppIfndef);
ppKeywords.put(Keywords.cELIF, IPreprocessorDirective.ppElif);
ppKeywords.put(Keywords.cELSE, IPreprocessorDirective.ppElse);
ppKeywords.put(Keywords.cENDIF, IPreprocessorDirective.ppEndif);
ppKeywords.put(Keywords.cINCLUDE, IPreprocessorDirective.ppInclude);
ppKeywords.put(Keywords.cDEFINE, IPreprocessorDirective.ppDefine);
ppKeywords.put(Keywords.cUNDEF, IPreprocessorDirective.ppUndef);
ppKeywords.put(Keywords.cERROR, IPreprocessorDirective.ppError);
ppKeywords.put(Keywords.cPRAGMA, IPreprocessorDirective.ppPragma);
ppKeywords.put(Keywords.cLINE, IPreprocessorDirective.ppIgnore);
}
}

View file

@ -162,5 +162,4 @@ public class CharArrayObjectMap <T> extends CharTable {
System.arraycopy(valueTable, 0, values, 0, values.length);
return values;
}
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Niefer (IBM Corporation) - Initial API and implementation
* Andrew Niefer (IBM Corporation) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.util;
@ -15,47 +15,47 @@ import java.util.List;
public class CharArraySet extends CharTable {
public static final CharArraySet EMPTY_SET = new CharArraySet( 0 ){
public static final CharArraySet EMPTY_SET = new CharArraySet(0) {
@Override
public Object clone() { return this; }
public Object clone() { return this; }
@Override
public List<char[]> toList() { return Collections.emptyList(); }
public List<char[]> toList() { return Collections.emptyList(); }
@Override
public void put( char[] key ) { throw new UnsupportedOperationException(); }
public void put(char[] key) { throw new UnsupportedOperationException(); }
@Override
public void addAll( List<char[]> list ) { throw new UnsupportedOperationException(); }
public void addAll(List<char[]> list) { throw new UnsupportedOperationException(); }
@Override
public void addAll( CharArraySet set ) { throw new UnsupportedOperationException(); }
public void addAll(CharArraySet set) { throw new UnsupportedOperationException(); }
};
public CharArraySet(int initialSize) {
super(initialSize);
}
public void put(char[] key ){
public void put(char[] key) {
addIndex(key);
}
public void addAll( List<char[]> list ){
if( list == null )
public void addAll(List<char[]> list) {
if (list == null)
return;
int size = list.size();
for( int i = 0; i < size; i++ ){
addIndex( list.get( i ) );
for (int i = 0; i < size; i++) {
addIndex(list.get(i));
}
}
public void addAll( CharArraySet set ){
if( set == null )
public void addAll(CharArraySet set) {
if (set == null)
return;
int size = set.size();
for( int i = 0; i < size; i++ ){
addIndex( set.keyAt( i ) );
for (int i = 0; i < size; i++) {
addIndex(set.keyAt(i));
}
}
final public boolean remove( char[] key ) {
final public boolean remove(char[] key) {
int i = lookup(key);
if (i < 0)
return false;
@ -65,11 +65,11 @@ public class CharArraySet extends CharTable {
}
@Override
final public void clear(){
for( int i = 0; i < keyTable.length; i++ ){
final public void clear() {
for (int i = 0; i < keyTable.length; i++) {
keyTable[i] = null;
hashTable[ 2*i ] = 0;
hashTable[ 2*i + 1 ] = 0;
hashTable[2 * i] = 0;
hashTable[2 * i + 1] = 0;
nextTable[i] = 0;
}
currEntry = -1;

View file

@ -291,7 +291,7 @@ public class CharArrayUtils {
return -1;
}
final static public char[] trim(char[] chars) {
static final public char[] trim(char[] chars) {
if (chars == null)
return null;
@ -308,7 +308,7 @@ public class CharArrayUtils {
return chars;
}
final static public char[] lastSegment(char[] array, char[] separator) {
static final public char[] lastSegment(char[] array, char[] separator) {
int pos = lastIndexOf(separator, array);
if (pos < 0)
return array;

View file

@ -10,7 +10,6 @@
* Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian)
*******************************************************************************/
package org.eclipse.cdt.core.parser.util;
import java.util.ArrayList;
@ -18,7 +17,6 @@ import java.util.List;
/**
* @author ddaoust
*
*/
public class CharTable extends HashTable {
protected char[][] keyTable;
@ -39,12 +37,12 @@ public class CharTable extends HashTable {
@Override
public void clear() {
super.clear();
for( int i = 0; i < capacity(); i++ )
for (int i = 0; i < capacity(); i++)
keyTable[i] = null;
}
@Override
public Object clone(){
public Object clone() {
CharTable newTable = (CharTable) super.clone();
int size = capacity();
@ -59,53 +57,49 @@ public class CharTable extends HashTable {
}
@Override
protected final int hash( int pos ){
protected final int hash(int pos) {
return hash(keyTable[pos], 0, keyTable[pos].length);
}
protected final int hash( char[] obj ){
return hash( obj, 0, obj.length );
protected final int hash(char[] obj) {
return hash(obj, 0, obj.length);
}
protected final int addIndex(char[] buffer ) {
protected final int addIndex(char[] buffer) {
return addIndex(buffer, 0, buffer.length);
}
public final int addIndex(char[] buffer, int start, int len) {
if (hashTable != null)
{
if (hashTable != null) {
int hash = hash(buffer, start, len);
int pos = lookup(buffer, start, len, hash);
if (pos != -1)
return pos;
// key is not here, add it.
if( (currEntry + 1) >= capacity()) {
if ((currEntry + 1) >= capacity()) {
resize();
hash = hash(buffer, start, len);
}
currEntry++;
keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len);
linkIntoHashTable(currEntry, hash);
}
else
{
} else {
int pos = lookup(buffer, start, len);
if (pos != -1)
return pos;
// key is not here, add it.
if( (currEntry + 1) >= capacity()) {
if ((currEntry + 1) >= capacity()) {
resize();
if( capacity() > minHashSize ){
if (capacity() > minHashSize) {
//if we grew from list to hash, then recurse and add as a hashtable
return addIndex( buffer, start, len );
return addIndex(buffer, start, len);
}
}
currEntry++;
keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len);
}
return currEntry;
}
protected void removeEntry(int i) {
@ -120,17 +114,17 @@ public class CharTable extends HashTable {
removeEntry(i, hash);
}
public List<char[]> toList(){
List<char[]> list = new ArrayList<char[]>( size() );
public List<char[]> toList() {
List<char[]> list = new ArrayList<char[]>(size());
int size = size();
for( int i = 0; i < size; i++ ){
list.add( keyAt( i ) );
for (int i = 0; i < size; i++) {
list.add(keyAt(i));
}
return list;
}
public final char[] keyAt( int i ){
if( i < 0 || i > currEntry )
public final char[] keyAt(int i) {
if (i < 0 || i > currEntry)
return null;
return keyTable[ i ];
@ -140,25 +134,25 @@ public class CharTable extends HashTable {
return lookup(key, start, len) != -1;
}
public final boolean containsKey(char[] key){
public final boolean containsKey(char[] key) {
return lookup(key) != -1;
}
public final char[] findKey( char[] buffer, int start, int len ){
int idx = lookup( buffer, start, len );
if( idx == -1 )
public final char[] findKey(char[] buffer, int start, int len) {
int idx = lookup(buffer, start, len);
if (idx == -1)
return null;
return keyTable[ idx ];
}
public int lookup(char[] buffer ){
public int lookup(char[] buffer) {
return lookup(buffer, 0, buffer.length);
}
protected final int lookup(char[] buffer, int start, int len) {
if (hashTable != null)
return lookup(buffer, start, len, hash(buffer, start, len) );
return lookup(buffer, start, len, hash(buffer, start, len));
for (int i = 0; i <= currEntry; i++) {
if (CharArrayUtils.equals(buffer, start, len, keyTable[i]))
return i;
@ -182,9 +176,9 @@ public class CharTable extends HashTable {
return -1;
}
public Object [] keyArray(){
Object [] keys = new Object[ size() ];
System.arraycopy( keyTable, 0, keys, 0, keys.length );
public Object[] keyArray() {
Object[] keys = new Object[ size() ];
System.arraycopy(keyTable, 0, keys, 0, keys.length);
return keys;
}
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -19,13 +19,14 @@ import org.eclipse.cdt.internal.core.model.ASTStringUtil;
* Base for all c++ declaration specifiers
*/
public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPASTDeclSpecifier {
private boolean friend;
private boolean inline;
private boolean isConst;
private boolean isConstexpr;
private boolean isVolatile;
private boolean isRestrict;
private int sc;
private boolean isThreadLocal;
private boolean virtual;
private boolean explicit;
@ -45,6 +46,17 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
sc = storageClass;
}
@Override
public boolean isThreadLocal() {
return isThreadLocal;
}
@Override
public void setThreadLocal(boolean value) {
assertNotFrozen();
isThreadLocal = value;
}
@Override
public boolean isConst() {
return isConst;
@ -56,6 +68,17 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
isConst = value;
}
@Override
public boolean isConstexpr() {
return isConstexpr;
}
@Override
public void setConstexpr(boolean value) {
assertNotFrozen();
isConstexpr = value;
}
@Override
public boolean isVolatile() {
return isVolatile;
@ -117,18 +140,19 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
this.explicit = value;
}
protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) {
other.friend = friend;
other.inline = inline;
other.isConst = isConst;
other.isVolatile = isVolatile;
other.isRestrict= isRestrict;
other.virtual = virtual;
other.explicit = explicit;
other.sc = sc;
other.setOffsetAndLength(this);
}
protected <T extends CPPASTBaseDeclSpecifier> T copy(T copy, CopyStyle style) {
copy.friend = friend;
copy.inline = inline;
copy.isConst = isConst;
copy.isConstexpr = isConstexpr;
copy.isVolatile = isVolatile;
copy.isRestrict= isRestrict;
copy.virtual = virtual;
copy.explicit = explicit;
copy.sc = sc;
return super.copy(copy, style);
}
/**
* Provided for debugging purposes, only.
*/

View file

@ -61,16 +61,11 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
public CPPASTCompositeTypeSpecifier copy(CopyStyle style) {
CPPASTCompositeTypeSpecifier copy =
new CPPASTCompositeTypeSpecifier(fKey, fName == null ? null : fName.copy(style));
copyBaseDeclSpec(copy);
for (IASTDeclaration member : getMembers())
copy.addMemberDeclaration(member == null ? null : member.copy(style));
for (ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers())
copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy(style));
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return super.copy(copy, style);
}
@Override

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
* IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -27,7 +27,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
*/
public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier
implements ICPPASTElaboratedTypeSpecifier, IASTInternalNameOwner {
private int kind;
private IASTName name;
@ -46,13 +45,9 @@ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier
@Override
public CPPASTElaboratedTypeSpecifier copy(CopyStyle style) {
CPPASTElaboratedTypeSpecifier copy = new CPPASTElaboratedTypeSpecifier(kind, name == null
? null : name.copy(style));
copyBaseDeclSpec(copy);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
CPPASTElaboratedTypeSpecifier copy =
new CPPASTElaboratedTypeSpecifier(kind, name == null ? null : name.copy(style));
return super.copy(copy, style);
}
@Override

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -24,16 +24,15 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalEnumerationSpecifier
*/
public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
implements IASTInternalEnumerationSpecifier, ICPPASTEnumerationSpecifier {
private boolean fIsScoped;
private boolean fIsOpaque;
private IASTName fName;
private ICPPASTDeclSpecifier fBaseType;
private IASTEnumerator[] fItems = null;
private int fItemPos=-1;
private IASTEnumerator[] fItems;
private int fItemPos= -1;
private boolean fValuesComputed= false;
private boolean fValuesComputed;
private CPPEnumScope fScope;
public CPPASTEnumerationSpecifier() {
@ -52,16 +51,14 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
@Override
public CPPASTEnumerationSpecifier copy(CopyStyle style) {
CPPASTEnumerationSpecifier copy = new CPPASTEnumerationSpecifier(fIsScoped, fName == null
? null : fName.copy(style), fBaseType == null ? null : fBaseType.copy(style));
CPPASTEnumerationSpecifier copy =
new CPPASTEnumerationSpecifier(fIsScoped, fName == null ? null : fName.copy(style),
fBaseType == null ? null : fBaseType.copy(style));
copy.fIsOpaque = fIsOpaque;
for (IASTEnumerator enumerator : getEnumerators())
for (IASTEnumerator enumerator : getEnumerators()) {
copy.addEnumerator(enumerator == null ? null : enumerator.copy(style));
copyBaseDeclSpec(copy);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return super.copy(copy, style);
}
@Override

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Bryan Wilkinson (QNX)
* John Camelon (IBM) - Initial API and implementation
* Bryan Wilkinson (QNX)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -26,12 +26,10 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
ICPPASTNamedTypeSpecifier, ICPPASTCompletionContext {
public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier
implements ICPPASTNamedTypeSpecifier, ICPPASTCompletionContext {
private boolean typename;
private IASTName name;
public CPPASTNamedTypeSpecifier() {
}
@ -47,14 +45,10 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
@Override
public CPPASTNamedTypeSpecifier copy(CopyStyle style) {
CPPASTNamedTypeSpecifier copy = new CPPASTNamedTypeSpecifier(name == null ? null
: name.copy(style));
copyBaseDeclSpec(copy);
CPPASTNamedTypeSpecifier copy =
new CPPASTNamedTypeSpecifier(name == null ? null : name.copy(style));
copy.typename = typename;
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return super.copy(copy, style);
}
@Override
@ -73,7 +67,6 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
return name;
}
@Override
public void setName(IASTName name) {
assertNotFrozen();

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -18,16 +18,16 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTSimpleDeclSpecifier,
IASTAmbiguityParent {
public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
implements ICPPASTSimpleDeclSpecifier, IASTAmbiguityParent {
private int type;
private boolean isSigned;
private boolean isUnsigned;
private boolean isShort;
private boolean isLong;
private boolean isLonglong;
private boolean isComplex=false;
private boolean isImaginary=false;
private boolean isComplex;
private boolean isImaginary;
private IASTExpression fDeclTypeExpression;
@Override
@ -37,27 +37,22 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
@Override
public CPPASTSimpleDeclSpecifier copy(CopyStyle style) {
CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return copy(new CPPASTSimpleDeclSpecifier(), style);
}
protected void copySimpleDeclSpec(CPPASTSimpleDeclSpecifier other, CopyStyle style) {
copyBaseDeclSpec(other);
other.type = type;
other.isSigned = isSigned;
other.isUnsigned = isUnsigned;
other.isShort = isShort;
other.isLong = isLong;
other.isLonglong= isLonglong;
other.isComplex= isComplex;
other.isImaginary= isImaginary;
protected <T extends CPPASTSimpleDeclSpecifier> T copy(T copy, CopyStyle style) {
copy.type = type;
copy.isSigned = isSigned;
copy.isUnsigned = isUnsigned;
copy.isShort = isShort;
copy.isLong = isLong;
copy.isLonglong= isLonglong;
copy.isComplex= isComplex;
copy.isImaginary= isImaginary;
if (fDeclTypeExpression != null) {
other.setDeclTypeExpression(fDeclTypeExpression.copy(style));
copy.setDeclTypeExpression(fDeclTypeExpression.copy(style));
}
return super.copy(copy, style);
}
/**

View file

@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
* The result of instantiating a class template.
*/
public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance {
private ICPPTemplateArgument[] arguments;
private final ICPPTemplateArgument[] arguments;
public CPPClassInstance(ICPPClassType orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
super(orig, owner, argMap);
@ -52,6 +52,8 @@ public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemp
protected ICPPClassSpecializationScope getSpecializationScope() {
// An instance with a declaration has no specialization scope.
checkForDefinition();
if (getDefinition() != null)
return null;
final IASTNode[] decls = getDeclarations();
if (decls != null && decls.length > 0 && decls[0] != null)
return null;

View file

@ -2593,11 +2593,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
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 final static int INLINE= 0x1, CONST= 0x2, CONSTEXPR= 0x4, RESTRICT= 0x8, VOLATILE= 0x10,
SHORT= 0x20, UNSIGNED= 0x40, SIGNED= 0x80, COMPLEX= 0x100, IMAGINARY= 0x200,
VIRTUAL= 0x400, EXPLICIT= 0x800, FRIEND= 0x1000, THREAD_LOCAL= 0x2000;
private static final int FORBID_IN_EMPTY_DECLSPEC =
CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND;
CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND | THREAD_LOCAL;
/**
@ -2605,14 +2605,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* the ANSI C++ specification.
* declSpecifier :
* "register" | "static" | "extern" | "mutable" |
* "inline" | "virtual" | "explicit" |
* "typedef" | "friend" |
* "const" | "volatile" |
* "inline" | "virtual" | "explicit" |
* "typedef" | "friend" | "constexpr" |
* "const" | "volatile" |
* "short" | "long" | "signed" | "unsigned" | "int" |
* "char" | "wchar_t" | "bool" | "float" | "double" | "void" |
* "auto" |
* ("typename")? name |
* { "class" | "struct" | "union" } classSpecifier |
* ("typename")? name |
* { "class" | "struct" | "union" } classSpecifier |
* {"enum"} enumSpecifier
*/
@Override
@ -2682,6 +2682,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
storageClass = IASTDeclSpecifier.sc_extern;
endOffset= consume().getEndOffset();
break;
case IToken.t_thread_local:
options |= THREAD_LOCAL; // thread_local may appear with static or extern
endOffset= consume().getEndOffset();
break;
case IToken.t_mutable:
storageClass = IASTDeclSpecifier.sc_mutable;
endOffset= consume().getEndOffset();
@ -2707,6 +2711,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
options |= FRIEND;
endOffset= consume().getEndOffset();
break;
case IToken.t_constexpr:
options |= CONSTEXPR;
endOffset= consume().getEndOffset();
break;
// type specifier
case IToken.t_const:
options |= CONST;
@ -3007,12 +3015,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private void configureDeclSpec(ICPPASTDeclSpecifier declSpec, int storageClass, int options) {
declSpec.setStorageClass(storageClass);
declSpec.setConst((options & CONST) != 0);
declSpec.setConstexpr((options & CONSTEXPR) != 0);
declSpec.setVolatile((options & VOLATILE) != 0);
declSpec.setInline((options & INLINE) != 0);
declSpec.setFriend((options & FRIEND) != 0);
declSpec.setVirtual((options & VIRTUAL) != 0);
declSpec.setExplicit((options & EXPLICIT) != 0);
declSpec.setRestrict((options & RESTRICT) != 0);
declSpec.setThreadLocal((options & THREAD_LOCAL) != 0);
}
private ICPPASTDeclSpecifier enumDeclaration(boolean allowOpaque) throws BacktrackException, EndOfFileException {

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
* @deprecated Replaced by {@link CPPASTSimpleDeclSpecifier}
*/
@Deprecated
public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier implements
IGPPASTSimpleDeclSpecifier {
public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
implements IGPPASTSimpleDeclSpecifier {
public GPPASTSimpleDeclSpecifier() {
}
@ -36,12 +36,7 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier impleme
@Override
public GPPASTSimpleDeclSpecifier copy(CopyStyle style) {
GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier();
copySimpleDeclSpec(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
return copy(new GPPASTSimpleDeclSpecifier(), style);
}
@Override

View file

@ -250,7 +250,7 @@ class BaseClassLookup {
continue;
final IName nbaseName = nbase.getBaseClassSpecifierName();
int cmp= baseName == null ? -1 : CPPSemantics.compareByRelevance(data, baseName, nbaseName);
int cmp= baseName == null ? 0 : CPPSemantics.compareByRelevance(data, baseName, nbaseName);
if (cmp <= 0) {
if (cmp < 0) {
selectedBases.clear();

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2012 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
@ -8,6 +8,7 @@
*
* Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@ -44,22 +45,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @author Emanuel Graf IFS
*/
public class DeclSpecWriter extends NodeWriter {
private static final String MUTABLE = "mutable "; //$NON-NLS-1$
private static final String _COMPLEX = "_Complex "; //$NON-NLS-1$
private static final String LONG_LONG = "long long "; //$NON-NLS-1$
private static final String REGISTER = "register "; //$NON-NLS-1$
private static final String AUTO = "auto "; //$NON-NLS-1$
private static final String TYPEDEF = "typedef "; //$NON-NLS-1$
private static final String UNION = "union"; //$NON-NLS-1$
private static final String STRUCT = "struct"; //$NON-NLS-1$
private static final String CLASS = "class"; //$NON-NLS-1$
private static final String FRIEND = "friend "; //$NON-NLS-1$
private static final String EXPLICIT = "explicit "; //$NON-NLS-1$
private static final String VIRTUAL = "virtual "; //$NON-NLS-1$
private static final String UNION_SPACE = "union "; //$NON-NLS-1$
private static final String STRUCT_SPACE = "struct "; //$NON-NLS-1$
private static final String ENUM = "enum "; //$NON-NLS-1$
private static final String _BOOL = "_Bool"; //$NON-NLS-1$
public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
@ -88,23 +73,23 @@ public class DeclSpecWriter extends NodeWriter {
case IASTSimpleDeclSpecifier.t_unspecified:
return ""; //$NON-NLS-1$
case IASTSimpleDeclSpecifier.t_void:
return VOID;
return Keywords.VOID;
case IASTSimpleDeclSpecifier.t_char:
return CHAR;
return Keywords.CHAR;
case IASTSimpleDeclSpecifier.t_int:
return INT;
return Keywords.INT;
case IASTSimpleDeclSpecifier.t_float:
return FLOAT;
return Keywords.FLOAT;
case IASTSimpleDeclSpecifier.t_double:
return DOUBLE;
return Keywords.DOUBLE;
case IASTSimpleDeclSpecifier.t_bool:
return isCpp ? CPP_BOOL : _BOOL;
return isCpp ? Keywords.BOOL : Keywords._BOOL;
case IASTSimpleDeclSpecifier.t_wchar_t:
if (isCpp)
return WCHAR_T;
return Keywords.WCHAR_T;
break;
case IASTSimpleDeclSpecifier.t_char16_t:
if (isCpp)
@ -133,7 +118,7 @@ public class DeclSpecWriter extends NodeWriter {
private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) {
if (cDeclSpec.isRestrict()) {
scribe.print(RESTRICT);
scribe.printStringSpace(Keywords.RESTRICT);
}
if (cDeclSpec instanceof ICASTCompositeTypeSpecifier) {
@ -151,7 +136,7 @@ public class DeclSpecWriter extends NodeWriter {
private void writeNamedTypeSpecifier(ICPPASTNamedTypeSpecifier namedSpc) {
if (namedSpc.isTypename()) {
scribe.print(TYPENAME);
scribe.printStringSpace(Keywords.TYPENAME);
}
namedSpc.getName().accept(visitor);
}
@ -161,20 +146,20 @@ public class DeclSpecWriter extends NodeWriter {
}
private void writeElaboratedTypeSec(IASTElaboratedTypeSpecifier elabType) {
scribe.print(getElabTypeString(elabType.getKind()));
scribe.printStringSpace(getElabTypeString(elabType.getKind()));
elabType.getName().accept(visitor);
}
private String getElabTypeString(int kind) {
switch (kind) {
case IASTElaboratedTypeSpecifier.k_enum:
return ENUM;
return Keywords.ENUM;
case IASTElaboratedTypeSpecifier.k_struct:
return STRUCT_SPACE;
return Keywords.STRUCT;
case IASTElaboratedTypeSpecifier.k_union:
return UNION_SPACE;
return Keywords.UNION;
case ICPPASTElaboratedTypeSpecifier.k_class:
return CLASS_SPACE;
return Keywords.CLASS;
default:
throw new IllegalArgumentException("Unknown elaborated type: " + kind); //$NON-NLS-1$
@ -183,16 +168,22 @@ public class DeclSpecWriter extends NodeWriter {
private void writeCPPDeclSpec(ICPPASTDeclSpecifier cppDelcSpec) {
if (cppDelcSpec.isVirtual()) {
scribe.print(VIRTUAL);
scribe.printStringSpace(Keywords.VIRTUAL);
}
if (cppDelcSpec.isConstexpr()) {
scribe.printStringSpace(Keywords.CONSTEXPR);
}
if (cppDelcSpec.isExplicit()) {
scribe.print(EXPLICIT);
scribe.printStringSpace(Keywords.EXPLICIT);
}
if (cppDelcSpec.isFriend()) {
scribe.print(FRIEND);
scribe.printStringSpace(Keywords.FRIEND);
}
if (cppDelcSpec.isThreadLocal()) {
scribe.printStringSpace(Keywords.THREAD_LOCAL);
}
if (cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
scribe.print(MUTABLE);
scribe.printStringSpace(Keywords.MUTABLE);
}
if (cppDelcSpec instanceof ICPPASTCompositeTypeSpecifier) {
@ -209,7 +200,7 @@ public class DeclSpecWriter extends NodeWriter {
}
private void writeEnumSpec(IASTEnumerationSpecifier enumSpec) {
scribe.print(ENUM);
scribe.printStringSpace(Keywords.ENUM);
enumSpec.getName().accept(visitor);
scribe.print('{');
scribe.printSpace();
@ -284,13 +275,13 @@ public class DeclSpecWriter extends NodeWriter {
private void writeBaseSpecifiers(ICPPASTBaseSpecifier specifier) {
switch (specifier.getVisibility()) {
case ICPPASTBaseSpecifier.v_public:
scribe.printStringSpace(PUBLIC);
scribe.printStringSpace(Keywords.PUBLIC);
break;
case ICPPASTBaseSpecifier.v_protected:
scribe.printStringSpace(PROTECTED);
scribe.printStringSpace(Keywords.PROTECTED);
break;
case ICPPASTBaseSpecifier.v_private:
scribe.printStringSpace(PRIVATE);
scribe.printStringSpace(Keywords.PRIVATE);
break;
}
specifier.getName().accept(visitor);
@ -302,7 +293,7 @@ public class DeclSpecWriter extends NodeWriter {
}
switch (key) {
case ICPPASTCompositeTypeSpecifier.k_class:
return CLASS;
return Keywords.CLASS;
default:
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
}
@ -311,9 +302,9 @@ public class DeclSpecWriter extends NodeWriter {
private String getCompositeTypeString(int key) {
switch (key) {
case IASTCompositeTypeSpecifier.k_struct:
return STRUCT;
return Keywords.STRUCT;
case IASTCompositeTypeSpecifier.k_union:
return UNION;
return Keywords.UNION;
default:
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
}
@ -321,30 +312,30 @@ public class DeclSpecWriter extends NodeWriter {
private void writeDeclSpec(IASTDeclSpecifier declSpec) {
if (declSpec.isInline()) {
scribe.print(INLINE);
scribe.printStringSpace(Keywords.INLINE);
}
switch (declSpec.getStorageClass()) {
case IASTDeclSpecifier.sc_typedef:
scribe.print(TYPEDEF);
scribe.printStringSpace(Keywords.TYPEDEF);
break;
case IASTDeclSpecifier.sc_extern:
scribe.print(EXTERN);
scribe.printStringSpace(Keywords.EXTERN);
break;
case IASTDeclSpecifier.sc_static:
scribe.print(STATIC);
scribe.printStringSpace(Keywords.STATIC);
break;
case IASTDeclSpecifier.sc_auto:
scribe.print(AUTO);
scribe.printStringSpace(Keywords.AUTO);
break;
case IASTDeclSpecifier.sc_register:
scribe.print(REGISTER);
scribe.printStringSpace(Keywords.REGISTER);
break;
}
if (declSpec.isConst()) {
scribe.printStringSpace(CONST);
scribe.printStringSpace(Keywords.CONST);
}
if (declSpec.isVolatile()) {
scribe.printStringSpace(VOLATILE);
scribe.printStringSpace(Keywords.VOLATILE);
}
}
@ -363,22 +354,23 @@ public class DeclSpecWriter extends NodeWriter {
private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) {
if (simpDeclSpec.isSigned()) {
scribe.printStringSpace(SIGNED);
scribe.printStringSpace(Keywords.SIGNED);
} else if (simpDeclSpec.isUnsigned()) {
scribe.printStringSpace(UNSIGNED);
scribe.printStringSpace(Keywords.UNSIGNED);
}
if (simpDeclSpec.isShort()) {
scribe.printStringSpace(SHORT);
scribe.printStringSpace(Keywords.SHORT);
} else if (simpDeclSpec.isLong()) {
scribe.printStringSpace(LONG);
scribe.printStringSpace(Keywords.LONG);
} else if (simpDeclSpec.isLongLong()) {
scribe.print(LONG_LONG);
scribe.printStringSpace(Keywords.LONG);
scribe.printStringSpace(Keywords.LONG);
}
if (simpDeclSpec instanceof ICASTSimpleDeclSpecifier) {
ICASTSimpleDeclSpecifier cSimpDeclSpec = (ICASTSimpleDeclSpecifier) simpDeclSpec;
if (cSimpDeclSpec.isComplex()) {
scribe.print(_COMPLEX);
scribe.printStringSpace(Keywords._COMPLEX);
}
}
}

View file

@ -51,10 +51,7 @@ public class DeclarationWriter extends NodeWriter {
private static final String ASM_END = ")"; //$NON-NLS-1$
private static final String ASM_START = "asm("; //$NON-NLS-1$
private static final String TEMPLATE_DECLARATION = "template<"; //$NON-NLS-1$
private static final String EXPORT = "export "; //$NON-NLS-1$
private static final String TEMPLATE_SPECIALIZATION = "template <> "; //$NON-NLS-1$
private static final String NAMESPACE = "namespace "; //$NON-NLS-1$
private static final String USING = "using "; //$NON-NLS-1$
private boolean printSemicolon;
public DeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
@ -111,15 +108,15 @@ public class DeclarationWriter extends NodeWriter {
scribe.decrementIndentationLevel();
switch (visiblityLabel.getVisibility()) {
case ICPPASTVisibilityLabel.v_private:
scribe.print(PRIVATE);
scribe.print(Keywords.PRIVATE);
scribe.print(':');
break;
case ICPPASTVisibilityLabel.v_protected:
scribe.print(PROTECTED);
scribe.print(Keywords.PROTECTED);
scribe.print(':');
break;
case ICPPASTVisibilityLabel.v_public:
scribe.print(PUBLIC);
scribe.print(Keywords.PUBLIC);
scribe.print(':');
break;
default:
@ -129,15 +126,16 @@ public class DeclarationWriter extends NodeWriter {
}
private void writeUsingDirective(ICPPASTUsingDirective usingDirective) {
scribe.print(USING + NAMESPACE);
scribe.printStringSpace(Keywords.USING);
scribe.printStringSpace(Keywords.NAMESPACE);
usingDirective.getQualifiedName().accept(visitor);
scribe.printSemicolon();
}
private void writeUsingDeclaration(ICPPASTUsingDeclaration usingDeclaration) {
scribe.print(USING);
scribe.printStringSpace(Keywords.USING);
if (usingDeclaration.isTypename()) {
scribe.print(TYPENAME);
scribe.printStringSpace(Keywords.TYPENAME);
}
usingDeclaration.getName().accept(visitor);
scribe.printSemicolon();
@ -150,7 +148,7 @@ public class DeclarationWriter extends NodeWriter {
protected void writeTemplateDeclaration(ICPPASTTemplateDeclaration templateDeclaration) {
if (templateDeclaration.isExported()) {
scribe.print(EXPORT);
scribe.printStringSpace(Keywords.EXPORT);
}
scribe.print(TEMPLATE_DECLARATION);
ICPPASTTemplateParameter[] paraDecls = templateDeclaration.getTemplateParameters();
@ -172,7 +170,7 @@ public class DeclarationWriter extends NodeWriter {
}
private void writeNamespaceDefinition(ICPPASTNamespaceDefinition namespaceDefinition) {
scribe.print(NAMESPACE);
scribe.printStringSpace(Keywords.NAMESPACE);
namespaceDefinition.getName().accept(visitor);
if (!hasTrailingComments(namespaceDefinition.getName())) {
scribe.newLine();
@ -200,7 +198,7 @@ public class DeclarationWriter extends NodeWriter {
}
private void writeNamespaceAlias(ICPPASTNamespaceAlias namespaceAliasDefinition) {
scribe.print(NAMESPACE);
scribe.printStringSpace(Keywords.NAMESPACE);
namespaceAliasDefinition.getAlias().accept(visitor);
scribe.print(EQUALS);
namespaceAliasDefinition.getMappingName().accept(visitor);
@ -208,9 +206,8 @@ public class DeclarationWriter extends NodeWriter {
}
private void writeLinkageSpecification(ICPPASTLinkageSpecification linkageSpecification) {
scribe.print(EXTERN);
scribe.print(linkageSpecification.getLiteral());
scribe.printSpaces(1);
scribe.printStringSpace(Keywords.EXTERN);
scribe.printStringSpace(linkageSpecification.getLiteral());
IASTDeclaration[] declarations = linkageSpecification.getDeclarations();
if (declarations.length > 1) {
@ -230,17 +227,17 @@ public class DeclarationWriter extends NodeWriter {
private void writeExplicitTemplateInstantiation(ICPPASTExplicitTemplateInstantiation explicitTemplateInstantiation) {
switch(explicitTemplateInstantiation.getModifier()) {
case ICPPASTExplicitTemplateInstantiation.EXTERN:
scribe.print(EXTERN);
scribe.printStringSpace(Keywords.EXTERN);
break;
case ICPPASTExplicitTemplateInstantiation.INLINE:
scribe.print(INLINE);
scribe.printStringSpace(Keywords.INLINE);
break;
case ICPPASTExplicitTemplateInstantiation.STATIC:
scribe.print(STATIC);
scribe.printStringSpace(Keywords.STATIC);
break;
}
scribe.print(TEMPLATE);
scribe.printStringSpace(Keywords.TEMPLATE);
explicitTemplateInstantiation.getDeclaration().accept(visitor);
}

View file

@ -9,6 +9,7 @@
* Contributors:
* Institute for Software - initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@ -29,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
@ -41,7 +43,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
public class DeclaratorWriter extends NodeWriter {
private static final String AMPERSAND_AMPERSAND = "&&"; //$NON-NLS-1$
private static final String PURE_VIRTUAL = " = 0"; //$NON-NLS-1$
private static final String MUTABLE = "mutable"; //$NON-NLS-1$
private static final String ARROW_OPERATOR = "->"; //$NON-NLS-1$
public DeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
@ -128,15 +129,15 @@ public class DeclaratorWriter extends NodeWriter {
private void writeCppFunctionDeclarator(ICPPASTFunctionDeclarator funcDec) {
if (funcDec.isConst()) {
scribe.printSpace();
scribe.print(CONST);
scribe.print(Keywords.CONST);
}
if (funcDec.isVolatile()) {
scribe.printSpace();
scribe.print(VOLATILE);
scribe.print(Keywords.VOLATILE);
}
if (funcDec.isMutable()) {
scribe.printSpace();
scribe.print(MUTABLE);
scribe.print(Keywords.MUTABLE);
}
if (funcDec.isPureVirtual()) {
scribe.print(PURE_VIRTUAL);
@ -153,7 +154,7 @@ public class DeclaratorWriter extends NodeWriter {
protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec, IASTTypeId[] exceptions) {
if (exceptions != ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION) {
scribe.printSpace();
scribe.print(THROW);
scribe.printStringSpace(Keywords.THROW);
scribe.print('(');
writeNodeList(exceptions);
scribe.print(')');
@ -182,13 +183,13 @@ public class DeclaratorWriter extends NodeWriter {
}
if (operator.isConst()) {
scribe.printStringSpace(CONST);
scribe.printStringSpace(Keywords.CONST);
}
if (operator.isVolatile()) {
scribe.printStringSpace(VOLATILE);
scribe.printStringSpace(Keywords.VOLATILE);
}
if (operator.isRestrict()) {
scribe.print(RESTRICT);
scribe.printStringSpace(Keywords.RESTRICT);
}
}

View file

@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
@ -112,6 +113,7 @@ public class ExpressionWriter extends NodeWriter{
private static final String OPENING_SQUARE_BRACKET = "["; //$NON-NLS-1$
private static final String CLOSING_SQUARE_BRACKET = "]"; //$NON-NLS-1$
private static final String THIS = "this"; //$NON-NLS-1$
private static final String THROW = "throw "; //$NON-NLS-1$
private final MacroExpansionHandler macroHandler;
public ExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
@ -423,7 +425,7 @@ public class ExpressionWriter extends NodeWriter{
if (fieldRef instanceof ICPPASTFieldReference) {
ICPPASTFieldReference cppFieldRef = (ICPPASTFieldReference) fieldRef;
if (cppFieldRef.isTemplate()) {
scribe.print(TEMPLATE);
scribe.printStringSpace(Keywords.TEMPLATE);
}
}
fieldRef.getFieldName().accept(visitor);

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeParameter;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -58,7 +59,7 @@ public class NameWriter extends NodeWriter {
private void writeTempalteId(ICPPASTTemplateId tempId) {
if (needsTemplateQualifier(tempId)) {
scribe.print(TEMPLATE);
scribe.printStringSpace(Keywords.TEMPLATE);
}
scribe.print(tempId.getTemplateName().toString());
scribe.print('<');

View file

@ -30,31 +30,7 @@ public class NodeWriter {
protected NodeCommentMap commentMap;
protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$
protected static final String EQUALS = " = "; //$NON-NLS-1$
protected static final String RESTRICT = "restrict "; //$NON-NLS-1$
protected static final String TYPENAME = "typename "; //$NON-NLS-1$
protected static final String PUBLIC = "public"; //$NON-NLS-1$
protected static final String PRIVATE = "private"; //$NON-NLS-1$
protected static final String PROTECTED = "protected"; //$NON-NLS-1$
protected static final String CONST = "const"; //$NON-NLS-1$
protected static final String VOLATILE = "volatile"; //$NON-NLS-1$
protected static final String INLINE = "inline "; //$NON-NLS-1$
protected static final String EXTERN = "extern "; //$NON-NLS-1$
protected static final String STATIC = "static "; //$NON-NLS-1$
protected static final String THROW = "throw "; //$NON-NLS-1$
protected static final String SPACE_COLON_SPACE = " : "; //$NON-NLS-1$
protected static final String TEMPLATE = "template "; //$NON-NLS-1$
protected static final String DOUBLE = "double"; //$NON-NLS-1$
protected static final String FLOAT = "float"; //$NON-NLS-1$
protected static final String INT = "int"; //$NON-NLS-1$
protected static final String CHAR = "char"; //$NON-NLS-1$
protected static final String VOID = "void"; //$NON-NLS-1$
protected static final String WCHAR_T = "wchar_t"; //$NON-NLS-1$
protected static final String CPP_BOOL = "bool"; //$NON-NLS-1$
protected static final String LONG = "long"; //$NON-NLS-1$
protected static final String SHORT = "short"; //$NON-NLS-1$
protected static final String UNSIGNED = "unsigned"; //$NON-NLS-1$
protected static final String SIGNED = "signed"; //$NON-NLS-1$
protected static final String CLASS_SPACE = "class "; //$NON-NLS-1$
protected static final String VAR_ARGS = "..."; //$NON-NLS-1$
protected static final String COLON_COLON = "::"; //$NON-NLS-1$
protected static final String COLON_SPACE = ": "; //$NON-NLS-1$

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
@ -69,10 +70,10 @@ public class TemplateParameterWriter extends NodeWriter {
private void writeSimpleTypeTemplateParameter(ICPPASTSimpleTypeTemplateParameter simple) {
switch (simple.getParameterType()) {
case ICPPASTSimpleTypeTemplateParameter.st_class:
scribe.print(CLASS_SPACE);
scribe.printStringSpace(Keywords.CLASS);
break;
case ICPPASTSimpleTypeTemplateParameter.st_typename:
scribe.print(TYPENAME);
scribe.printStringSpace(Keywords.TYPENAME);
break;
}

View file

@ -242,11 +242,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
private boolean fHandledCompletion= false;
private boolean fSplitShiftRightOperator= false;
// state information
// State information
private final CharArrayMap<PreprocessorMacro> fMacroDictionary = new CharArrayMap<PreprocessorMacro>(512);
private final IMacroDictionary fMacroDictionaryFacade = new MacroDictionary();
private final LocationMap fLocationMap;
private CharArraySet fPreventInclusion= new CharArraySet(0);
private CharArraySet fPreventInclusion;
private CharArraySet fImports;
private final ScannerContext fRootContext;
protected ScannerContext fCurrentContext;
@ -1233,11 +1234,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
switch (type) {
case IPreprocessorDirective.ppImport:
case IPreprocessorDirective.ppInclude:
executeInclude(lexer, startOffset, false, fCurrentContext.getCodeState() == CodeState.eActive,
withinExpansion);
break;
case IPreprocessorDirective.ppInclude_next:
executeInclude(lexer, startOffset, true, fCurrentContext.getCodeState() == CodeState.eActive,
executeInclude(lexer, startOffset, type, fCurrentContext.getCodeState() == CodeState.eActive,
withinExpansion);
break;
case IPreprocessorDirective.ppDefine:
@ -1329,7 +1327,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
}
}
private void executeInclude(final Lexer lexer, int poundOffset, boolean include_next,
private void executeInclude(final Lexer lexer, int poundOffset, int includeType,
boolean active, boolean withinExpansion) throws OffsetLimitReachedException {
// Make sure to clear the extern include guard.
final char[] externGuard= fExternIncludeGuard;
@ -1409,13 +1407,29 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
return;
}
if (active && fCurrentContext.getDepth() == MAX_INCLUSION_DEPTH || fPreventInclusion.containsKey(headerName)) {
if (includeType == IPreprocessorDirective.ppImport) {
// Imports are executed only once.
// See http://gcc.gnu.org/onlinedocs/gcc-3.2/cpp/Obsolete-once-only-headers.html.
if (fImports != null && fImports.containsKey(headerName))
return;
if (active) {
if (fImports == null)
fImports = new CharArraySet(0);
fImports.put(headerName);
}
}
if ((active && fCurrentContext.getDepth() == MAX_INCLUSION_DEPTH) ||
(fPreventInclusion != null && fPreventInclusion.containsKey(headerName))) {
handleProblem(IProblem.PREPROCESSOR_EXCEEDS_MAXIMUM_INCLUSION_DEPTH,
lexer.getInputChars(poundOffset, condEndOffset), poundOffset, condEndOffset);
if (fPreventInclusion == null)
fPreventInclusion = new CharArraySet(0);
fPreventInclusion.put(headerName);
return;
}
boolean includeNext = includeType == IPreprocessorDirective.ppInclude_next;
final String includeDirective = new String(headerName);
if (!active) {
// Inactive include
@ -1429,7 +1443,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
// #endif
// When the extern guard matches we need to resolve the inclusion. We don't actually
// check whether the guard matches.
final IncludeResolution resolved= findInclusion(includeDirective, userInclude, include_next,
final IncludeResolution resolved= findInclusion(includeDirective, userInclude, includeNext,
getCurrentFilename(), createPathTester);
if (resolved != null) {
nominationDelegate = fFileContentProvider.isIncludedWithPragmaOnceSemantics(resolved.fLocation);
@ -1445,7 +1459,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
}
// Active include
final InternalFileContent fi= findInclusion(includeDirective, userInclude, include_next,
final InternalFileContent fi= findInclusion(includeDirective, userInclude, includeNext,
getCurrentFilename(), createCodeReaderTester);
if (fi == null) {
// Unresolved active include
@ -1824,10 +1838,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
switch (type) {
case IPreprocessorDirective.ppImport:
case IPreprocessorDirective.ppInclude:
executeInclude(lexer, ident.getOffset(), false, false, withinExpansion);
break;
case IPreprocessorDirective.ppInclude_next:
executeInclude(lexer, ident.getOffset(), true, false, withinExpansion);
executeInclude(lexer, ident.getOffset(), type, false, withinExpansion);
break;
case IPreprocessorDirective.ppIfdef:
return executeIfdef(lexer, pound.getOffset(), false, withinExpansion);

View file

@ -24,8 +24,8 @@ import org.eclipse.cdt.core.parser.util.CharArraySet;
* @since 5.0
*/
final class ScannerContext {
enum BranchKind {eIf, eElif, eElse, eEnd}
enum CodeState {eActive, eParseInactive, eSkipInactive}
enum BranchKind { eIf, eElif, eElse, eEnd }
enum CodeState { eActive, eParseInactive, eSkipInactive }
final static class Conditional {
private final CodeState fInitialState;
@ -52,7 +52,7 @@ final class ScannerContext {
private final ScannerContext fParent;
private final Lexer fLexer;
private Token fTokens;
private ArrayList<Conditional> fConditionals= null;
private ArrayList<Conditional> fConditionals;
private CodeState fCurrentState= CodeState.eActive;
private IncludeSearchPathElement fFoundOnPath;
private String fFoundViaDirective;
@ -60,7 +60,6 @@ final class ScannerContext {
private CharArrayObjectMap<char[]> fSignificantMacros;
private boolean fPragmaOnce;
private int fLoadedVersionCount;
/**
* @param ctx
@ -70,7 +69,7 @@ final class ScannerContext {
fLocationCtx= ctx;
fParent= parent;
fLexer= lexer;
fDepth = parent == null ? 0 : parent.fDepth+1;
fDepth = parent == null ? 0 : parent.fDepth + 1;
}
public ScannerContext(ILocationCtx ctx, ScannerContext parent, TokenList tokens) {
@ -131,7 +130,7 @@ final class ScannerContext {
}
// if we are not inside of an conditional there shouldn't be an #else, #elsif or #end
final int pos= fConditionals.size()-1;
final int pos= fConditionals.size() - 1;
if (pos < 0) {
return null;
}
@ -348,6 +347,11 @@ final class ScannerContext {
}
public void significantMacro(IMacroBinding macro) {
if (fCurrentState == CodeState.eParseInactive) {
// Macros in inactive code should not be considered significant to match behavior of indexer,
// which doesn't parse inactive code (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=370146).
return;
}
final char[] macroName= macro.getNameCharArray();
if (fInternalModifications != null && !fInternalModifications.containsKey(macroName)) {
final char[] expansion = macro.getExpansion();
@ -393,7 +397,7 @@ final class ScannerContext {
// Propagate significant macros to direct parent, if it is interested.
if (collector == fParent.fInternalModifications) {
final CharArrayObjectMap<char[]> significant = fParent.fSignificantMacros;
for (int i=0; i<fSignificantMacros.size(); i++) {
for (int i= 0; i < fSignificantMacros.size(); i++) {
final char[] name = fSignificantMacros.keyAt(i);
if (!collector.containsKey(name)) {
final char[] value= fSignificantMacros.getAt(i);
@ -425,6 +429,7 @@ final class ScannerContext {
}
return true;
}
@Override
public boolean visitUndefined(char[] macro) {
if (!fInternalModifications.containsKey(macro)) {
@ -432,6 +437,7 @@ final class ScannerContext {
}
return true;
}
@Override
public boolean visitDefined(char[] macro) {
if (!fInternalModifications.containsKey(macro)) {

View file

@ -49,8 +49,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
if (project != null) {
fIndexerSetupParticipant.notifyIndexerSetup(project);
}
}
else if (old != null && changedDefaultSettingConfiguration(old, act)) {
} else if (old != null && changedDefaultSettingConfiguration(old, act)) {
ICProject project= getProject(event);
if (project != null) {
fIndexManager.reindex(project);
@ -86,7 +85,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
// Check for a project that has been created by the new project wizard just
// just for the purpose of editing preferences (Advanced button)
ICProjectDescription desc= CProjectDescriptionManager.getInstance().getProjectDescription(project.getProject(), false, false);
return desc==null || !desc.isCdtProjectCreating();
return desc == null || !desc.isCdtProjectCreating();
}
private boolean completedProjectCreation(ICProjectDescription old, ICProjectDescription act) {

View file

@ -30,11 +30,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.index.IIndexName;
@ -140,10 +138,6 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
}
private IBinding getClassNameBinding() {
if (fBinding instanceof ICPPClassTemplatePartialSpecialization)
return ((ICPPClassTemplatePartialSpecialization) fBinding).getPrimaryClassTemplate();
if (fBinding instanceof ICPPSpecialization)
return ((ICPPSpecialization) fBinding).getSpecializedBinding();
return fBinding;
}

View file

@ -61,7 +61,7 @@ class PDOMCPPUsingDeclarationSpecialization extends PDOMCPPSpecialization implem
@Override
public int getNodeType() {
return IIndexCPPBindingConstants.CPP_USING_DECLARATION;
return IIndexCPPBindingConstants.CPP_USING_DECLARATION_SPECIALIZATION;
}
@Override

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
import org.eclipse.core.runtime.CoreException;
@ -30,7 +31,7 @@ import org.eclipse.core.runtime.CoreException;
*/
class PDOMClassUtil {
static class FieldCollector implements IPDOMVisitor {
private List<ICPPField> fields = new ArrayList<ICPPField>();
private final List<ICPPField> fields = new ArrayList<ICPPField>();
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof ICPPField) {
@ -50,7 +51,7 @@ class PDOMClassUtil {
}
static class ConstructorCollector implements IPDOMVisitor {
private List<ICPPConstructor> fConstructors = new ArrayList<ICPPConstructor>();
private final List<ICPPConstructor> fConstructors = new ArrayList<ICPPConstructor>();
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof ICPPConstructor) {
@ -108,10 +109,10 @@ class PDOMClassUtil {
}
static class NestedClassCollector implements IPDOMVisitor {
private List<IPDOMNode> nestedClasses = new ArrayList<IPDOMNode>();
private final List<IPDOMNode> nestedClasses = new ArrayList<IPDOMNode>();
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof ICPPClassType)
if (node instanceof ICPPClassType && !(node instanceof ICPPDeferredClassInstance))
nestedClasses.add(node);
return false;
}

View file

@ -260,8 +260,8 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
*/
private boolean fileIsNotOlderThanTimestamp(String filename, long timestamp) {
// We are subtracting 1 second from the timestamp to account for limited precision
// of File.lastModified() method and possible asynchrony between clocks on multi-CPU
// systems. This may produce false positives, but they are pretty harmless.
// of File.lastModified() method and possible skew between clocks on a multi-CPU
// system. This may produce false positives, but they are pretty harmless.
return new File(filename).lastModified() >= timestamp - 1000;
}

View file

@ -33,10 +33,10 @@ import org.eclipse.osgi.util.NLS;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class CConventions {
private final static String scopeResolutionOperator= "::"; //$NON-NLS-1$
private final static char fgDot= '.';
private static final String scopeResolutionOperator= "::"; //$NON-NLS-1$
private static final char fgDot= '.';
private final static String ILLEGAL_FILE_CHARS = "/\\:<>?*|\""; //$NON-NLS-1$
private static final String ILLEGAL_FILE_CHARS = "/\\:<>?*|\""; //$NON-NLS-1$
public static boolean isLegalIdentifier(String name) {
if (name == null) {

View file

@ -109,11 +109,11 @@ public class CCorePlugin extends Plugin {
public static final String BUILDER_MODEL_ID = PLUGIN_ID + ".CBuildModel"; //$NON-NLS-1$
public static final String BINARY_PARSER_SIMPLE_ID = "BinaryParser"; //$NON-NLS-1$
public final static String BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$
public final static String PREF_BINARY_PARSER = "binaryparser"; //$NON-NLS-1$
public final static String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF"; //$NON-NLS-1$
public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$
public final static String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$
public static final String BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$
public static final String PREF_BINARY_PARSER = "binaryparser"; //$NON-NLS-1$
public static final String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF"; //$NON-NLS-1$
public static final String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$
public static final String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$
public static final String INDEX_SIMPLE_ID = "CIndex"; //$NON-NLS-1$
public static final String INDEX_UNIQ_ID = PLUGIN_ID + "." + INDEX_SIMPLE_ID; //$NON-NLS-1$
@ -126,23 +126,23 @@ public class CCorePlugin extends Plugin {
/**
* Name of the extension point for contributing an error parser
*/
public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
public static final String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
/**
* Full unique name of the extension point for contributing an error parser
*/
public final static String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$
public static final String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$
// default store for pathentry
public final static String DEFAULT_PATHENTRY_STORE_ID = PLUGIN_ID + ".cdtPathEntryStore"; //$NON-NLS-1$
public static final String DEFAULT_PATHENTRY_STORE_ID = PLUGIN_ID + ".cdtPathEntryStore"; //$NON-NLS-1$
// Build Model Interface Discovery
public final static String BUILD_SCANNER_INFO_SIMPLE_ID = "ScannerInfoProvider"; //$NON-NLS-1$
public final static String BUILD_SCANNER_INFO_UNIQ_ID = PLUGIN_ID + "." + BUILD_SCANNER_INFO_SIMPLE_ID; //$NON-NLS-1$
public static final String BUILD_SCANNER_INFO_SIMPLE_ID = "ScannerInfoProvider"; //$NON-NLS-1$
public static final String BUILD_SCANNER_INFO_UNIQ_ID = PLUGIN_ID + "." + BUILD_SCANNER_INFO_SIMPLE_ID; //$NON-NLS-1$
public static final String DEFAULT_PROVIDER_ID = CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$
private final static String SCANNER_INFO_PROVIDER2_NAME = "ScannerInfoProvider2"; //$NON-NLS-1$
private final static String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$
private static final String SCANNER_INFO_PROVIDER2_NAME = "ScannerInfoProvider2"; //$NON-NLS-1$
private static final String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$
/**
* Name of the extension point for contributing a source code formatter
@ -158,27 +158,27 @@ public class CCorePlugin extends Plugin {
/**
* IContentType id for C Source Unit
*/
public final static String CONTENT_TYPE_CSOURCE = "org.eclipse.cdt.core.cSource"; //$NON-NLS-1$
public static final String CONTENT_TYPE_CSOURCE = "org.eclipse.cdt.core.cSource"; //$NON-NLS-1$
/**
* IContentType id for C Header Unit
*/
public final static String CONTENT_TYPE_CHEADER = "org.eclipse.cdt.core.cHeader"; //$NON-NLS-1$
public static final String CONTENT_TYPE_CHEADER = "org.eclipse.cdt.core.cHeader"; //$NON-NLS-1$
/**
* IContentType id for C++ Source Unit
*/
public final static String CONTENT_TYPE_CXXSOURCE = "org.eclipse.cdt.core.cxxSource"; //$NON-NLS-1$
public static final String CONTENT_TYPE_CXXSOURCE = "org.eclipse.cdt.core.cxxSource"; //$NON-NLS-1$
/**
* IContentType id for C++ Header Unit
*/
public final static String CONTENT_TYPE_CXXHEADER = "org.eclipse.cdt.core.cxxHeader"; //$NON-NLS-1$
public static final String CONTENT_TYPE_CXXHEADER = "org.eclipse.cdt.core.cxxHeader"; //$NON-NLS-1$
/**
* IContentType id for ASM Unit
*/
public final static String CONTENT_TYPE_ASMSOURCE = "org.eclipse.cdt.core.asmSource"; //$NON-NLS-1$
public static final String CONTENT_TYPE_ASMSOURCE = "org.eclipse.cdt.core.asmSource"; //$NON-NLS-1$
/**
* IContentType id for Binary Files
*/
public final static String CONTENT_TYPE_BINARYFILE = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$
public static final String CONTENT_TYPE_BINARYFILE = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$
/**
* Possible configurable option value.

View file

@ -268,7 +268,7 @@ public class BuildRunnerHelper implements Closeable {
}
/**
* Close all streams.
* Close all streams except console Info stream which is handled by {@link #greeting(String)}/{@link #goodbye()}.
*/
@Override
public void close() throws IOException {
@ -303,14 +303,6 @@ public class BuildRunnerHelper implements Closeable {
CCorePlugin.log(e);
} finally {
consoleOut = null;
try {
if (consoleInfo != null)
consoleInfo.close();
} catch (Exception e) {
CCorePlugin.log(e);
} finally {
consoleInfo = null;
}
}
}
}
@ -349,6 +341,9 @@ public class BuildRunnerHelper implements Closeable {
* Print a standard greeting to the console.
* Note that start time of the build is recorded by this method.
*
* This method may open an Info stream which must be closed by call to {@link #goodbye()}
* after all informational messages are printed.
*
* @param kind - kind of build. {@link IncrementalProjectBuilder} constants such as
* {@link IncrementalProjectBuilder#FULL_BUILD} should be used.
*/
@ -362,6 +357,9 @@ public class BuildRunnerHelper implements Closeable {
* Print a standard greeting to the console.
* Note that start time of the build is recorded by this method.
*
* This method may open an Info stream which must be closed by call to {@link #goodbye()}
* after all informational messages are printed.
*
* @param kind - kind of build. {@link IncrementalProjectBuilder} constants such as
* {@link IncrementalProjectBuilder#FULL_BUILD} should be used.
* @param cfgName - configuration name.
@ -376,6 +374,9 @@ public class BuildRunnerHelper implements Closeable {
* Print a standard greeting to the console.
* Note that start time of the build is recorded by this method.
*
* This method may open an Info stream which must be closed by call to {@link #goodbye()}
* after all informational messages are printed.
*
* @param kind - kind of build as a String.
* @param cfgName - configuration name.
* @param toolchainName - tool-chain name.
@ -396,6 +397,9 @@ public class BuildRunnerHelper implements Closeable {
/**
* Print the specified greeting to the console.
* Note that start time of the build is recorded by this method.
*
* This method may open an Info stream which must be closed by call to {@link #goodbye()}
* after all informational messages are printed.
*/
public void greeting(String msg) {
startTime = System.currentTimeMillis();
@ -410,14 +414,14 @@ public class BuildRunnerHelper implements Closeable {
}
/**
* Print a standard footer to the console.
* Print a standard footer to the console and close Info stream (must be open with one of {@link #greeting(String)} calls).
* That prints duration of the build determined by start time recorded in {@link #greeting(String)}.
*
* <br><strong>Important: {@link #close()} the streams BEFORE calling this method to properly flush all outputs</strong>
*/
public void goodbye() {
Assert.isTrue(startTime != 0, "Start time must be set before calling this method"); //$NON-NLS-1$
Assert.isTrue(!isStreamsOpen, "Close streams before calling this method."); //$NON-NLS-1$
Assert.isTrue(startTime != 0, "Start time must be set before calling this method."); //$NON-NLS-1$
Assert.isTrue(consoleInfo != null, "consoleInfo must be open with greetings(...) call before using this method."); //$NON-NLS-1$
endTime = System.currentTimeMillis();
String duration = durationToString(endTime - startTime);
@ -425,17 +429,15 @@ public class BuildRunnerHelper implements Closeable {
: CCorePlugin.getFormattedString("BuildRunnerHelper.buildFinished", duration); //$NON-NLS-1$
String goodbye = '\n' + timestamp(endTime) + msg + '\n';
if (consoleInfo != null) {
try {
toConsole(goodbye);
} else {
// in current flow goodbye() can be called after close()
} finally {
try {
consoleInfo = console.getInfoStream();
toConsole(goodbye);
consoleInfo.close();
consoleInfo = null;
} catch (Exception e) {
CCorePlugin.log(e);
} finally {
consoleInfo = null;
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* Copyright (c) 2000, 2012 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
@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Salvatore Culcasi - Bug 322475
*******************************************************************************/
package org.eclipse.cdt.utils.debug.dwarf;
@ -476,7 +477,7 @@ public class Dwarf {
case DwarfConstants.DW_FORM_block1 :
{
int size = in.get();
byte[] bytes = new byte[size];
byte[] bytes = new byte[size & 0xff];
in.get(bytes);
obj = bytes;
}
@ -485,7 +486,7 @@ public class Dwarf {
case DwarfConstants.DW_FORM_block2 :
{
int size = read_2_bytes(in);
byte[] bytes = new byte[size];
byte[] bytes = new byte[size & 0xffff];
in.get(bytes);
obj = bytes;
}

View file

@ -368,7 +368,7 @@ public abstract class RefactoringTestBase extends BaseTestCase {
while ((read= reader.read(part)) != -1)
buffer.append(part, 0, read);
reader.close();
return buffer.toString();
return buffer.toString().replace("\r", "");
}
protected void resetPreferences() {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2012 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
@ -25,13 +25,13 @@ public class TestSourceFile {
private static final String LINE_SEPARATOR = "\n"; //$NON-NLS-1$
private static final Pattern SELECTION_START = Pattern.compile("/\\*\\$\\*/"); //$NON-NLS-1$
private static final Pattern SELECTION_END = Pattern.compile("/\\*\\$\\$\\*/"); //$NON-NLS-1$
private final String name;
private final StringBuilder source = new StringBuilder();
private final StringBuilder expectedSource = new StringBuilder();
private int selectionStart = -1;
private int selectionEnd = -1;
public TestSourceFile(String name) {
super();
this.name = name;
@ -44,7 +44,7 @@ public class TestSourceFile {
public String getSource() {
return source.toString();
}
public String getExpectedSource() {
if (expectedSource.length() == 0) {
return getSource();
@ -66,12 +66,12 @@ public class TestSourceFile {
source.append(code);
source.append(LINE_SEPARATOR);
}
public void addLineToExpectedSource(String code) {
expectedSource.append(code);
expectedSource.append(LINE_SEPARATOR);
}
public TextSelection getSelection() {
if (selectionStart < 0 || selectionEnd < selectionStart)
return null;

View file

@ -1599,4 +1599,36 @@ public class GenerateGettersAndSettersTest extends RefactoringTestBase {
selectedSetters = new String[] { "mClass" };
assertRefactoringSuccess();
}
//A.h
//class Foo {
// int a, *b, /*$*/c[2]/*$$*/;
//};
//====================
//class Foo {
//public:
// void setA(int a) {
// this->a = a;
// }
//
// int* getB() const {
// return b;
// }
//
// void setB(int* b) {
// this->b = b;
// }
//
// const int* getC() const {
// return c;
// }
//
//private:
// int a, *b, c[2];
//};
public void testMultipleDeclarators_371840() throws Exception {
selectedGetters = new String[] { "b", "c" };
selectedSetters = new String[] { "a", "b" };
assertRefactoringSuccess();
}
}

View file

@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2005, 2010 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
* Copyright (c) 2005, 2010 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:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.ui.tests.text.selection;
@ -228,7 +228,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
final IASTName[] result= {null};
if (sel instanceof ITextSelection) {
final ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)editor.getInputCElement();
ITranslationUnit tu = editor.getInputCElement();
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
@Override
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.ui.tests.text.selection;
@ -34,7 +34,7 @@ import org.eclipse.cdt.ui.testplugin.CTestPlugin;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
* Test Ctrl_F3/F3 with the DOM Indexer for a C++ project.
* Test Ctrl-F3/F3 with the DOM Indexer for a C++ project.
*/
public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsIndexer {
private static final int MAX_WAIT_TIME = 8000;
@ -170,7 +170,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
int hoffset= hcode.indexOf("testTemplate");
int soffset = scode.indexOf("testTemplate");
IASTNode def = testF3(file, soffset+2);
IASTNode def = testF3(file, soffset + 2);
assertTrue(def instanceof IASTName);
assertEquals("testTemplate", ((IASTName) def).toString());
assertEquals(hoffset, ((ASTNode) def).getOffset());
@ -227,8 +227,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
int hoffset= hcode.indexOf("MyInt");
int soffset = scode.indexOf("MyInt");
IASTNode decl = testF3(file, soffset+2);
IASTNode def = testF3(hfile, hoffset+2);
IASTNode decl = testF3(file, soffset + 2);
IASTNode def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyInt", ((IASTName) decl).toString());
@ -240,8 +240,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyConst");
soffset = scode.indexOf("MyConst");
decl = testF3(file, soffset+2);
def = testF3(hfile, hoffset+2);
decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyConst", ((IASTName) decl).toString());
@ -253,8 +253,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyFunc");
soffset = scode.indexOf("MyFunc");
decl = testF3(file, soffset+2);
def = testF3(hfile, hoffset+2);
decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyFunc", ((IASTName) decl).toString());
@ -266,8 +266,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyStruct");
soffset = scode.indexOf("MyStruct");
decl = testF3(file, soffset+2);
def = testF3(hfile, hoffset+2);
decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyStruct", ((IASTName) decl).toString());
@ -279,8 +279,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyClass");
soffset = scode.indexOf("MyClass");
decl = testF3(file, soffset+2);
def = testF3(hfile, hoffset+2);
decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName);
assertEquals("MyClass", ((IASTName) decl).toString());
@ -983,6 +983,24 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
decl = testF3(file, offset1);
assertNode("gvar", offset0, decl);
}
// #define MYMACRO
// #undef MYMACRO
public void testUndef_312399() throws Exception {
StringBuilder[] buffers= getContents(2);
String hcode= buffers[0].toString();
String scode= buffers[1].toString();
IFile hfile = importFile("testUndef_312399.h", hcode);
IFile file = importFile("testUndef_312399.cpp", scode);
waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
IASTNode target = testF3(file, scode.indexOf("MYMACRO"));
assertTrue(target instanceof IASTName);
assertEquals("MYMACRO", ((IASTName) target).toString());
assertEquals(hcode.indexOf("MYMACRO"), target.getFileLocation().getNodeOffset());
assertEquals("MYMACRO".length(), ((ASTNode) target).getLength());
}
// int wurscht;
@ -1230,21 +1248,31 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
}
}
// #define MYMACRO
// namespace ns {
// void func();
// }
// #undef MYMACRO
public void testUndef_312399() throws Exception {
StringBuilder[] buffers= getContents(2);
// #include "test.h"
// using ns::func;
//
// void test() {
// func();
// }
public void testBug380197() throws Exception {
StringBuilder[] buffers= getContents(2);
String hcode= buffers[0].toString();
String scode= buffers[1].toString();
IFile hfile = importFile("testUndef_312399.h", hcode);
IFile file = importFile("testUndef_312399.cpp", scode);
IFile hfile = importFile("test.h", hcode);
IFile file = importFile("test.cpp", scode);
waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
IASTNode target = testF3(file, scode.indexOf("MYMACRO"));
assertTrue(target instanceof IASTName);
assertEquals("MYMACRO", ((IASTName) target).toString());
assertEquals(hcode.indexOf("MYMACRO"), target.getFileLocation().getNodeOffset());
assertEquals("MYMACRO".length(), ((ASTNode) target).getLength());
int hoffset= hcode.indexOf("func");
int offset = scode.indexOf("func()");
IASTNode def = testF3(file, offset + 1);
assertTrue(def instanceof IASTName);
assertEquals("func", def.toString());
IASTFileLocation location = def.getFileLocation();
assertEquals(hfile.getLocation().toOSString(), location.getFileName());
assertEquals(hoffset, location.getNodeOffset());
}
}

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.text.selection;
import junit.framework.Test;

View file

@ -9,7 +9,6 @@
* QNX Software Systems - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.corext.template.c;
import org.eclipse.jface.text.IDocument;
@ -21,29 +20,21 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
* A context type for C/C++ code.
*/
public class CContextType extends TranslationUnitContextType {
public final static String ID = "org.eclipse.cdt.ui.text.templates.c"; //$NON-NLS-1$
public static final String ID = "org.eclipse.cdt.ui.text.templates.c"; //$NON-NLS-1$
public CContextType() {
super();
}
/*
* @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, org.eclipse.cdt.core.model.ITranslationUnit)
*/
@Override
public TranslationUnitContext createContext(IDocument document, int offset,
int length, ITranslationUnit translationUnit) {
return new CContext(this, document, offset, length, translationUnit);
}
/*
* @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position, org.eclipse.cdt.core.model.ITranslationUnit)
*/
@Override
public TranslationUnitContext createContext(IDocument document,
Position position, ITranslationUnit translationUnit) {
return new CContext(this, document, position, translationUnit);
}
}

View file

@ -10,16 +10,19 @@
* Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
* Andrew Gvozdev (Quoin Inc.) - Copy build log (bug 306222)
* Alex Collins (Broadcom Corp.) - Global console
* Sergey Prigogin (Google) - Performance improvements
*******************************************************************************/
package org.eclipse.cdt.internal.ui.buildconsole;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
@ -48,14 +51,205 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
public class BuildConsolePartitioner
implements
IDocumentPartitioner,
IDocumentPartitionerExtension,
IConsole,
IPropertyChangeListener {
implements IDocumentPartitioner, IDocumentPartitionerExtension, IConsole, IPropertyChangeListener {
private static class SynchronizedDeque<E> implements Deque<E> {
private final Deque<E> deque;
public SynchronizedDeque(Deque<E> deque) {
this.deque = deque;
}
@Override
public synchronized boolean isEmpty() {
return deque.isEmpty();
}
@Override
public synchronized void addFirst(E e) {
deque.addFirst(e);
}
@Override
public synchronized void addLast(E e) {
deque.addLast(e);
}
@Override
public synchronized Object[] toArray() {
return deque.toArray();
}
@Override
public synchronized <T> T[] toArray(T[] a) {
return deque.toArray(a);
}
@Override
public synchronized boolean offerFirst(E e) {
return deque.offerFirst(e);
}
@Override
public synchronized boolean offerLast(E e) {
return deque.offerLast(e);
}
@Override
public synchronized E removeFirst() {
return deque.removeFirst();
}
@Override
public synchronized E removeLast() {
return deque.removeLast();
}
@Override
public synchronized E pollFirst() {
return deque.pollFirst();
}
@Override
public synchronized E pollLast() {
return deque.pollLast();
}
@Override
public synchronized E getFirst() {
return deque.getFirst();
}
@Override
public synchronized E getLast() {
return deque.getLast();
}
@Override
public synchronized E peekFirst() {
return deque.peekFirst();
}
@Override
public synchronized E peekLast() {
return deque.peekLast();
}
@Override
public synchronized boolean removeFirstOccurrence(Object o) {
return deque.removeFirstOccurrence(o);
}
@Override
public synchronized boolean containsAll(Collection<?> c) {
return deque.containsAll(c);
}
@Override
public synchronized boolean removeLastOccurrence(Object o) {
return deque.removeLastOccurrence(o);
}
@Override
public synchronized boolean addAll(Collection<? extends E> c) {
return deque.addAll(c);
}
@Override
public synchronized boolean add(E e) {
return deque.add(e);
}
@Override
public synchronized boolean removeAll(Collection<?> c) {
return deque.removeAll(c);
}
@Override
public synchronized boolean offer(E e) {
return deque.offer(e);
}
@Override
public synchronized boolean retainAll(Collection<?> c) {
return deque.retainAll(c);
}
@Override
public synchronized E remove() {
return deque.remove();
}
@Override
public synchronized E poll() {
return deque.poll();
}
@Override
public synchronized E element() {
return deque.element();
}
@Override
public synchronized void clear() {
deque.clear();
}
@Override
public synchronized boolean equals(Object o) {
return deque.equals(o);
}
@Override
public synchronized E peek() {
return deque.peek();
}
@Override
public synchronized void push(E e) {
deque.push(e);
}
@Override
public synchronized E pop() {
return deque.pop();
}
@Override
public synchronized int hashCode() {
return deque.hashCode();
}
@Override
public synchronized boolean remove(Object o) {
return deque.remove(o);
}
@Override
public synchronized boolean contains(Object o) {
return deque.contains(o);
}
@Override
public synchronized int size() {
return deque.size();
}
@Override
public synchronized Iterator<E> iterator() {
return deque.iterator();
}
@Override
public synchronized Iterator<E> descendingIterator() {
return deque.descendingIterator();
}
}
private IProject fProject;
private int openStreamCount = 0;
/**
* List of partitions
*/
@ -66,7 +260,7 @@ public class BuildConsolePartitioner
/**
* The stream that was last appended to
*/
BuildConsoleStreamDecorator fLastStream = null;
BuildConsoleStreamDecorator fLastStream;
BuildConsoleDocument fDocument;
DocumentMarkerManager fDocumentMarkerManager;
@ -76,19 +270,18 @@ public class BuildConsolePartitioner
/**
* A queue of stream entries written to standard out and standard err.
* Entries appended to the end of the queue and removed from the front.
* Intentionally a vector to obtain synchronization as entries are added and
* removed.
*/
Vector<StreamEntry> fQueue = new Vector<StreamEntry>(5);
private final Deque<StreamEntry> fQueue =
new SynchronizedDeque<StreamEntry>(new ArrayDeque<StreamEntry>());
private URI fLogURI;
private OutputStream fLogStream;
private class StreamEntry {
static public final int EVENT_APPEND = 0;
static public final int EVENT_OPEN_LOG = 1;
static public final int EVENT_CLOSE_LOG = 2;
static public final int EVENT_OPEN_APPEND_LOG = 3;
public static final int EVENT_APPEND = 0;
public static final int EVENT_OPEN_LOG = 1;
public static final int EVENT_CLOSE_LOG = 2;
public static final int EVENT_OPEN_APPEND_LOG = 3;
/** Identifier of the stream written to. */
private BuildConsoleStreamDecorator fStream;
@ -153,7 +346,6 @@ public class BuildConsolePartitioner
public int getEventType() {
return eventType;
}
}
/**
@ -214,12 +406,12 @@ public class BuildConsolePartitioner
public void appendToDocument(String text, BuildConsoleStreamDecorator stream, ProblemMarkerInfo marker) {
boolean addToQueue = true;
synchronized (fQueue) {
int i = fQueue.size();
if (i > 0) {
StreamEntry entry = fQueue.get(i - 1);
// if last stream is the same and we have not exceeded our
// display write limit, append.
if (entry.getStream()==stream && entry.getEventType()==StreamEntry.EVENT_APPEND && entry.getMarker()==marker && entry.size()<10000) {
StreamEntry entry = fQueue.peekLast();
if (entry != null) {
// If last stream is the same and we have not exceeded
// the display write limit, append.
if (entry.getStream() == stream && entry.getEventType() == StreamEntry.EVENT_APPEND &&
entry.getMarker() == marker && entry.size() < 10000) {
entry.appendText(text);
addToQueue = false;
}
@ -243,13 +435,14 @@ public class BuildConsolePartitioner
@Override
public void run() {
StreamEntry entry;
try {
entry = fQueue.remove(0);
} catch (ArrayIndexOutOfBoundsException e) {
entry = fQueue.pollFirst();
if (entry == null)
return;
}
switch (entry.getEventType()) {
case StreamEntry.EVENT_OPEN_LOG:
openStreamCount++;
//$FALL-THROUGH$
case StreamEntry.EVENT_OPEN_APPEND_LOG:
logOpen(entry.getEventType() == StreamEntry.EVENT_OPEN_APPEND_LOG);
break;
@ -265,16 +458,28 @@ public class BuildConsolePartitioner
fDocument.set(""); //$NON-NLS-1$
}
String text = entry.getText();
if (text.length()>0) {
if (text.length() > 0) {
addStreamEntryToDocument(entry);
log(text);
checkOverflow();
boolean allowSlack = false;
entry = fQueue.peekFirst();
if (entry != null && entry.getEventType() == StreamEntry.EVENT_APPEND) {
// Buffer truncation is an expensive operation. Allow some slack
// if more data is coming and we will be truncating the buffer
// again soon.
allowSlack = true;
}
checkOverflow(allowSlack);
}
} catch (BadLocationException e) {
}
break;
case StreamEntry.EVENT_CLOSE_LOG:
logClose();
openStreamCount--;
if (openStreamCount <= 0) {
openStreamCount = 0;
logClose();
}
break;
}
}
@ -285,7 +490,7 @@ public class BuildConsolePartitioner
*/
private void logOpen(boolean append) {
fLogURI = fManager.getLogURI(fProject);
if (fLogURI!=null) {
if (fLogURI != null) {
try {
IFileStore logStore = EFS.getStore(fLogURI);
// Ensure the directory exists before opening the file
@ -303,7 +508,7 @@ public class BuildConsolePartitioner
}
private void log(String text) {
if (fLogStream!=null) {
if (fLogStream != null) {
try {
fLogStream.write(text.getBytes());
if (fQueue.isEmpty()) {
@ -318,7 +523,7 @@ public class BuildConsolePartitioner
}
private void logClose() {
if (fLogStream!=null) {
if (fLogStream != null) {
try {
fLogStream.close();
} catch (IOException e) {
@ -339,7 +544,7 @@ public class BuildConsolePartitioner
private void addStreamEntryToDocument(StreamEntry entry) throws BadLocationException {
ProblemMarkerInfo marker = entry.getMarker();
if (marker==null) {
if (marker == null) {
// It is plain unmarkered console output
addPartition(new BuildConsolePartition(fLastStream,
fDocument.getLength(),
@ -349,9 +554,9 @@ public class BuildConsolePartitioner
// this text line in entry is markered with ProblemMarkerInfo,
// create special partition for it.
String errorPartitionType;
if (marker.severity==IMarker.SEVERITY_INFO) {
if (marker.severity == IMarker.SEVERITY_INFO) {
errorPartitionType = BuildConsolePartition.INFO_PARTITION_TYPE;
} else if (marker.severity==IMarker.SEVERITY_WARNING) {
} else if (marker.severity == IMarker.SEVERITY_WARNING) {
errorPartitionType = BuildConsolePartition.WARNING_PARTITION_TYPE;
} else {
errorPartitionType = BuildConsolePartition.ERROR_PARTITION_TYPE;
@ -377,8 +582,7 @@ public class BuildConsolePartitioner
public void setDocumentSize(int nLines) {
fMaxLines = nLines;
nLines = fDocument.getNumberOfLines();
checkOverflow();
checkOverflow(false);
}
@Override
@ -437,7 +641,7 @@ public class BuildConsolePartitioner
ITypedRegion partition = fPartitions.get(i);
int partitionStart = partition.getOffset();
int partitionEnd = partitionStart + partition.getLength();
if ( (offset >= partitionStart && offset <= partitionEnd) ||
if ((offset >= partitionStart && offset <= partitionEnd) ||
(offset < partitionStart && end >= partitionStart)) {
list.add(partition);
}
@ -489,55 +693,56 @@ public class BuildConsolePartitioner
* Checks to see if the console buffer has overflowed, and empties the
* overflow if needed, updating partitions and hyperlink positions.
*/
protected void checkOverflow() {
if (fMaxLines >= 0) {
int nLines = fDocument.getNumberOfLines();
if (nLines > fMaxLines + 1) {
int overflow = 0;
try {
overflow = fDocument.getLineOffset(nLines - fMaxLines);
} catch (BadLocationException e1) {
}
// update partitions
List<ITypedRegion> newParitions = new ArrayList<ITypedRegion>(fPartitions.size());
Iterator<ITypedRegion> partitions = fPartitions.iterator();
while (partitions.hasNext()) {
ITypedRegion region = partitions.next();
if (region instanceof BuildConsolePartition) {
BuildConsolePartition messageConsolePartition = (BuildConsolePartition)region;
protected void checkOverflow(boolean allowSlack) {
if (fMaxLines <= 0)
return;
int nLines = fDocument.getNumberOfLines();
if (nLines <= (allowSlack ? fMaxLines * 2 : fMaxLines) + 1)
return;
ITypedRegion newPartition = null;
int offset = region.getOffset();
String type = messageConsolePartition.getType();
if (offset < overflow) {
int endOffset = offset + region.getLength();
if (endOffset < overflow || BuildConsolePartition.isProblemPartitionType(type)) {
// remove partition,
// partitions with problem markers can't be split - remove them too
} else {
// split partition
int length = endOffset - overflow;
newPartition = messageConsolePartition.createNewPartition(0, length, type);
}
} else {
// modify partition offset
offset = messageConsolePartition.getOffset() - overflow;
newPartition = messageConsolePartition.createNewPartition(offset, messageConsolePartition.getLength(), type);
}
if (newPartition != null) {
newParitions.add(newPartition);
}
int overflow = 0;
try {
overflow = fDocument.getLineOffset(nLines - fMaxLines);
} catch (BadLocationException e) {
}
// Update partitions
List<ITypedRegion> newParitions = new ArrayList<ITypedRegion>(fPartitions.size());
Iterator<ITypedRegion> partitions = fPartitions.iterator();
while (partitions.hasNext()) {
ITypedRegion region = partitions.next();
if (region instanceof BuildConsolePartition) {
BuildConsolePartition messageConsolePartition = (BuildConsolePartition) region;
ITypedRegion newPartition = null;
int offset = region.getOffset();
String type = messageConsolePartition.getType();
if (offset < overflow) {
int endOffset = offset + region.getLength();
if (endOffset < overflow || BuildConsolePartition.isProblemPartitionType(type)) {
// Remove partition,
// partitions with problem markers can't be split - remove them too.
} else {
// Split partition
int length = endOffset - overflow;
newPartition = messageConsolePartition.createNewPartition(0, length, type);
}
} else {
// Modify partition offset
offset = messageConsolePartition.getOffset() - overflow;
newPartition = messageConsolePartition.createNewPartition(offset, messageConsolePartition.getLength(), type);
}
fPartitions = newParitions;
fDocumentMarkerManager.moveToFirstError();
try {
fDocument.replace(0, overflow, ""); //$NON-NLS-1$
} catch (BadLocationException e) {
if (newPartition != null) {
newParitions.add(newPartition);
}
}
}
fPartitions = newParitions;
fDocumentMarkerManager.moveToFirstError();
try {
fDocument.replace(0, overflow, ""); //$NON-NLS-1$
} catch (BadLocationException e) {
}
}
/**
@ -548,7 +753,7 @@ public class BuildConsolePartitioner
fPartitions.add(partition);
} else {
int index = fPartitions.size() - 1;
BuildConsolePartition last = (BuildConsolePartition)fPartitions.get(index);
BuildConsolePartition last = (BuildConsolePartition) fPartitions.get(index);
if (last.canBeCombinedWith(partition)) {
// replace with a single partition
partition = last.combineWith(partition);

View file

@ -690,7 +690,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
/** Preference key for temporary problems */
private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS;
private static final String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS;
/** Internal property changed listener */
private IPropertyChangeListener fPropertyListener;

View file

@ -1336,7 +1336,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private SurroundWithActionGroup fSurroundWithActionGroup;
/** Pairs of brackets, used to match. */
protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
protected static final char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
/** Matches the brackets. */
protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
@ -1348,24 +1348,24 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
/** Preference key for sub-word navigation, aka smart caret positioning */
public final static String SUB_WORD_NAVIGATION = "subWordNavigation"; //$NON-NLS-1$
public static final String SUB_WORD_NAVIGATION = "subWordNavigation"; //$NON-NLS-1$
/** Preference key for matching brackets */
public final static String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
public static final String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
/** Preference key for matching brackets color */
public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
public static final String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
/** Preference key for inactive code painter enablement */
public static final String INACTIVE_CODE_ENABLE = "inactiveCodeEnable"; //$NON-NLS-1$
/** Preference key for inactive code painter color */
public static final String INACTIVE_CODE_COLOR = "inactiveCodeColor"; //$NON-NLS-1$
/** Preference key for automatically closing strings */
private final static String CLOSE_STRINGS = PreferenceConstants.EDITOR_CLOSE_STRINGS;
private static final String CLOSE_STRINGS = PreferenceConstants.EDITOR_CLOSE_STRINGS;
/** Preference key for automatically closing brackets and parenthesis */
private final static String CLOSE_BRACKETS = PreferenceConstants.EDITOR_CLOSE_BRACKETS;
private static final String CLOSE_BRACKETS = PreferenceConstants.EDITOR_CLOSE_BRACKETS;
/** Preference key for automatically closing angular brackets */
private final static String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS;
private static final String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS;
/** Preference key for compiler task tags */
private final static String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS;
private static final String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS;
/**
* This editor's projection support

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2012 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
@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
@ -37,7 +38,10 @@ public class IBFile {
public IBFile(ICProject preferredProject, IIndexFileLocation location) throws CModelException {
fLocation= location;
fTU= CoreModelUtil.findTranslationUnitForLocation(location, preferredProject);
ITranslationUnit TU = CoreModelUtil.findTranslationUnitForLocation(location, preferredProject);
if (TU == null) //for EFS file that might not be on this filesystem
TU = CoreModelUtil.findTranslationUnitForLocation(location.getURI(), preferredProject);
fTU = TU;
String name= fLocation.getURI().getPath();
fName= name.substring(name.lastIndexOf('/')+1);
}

View file

@ -67,7 +67,7 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
/**
* Some C++ source code used for preview.
*/
private final static String PREVIEW=
private static final String PREVIEW=
"/*\n* " + //$NON-NLS-1$
FormatterMessages.CodingStyleConfigurationBlock_preview_title +
"\n*/\n" + //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2012 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 java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
@ -106,8 +105,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
} else if (node instanceof IASTName) {
return isNameEqual(trailNode, node);
} else {
Assert.isLegal(false, "Unexpected node type " + node.getClass().getSimpleName() + //$NON-NLS-1$
", this code shoud not be reached"); //$NON-NLS-1$
CUIPlugin.logError("Unexpected node type " + node.getClass().getSimpleName()); //$NON-NLS-1$
return true;
}
}
@ -140,10 +138,12 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl)
&& isSameNamedTypeSpecifierName(trailDecl, decl)
&& trailDecl.isTypename() == decl.isTypename()
&& trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isVirtual() == decl.isVirtual();
&& trailDecl.isConstexpr() == decl.isConstexpr()
&& trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isThreadLocal() == decl.isThreadLocal()
&& trailDecl.isTypename() == decl.isTypename()
&& trailDecl.isVirtual() == decl.isVirtual();
} else if (trailNode instanceof IASTNamedTypeSpecifier) {
IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node;
@ -158,25 +158,27 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
IASTCompositeTypeSpecifier trailDecl = (IASTCompositeTypeSpecifier) trailNode;
IASTCompositeTypeSpecifier decl = (IASTCompositeTypeSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl)
&& trailDecl.getKey() == decl.getKey();
&& trailDecl.getKey() == decl.getKey();
} else if (trailNode instanceof ICPPASTDeclSpecifier) {
ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode;
ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl)
&& trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isVirtual() == decl.isVirtual();
&& trailDecl.isConstexpr() == decl.isConstexpr()
&& trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isThreadLocal() == decl.isThreadLocal()
&& trailDecl.isVirtual() == decl.isVirtual();
} else if (trailNode instanceof ICASTDeclSpecifier) {
ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl)
&& trailDecl.isRestrict() == decl.isRestrict();
&& trailDecl.isRestrict() == decl.isRestrict();
} else if (trailNode instanceof IASTDeclSpecifier) {
IASTDeclSpecifier trailDecl = (IASTDeclSpecifier) trailNode;
IASTDeclSpecifier decl = (IASTDeclSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl);
} else {
//is same
// The same.
return true;
}
}
@ -315,8 +317,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
if (trailCppDecl.isExplicit() != cppDecl.isExplicit()
if (trailCppDecl.isConstexpr() != cppDecl.isConstexpr()
|| trailCppDecl.isExplicit() != cppDecl.isExplicit()
|| trailCppDecl.isFriend() != cppDecl.isFriend()
|| trailCppDecl.isThreadLocal() != cppDecl.isThreadLocal()
|| trailCppDecl.isVirtual() != cppDecl.isVirtual()) {
return false;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc and others.
* Copyright (c) 2011, 2012 Google, 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,7 @@ public class AccessorDescriptor implements Comparable<AccessorDescriptor> {
this.fieldName = fieldDescriptor.getFieldName();
if (accessorName != null) {
this.accessorFactory = AccessorFactory.createFactory(kind, fieldName,
fieldDescriptor.getFieldDeclaration(), accessorName);
fieldDescriptor.getFieldDeclarator(), accessorName);
this.accessorDeclaration = accessorFactory.createDeclaration();
for (IASTFunctionDefinition currentDefinition : context.existingFunctionDefinitions) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2012 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
@ -55,26 +55,29 @@ import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescrip
public abstract class AccessorFactory {
protected final IASTName fieldName;
protected final IASTSimpleDeclaration fieldDeclaration;
protected final IASTDeclarator fieldDeclarator;
private final IASTDeclSpecifier declSpecifier;
protected final String accessorName;
protected boolean passByReference;
public static AccessorFactory createFactory(AccessorKind kind, IASTName fieldName,
IASTSimpleDeclaration fieldDeclaration, String accessorName) {
IASTDeclarator declarator, String accessorName) {
if (kind == AccessorKind.GETTER) {
return new GetterFactory(fieldName, fieldDeclaration, accessorName);
return new GetterFactory(fieldName, declarator, accessorName);
} else {
return new SetterFactory(fieldName, fieldDeclaration, accessorName);
return new SetterFactory(fieldName, declarator, accessorName);
}
}
protected AccessorFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration,
String accessorName) {
protected AccessorFactory(IASTName fieldName, IASTDeclarator fieldDeclarator, String accessorName) {
this.fieldName = fieldName;
this.fieldDeclaration = fieldDeclaration;
this.fieldDeclarator = fieldDeclarator;
this.accessorName = accessorName;
IType type = CPPVisitor.createType(fieldDeclaration.getDeclSpecifier());
passByReference = TypeHelper.shouldBePassedByReference(type, fieldDeclaration.getTranslationUnit());
IASTSimpleDeclaration declaration =
CPPVisitor.findAncestorWithType(fieldDeclarator, IASTSimpleDeclaration.class);
this.declSpecifier = declaration.getDeclSpecifier();
IType type = CPPVisitor.createType(declSpecifier);
passByReference = TypeHelper.shouldBePassedByReference(type, fieldDeclarator.getTranslationUnit());
}
/**
@ -90,16 +93,16 @@ public abstract class AccessorFactory {
public abstract IASTFunctionDefinition createDefinition(ICPPASTQualifiedName className);
protected IASTDeclSpecifier getParamOrReturnDeclSpecifier() {
IASTDeclSpecifier declSpec = fieldDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations);
if (passByReference || fieldDeclaration.getDeclarators()[0] instanceof IASTArrayDeclarator) {
IASTDeclSpecifier declSpec = declSpecifier.copy(CopyStyle.withLocations);
if (passByReference || fieldDeclarator instanceof IASTArrayDeclarator) {
declSpec.setConst(true);
}
return declSpec;
}
private static class GetterFactory extends AccessorFactory {
GetterFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, String getterName) {
super(fieldName, fieldDeclaration, getterName);
GetterFactory(IASTName fieldName, IASTDeclarator fieldDeclarator, String getterName) {
super(fieldName, fieldDeclarator, getterName);
}
@Override
@ -142,7 +145,7 @@ public abstract class AccessorFactory {
getterName.setName(accessorName.toCharArray());
// Copy declarator hierarchy
IASTDeclarator topDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations);
IASTDeclarator topDeclarator = fieldDeclarator.copy(CopyStyle.withLocations);
if (topDeclarator instanceof IASTArrayDeclarator) {
boolean isCpp = topDeclarator instanceof ICPPASTArrayDeclarator;
@ -190,8 +193,8 @@ public abstract class AccessorFactory {
}
private static class SetterFactory extends AccessorFactory {
SetterFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, String setterName) {
super(fieldName, fieldDeclaration, setterName);
SetterFactory(IASTName fieldName, IASTDeclarator fieldDeclarator, String setterName) {
super(fieldName, fieldDeclarator, setterName);
}
@Override
@ -215,7 +218,7 @@ public abstract class AccessorFactory {
CPPASTCompoundStatement compound = new CPPASTCompoundStatement();
CPPASTExpressionStatement exprStmt = new CPPASTExpressionStatement();
CPPASTBinaryExpression binExpr = new CPPASTBinaryExpression();
IASTDeclarator innerDeclarator = fieldDeclaration.getDeclarators()[0];
IASTDeclarator innerDeclarator = fieldDeclarator;
while (innerDeclarator.getNestedDeclarator() != null) {
innerDeclarator = innerDeclarator.getNestedDeclarator();
}
@ -252,7 +255,7 @@ public abstract class AccessorFactory {
declarator.setName(setterName);
}
CPPASTParameterDeclaration parameterDeclaration = new CPPASTParameterDeclaration();
IASTDeclarator parameterDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations);
IASTDeclarator parameterDeclarator = fieldDeclarator.copy(CopyStyle.withLocations);
parameterDeclarator.setName(getSetterParameterName());
if (passByReference) {
parameterDeclarator.addPointerOperator(new CPPASTReferenceOperator(false));

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2011, 2012 Google, 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
import java.util.ArrayList;
@ -6,9 +16,9 @@ import java.util.List;
import java.util.Set;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
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.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IPointerType;
@ -23,21 +33,21 @@ import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescrip
class FieldDescriptor {
private final IASTName fieldName;
private final IASTSimpleDeclaration fieldDeclaration;
private final IASTDeclarator fieldDeclarator;
private final AccessorDescriptor getter;
private final AccessorDescriptor setter;
private final AccessorDescriptor[] childNodes;
private final GetterSetterContext context;
FieldDescriptor(IASTSimpleDeclaration fieldDeclaration, GetterSetterContext context) {
this.fieldName = GetterSetterContext.getDeclarationName(fieldDeclaration);
this.fieldDeclaration = fieldDeclaration;
FieldDescriptor(IASTDeclarator field, GetterSetterContext context) {
this.fieldName = GetterSetterContext.getDeclaratorName(field);
this.fieldDeclarator = field;
this.context = context;
Set<String> namesToAvoid = getNamesToAvoid();
String name = GetterSetterNameGenerator.generateGetterName(fieldName, namesToAvoid);
this.getter = new AccessorDescriptor(AccessorKind.GETTER, name, this);
name = GetterSetterNameGenerator.generateSetterName(fieldName, namesToAvoid);
if (!isAssignable(fieldDeclaration))
if (!isAssignable(field))
name = null;
this.setter = new AccessorDescriptor(AccessorKind.SETTER, name, this);
@ -54,8 +64,8 @@ class FieldDescriptor {
private Set<String> getNamesToAvoid() {
Set<String> namesToAvoid = new HashSet<String>();
// Add field names.
for (IASTSimpleDeclaration fieldDeclaration : context.existingFields) {
namesToAvoid.add(String.valueOf(GetterSetterContext.getDeclarationName(fieldDeclaration).getSimpleID()));
for (IASTDeclarator fieldDeclarator : context.existingFields) {
namesToAvoid.add(String.valueOf(GetterSetterContext.getDeclaratorName(fieldDeclarator).getSimpleID()));
}
// Add constructor name.
if (!context.existingFields.isEmpty()) {
@ -69,8 +79,8 @@ class FieldDescriptor {
return namesToAvoid;
}
private static boolean isAssignable(IASTSimpleDeclaration declaration) {
IASTName name = GetterSetterContext.getDeclarationName(declaration);
private static boolean isAssignable(IASTDeclarator fieldDeclarator) {
IASTName name = GetterSetterContext.getDeclaratorName(fieldDeclarator);
IBinding binding = name.resolveBinding();
if (!(binding instanceof ICPPField))
return false;
@ -107,8 +117,8 @@ class FieldDescriptor {
return fieldName;
}
public IASTSimpleDeclaration getFieldDeclaration() {
return fieldDeclaration;
public IASTDeclarator getFieldDeclarator() {
return fieldDeclarator;
}
public AccessorDescriptor getGetter() {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2012 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
@ -26,7 +26,6 @@ import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@ -44,6 +43,7 @@ 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.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ContainerNode;
import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
@ -87,7 +87,6 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
}
}
private static final String MEMBER_DECLARATION = "MEMBER_DECLARATION"; //$NON-NLS-1$
private final GetterSetterContext context;
private InsertLocation definitionInsertLocation;
@ -195,27 +194,23 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
@Override
public int visit(IASTDeclaration declaration) {
if (declaration instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration fieldDeclaration = (IASTSimpleDeclaration) declaration;
ASTNodeProperty props = fieldDeclaration.getPropertyInParent();
if (props.getName().contains(MEMBER_DECLARATION)) {
final IASTDeclarator[] declarators = fieldDeclaration.getDeclarators();
if (declarators.length > 0) {
IASTDeclarator innermostDeclarator = declarators[0];
IASTSimpleDeclaration simpleDeclaration = (IASTSimpleDeclaration) declaration;
if (simpleDeclaration.getPropertyInParent() == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
for (IASTDeclarator declarator : simpleDeclaration.getDeclarators()) {
IASTDeclarator innermostDeclarator = declarator;
while (innermostDeclarator.getNestedDeclarator() != null) {
innermostDeclarator = innermostDeclarator.getNestedDeclarator();
}
if ((innermostDeclarator instanceof IASTFunctionDeclarator)) {
context.existingFunctionDeclarations.add(fieldDeclaration);
} else if (fieldDeclaration.isPartOfTranslationUnitFile()) {
context.existingFields.add(fieldDeclaration);
context.existingFunctionDeclarations.add(simpleDeclaration);
} else if (simpleDeclaration.isPartOfTranslationUnitFile()) {
context.existingFields.add(declarator);
}
}
}
}
if (declaration instanceof IASTFunctionDefinition) {
} else if (declaration instanceof IASTFunctionDefinition) {
IASTFunctionDefinition functionDefinition = (IASTFunctionDefinition) declaration;
ASTNodeProperty props = functionDefinition.getPropertyInParent();
if (props.getName().contains(MEMBER_DECLARATION)) {
if (functionDefinition.getPropertyInParent() == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
context.existingFunctionDefinitions.add(functionDefinition);
}
}
@ -246,7 +241,7 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
addDefinition(collector, definitions, pm);
}
ICPPASTCompositeTypeSpecifier classDefinition =
(ICPPASTCompositeTypeSpecifier) context.existingFields.get(context.existingFields.size() - 1).getParent();
CPPVisitor.findAncestorWithType(context.existingFields.get(0), ICPPASTCompositeTypeSpecifier.class);
ClassMemberInserter.createChange(classDefinition, VisibilityEnum.v_public,
getterAndSetters, false, collector);
@ -275,7 +270,8 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
return;
}
IASTSimpleDeclaration decl = context.existingFields.get(0);
IASTSimpleDeclaration decl =
CPPVisitor.findAncestorWithType(context.existingFields.get(0), IASTSimpleDeclaration.class);
MethodDefinitionInsertLocationFinder locationFinder = new MethodDefinitionInsertLocationFinder();
InsertLocation location = locationFinder.find(tu, decl.getFileLocation(), decl.getParent(),
refactoringContext, pm);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2012 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,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind;
public class GetterSetterContext implements ITreeContentProvider {
final List<IASTSimpleDeclaration> existingFields = new ArrayList<IASTSimpleDeclaration>();
final List<IASTDeclarator> existingFields = new ArrayList<IASTDeclarator>();
final List<IASTFunctionDefinition> existingFunctionDefinitions = new ArrayList<IASTFunctionDefinition>();
final List<IASTSimpleDeclaration> existingFunctionDeclarations = new ArrayList<IASTSimpleDeclaration>();
final SortedSet<AccessorDescriptor> selectedAccessors = new TreeSet<AccessorDescriptor>();
@ -110,7 +110,7 @@ public class GetterSetterContext implements ITreeContentProvider {
private List<FieldDescriptor> getFieldDescriptors() {
if (fieldDescriptors == null) {
fieldDescriptors = new ArrayList<FieldDescriptor>();
for (IASTSimpleDeclaration field : existingFields) {
for (IASTDeclarator field : existingFields) {
FieldDescriptor descriptor = new FieldDescriptor(field, this);
if (descriptor.missingGetterOrSetter()) {
fieldDescriptors.add(descriptor);
@ -120,11 +120,14 @@ public class GetterSetterContext implements ITreeContentProvider {
return fieldDescriptors;
}
static IASTName getDeclarationName(IASTSimpleDeclaration declaration) {
IASTDeclarator declarator = declaration.getDeclarators()[0];
static IASTName getDeclaratorName(IASTDeclarator declarator) {
while (declarator.getNestedDeclarator() != null) {
declarator = declarator.getNestedDeclarator();
}
return declarator.getName();
}
static IASTName getDeclarationName(IASTSimpleDeclaration declaration) {
return getDeclaratorName(declaration.getDeclarators()[0]);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2012 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
@ -197,7 +197,14 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
}
}
/**
* @return true if the preview job could still be running, false otherwise
*/
protected boolean cancelPreviewJob() {
if (delayedPreviewUpdater == null) {
return false;
}
// We cannot rely on getState being accurate in all cases so we only use this
// as a hint to change the preview text
if (delayedPreviewUpdater.getState() != Job.NONE) {
@ -207,6 +214,10 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
}
protected void joinPreviewJob() {
if (delayedPreviewUpdater == null) {
return;
}
try {
delayedPreviewUpdater.join();
} catch (InterruptedException e1) {

View file

@ -57,6 +57,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
@ -321,15 +322,26 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
}
private IName[] findDeclarations(IIndex index, IASTTranslationUnit ast, IBinding binding) throws CoreException {
IName[] declNames= ast.getDeclarationsInAST(binding);
for (int i = 0; i < declNames.length; i++) {
IName name = declNames[i];
if (name.isDefinition())
declNames[i]= null;
IASTName[] astNames= ast.getDeclarationsInAST(binding);
ArrayList<IASTName> usingDeclarations = null;
for (int i = 0; i < astNames.length; i++) {
IASTName name = astNames[i];
if (name.isDefinition()) {
astNames[i]= null;
} else if (CPPVisitor.findAncestorWithType(name, ICPPASTUsingDeclaration.class) != null) {
if (usingDeclarations == null)
usingDeclarations = new ArrayList<IASTName>(1);
usingDeclarations.add(name);
astNames[i]= null;
}
}
declNames= ArrayUtil.removeNulls(IName.class, declNames);
IName[] declNames= ArrayUtil.removeNulls(astNames);
if (declNames.length == 0) {
declNames= index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
declNames = index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
}
// 'using' declarations are considered only when there are no other declarations.
if (declNames.length == 0 && usingDeclarations != null) {
declNames = usingDeclarations.toArray(new IName[usingDeclarations.size()]);
}
return declNames;
}

View file

@ -151,7 +151,7 @@ public class CBreakIterator extends BreakIterator {
private int fState;
private final static int[][] MATRIX= new int[][] {
private static final int[][] MATRIX= new int[][] {
// K_INVALID, K_LOWER, K_UPPER, K_UNDERSCORE, K_OTHER
{ S_EXIT, S_LOWER, S_ONE_CAP, S_UNDERSCORE, S_LOWER }, // S_INIT
{ S_EXIT, S_LOWER, S_EXIT, S_UNDERSCORE, S_LOWER }, // S_LOWER

View file

@ -262,7 +262,7 @@ public final class CHeuristicScanner implements Symbols {
/* preset stop conditions */
private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition();
private final static StopCondition fNonWS= new NonWhitespace();
private static final StopCondition fNonWS= new NonWhitespace();
private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition();
/**

View file

@ -31,18 +31,19 @@ import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
/**
* This is the base class for the GDB/MI Unit tests.
@ -53,19 +54,22 @@ import org.junit.rules.TestName;
* code is to be run.
*/
public class BaseTestCase {
// Timeout value for each individual test
private final static int TEST_TIMEOUT = 5 * 60 * 1000; // 5 minutes in milliseconds
// Make the current test naem available through testName.getMethodName()
@Rule public TestName testName = new TestName();
// Add a timeout for each test, to make sure no test hangs
@Rule public TestRule timeout = new Timeout(TEST_TIMEOUT);
public static final String ATTR_DEBUG_SERVER_NAME = TestsPlugin.PLUGIN_ID + ".DEBUG_SERVER_NAME";
private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp.exe";
private static GdbLaunch fLaunch;
// The set of attributes used for the launch
// These are seset to their default whenever a new class
// of tests is started.
private static Map<String, Object> launchAttributes;
// The set of attributes used for the launch of a single test.
private Map<String, Object> launchAttributes;
// A set of global launch attributes which are not
// reset when we load a new class of tests.
@ -87,11 +91,11 @@ public class BaseTestCase {
public GdbLaunch getGDBLaunch() { return fLaunch; }
public static void setLaunchAttribute(String key, Object value) {
public void setLaunchAttribute(String key, Object value) {
launchAttributes.put(key, value);
}
public static void removeLaunchAttribute(String key) {
public void removeLaunchAttribute(String key) {
launchAttributes.remove(key);
}
@ -105,7 +109,7 @@ public class BaseTestCase {
public synchronized MIStoppedEvent getInitialStoppedEvent() { return fInitialStoppedEvent; }
public static boolean isRemoteSession() {
public boolean isRemoteSession() {
return launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE)
.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
}
@ -173,13 +177,17 @@ public class BaseTestCase {
}
}
}
@BeforeClass
public static void baseBeforeClassMethod() {
// Clear all launch attributes before starting a new class of tests
@Before
public void doBeforeTest() throws Exception {
setLaunchAttributes();
doLaunch();
}
protected void setLaunchAttributes() {
// Clear all launch attributes before starting a new test
launchAttributes = new HashMap<String, Object>();
// Setup information for the launcher
launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, DEFAULT_TEST_APP);
launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
@ -196,14 +204,21 @@ public class BaseTestCase {
launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_HOST, "localhost");
launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_PORT, "9999");
setGdbVersion();
// Set the global launch attributes
launchAttributes.putAll(globalLaunchAttributes);
}
@Before
public void baseBeforeMethod() throws Exception {
/**
* Launch GDB. The launch attributes must have been set already.
*/
protected void doLaunch() throws Exception {
boolean remote = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE).equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
System.out.println("====================================================================================================");
System.out.println("Running test: " + testName.getMethodName() + " using GDB: " + launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME));
System.out.println(String.format("Running test: %s using GDB: %s remote %s",
testName.getMethodName(), launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME), remote ? "on" : "off"));
System.out.println("====================================================================================================");
boolean postMortemLaunch = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE)
@ -272,22 +287,22 @@ public class BaseTestCase {
}
@After
public void baseAfterMethod() throws Exception {
public void doAfterTest() throws Exception {
if (fLaunch != null) {
fLaunch.terminate();
try {
fLaunch.terminate();
} catch (DebugException e) {
assert false : "Could not terminate launch";
}
fLaunch = null;
}
}
@AfterClass
public static void baseAfterClassMehod() throws Exception {
}
/**
* This method start gdbserver on the localhost.
* If the user specified a different host, things won't work.
*/
private static void launchGdbServer() {
private void launchGdbServer() {
if (launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE)
.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) {
if (launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP).equals(Boolean.TRUE)) {
@ -331,13 +346,17 @@ public class BaseTestCase {
* string that contains the major and minor version number, e.g.,
* "6.8"
*/
protected static void setGdbProgramNamesLaunchAttributes(String version) {
public static void setGdbProgramNamesLaunchAttributes(String version) {
// See bugzilla 303811 for why we have to append ".exe" on Windows
boolean isWindows = Platform.getOS().equals(Platform.OS_WIN32);
BaseTestCase.setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : ""));
BaseTestCase.setLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : ""));
setGlobalLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : ""));
setGlobalLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : ""));
}
protected void setGdbVersion() {
// Leave empty for the base class
}
/**
* In some tests we need to start a gdbserver session without starting gdbserver.
* This method allows super classes of this class control the launch of gdbserver.

View file

@ -22,8 +22,6 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.core.DebugException;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -35,8 +33,7 @@ public class CommandTimeoutTest extends BaseTestCase {
private static int fgTimeout = IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT;
@BeforeClass
public static void beforeClassMethod() {
// Save the original values of the timeout-related preferences
public static void doBeforeClass() throws Exception {
fgTimeoutEnabled = Platform.getPreferencesService().getBoolean(
GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT,
@ -48,21 +45,32 @@ public class CommandTimeoutTest extends BaseTestCase {
IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT,
null );
}
@Override
public void doBeforeTest() throws Exception {
setLaunchAttributes();
// Can't run the launch right away because each test needs to first set some
// parameters. The individual tests will be responsible for starting the launch.
// Save the original values of the timeout-related preferences
}
@Before
@Override
public void baseBeforeMethod() throws Exception {
}
public void doAfterTest() throws Exception {
// Don't call super here, as the launch is already terminated
@After
@Override
public void baseAfterMethod() throws Exception {
// Restore the timeout preferences
IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, fgTimeoutEnabled );
node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, fgTimeout );
}
protected void performLaunchAndTerminate() throws Exception {
// perform the launch
doLaunch();
// terminate the launch right away
super.doAfterTest();
}
@Override
protected boolean reallyLaunchGDBServer() {
return false;
@ -109,11 +117,6 @@ public class CommandTimeoutTest extends BaseTestCase {
}
}
private void performLaunchAndTerminate() throws Exception {
super.baseBeforeMethod();
super.baseAfterMethod();
}
/**
* Checks whether the given exception is an instance of {@link CoreException}
* with the status code 20100 which indicates that a gdb command has been timed out.

View file

@ -1,117 +0,0 @@
/*******************************************************************************
* Copyright (c) 2007, 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.tests.dsf.gdb.tests;
import static org.junit.Assert.assertTrue;
import java.io.FileNotFoundException;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
/*
* This is an example of how to write new JUnit test cases
* for services of DSF.
*
* Each test class should extend BaseTestCase
* so as to automatically launch the application before
* each testcase and tear it down after.
*
* Also, each new test class must be added to the list within AllTest.
*
* Finally, each testcase should be @RunWith(BackgroundRunner.class)
* so as to release the UI thread and allow things such as
* timeouts to work in JUnit
*/
// Each test must run with the BackgroundRunner so as
// to release the UI thread
@RunWith(BackgroundRunner.class)
public class ExampleTest extends BaseTestCase {
@BeforeClass
public static void beforeClassMethod() {
// Things to run once specifically for this class,
// before starting this set of tests.
// Any method name can be used
// To choose your own test application, use the following form
// You must make sure the compiled binary is available in the
// specified location.
// If this method call is not made, the default GDBMIGenericTestApp
// will be used
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
"data/launch/bin/SpecialTestApp.exe");
// Other attributes can be changed here
}
@AfterClass
public static void afterClassMethod() {
// Things to run once specifically for this class,
// after the launch has been performed
// Any method name can be used
}
@Before
public void beforeMethod() {
// Things to run specifically for this class,
// before each test but after the launch has been performed
// The Launched used is for the default test application
// Any method name can be used
}
@After
public void afterMethod() {
// Things to run specifically for this class
// after each test but before the launch has been torn down
// Any method name can be used
}
// @Override
// public void baseBeforeMethod() {
// // Can be used to override and prevent the baseSetup from being run
// // The name baseBeforeMethod must be used
// }
// @Override
// public void baseAfterMethod() {
// // Can be used to override and prevent the baseTeardown from being run
// // The name baseAfterMethod must be used
// }
@Test
public void basicTest() {
// First test to run
assertTrue("", true);
}
@Test(timeout=5000)
public void timeoutTest() {
// Second test to run, which will timeout if not finished on time
assertTrue("", true);
}
@Test(expected=FileNotFoundException.class)
public void exceptionTest() throws FileNotFoundException {
// Third test to run which expects an exception
throw new FileNotFoundException("Just testing");
}
}

View file

@ -32,10 +32,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -62,8 +59,10 @@ public class GDBProcessesTest extends BaseTestCase {
*/
private final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor();
@Before
public void init() throws Exception {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@Override
@ -75,14 +74,18 @@ public class GDBProcessesTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get();
}
@After
public void tearDown() {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
fProcService = null;
fServicesTracker.dispose();
}
@BeforeClass
public static void beforeClassMethod() {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME);
}

View file

@ -45,8 +45,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -71,29 +69,27 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
protected boolean fRestart;
@Override
@Before
public void baseBeforeMethod() throws Exception {
// The class BaseTestCase sets up the launch in its @BeforeClass method.
// Usually this is ok, because every test uses the same launch configuration.
// However, for the tests of this class, we are changing the launch
// configuration every time. Therefore, we need to reset it to the default
// before every test; that means in the @Before method instead of @BeforeClass
public void doBeforeTest() throws Exception {
setLaunchAttributes();
// Can't run the launch right away because each test needs to first set some
// parameters. The individual tests will be responsible for starting the launch.
}
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Reset the launch configuration
super.baseBeforeClassMethod();
// Set the binary
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, PROGRAM);
// Can't run the launch right away because each test needs to first set some
// parameters. The individual tests will be responsible for starting the launch.
}
// This method cannot be tagged as @Before, because the launch is not
// running yet. We have to call this manually after all the proper
// parameters have been set for the launch
public void performLaunch() throws Exception {
@Override
protected void doLaunch() throws Exception {
// perform the launch
super.baseBeforeMethod();
super.doLaunch();
fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@ -121,8 +117,10 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
}
}
@After
public void shutdown() throws Exception {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
if (fServicesTracker != null) fServicesTracker.dispose();
}
@ -132,7 +130,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
private static String fFullProgramPath;
@Test
public void getFullPath() throws Throwable {
performLaunch();
doLaunch();
MIStoppedEvent stopped = getInitialStoppedEvent();
fFullProgramPath = stopped.getFrame().getFullname();
}
@ -153,7 +151,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, dir);
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, dir + PROGRAM_NAME);
performLaunch();
doLaunch();
Query<MIInfo> query = new Query<MIInfo>() {
@Override
@ -185,7 +183,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
"gdbinitThatDoesNotExist");
try {
performLaunch();
doLaunch();
} catch (CoreException e) {
// Success of the test
return;
@ -203,7 +201,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
".gdbinit");
try {
performLaunch();
doLaunch();
} catch (CoreException e) {
fail("Launch has failed even though the gdbinit file has the default name of .gdbinit");
}
@ -219,7 +217,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
public void testSourceGdbInit() throws Throwable {
setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
"data/launch/src/launchConfigTestGdbinit");
performLaunch();
doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
@ -286,7 +284,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
@Test
public void testClearingEnvironment() throws Throwable {
setLaunchAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false);
performLaunch();
doLaunch();
SyncUtil.runToLocation("envTest");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
@ -335,7 +333,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
Map<String, String> map = new HashMap<String, String>(1);
map.put("LAUNCHTEST", "IS SET");
setLaunchAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
performLaunch();
doLaunch();
SyncUtil.runToLocation("envTest");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
@ -409,7 +407,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
Map<String, String> map = new HashMap<String, String>(1);
map.put("LAUNCHTEST", "IS SET");
setLaunchAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
performLaunch();
doLaunch();
SyncUtil.runToLocation("envTest");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
@ -477,7 +475,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
@Test
public void testSettingArguments() throws Throwable {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "1 2 3\n4 5 6");
performLaunch();
doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
@ -544,7 +542,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
public void testStopAtMain() throws Throwable {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "main");
performLaunch();
doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
assertTrue("Expected to stop at main:27 but got " +
@ -571,7 +569,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
public void testStopAtOther() throws Throwable {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "stopAtOther");
performLaunch();
doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
assertTrue("Expected to stop at stopAtOther but got " +
@ -608,7 +606,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
IFile fakeFile = null;
CDIDebugModel.createLineBreakpoint(PROGRAM, fakeFile, ICBreakpointType.REGULAR, LAST_LINE_IN_MAIN + 1, true, 0, "", true); //$NON-NLS-1$
performLaunch();
doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
assertTrue("Expected to stop at envTest but got " +

View file

@ -55,10 +55,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -167,18 +163,17 @@ public class MIBreakpointsTest extends BaseTestCase {
// Housekeeping stuff
// ========================================================================
@BeforeClass
public static void testSuiteInitialization() {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, TEST_APPL);
}
@AfterClass
public static void testSuiteCleanup() {
}
@Before
public void testCaseInitialization() throws Exception {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
// Get a reference to the breakpoint service
fSession = getGDBLaunch().getSession();
@ -210,9 +205,10 @@ public class MIBreakpointsTest extends BaseTestCase {
assert(fBreakpointsDmc != null);
}
@After
public void testCaseCleanup() throws Exception {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
// Clear the references (not strictly necessary)
Runnable runnable = new Runnable() {
@Override

View file

@ -61,10 +61,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -148,18 +144,9 @@ public class MICatchpointsTest extends BaseTestCase {
// Housekeeping stuff
// ========================================================================
@BeforeClass
public static void testSuiteInitialization() {
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, TEST_APPL);
}
@AfterClass
public static void testSuiteCleanup() {
}
@Before
public void testCaseInitialization() throws Exception {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
// Get a reference to the breakpoint service
fSession = getGDBLaunch().getSession();
@ -190,11 +177,20 @@ public class MICatchpointsTest extends BaseTestCase {
IContainerDMContext containerDmc = SyncUtil.getContainerContext();
fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class);
assertNotNull(fBreakpointsDmc);
}
@After
public void testCaseCleanup() throws Exception {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, TEST_APPL);
}
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
Runnable runnable = new Runnable() {
@Override
public void run() {

View file

@ -40,10 +40,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.cdt.utils.Addr64;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -78,18 +74,10 @@ public class MIDisassemblyTest extends BaseTestCase {
// Housekeeping stuff
// ========================================================================
@BeforeClass
public static void testSuiteInitialization() {
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/MemoryTestApp.exe");
}
@AfterClass
public static void testSuiteCleanup() {
}
@Before
public void testCaseInitialization() throws Exception {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@Override
@ -113,8 +101,18 @@ public class MIDisassemblyTest extends BaseTestCase {
}
@After
public void testCaseCleanup() {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/MemoryTestApp.exe");
}
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
fExpressionService = null;
fDisassembly = null;
fServicesTracker.dispose();

View file

@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.HashMap;
@ -52,9 +52,6 @@ import org.eclipse.cdt.utils.Addr32;
import org.eclipse.cdt.utils.Addr64;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -75,15 +72,18 @@ public class MIExpressionsTest extends BaseTestCase {
private IExpressionDMContext globalExpressionCtx1 = null;
private IExpressionDMContext globalExpressionCtx2 = null;
@BeforeClass
public static void beforeClassMethod() {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/ExpressionTestApp.exe");
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/ExpressionTestApp.exe");
}
@Before
public void init() throws Exception {
fSession = getGDBLaunch().getSession();
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@Override
public void run() {
@ -97,8 +97,10 @@ public class MIExpressionsTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get();
}
@After
public void shutdown() throws Exception {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
Runnable runnable = new Runnable() {
@Override
public void run() {

View file

@ -40,10 +40,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.cdt.utils.Addr64;
import org.eclipse.debug.core.model.MemoryByte;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -81,18 +77,12 @@ public class MIMemoryTest extends BaseTestCase {
// Housekeeping stuff
// ========================================================================
@BeforeClass
public static void testSuiteInitialization() {
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/MemoryTestApp.exe");
}
@AfterClass
public static void testSuiteCleanup() {
}
@Before
public void testCaseInitialization() throws Throwable {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession();
fMemoryDmc = (IMemoryDMContext)SyncUtil.getContainerContext();
assert(fMemoryDmc != null);
@ -121,8 +111,18 @@ public class MIMemoryTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get();
}
@After
public void testCaseCleanup() throws Exception {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/MemoryTestApp.exe");
}
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
// Clear the references (not strictly necessary)
Runnable runnable = new Runnable() {
@Override

View file

@ -55,16 +55,12 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class MIRegistersTest extends BaseTestCase {
protected List<String> get_X86_REGS() {
@ -90,16 +86,16 @@ public class MIRegistersTest extends BaseTestCase {
private static final String EXEC_NAME = "MultiThread.exe";
private static final String SRC_NAME = "MultiThread.cc";
// Will be used to wait for asynchronous call to complete
//private final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor();
private DsfSession fSession;
private DsfServicesTracker fServicesTracker;
private IContainerDMContext fContainerDmc;
private IRegisters fRegService;
private IRunControl fRunControl;
@Before
public void init() throws Exception {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@ -121,15 +117,19 @@ public class MIRegistersTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get();
}
@BeforeClass
public static void beforeClassMethod() {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME);
}
@After
public void tearDown() {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
fServicesTracker.dispose();
fRegService = null;
}

View file

@ -37,10 +37,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -70,8 +67,10 @@ public class MIRunControlTargetAvailableTest extends BaseTestCase {
private static final String EXEC_NAME = "TargetAvail.exe";
private static final String SOURCE_NAME = "TargetAvail.cc";
@Before
public void init() throws Exception {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
final DsfSession session = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@ -91,13 +90,17 @@ public class MIRunControlTargetAvailableTest extends BaseTestCase {
}
@After
public void tearDown() {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
fServicesTracker.dispose();
}
@BeforeClass
public static void beforeClassMethod() {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME);
}

View file

@ -52,10 +52,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -98,8 +95,10 @@ public class MIRunControlTest extends BaseTestCase {
private static final String EXEC_NAME = "MultiThread.exe";
private static final String SOURCE_NAME = "MultiThread.cc";
@Before
public void init() throws Exception {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
final DsfSession session = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@ -123,13 +122,17 @@ public class MIRunControlTest extends BaseTestCase {
}
@After
public void tearDown() {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
fServicesTracker.dispose();
}
@BeforeClass
public static void beforeClassMethod() {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME);

View file

@ -38,10 +38,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.service.prefs.Preferences;
@ -70,8 +67,10 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
*/
private static final String EXEC_NAME = "TargetAvail.exe";
@Before
public void init() throws Exception {
@Override
public void doBeforeTest() throws Exception {
super.doBeforeTest();
final DsfSession session = getGDBLaunch().getSession();
Runnable runnable = new Runnable() {
@ -92,13 +91,17 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
}
@After
public void tearDown() {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
fServicesTracker.dispose();
}
@BeforeClass
public static void beforeClassMethod() {
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME);
}
@ -110,7 +113,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test
public void restartWhileTargetRunningKillGDB() throws Throwable {
// Restart is not supported for a remote session
if (BaseTestCase.isRemoteSession()) {
if (isRemoteSession()) {
Assert.assertFalse("Restart operation should not be allowed for a remote session",
SyncUtil.canRestart());
return;
@ -140,7 +143,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test
public void restartWhileTargetRunningGDBAlive() throws Throwable {
// Restart is not supported for a remote session
if (BaseTestCase.isRemoteSession()) {
if (isRemoteSession()) {
Assert.assertFalse("Restart operation should not be allowed for a remote session",
SyncUtil.canRestart());
return;

View file

@ -51,9 +51,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.MemoryByte;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -70,22 +67,16 @@ public class PostMortemCoreTest extends BaseTestCase {
private IMemoryDMContext fMemoryDmc;
@BeforeClass
public static void beforeClassMethod() {
}
@Override
@Before
public void baseBeforeMethod() throws Exception {
// The class BaseTestCase sets up the launch in its @BeforeClass method.
// Usually this is ok, because every test uses the same launch configuration.
// However, for some of the tests of this class, we are changing the launch
// configuration. Therefore, we need to reset it to the default
// before every test; that means in the @Before method instead of @BeforeClass
// Reset the launch configuration
super.baseBeforeClassMethod();
public void doBeforeTest() throws Exception {
setLaunchAttributes();
// Can't run the launch right away because each test needs to first set some
// parameters. The individual tests will be responsible for starting the launch.
}
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Set a working directory for GDB that is different than eclipse's directory.
// This allows us to make sure we properly handle finding the core file,
@ -103,18 +94,15 @@ public class PostMortemCoreTest extends BaseTestCase {
IGDBLaunchConfigurationConstants.DEBUGGER_POST_MORTEM_CORE_FILE);
// Set default core file path
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, "data/launch/bin/core");
// Can't run the launch right away because each test needs to first set some
// parameters. The individual tests will be responsible for starting the launch.
}
// This method cannot be tagged as @Before, because the launch is not
// running yet. We have to call this manually after all the proper
// parameters have been set for the launch
public void performLaunch() throws Exception {
@Override
protected void doLaunch() throws Exception {
// perform the launch
super.baseBeforeMethod();
super.doLaunch();
fSession = getGDBLaunch().getSession();
@ -132,8 +120,10 @@ public class PostMortemCoreTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get();
}
@After
public void shutdown() throws Exception {
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
if (fSession != null) {
Runnable runnable = new Runnable() {
@Override
@ -161,7 +151,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile);
performLaunch();
doLaunch();
// If the launch passed, we are ok, nothing more to check
}
@ -178,7 +168,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile);
performLaunch();
doLaunch();
// If the launch passed, we are ok, nothing more to check
}
@ -196,7 +186,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile);
try {
performLaunch();
doLaunch();
} catch (DebugException e) {
// Success of the test
return;
@ -218,7 +208,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile);
try {
performLaunch();
doLaunch();
} catch (CoreException e) {
// Success of the test
return;
@ -240,7 +230,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile);
try {
performLaunch();
doLaunch();
} catch (CoreException e) {
// Success of the test
return;
@ -262,7 +252,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile);
try {
performLaunch();
doLaunch();
} catch (CoreException e) {
// Success of the test
return;
@ -319,7 +309,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, coreFile);
performLaunch();
doLaunch();
}
/**
@ -327,7 +317,7 @@ public class PostMortemCoreTest extends BaseTestCase {
*/
@Test
public void testLiteralIntegerExpressions() throws Throwable {
performLaunch();
doLaunch();
// Create a map of expressions and their expected values.
Map<String, String[]> tests = new HashMap<String, String[]>();
@ -350,7 +340,7 @@ public class PostMortemCoreTest extends BaseTestCase {
*/
@Test
public void testLiteralFloatingPointExpressions() throws Throwable {
performLaunch();
doLaunch();
// Create a map of expressions and their expected values.
Map<String, String[]> tests = new HashMap<String, String[]>();
@ -374,7 +364,7 @@ public class PostMortemCoreTest extends BaseTestCase {
*/
@Test
public void testLocalVariables() throws Throwable {
performLaunch();
doLaunch();
// Create a map of expressions to expected values.
Map<String, String[]> tests1 = new HashMap<String, String[]>();
@ -406,7 +396,7 @@ public class PostMortemCoreTest extends BaseTestCase {
@Test
public void readMemoryArray() throws Throwable {
performLaunch();
doLaunch();
IAddress address = evaluateExpression(SyncUtil.getStackFrame(SyncUtil.getExecutionContext(0), 0), "&lBoolPtr2");

View file

@ -14,13 +14,12 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class CommandTimeoutTest_6_6 extends CommandTimeoutTest {
@BeforeClass
public static void beforeClassMethod_6_6() {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
}
}

View file

@ -13,13 +13,12 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.GDBProcessesTest;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class GDBProcessesTest_6_6 extends GDBProcessesTest {
@BeforeClass
public static void beforeClassMethod_6_6() {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
}
}

View file

@ -13,17 +13,12 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.LaunchConfigurationAndRestartTest;
import org.junit.Before;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class LaunchConfigurationAndRestartTest_6_6 extends LaunchConfigurationAndRestartTest {
// For the launch config test, we must set the attributes in the @Before method
// instead of the @BeforeClass method. This is because the attributes are overwritten
// by the tests themselves
@Before
public void beforeMethod_6_6() {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
}
}

View file

@ -13,13 +13,12 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.MIBreakpointsTest;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class MIBreakpointsTest_6_6 extends MIBreakpointsTest {
@BeforeClass
public static void beforeClassMethod_6_6() {
@Override
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
}
}

Some files were not shown because too many files have changed in this diff Show more