mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Combined classes CPPNameCollector and CNameCollector into a single
NameCollector class, as was suggested by Nathan Ridge.
This commit is contained in:
parent
6ffc402b86
commit
dc086d6a53
15 changed files with 539 additions and 804 deletions
|
@ -73,7 +73,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
public void testBinaryExpressions() throws Exception {
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
IASTImplicitName n;
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
public void testPointerToMember() throws Exception {
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ba.assertNoImplicitName("&Y::x;", 1);
|
||||
|
@ -168,7 +168,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
public void testArrowOperator() throws Exception {
|
||||
String contents = getAboveComment();
|
||||
IASTTranslationUnit tu = parse(contents, ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IASTImplicitName[] implicits = getImplicitNames(tu, contents, "->doA();", 2);
|
||||
|
@ -231,7 +231,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
ba.assertNoImplicitName(", d; // expr", 1);
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertSame(opAB.resolveBinding(), col.getName(5).resolveBinding());
|
||||
|
@ -262,7 +262,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
IASTImplicitName opDD = ba.assertImplicitName(", d", 1, ICPPMethod.class);
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
// 6, 11, 15
|
||||
|
@ -288,7 +288,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
public void testFunctionCallOperator() throws Exception {
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IASTImplicitName n1 = ba.assertImplicitName("(b); // 1", 1, ICPPMethod.class);
|
||||
|
@ -347,7 +347,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
public void testArraySubscript() throws Exception {
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IASTImplicitName n1 = ba.assertImplicitName("[0]); //1", 1, ICPPMethod.class);
|
||||
|
@ -387,7 +387,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
IASTImplicitName delete = names[1];
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertSame(col.getName(1).resolveBinding(), destructor.resolveBinding());
|
||||
|
@ -485,7 +485,7 @@ public class AST2CPPImplicitNameTests extends AST2TestBase {
|
|||
IASTImplicitName n3 = ba.assertImplicitName("new (5, 6) int", 3, ICPPFunction.class);
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertSame(col.getName(4).resolveBinding(), n1.resolveBinding());
|
||||
|
|
|
@ -1853,7 +1853,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
|
|||
// S<int(1)> y; // expression (illformed)
|
||||
public void test8_2s4() throws Exception {
|
||||
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 1);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertInstance(col.getName(4), ICPPASTTemplateId.class);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2005, 2013 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 Rational Software - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -608,7 +608,7 @@ public class AST2KnRTests extends AST2TestBase {
|
|||
buffer.append("void f(int); \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IFunction def = (IFunction) col.getName(0).resolveBinding();
|
||||
|
|
|
@ -131,15 +131,15 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
return new BindingAssertionHelper(code, true);
|
||||
}
|
||||
|
||||
private CPPNameCollector getCPPNameCollector(IASTTranslationUnit ast) {
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
private NameCollector getNameCollector(IASTTranslationUnit ast) {
|
||||
NameCollector collector = new NameCollector();
|
||||
ast.accept(collector);
|
||||
return collector;
|
||||
}
|
||||
|
||||
public void testBasicClassTemplate() throws Exception {
|
||||
IASTTranslationUnit tu = parse("template <class T> class A{ T t; };", CPP); //$NON-NLS-1$
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -171,7 +171,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBasicTemplateInstance_a() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 14);
|
||||
|
@ -222,7 +222,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBasicTemplateInstance_b() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
|
||||
|
@ -254,7 +254,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBasicTemplateFunction() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -283,7 +283,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testStackOverflow_a() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertTrue(col.getName(0).resolveBinding() instanceof ICPPTemplateParameter);
|
||||
|
@ -304,7 +304,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template < class T > class A< T** > {};
|
||||
public void testBasicClassPartialSpecialization() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -330,7 +330,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template < class T > typename A<T>::TYPE foo(T);
|
||||
public void testStackOverflow_b() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T0 = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -365,7 +365,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template < class T > void A<T>::f() { }
|
||||
public void testTemplateMemberDef() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPMethod f1 = (ICPPMethod) col.getName(2).resolveBinding();
|
||||
|
@ -380,7 +380,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testTemplateFunctionImplicitInstantiation() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -399,7 +399,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test_14_5_5_2s5_OrderingFunctionTemplates_a() throws Exception{
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -423,7 +423,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test_14_5_5_2s5_OrderingFunctionTemplates_b() throws Exception{
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -439,7 +439,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testTemplateParameters() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateTypeParameter T = (ICPPTemplateTypeParameter) col.getName(0).resolveBinding();
|
||||
|
@ -466,7 +466,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testDeferredInstances() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -506,7 +506,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// A <int*, int*, 2> a5; //ambiguous, matches #3 & #5.
|
||||
public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(3).resolveBinding();
|
||||
|
@ -549,7 +549,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template <> void f<int>(int*); //ok
|
||||
public void test14_7_3_FunctionExplicitSpecialization() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate fT1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -566,7 +566,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// void g(int* p) { f(p); }
|
||||
public void test_14_5_5_1_FunctionTemplates_a() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -580,7 +580,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// void g(int* p) { f(p); }
|
||||
public void test_14_5_5_1_FunctionTemplates_b() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -596,7 +596,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test_14_8_1s2_FunctionTemplates() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(3).resolveBinding();
|
||||
|
@ -612,7 +612,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test14_8_3s6_FunctionTemplates() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -632,7 +632,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test14_5_5_2s6_FunctionTemplates() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -659,7 +659,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void test14_6_1s1_LocalNames() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate X = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -680,7 +680,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test14_8s2_() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(2).resolveBinding();
|
||||
|
@ -711,7 +711,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template<> int g<>(int) { } // OK: not inline
|
||||
public void test14_7_3s14() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -740,7 +740,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test14_7_1s14_InfiniteInstantiation() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate X = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -772,7 +772,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void test14_6_1s2() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate Y = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -796,7 +796,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug45129() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunction f1 = (ICPPFunction) col.getName(2).resolveBinding();
|
||||
|
@ -819,7 +819,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug76951() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -849,7 +849,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// void f(A<int> p) { }
|
||||
public void testInstances() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -865,7 +865,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template <class T> void f(T) {}
|
||||
public void testTemplateParameterDeclarations() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(4).resolveBinding();
|
||||
|
@ -887,7 +887,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testDeferredInstantiation() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -933,7 +933,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test14_5_2s2_MemberSpecializations() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -977,7 +977,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// A<int> ai;
|
||||
public void testClassSpecializations() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1009,7 +1009,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// void A<int>::f(int) { }
|
||||
public void test14_7_3s5_SpecializationMemberDefinition() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1046,7 +1046,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testNestedSpecializations() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassType C = (ICPPClassType) col.getName(0).resolveBinding();
|
||||
|
@ -1088,7 +1088,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// A<int,int*> a;
|
||||
public void test14_5_4s7_UsingClassTemplate() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(3).resolveBinding();
|
||||
|
@ -1118,7 +1118,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testTemplateTemplateParameter() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1165,7 +1165,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testNestedTypeSpecializations() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -1199,7 +1199,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testNestedClassTypeSpecializations() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -1238,7 +1238,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testTemplateParameterQualifiedType() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateTypeParameter T = (ICPPTemplateTypeParameter) col.getName(0).resolveBinding();
|
||||
|
@ -1290,7 +1290,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testTemplateScopes_a() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -1314,7 +1314,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template <class U> void A::f<>(U){}
|
||||
public void testTemplateScopes_b() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
|
||||
|
@ -1471,7 +1471,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template<> void A<int>::h(int) { }
|
||||
public void test14_7_3s16() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -1533,7 +1533,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void test14_6_1s6() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(2).resolveBinding();
|
||||
|
@ -1566,7 +1566,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template void sort<>(Array<int> &);
|
||||
public void testBug90689_ExplicitInstantiation() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1592,7 +1592,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// template void sort(Array<char>&); // argument is deduced here
|
||||
public void test14_7_2s2_ExplicitInstantiation() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1615,7 +1615,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testBug74204() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IField p = (IField) col.getName(5).resolveBinding();
|
||||
|
@ -1634,7 +1634,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testDeferredFunctionTemplates() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1653,7 +1653,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testRelaxationForTemplateInheritance() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPMethod init = (ICPPMethod) col.getName(4).resolveBinding();
|
||||
|
@ -1679,7 +1679,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug91707() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPMethod begin = (ICPPMethod) col.getName(16).resolveBinding();
|
||||
|
@ -1709,7 +1709,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug98961() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassType B = (ICPPClassType) col.getName(0).resolveBinding();
|
||||
|
@ -1732,7 +1732,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testBug98784() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertSame(col.getName(5).resolveBinding(), col.getName(6).resolveBinding());
|
||||
|
@ -1812,7 +1812,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testBug98666() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse("A::template B<T> b;", CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0);
|
||||
|
@ -1831,7 +1831,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// A<short>::C::B<int*> ab;
|
||||
public void testBug90678() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -1863,7 +1863,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testBug95208() throws Exception {
|
||||
String content= getAboveComment();
|
||||
IASTTranslationUnit tu = parse(content, CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1878,7 +1878,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
|
||||
|
||||
tu = parse(content,CPP);
|
||||
col = new CPPNameCollector();
|
||||
col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1892,7 +1892,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testBug103578() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate A = (ICPPClassTemplate) col.getName(2).resolveBinding();
|
||||
|
@ -1912,7 +1912,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug103715() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPField base = (ICPPField) col.getName(4).resolveBinding();
|
||||
|
@ -1937,7 +1937,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug74276() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassTemplate complex = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
@ -1963,7 +1963,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug105852() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ITypedef myType = (ITypedef) col.getName(31).resolveBinding();
|
||||
|
@ -1985,7 +1985,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug105769() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPVariable c = (ICPPVariable) col.getName(13).resolveBinding();
|
||||
|
@ -2000,7 +2000,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testBug162230() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -2035,7 +2035,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// typedef struct C<int> CInt;
|
||||
public void testBug169628() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertTrue(col.getName(2).resolveBinding() instanceof ICPPSpecialization);
|
||||
|
@ -2376,7 +2376,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testCPPConstructorTemplateSpecialization() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
NameCollector col = new NameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
IASTImplicitName tid= (IASTImplicitName) col.getName(20);
|
||||
|
@ -2398,7 +2398,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testNestedFuncTemplatedDeclarator_bug190241() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IASTName name;
|
||||
|
@ -2448,7 +2448,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (IASTName name : col.nameList) {
|
||||
if ("r".equals(String.valueOf(name))) {
|
||||
|
@ -2482,7 +2482,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (IASTName name : col.nameList) {
|
||||
if ("r".equals(String.valueOf(name))) {
|
||||
|
@ -2522,7 +2522,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (IASTName name : col.nameList) {
|
||||
if ("r".equals(String.valueOf(name))) {
|
||||
|
@ -2560,7 +2560,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testRebindPattern_236197() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (IASTName name : col.nameList) {
|
||||
if ("r".equals(String.valueOf(name))) {
|
||||
|
@ -2592,7 +2592,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testSpecializationSelection_229218() throws Exception {
|
||||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (IASTName name : col.nameList) {
|
||||
if ("r".equals(String.valueOf(name))) {
|
||||
|
@ -2622,7 +2622,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
CPPASTNameBase.sAllowNameComputation= true;
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (IASTName name : col.nameList) {
|
||||
if ("x".equals(String.valueOf(name))) {
|
||||
|
@ -2766,7 +2766,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// A<i> a1;
|
||||
public void testNonTypeArgumentIsIDExpression_229942a() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertInstance(col.getName(4).getParent(), ICPPASTTemplateId.class);
|
||||
|
@ -2785,7 +2785,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testNonTypeArgumentIsIDExpression_229942b() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertInstance(col.getName(5).getParent(), ICPPASTTemplateId.class);
|
||||
|
@ -2799,7 +2799,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// A<i+1> a1;
|
||||
public void testExpressionArgumentIsExpression_229942() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertInstance(col.getName(4).getParent(), ICPPASTTemplateId.class);
|
||||
|
@ -2814,7 +2814,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// A<typeid(1)> a1;
|
||||
public void testTypeIdOperatorArgumentIsUnaryExpression_229942() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertInstance(col.getName(3), ICPPASTTemplateId.class);
|
||||
|
@ -2827,7 +2827,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// class A< C<T1, q1>, C<T2, q2> > {};
|
||||
public void testTemplateIdAsTemplateArgumentIsTypeId_229942() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
// 12 is template-id: C<T1, q1>
|
||||
|
@ -2860,7 +2860,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
ba.assertNonProblem("T> at) {", 1);
|
||||
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertInstance(col.getName(23).getParent().getParent(), IASTTypeId.class);
|
||||
|
@ -2880,7 +2880,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// }
|
||||
public void testTypeIdAsTemplateArgumentIsTypeId_229942b() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
// 7 is T in A<T>
|
||||
|
@ -2896,7 +2896,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
// };
|
||||
public void testNonAmbiguityCase_229942() throws Exception {
|
||||
IASTTranslationUnit tu= parse(getAboveComment(), CPP);
|
||||
CPPNameCollector col= new CPPNameCollector();
|
||||
NameCollector col= new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
// 2 is Alias
|
||||
|
@ -3492,7 +3492,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testBug177418() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true );
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept( col );
|
||||
|
||||
ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
|
@ -6413,7 +6413,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
|
||||
ICPPField x = assertionHelper.assertNonProblem("int x", "x", ICPPField.class);
|
||||
|
@ -6442,7 +6442,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S", "S", ICPPClassType.class);
|
||||
ICPPField x = assertionHelper.assertNonProblem("T x;", "x", ICPPField.class);
|
||||
|
@ -6467,7 +6467,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class);
|
||||
ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;", "Alias<float>", ICPPAliasTemplateInstance.class);
|
||||
|
@ -6490,7 +6490,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
|
@ -6765,7 +6765,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ITypedef function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function", ITypedef.class);
|
||||
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int)", "foo", ICPPFunction.class);
|
||||
|
@ -6806,7 +6806,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (int)", "function", ICPPAliasTemplate.class);
|
||||
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
|
||||
|
@ -6826,7 +6826,7 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
parseAndCheckBindings();
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
NameCollector collector = getNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
ICPPAliasTemplate function = assertionHelper.assertNonProblem("using function = void (&)(int)", "function", ICPPAliasTemplate.class);
|
||||
ICPPFunction foo = assertionHelper.assertNonProblem("void foo(int) {", "foo", ICPPFunction.class);
|
||||
|
|
|
@ -302,49 +302,12 @@ public class AST2TestBase extends BaseTestCase {
|
|||
return (T) copy;
|
||||
}
|
||||
|
||||
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List<IASTName> nameList = new ArrayList<IASTName>();
|
||||
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
nameList.add(name);
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public IASTName getName(int idx) {
|
||||
if (idx < 0 || idx >= nameList.size())
|
||||
return null;
|
||||
return nameList.get(idx);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertInstances(CNameCollector collector, IBinding binding, int num) throws Exception {
|
||||
int count = 0;
|
||||
|
||||
assertNotNull(binding);
|
||||
|
||||
for (int i = 0; i < collector.size(); i++) {
|
||||
if (collector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
}
|
||||
|
||||
assertEquals(count, num);
|
||||
}
|
||||
|
||||
static protected class CPPNameCollector extends ASTVisitor {
|
||||
public CPPNameCollector() {
|
||||
static protected class NameCollector extends ASTVisitor {
|
||||
public NameCollector() {
|
||||
this(false); // don't visit implicit names by default
|
||||
}
|
||||
|
||||
public CPPNameCollector(boolean shouldVisitImplicitNames) {
|
||||
public NameCollector(boolean shouldVisitImplicitNames) {
|
||||
this.shouldVisitNames = true;
|
||||
this.shouldVisitImplicitNames = shouldVisitImplicitNames;
|
||||
}
|
||||
|
@ -376,7 +339,7 @@ public class AST2TestBase extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
protected void assertInstances(CPPNameCollector collector, IBinding binding, int num) throws Exception {
|
||||
protected void assertInstances(NameCollector collector, IBinding binding, int num) throws Exception {
|
||||
int count = 0;
|
||||
for (int i = 0; i < collector.size(); i++) {
|
||||
if (collector.getName(i).resolveBinding() == binding)
|
||||
|
@ -792,22 +755,22 @@ public class AST2TestBase extends BaseTestCase {
|
|||
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions,
|
||||
boolean skipTrivialInitializers) throws Exception {
|
||||
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertNoProblemBindings(col);
|
||||
return tu;
|
||||
}
|
||||
|
||||
final protected void assertNoProblemBindings(CNameCollector col) {
|
||||
final protected void assertNoProblemBindings(NameCollector col) {
|
||||
for (IASTName n : col.nameList) {
|
||||
assertFalse("ProblemBinding for " + n.getRawSignature(), n.resolveBinding() instanceof IProblemBinding);
|
||||
}
|
||||
}
|
||||
|
||||
final protected void assertProblemBindings(CNameCollector col, int count) {
|
||||
final protected void assertProblemBindings(NameCollector col, int count) {
|
||||
int sum = 0;
|
||||
for (IASTName n : col.nameList) {
|
||||
if (n.getBinding() instanceof IProblemBinding)
|
||||
if (n.resolveBinding() instanceof IProblemBinding)
|
||||
++sum;
|
||||
}
|
||||
assertEquals(count, sum);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
|
@ -194,7 +194,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// int (*(zzz4)) (char);
|
||||
public void testBug40768() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertNoProblemBindings(col);
|
||||
}
|
||||
|
@ -1265,7 +1265,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 3);
|
||||
|
@ -2608,7 +2608,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// // }
|
||||
// public void testExternalVariable() throws Exception {
|
||||
// IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
// CNameCollector col = new CNameCollector();
|
||||
// NameCollector col = new NameCollector();
|
||||
// tu.accept(col);
|
||||
//
|
||||
// IVariable a = (IVariable) col.getName(1).resolveBinding();
|
||||
|
@ -2630,7 +2630,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IVariable a = (IVariable) col.getName(1).resolveBinding();
|
||||
|
@ -2655,7 +2655,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
@ -2680,7 +2680,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 6);
|
||||
|
@ -2736,7 +2736,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -2756,7 +2756,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 5);
|
||||
|
@ -2775,7 +2775,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
"struct s { int a; } ss = { .a = 1 }; \n", C); //$NON-NLS-1$
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 4);
|
||||
|
@ -2803,7 +2803,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -2824,7 +2824,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug84185() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -2843,7 +2843,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug84185_2() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -2872,7 +2872,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
public void testBug84266() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit tu = parse(code, C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertEquals(col.size(), 7);
|
||||
|
||||
|
@ -2881,7 +2881,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
assertSame(s_ref, s_decl);
|
||||
|
||||
tu = parse(code, C);
|
||||
col = new CNameCollector();
|
||||
col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertEquals(col.size(), 7);
|
||||
|
||||
|
@ -2892,7 +2892,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
|
||||
public void testBug84266_2() throws Exception {
|
||||
IASTTranslationUnit tu = parse("struct s f(void);", C); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -2901,7 +2901,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
assertNotNull(s);
|
||||
|
||||
tu = parse("struct s f(void) {}", C); //$NON-NLS-1$
|
||||
col = new CNameCollector();
|
||||
col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -2921,7 +2921,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
for (ParserLanguage lang : ParserLanguage.values()) {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit tu = parse(code, lang);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertEquals(col.size(), 6);
|
||||
|
||||
|
@ -2931,7 +2931,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
|
||||
|
||||
tu = parse(code, lang);
|
||||
col = new CNameCollector();
|
||||
col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertEquals(col.size(), 6);
|
||||
|
||||
|
@ -2948,7 +2948,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug84267() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 11);
|
||||
|
@ -2975,7 +2975,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug84228() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 13);
|
||||
|
@ -3029,7 +3029,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
public void testBug86766() throws Exception {
|
||||
IASTTranslationUnit tu = parse(
|
||||
"char foo; void foo() {}", C); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IVariable foo = (IVariable) col.getName(0).resolveBinding();
|
||||
|
@ -3042,7 +3042,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
public void testBug88338_C() throws Exception {
|
||||
IASTTranslationUnit tu = parse(
|
||||
"struct A; struct A* a;", C); //$NON-NLS-1$
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertTrue(col.getName(0).isDeclaration());
|
||||
|
@ -3051,7 +3051,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
assertFalse(col.getName(1).isDeclaration());
|
||||
|
||||
tu = parse("struct A* a; struct A;", C); //$NON-NLS-1$
|
||||
col = new CPPNameCollector();
|
||||
col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
col.getName(2).resolveBinding();
|
||||
|
@ -3065,7 +3065,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
|
||||
public void test88460() throws Exception {
|
||||
IASTTranslationUnit tu = parse("void f();", C); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IFunction f = (IFunction) col.getName(0).resolveBinding();
|
||||
|
@ -3075,7 +3075,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
public void testBug90253() throws Exception {
|
||||
IASTTranslationUnit tu = parse(
|
||||
"void f(int par) { int v1; };", C); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IFunction f = (IFunction) col.getName(0).resolveBinding();
|
||||
|
@ -3104,7 +3104,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testFind() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICompositeType S1 = (ICompositeType) col.getName(0).resolveBinding();
|
||||
|
@ -3128,14 +3128,14 @@ public class AST2Tests extends AST2TestBase {
|
|||
public void test92791() throws Exception {
|
||||
IASTTranslationUnit tu = parse(
|
||||
"void f() { int x, y; x * y; }", C); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (int i = 0; i < col.size(); ++i)
|
||||
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
|
||||
|
||||
tu = parse(
|
||||
"int y; void f() { typedef int x; x * y; }", C); //$NON-NLS-1$
|
||||
col = new CNameCollector();
|
||||
col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (int i = 0; i < col.size(); ++i)
|
||||
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
|
||||
|
@ -3144,7 +3144,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
public void testBug85786() throws Exception {
|
||||
IASTTranslationUnit tu = parse(
|
||||
"void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", C); //$NON-NLS-1$
|
||||
CNameCollector nameResolver = new CNameCollector();
|
||||
NameCollector nameResolver = new NameCollector();
|
||||
tu.accept(nameResolver);
|
||||
assertNoProblemBindings(nameResolver);
|
||||
}
|
||||
|
@ -3156,7 +3156,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug95720() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C);
|
||||
CNameCollector nameResolver = new CNameCollector();
|
||||
NameCollector nameResolver = new NameCollector();
|
||||
tu.accept(nameResolver);
|
||||
assertNoProblemBindings(nameResolver);
|
||||
}
|
||||
|
@ -3229,7 +3229,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// x; }) zoot;
|
||||
public void testBug93980() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C, true);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IFunction foo = (IFunction) col.getName(0).resolveBinding();
|
||||
|
@ -3243,14 +3243,14 @@ public class AST2Tests extends AST2TestBase {
|
|||
|
||||
public void testBug95866() throws Exception {
|
||||
IASTTranslationUnit tu = parse("int test[10] = { [0 ... 9] = 2 };", C, true, true); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertNoProblemBindings(col);
|
||||
}
|
||||
|
||||
public void testBug98502() throws Exception {
|
||||
IASTTranslationUnit tu = parse("typedef enum { ONE } e;", C, true, true); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IEnumeration etion = (IEnumeration) col.getName(0).resolveBinding();
|
||||
|
@ -3266,7 +3266,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug98365() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C, true);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IEnumerator etor = (IEnumerator) col.getName(2).resolveBinding();
|
||||
|
@ -3293,7 +3293,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug98960() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C, true);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IVariable a1 = (IVariable) col.getName(1).resolveBinding();
|
||||
|
@ -3306,7 +3306,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
|
||||
public void testBug100408() throws Exception {
|
||||
IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", C); //$NON-NLS-1$
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertNoProblemBindings(col);
|
||||
}
|
||||
|
@ -3322,7 +3322,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug98760() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C, true);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IFunction free = (IFunction) col.getName(4).resolveBinding();
|
||||
|
@ -3399,7 +3399,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug104390_2() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), C, true);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IVariable x = (IVariable) col.getName(1).resolveBinding();
|
||||
|
@ -3749,7 +3749,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
IBinding methodb= col.getName(27).resolveBinding();
|
||||
IBinding methodc= col.getName(30).resolveBinding();
|
||||
|
@ -3801,7 +3801,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
IBinding methodA= col.getName(30).resolveBinding();
|
||||
IBinding methodAA= col.getName(33).resolveBinding();
|
||||
|
@ -3868,7 +3868,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
public void testBug192165() throws Exception {
|
||||
for (ParserLanguage lang : ParserLanguage.values()) {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), lang, true, false);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertInstance(col.getName(0).resolveBinding(), IProblemBinding.class);
|
||||
assertInstance(col.getName(1).resolveBinding(), ITypedef.class);
|
||||
|
@ -3967,7 +3967,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertInstance(col.getName(0).resolveBinding(), ICPPClassType.class);
|
||||
assertInstance(col.getName(1).resolveBinding(), ICPPNamespace.class);
|
||||
|
@ -4075,7 +4075,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void _testBug210019_nestedDesignatedInitializers() throws Exception {
|
||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
// Point p1
|
||||
|
@ -4155,7 +4155,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), C);
|
||||
assertTrue(tu.isFrozen());
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertField(col.getName(6).resolveBinding(), "f", "S1");
|
||||
|
@ -4206,7 +4206,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
// }
|
||||
public void testBug213029_cvConversion() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, false);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
for (Object o : col.nameList) {
|
||||
IASTName n = (IASTName) o;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2010, 2013 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,13 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
||||
public class ASTCPPSpecDefectTests extends AST2TestBase {
|
||||
|
@ -34,7 +30,7 @@ public class ASTCPPSpecDefectTests extends AST2TestBase {
|
|||
|
||||
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
|
||||
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
assertNoProblemBindings(col);
|
||||
return tu;
|
||||
|
@ -45,14 +41,6 @@ public class ASTCPPSpecDefectTests extends AST2TestBase {
|
|||
return parseAndCheckBindings(code);
|
||||
}
|
||||
|
||||
protected void assertNoProblemBindings(CPPNameCollector col) {
|
||||
Iterator i = col.nameList.iterator();
|
||||
while (i.hasNext()) {
|
||||
IASTName n = (IASTName) i.next();
|
||||
assertFalse(n.resolveBinding() instanceof IProblemBinding);
|
||||
}
|
||||
}
|
||||
|
||||
// // C++ defect #33
|
||||
// namespace ns {
|
||||
// struct S {};
|
||||
|
|
|
@ -89,7 +89,6 @@ import org.eclipse.core.runtime.Platform;
|
|||
* @author jcamelon
|
||||
*/
|
||||
public class CompleteParser2Tests extends BaseTestCase {
|
||||
|
||||
private static final NullLogService NULL_LOG = new NullLogService();
|
||||
|
||||
public CompleteParser2Tests() {
|
||||
|
@ -102,60 +101,45 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
return suite(CompleteParser2Tests.class);
|
||||
}
|
||||
|
||||
static private class CPPNameCollector extends ASTVisitor {
|
||||
public CPPNameCollector() {
|
||||
this(false); // don't visit implicit names by default
|
||||
static private class NameCollector extends ASTVisitor {
|
||||
public List nameList = new ArrayList();
|
||||
|
||||
public NameCollector() {
|
||||
this(false); // Don't visit implicit names by default
|
||||
}
|
||||
public CPPNameCollector(boolean shouldVisitImplicitNames) {
|
||||
|
||||
public NameCollector(boolean shouldVisitImplicitNames) {
|
||||
this.shouldVisitNames = true;
|
||||
this.shouldVisitImplicitNames = shouldVisitImplicitNames;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public int visit(IASTName name){
|
||||
nameList.add(name);
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
public IASTName getName(int idx){
|
||||
|
||||
public IASTName getName(int idx){
|
||||
if (idx < 0 || idx >= nameList.size())
|
||||
return null;
|
||||
return (IASTName) nameList.get(idx);
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
@Override
|
||||
public int visit(IASTName name){
|
||||
nameList.add(name);
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
public IASTName getName(int idx){
|
||||
if (idx < 0 || idx >= nameList.size())
|
||||
return null;
|
||||
return (IASTName) nameList.get(idx);
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
}
|
||||
protected void assertInstances(CPPNameCollector nameCollector, IBinding binding, int num) throws Exception {
|
||||
|
||||
protected void assertInstances(NameCollector nameCollector, IBinding binding, int num) throws Exception {
|
||||
int count = 0;
|
||||
for (int i = 0; i < nameCollector.size(); i++)
|
||||
for (int i = 0; i < nameCollector.size(); i++) {
|
||||
if (nameCollector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
}
|
||||
|
||||
assertEquals(num, count);
|
||||
}
|
||||
protected void assertInstances(CNameCollector nameCollector, IBinding binding, int num) throws Exception {
|
||||
int count = 0;
|
||||
for (int i = 0; i < nameCollector.size(); i++)
|
||||
if (nameCollector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
|
||||
assertEquals(num, count);
|
||||
}
|
||||
protected IASTTranslationUnit parse(String code, boolean expectedToPass,
|
||||
ParserLanguage lang) throws Exception {
|
||||
return parse(code, expectedToPass, lang, false);
|
||||
|
@ -180,18 +164,20 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
if (lang == ParserLanguage.CPP) {
|
||||
ICPPParserExtensionConfiguration config = null;
|
||||
if (gcc)
|
||||
if (gcc) {
|
||||
config = new GPPParserExtensionConfiguration();
|
||||
else
|
||||
} else {
|
||||
config = new ANSICPPParserExtensionConfiguration();
|
||||
}
|
||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
||||
NULL_LOG, config);
|
||||
} else {
|
||||
ICParserExtensionConfiguration config = null;
|
||||
if (gcc)
|
||||
if (gcc) {
|
||||
config = new GCCParserExtensionConfiguration();
|
||||
else
|
||||
} else {
|
||||
config = new ANSICParserExtensionConfiguration();
|
||||
}
|
||||
|
||||
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
||||
NULL_LOG, config);
|
||||
|
@ -217,7 +203,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleNamespace() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace A { }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 1);
|
||||
|
@ -226,7 +212,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testMultipleNamespaceDefinitions() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace A { } namespace A { }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 2);
|
||||
|
@ -236,7 +222,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testNestedNamespaceDefinitions() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace A { namespace B { } }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 2);
|
||||
|
@ -248,7 +234,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testEmptyClassDeclaration() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 1);
|
||||
|
@ -257,7 +243,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleSubclass() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { }; class B : public A { };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -275,7 +261,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testNestedSubclass() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace N { class A { }; } class B : protected virtual N::A { };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 6);
|
||||
|
@ -297,7 +283,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleVariable() throws Exception {
|
||||
IASTTranslationUnit tu = parse("int x;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 1);
|
||||
|
@ -310,7 +296,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleClassReferenceVariable() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { }; A x;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -323,7 +309,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testNestedClassReferenceVariable() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace N { class A { }; } N::A x;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 6);
|
||||
|
@ -339,7 +325,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testMultipleDeclaratorsVariable() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { }; A x, y, z;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -356,7 +342,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleField() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { double x; };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 2);
|
||||
|
@ -375,7 +361,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
"using A::B::x;" +
|
||||
"using A::B::C;" +
|
||||
"using A::B::C::y;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 21);
|
||||
|
@ -403,7 +389,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testEnumerations() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace A { enum E { e1, e2, e3 }; E varE;}");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 7);
|
||||
|
@ -424,7 +410,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleFunction() throws Exception {
|
||||
IASTTranslationUnit tu = parse("void foo(void);");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 2);
|
||||
|
@ -438,7 +424,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleFunctionWithTypes() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { public: \n class B { }; }; const A::B & foo(A * myParam);");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 8);
|
||||
|
@ -464,7 +450,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleMethod() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { void foo(); };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 2);
|
||||
|
@ -476,7 +462,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleMethodWithTypes() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class U { }; class A { U foo(U areDumb); };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 6);
|
||||
|
@ -494,7 +480,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testUsingDeclarationWithFunctionsAndMethods() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace N { int foo(void); } class A { static int bar(void); }; using N::foo; using ::A::bar;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 12);
|
||||
|
@ -517,7 +503,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testLinkageSpec() throws Exception {
|
||||
IASTTranslationUnit tu = parse("extern \"C\" { int foo(); }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 1);
|
||||
|
@ -527,7 +513,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBogdansExample() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace A { namespace B { enum e1{e_1,e_2}; int x; class C { static int y = 5; }; }} ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 8);
|
||||
|
@ -551,7 +537,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testAndrewsExample() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace N{ class A {}; } using namespace N; class B: public A{};");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -568,7 +554,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleTypedef() throws Exception {
|
||||
IASTTranslationUnit tu = parse("typedef int myInt;\n myInt var;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -582,7 +568,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testComplexTypedef() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A{ }; typedef A ** A_DOUBLEPTR;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -622,7 +608,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testNestedClassname() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace A { \n class A::B { };}");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
|
||||
|
@ -643,7 +629,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testElaboratedType() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A; class A * a;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -656,7 +642,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testForewardDeclarationWithUsage() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A; A * anA;class A { };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -710,7 +696,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testOverride() throws Exception {
|
||||
IASTTranslationUnit tu = parse("void foo();\n void foo(int);\n");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -722,7 +708,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleExpression() throws Exception {
|
||||
IASTTranslationUnit tu = parse("int x; int y = x;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -734,7 +720,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testParameterExpressions() throws Exception {
|
||||
IASTTranslationUnit tu = parse("int x = 5; void foo(int sub = x) { }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -744,7 +730,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testNestedNamespaceExpression() throws Exception {
|
||||
IASTTranslationUnit tu = parse("namespace A { int x = 666; } int y = A::x;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 6);
|
||||
|
@ -756,7 +742,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testConstructorChain() throws Exception {
|
||||
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 6);
|
||||
|
@ -770,7 +756,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testArrayModExpression() throws Exception {
|
||||
IASTTranslationUnit tu = parse("const int x = 5; int y[ x ]; ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -783,7 +769,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testPointerVariable() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { }; A * anA;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -796,7 +782,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testExceptionSpecification() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { }; void foo(void) throw (A);");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -806,7 +792,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testNewExpressions() throws Exception {
|
||||
IASTTranslationUnit tu = parse("typedef int A; int B; int C; int D; int P; int*p = new (P) (A[B][C][D]);");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 11);
|
||||
|
@ -836,7 +822,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
assertFalse(dtor instanceof IASTFunctionDeclarator);
|
||||
assertNotNull(dtor.getInitializer());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -848,7 +834,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testNewXReferences() throws Exception {
|
||||
IASTTranslationUnit tu = parse("const int max = 5;\n int * x = new int[max];");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -859,7 +845,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
public void testQualifiedNameReferences() throws Exception {
|
||||
// Used to cause AST Semantic exception
|
||||
IASTTranslationUnit tu = parse("class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
@ -880,7 +866,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testIsConstructor() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A{ public: A(); }; \n A::A() {}; \n");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -893,7 +879,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testIsDestructor() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A{ public: ~A(); }; \n A::~A() {}; \n");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -906,7 +892,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug41445() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { }; namespace N { class B : public A { struct A {}; }; }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -925,7 +911,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleFunctionBody() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { int f1(); }; const int x = 4; int f() { return x; } int A::f1() { return x; }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
@ -940,7 +926,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleForLoop() throws Exception {
|
||||
IASTTranslationUnit tu = parse("const int FIVE = 5; void f() { int x = 0; for (int i = 0; i < FIVE; ++i) { x += i; } }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
@ -955,7 +941,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug42541() throws Exception {
|
||||
IASTTranslationUnit tu = parse("union{ int v; char a; } id;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -985,7 +971,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
assertTrue(ifstmt.getThenClause() instanceof IASTReturnStatement);
|
||||
assertTrue(ifstmt.getElseClause() instanceof IASTCompoundStatement);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -996,7 +982,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleWhileStatement() throws Exception {
|
||||
IASTTranslationUnit tu = parse("const bool T = true; void foo() { int x = 0; while(T) { ++x; if (x == 100) break; } }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 6);
|
||||
|
@ -1019,7 +1005,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
" } " +
|
||||
" blah : ; " +
|
||||
"} ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 7);
|
||||
|
@ -1034,7 +1020,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testSimpleDoStatement() throws Exception {
|
||||
IASTTranslationUnit tu = parse("const int x = 3; int counter = 0; void foo() { do { ++counter; } while(counter != x); } ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 6);
|
||||
|
@ -1046,7 +1032,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testThrowStatement() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { }; void foo() throw (A) { A a; throw a; throw; } ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(6, col.size());
|
||||
|
@ -1059,7 +1045,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testScoping() throws Exception {
|
||||
IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -1074,7 +1060,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testEnumeratorReferences() throws Exception {
|
||||
IASTTranslationUnit tu = parse("enum E { e1, e2, e3 }; E anE = e1;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 7);
|
||||
|
@ -1093,7 +1079,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug42840() throws Exception {
|
||||
IASTTranslationUnit tu = parse("void foo(); void foo() { } class SearchMe { };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -1104,7 +1090,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug42872() throws Exception {
|
||||
IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 10);
|
||||
|
@ -1117,7 +1103,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug43503A() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ");
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
NameCollector col = new NameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
@ -1142,7 +1128,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
code.write("{ return false; }\n");
|
||||
|
||||
IASTTranslationUnit tu = parse(code.toString());
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 12);
|
||||
|
@ -1159,7 +1145,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
*/
|
||||
public void testBug43373() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { static int x; }; int A::x = 5;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -1172,7 +1158,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug39504() throws Exception {
|
||||
IASTTranslationUnit tu = parse("const int w = 2; int x[ 5 ]; int y = sizeof (x[w]);");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -1209,7 +1195,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
buff.append("} \n");
|
||||
IASTTranslationUnit tu = parse(buff.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
NameCollector col = new NameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 18);
|
||||
|
@ -1230,7 +1216,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug43679_A () throws Exception {
|
||||
IASTTranslationUnit tu = parse("struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 7);
|
||||
|
@ -1245,7 +1231,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug43679_B () throws Exception {
|
||||
IASTTranslationUnit tu = parse("struct Sample{int size() const; }; struct Sample; ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -1258,7 +1244,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug43951() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class B{ B(); ~B(); }; B::B(){} B::~B(){}");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
@ -1273,7 +1259,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug44342() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} ");
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
NameCollector col = new NameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 11);
|
||||
|
@ -1329,7 +1315,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
"int initialize(){ return 1; } " +
|
||||
"void main(){ int i = initialize(); }");
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 7);
|
||||
|
@ -1348,7 +1334,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
buffer.append("enum MyEnum myObj2;");
|
||||
IASTTranslationUnit tu = parse(buffer.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 7);
|
||||
|
@ -1371,7 +1357,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
buffer.append("A::A(int x) : myX(x) { if (x == 5) myX++; }\n");
|
||||
IASTTranslationUnit tu = parse(buffer.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 12);
|
||||
|
@ -1401,7 +1387,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
buffer.append("}\n");
|
||||
IASTTranslationUnit tu = parse(buffer.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -1425,7 +1411,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
buffer.append("void main() { N::A * a = new N::A(); a->f(); } ");
|
||||
IASTTranslationUnit tu = parse(buffer.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
NameCollector col = new NameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 14);
|
||||
|
@ -1451,7 +1437,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
buffer.append("void z(...);");
|
||||
IASTTranslationUnit tu = parse(buffer.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 5);
|
||||
|
@ -1470,7 +1456,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
IASTTranslationUnit tu = parse(buffer.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -1481,7 +1467,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
public void testErrorHandling_1() throws Exception {
|
||||
IASTTranslationUnit tu = parse("A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
@ -1505,7 +1491,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
// Inline function with reference to variables declared after them
|
||||
IASTTranslationUnit tu = parse ("class A{ int getX() {return x[1];} int x[10];};");
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -1528,7 +1514,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("void f(char[]); \n");
|
||||
writer.write("void f(char *){} \n");
|
||||
IASTTranslationUnit tu = parse(writer.toString());
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -1546,7 +1532,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write(" int f(char){ } ");
|
||||
|
||||
IASTTranslationUnit tu = parse(writer.toString());
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -1564,7 +1550,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("typedef enum _A { } A, *pA; ");
|
||||
|
||||
IASTTranslationUnit tu = parse(writer.toString());
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 3);
|
||||
|
@ -1588,7 +1574,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("}\n");
|
||||
|
||||
IASTTranslationUnit tu = parse(writer.toString());
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 11);
|
||||
|
@ -1606,7 +1592,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
parse(writer.toString());
|
||||
IASTTranslationUnit tu = parse(writer.toString());
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 4);
|
||||
|
@ -1623,7 +1609,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug56516() throws Exception {
|
||||
IASTTranslationUnit tu = parse("typedef struct blah sb;");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 2);
|
||||
|
@ -1652,7 +1638,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
IASTTranslationUnit tu = parse(writer.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 10);
|
||||
|
@ -1675,7 +1661,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("}; ");
|
||||
writer.write("void X::f(T) { } ");
|
||||
IASTTranslationUnit tu = parse(writer.toString());
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 10);
|
||||
|
@ -1694,7 +1680,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("typedef G2 AltG2;");
|
||||
writer.write("class AltG3 : AltG2 { int x;};");
|
||||
IASTTranslationUnit tu = parse(writer.toString());
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 7);
|
||||
|
@ -1715,7 +1701,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("struct B b1; ");
|
||||
|
||||
IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.C);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 9);
|
||||
|
@ -2475,7 +2461,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("struct __declspec(foobar) Foo3 {};\n");
|
||||
IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(3, col.size());
|
||||
|
@ -2500,7 +2486,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("__declspec(foobar) class Foo {} bar;\n");
|
||||
IASTTranslationUnit tu = parse(writer.toString(), true, ParserLanguage.CPP, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(2, col.size());
|
||||
|
@ -2525,7 +2511,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
IASTProblem[] problems = CPPVisitor.getProblems(tu);
|
||||
assertFalse("__declspec rejected inside declarator", problems.length>0);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(1, col.size());
|
||||
|
@ -2538,7 +2524,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
String code = "class aClass { class bClass; int x; };";
|
||||
IASTTranslationUnit tu = parse(code, true, ParserLanguage.CPP, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassType cls = (ICPPClassType)col.getName(0).resolveBinding();
|
||||
|
|
|
@ -662,7 +662,7 @@ public class DOMLocationTests extends AST2TestBase {
|
|||
|
||||
public void testTemplateIdNameLocation_Bug211444() throws Exception {
|
||||
IASTTranslationUnit tu = parse( "Foo::template test<T> bar;", ParserLanguage.CPP );
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
tu.accept( col );
|
||||
|
||||
ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0);
|
||||
|
|
|
@ -66,53 +66,36 @@ public class DOMSearchUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* The CPPNameCollector used to get IASTNames from an IASTNode.
|
||||
* The NameCollector used to get IASTNames from an IASTNode.
|
||||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
static public class CPPNameCollector extends ASTVisitor {
|
||||
static public class NameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
nameList.add(name);
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
public IASTName getName(int idx) {
|
||||
if (idx < 0 || idx >= nameList.size())
|
||||
return null;
|
||||
return (IASTName) nameList.get(idx);
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
}
|
||||
|
||||
/**
|
||||
* The CNameCollector used to get IASTNames from an IASTNode.
|
||||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
static public class CNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
nameList.add(name);
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public IASTName getName(int idx) {
|
||||
if (idx < 0 || idx >= nameList.size())
|
||||
return null;
|
||||
return (IASTName) nameList.get(idx);
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ParserLanguage corresponding to the IPath and IProject. Returns ParserLanguage.CPP if the file type is a header.
|
||||
* Returns the ParserLanguage corresponding to the IPath and IProject.
|
||||
* Returns ParserLanguage.CPP if the file type is a header.
|
||||
*/
|
||||
public static ParserLanguage getLanguage(IPath path, IProject project) {
|
||||
//FIXME: ALAIN, for headers should we assume CPP ??
|
||||
|
|
|
@ -57,7 +57,7 @@ public class GCCTests extends AST2TestBase {
|
|||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 33);
|
||||
|
@ -98,7 +98,7 @@ public class GCCTests extends AST2TestBase {
|
|||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 5);
|
||||
|
@ -125,7 +125,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 12);
|
||||
|
@ -163,7 +163,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 16);
|
||||
|
@ -197,7 +197,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 11);
|
||||
|
@ -225,7 +225,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 11);
|
||||
|
@ -255,7 +255,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 19);
|
||||
|
@ -290,7 +290,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 7);
|
||||
|
@ -316,7 +316,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 15);
|
||||
|
@ -354,7 +354,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("unsigned long bb[] = { (1UL << (sizeof(long) *8 - 1)) = 0xfff }; \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 34);
|
||||
|
@ -396,7 +396,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 11);
|
||||
|
@ -425,7 +425,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 14);
|
||||
|
@ -465,7 +465,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 36);
|
||||
|
@ -510,7 +510,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 43);
|
||||
|
@ -556,7 +556,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 10);
|
||||
|
@ -585,7 +585,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 25);
|
||||
|
@ -628,7 +628,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 6);
|
||||
|
@ -670,7 +670,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 95);
|
||||
|
@ -711,7 +711,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 22);
|
||||
|
@ -750,7 +750,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 27);
|
||||
|
@ -789,7 +789,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 14);
|
||||
|
@ -821,7 +821,7 @@ public class GCCTests extends AST2TestBase {
|
|||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||
CNameCollector collector = new CNameCollector();
|
||||
NameCollector collector = new NameCollector();
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 11);
|
||||
|
|
|
@ -300,7 +300,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
final protected void checkBindings() throws Exception {
|
||||
for (int i = 0; i < strategy.getAstCount(); i++) {
|
||||
IASTTranslationUnit ast = strategy.getAst(i);
|
||||
CNameCollector col = new CNameCollector();
|
||||
NameCollector col = new NameCollector();
|
||||
ast.accept(col);
|
||||
for (IASTName n : col.nameList) {
|
||||
assertFalse("ProblemBinding for " + n.getRawSignature(), n.resolveBinding() instanceof IProblemBinding);
|
||||
|
@ -308,7 +308,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
static protected class NameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
|
|
@ -29,126 +29,19 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTargetExtension3 {
|
||||
|
||||
IASTTranslationUnit tu = null;
|
||||
DOMASTNodeParent tuTreeParent = null;
|
||||
TreeViewer viewer = null;
|
||||
IASTName[] matchingNames = null;
|
||||
boolean wasForward = true;
|
||||
int index = 0;
|
||||
IASTTranslationUnit tu;
|
||||
DOMASTNodeParent tuTreeParent;
|
||||
TreeViewer viewer;
|
||||
IASTName[] matchingNames;
|
||||
boolean wasForward;
|
||||
int index;
|
||||
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
private static final int REGULAR_NAME_ADD = -1;
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List<IASTName> nameList = new ArrayList<IASTName>();
|
||||
|
||||
String findString = null;
|
||||
boolean caseSensitive = true;
|
||||
boolean wholeWord = true;
|
||||
boolean regExSearch = false;
|
||||
|
||||
public CNameCollector(String findString, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
|
||||
this.findString = findString;
|
||||
this.caseSensitive = caseSensitive;
|
||||
this.wholeWord = wholeWord;
|
||||
this.regExSearch = regExSearch;
|
||||
}
|
||||
|
||||
public int processName( IASTName name, int offset) {
|
||||
if (name.toString() == null || name.toString() == BLANK_STRING) return PROCESS_CONTINUE;
|
||||
String searchString = null;
|
||||
String match = null;
|
||||
boolean addName = false;
|
||||
|
||||
if (caseSensitive) {
|
||||
searchString = findString;
|
||||
match = name.toString();
|
||||
} else {
|
||||
searchString = findString.toUpperCase();
|
||||
match = name.toString().toUpperCase();
|
||||
}
|
||||
|
||||
if (regExSearch) {
|
||||
if (match.matches(searchString))
|
||||
addName = true;
|
||||
} else if (!wholeWord) {
|
||||
if (match.indexOf(searchString) >= 0)
|
||||
addName = true;
|
||||
} else {
|
||||
if (match.equals(searchString))
|
||||
addName = true;
|
||||
}
|
||||
|
||||
if (addName) {
|
||||
if (offset >= 0)
|
||||
nameList.add(offset, name);
|
||||
else
|
||||
nameList.add( name );
|
||||
}
|
||||
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit( IASTName name ){
|
||||
return processName(name, REGULAR_NAME_ADD);
|
||||
}
|
||||
public IASTName getName( int idx ){
|
||||
if( idx < 0 || idx >= nameList.size() )
|
||||
return null;
|
||||
return nameList.get( idx );
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
|
||||
private void mergeName(IASTName name) {
|
||||
if (name instanceof ASTNode) {
|
||||
int offset = ((ASTNode)name).getOffset();
|
||||
for( int i=0; i<nameList.size(); i++) {
|
||||
if (nameList.get(i) instanceof ASTNode &&
|
||||
((ASTNode)nameList.get(i)).getOffset() > offset) {
|
||||
processName(name, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if couldn't find the proper place to put the name, then add default
|
||||
visit(name);
|
||||
}
|
||||
}
|
||||
|
||||
public IASTName[] getNameArray(IASTPreprocessorStatement[] statements) {
|
||||
// first merge all of the preprocessor names into the array list
|
||||
for (IASTPreprocessorStatement statement : statements) {
|
||||
if (statement instanceof IASTPreprocessorMacroDefinition) {
|
||||
IASTName name = ((IASTPreprocessorMacroDefinition)statement).getName();
|
||||
if (name != null) {
|
||||
mergeName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// convert the array list into an array of IASTNames
|
||||
IASTName[] namedArray = new IASTName[nameList.size()];
|
||||
|
||||
for(int i=0; i<nameList.size(); i++) {
|
||||
if (nameList.get(i) instanceof IASTName)
|
||||
namedArray[i] = nameList.get(i);
|
||||
}
|
||||
|
||||
return namedArray;
|
||||
}
|
||||
}
|
||||
|
||||
static protected class CPPNameCollector extends ASTVisitor {
|
||||
static protected class NameCollector extends ASTVisitor {
|
||||
private static final int REGULAR_NAME_ADD = -1;
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
{
|
||||
|
@ -163,14 +56,14 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
Pattern p = null;
|
||||
Matcher m = null;
|
||||
|
||||
public CPPNameCollector(String findString, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
|
||||
public NameCollector(String findString, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
|
||||
this.findString = findString;
|
||||
this.caseSensitive = caseSensitive;
|
||||
this.wholeWord = wholeWord;
|
||||
this.regExSearch = regExSearch;
|
||||
}
|
||||
|
||||
public int processName( IASTName name, int index) {
|
||||
public int processName(IASTName name, int index) {
|
||||
if (name.toString() == null || name.toString() == BLANK_STRING) return PROCESS_CONTINUE;
|
||||
String searchString = null;
|
||||
String match = null;
|
||||
|
@ -196,10 +89,11 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
}
|
||||
|
||||
if (addName) {
|
||||
if (index >= 0)
|
||||
if (index >= 0) {
|
||||
nameList.add(index, name);
|
||||
else
|
||||
nameList.add( name );
|
||||
} else {
|
||||
nameList.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
return PROCESS_CONTINUE;
|
||||
|
@ -209,12 +103,16 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
public int visit( IASTName name ){
|
||||
return processName(name, REGULAR_NAME_ADD);
|
||||
}
|
||||
|
||||
public IASTName getName( int idx ){
|
||||
if( idx < 0 || idx >= nameList.size() )
|
||||
return null;
|
||||
return nameList.get( idx );
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
|
||||
private void mergeName(IASTName name) {
|
||||
if (name instanceof ASTNode) {
|
||||
|
@ -263,9 +161,6 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
this.viewer = viewer;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IFindReplaceTarget#canPerformFind()
|
||||
*/
|
||||
@Override
|
||||
public boolean canPerformFind() {
|
||||
return true;
|
||||
|
@ -274,23 +169,16 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
// recursively search for the next node
|
||||
public IASTName findNextMatchingName(String findString,
|
||||
boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
|
||||
|
||||
if (matchingNames == null && tu != null) {
|
||||
if (tu instanceof CPPASTTranslationUnit) {
|
||||
CPPNameCollector col = new CPPNameCollector(findString, caseSensitive, wholeWord, regExSearch);
|
||||
tu.accept(col);
|
||||
matchingNames = col.getNameArray(tu.getAllPreprocessorStatements());
|
||||
} else if(tu instanceof CASTTranslationUnit) {
|
||||
CNameCollector col = new CNameCollector(findString, caseSensitive, wholeWord, regExSearch);
|
||||
tu.accept(col);
|
||||
matchingNames = col.getNameArray(tu.getAllPreprocessorStatements());
|
||||
}
|
||||
NameCollector col = new NameCollector(findString, caseSensitive, wholeWord, regExSearch);
|
||||
tu.accept(col);
|
||||
matchingNames = col.getNameArray(tu.getAllPreprocessorStatements());
|
||||
}
|
||||
|
||||
if (searchForward) {
|
||||
if (!wasForward) {
|
||||
wasForward = true;
|
||||
index+=2;
|
||||
index += 2;
|
||||
}
|
||||
|
||||
if (index >=0 && index < matchingNames.length && matchingNames[index] != null)
|
||||
|
@ -298,7 +186,7 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
} else {
|
||||
if (wasForward) {
|
||||
wasForward = false;
|
||||
index-=2;
|
||||
index -= 2;
|
||||
}
|
||||
|
||||
if (index >= 0 && index < matchingNames.length && matchingNames[index] != null)
|
||||
|
@ -338,18 +226,12 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
return expandTreeToTreeObject(viewer.getTree().getItems(), treeObj);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IFindReplaceTarget#findAndSelect(int, java.lang.String, boolean, boolean, boolean)
|
||||
*/
|
||||
@Override
|
||||
public int findAndSelect(int widgetOffset, String findString,
|
||||
boolean searchForward, boolean caseSensitive, boolean wholeWord) {
|
||||
return findAndSelect(widgetOffset, findString, searchForward, caseSensitive, wholeWord, false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IFindReplaceTarget#getSelection()
|
||||
*/
|
||||
@Override
|
||||
public Point getSelection() {
|
||||
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
|
||||
|
@ -361,31 +243,18 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
return new Point(((ASTNode)((DOMASTNodeLeaf)selection.getFirstElement()).getNode()).getOffset(), 0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IFindReplaceTarget#getSelectionText()
|
||||
*/
|
||||
@Override
|
||||
public String getSelectionText() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IFindReplaceTarget#isEditable()
|
||||
*/
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.IFindReplaceTarget#replaceSelection(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void replaceSelection(String text) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void clearMatchingNames() {
|
||||
|
@ -442,8 +311,5 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
|
|||
*/
|
||||
@Override
|
||||
public void replaceSelection(String text, boolean regExReplace) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
@ -18,12 +18,11 @@ import junit.framework.Assert;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
@ -41,19 +40,14 @@ import org.eclipse.core.runtime.content.IContentType;
|
|||
* @author dsteffle
|
||||
*/
|
||||
public class DOMSearchUtil {
|
||||
private static final IASTName[] BLANK_NAME_ARRAY = new IASTName[0];
|
||||
// private static final IASTName[] EMPTY_NAME_LIST = BLANK_NAME_ARRAY;
|
||||
|
||||
public static final int DECLARATIONS = 1;
|
||||
public static final int DEFINITIONS = 2;
|
||||
public static final int DECLARATIONS_DEFINITIONS = 3;
|
||||
public static final int REFERENCES = 4;
|
||||
public static final int ALL_OCCURRENCES = 5;
|
||||
|
||||
/**
|
||||
* This retrieves the ParserLanguage from an IFile.
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* Retrieves the ParserLanguage from an IFile.
|
||||
*/
|
||||
public static ParserLanguage getLanguageFromFile(IFile file) {
|
||||
IProject project = file.getProject();
|
||||
|
@ -69,58 +63,36 @@ public class DOMSearchUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* The CPPNameCollector used to get IASTNames from an IASTNode.
|
||||
*
|
||||
* @author dsteffle
|
||||
* The NameCollector used to get IASTNames from an IASTNode.
|
||||
*/
|
||||
static public class CPPNameCollector extends CPPASTVisitor {
|
||||
static public class NameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
public int visit( IASTName name ){
|
||||
public List<IASTName> nameList = new ArrayList<IASTName>();
|
||||
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
nameList.add( name );
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public IASTName getName( int idx ){
|
||||
if( idx < 0 || idx >= nameList.size() )
|
||||
return null;
|
||||
return (IASTName) nameList.get( idx );
|
||||
return nameList.get(idx);
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The CNameCollector used to get IASTNames from an IASTNode.
|
||||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
static public class CNameCollector extends CASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
public int visit( IASTName name ){
|
||||
nameList.add( name );
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
public IASTName getName( int idx ){
|
||||
if( idx < 0 || idx >= nameList.size() )
|
||||
return null;
|
||||
return (IASTName) nameList.get( idx );
|
||||
}
|
||||
public int size() { return nameList.size(); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ParserLanguage corresponding to the IPath and IProject. Returns ParserLanguage.CPP if the file type is a header.
|
||||
*
|
||||
* @param path
|
||||
* @param project
|
||||
* @return
|
||||
* Returns the ParserLanguage corresponding to the IPath and IProject.
|
||||
* Returns ParserLanguage.CPP if the file type is a header.
|
||||
*/
|
||||
public static ParserLanguage getLanguage( IPath path, IProject project )
|
||||
{
|
||||
public static ParserLanguage getLanguage(IPath path, IProject project) {
|
||||
//FIXME: ALAIN, for headers should we assume CPP ??
|
||||
// The problem is that it really depends on how the header was included.
|
||||
String id = null;
|
||||
|
@ -148,7 +120,7 @@ public class DOMSearchUtil {
|
|||
/**
|
||||
* This is used to get the names from the TU that the IASTName searchName belongs to.
|
||||
*
|
||||
* @param searchName the IASTName whose references/delcarations are to be retrieved
|
||||
* @param searchName the IASTName whose references/declarations are to be retrieved
|
||||
* @param limitTo used to specify whether to get declarations, references, or both, one of:
|
||||
* ( CSearchPattern.DECLARATION | CSearchPattern.REFERENCES | CSearchPattern.ALL_OCCURRENCES )
|
||||
* @return IASTName[] declarations, references, or both depending on limitTo that correspond to the IASTName searchName searched for
|
||||
|
@ -158,7 +130,7 @@ public class DOMSearchUtil {
|
|||
IASTTranslationUnit tu = searchName.getTranslationUnit();
|
||||
|
||||
if (tu == null) {
|
||||
return BLANK_NAME_ARRAY;
|
||||
return IASTName.EMPTY_NAME_ARRAY;
|
||||
}
|
||||
|
||||
IBinding binding = searchName.resolveBinding();
|
||||
|
@ -206,13 +178,12 @@ public class DOMSearchUtil {
|
|||
names = tu.getDefinitionsInAST(binding);
|
||||
} else if (limitTo == ALL_OCCURRENCES){
|
||||
names = tu.getDeclarationsInAST(binding);
|
||||
names = (IASTName[])ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
|
||||
names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
|
||||
} else { // assume ALL
|
||||
names = tu.getDeclarationsInAST(binding);
|
||||
names = (IASTName[])ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
|
||||
names = ArrayUtil.addAll(IASTName.class, names, tu.getReferences(binding));
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue