mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
Automatically add appropriate #include statements in index tests.
This commit is contained in:
parent
6a1c54cc57
commit
14bd577ad2
15 changed files with 126 additions and 129 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2013 Symbian Software Systems and others.
|
||||
* Copyright (c) 2006, 2014 Symbian Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -68,6 +68,7 @@ import org.osgi.framework.Bundle;
|
|||
*/
|
||||
public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||
private static final boolean DEBUG= false;
|
||||
private static final String END_OF_ADDED_CODE_MARKER = "/*END_OF_ADDED_CODE*/";
|
||||
protected ITestStrategy strategy;
|
||||
|
||||
public void setStrategy(ITestStrategy strategy) {
|
||||
|
@ -93,16 +94,24 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
for (int i = 0; i < strategy.getAstCount(); i++) {
|
||||
IASTTranslationUnit ast = strategy.getAst(i);
|
||||
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
||||
final int offset = strategy.getAstSource(i).indexOf(section);
|
||||
String source = ast.getRawSignature();
|
||||
// Skip the automatically added code.
|
||||
int offset = source.indexOf(END_OF_ADDED_CODE_MARKER);
|
||||
if (offset >= 0) {
|
||||
if (preferImplicitName) {
|
||||
return nodeSelector.findImplicitName(offset, len);
|
||||
} else {
|
||||
IASTName name= nodeSelector.findName(offset, len);
|
||||
if (name == null)
|
||||
name= nodeSelector.findImplicitName(offset, len);
|
||||
return name;
|
||||
}
|
||||
offset += END_OF_ADDED_CODE_MARKER.length();
|
||||
if (source.charAt(offset) == '\n')
|
||||
offset++;
|
||||
} else {
|
||||
offset = 0;
|
||||
}
|
||||
offset = source.indexOf(section, offset);
|
||||
if (offset >= 0) {
|
||||
IASTName name= null;
|
||||
if (!preferImplicitName)
|
||||
name= nodeSelector.findName(offset, len);
|
||||
if (name == null)
|
||||
name= nodeSelector.findImplicitName(offset, len);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,14 +323,17 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
final protected void checkBindings() throws Exception {
|
||||
protected final void checkBindings() throws Exception {
|
||||
for (int i = 0; i < strategy.getAstCount(); i++) {
|
||||
IASTTranslationUnit ast = strategy.getAst(i);
|
||||
NameCollector col = new NameCollector();
|
||||
ast.accept(col);
|
||||
for (IASTName n : col.nameList) {
|
||||
assertFalse("ProblemBinding for " + n.getRawSignature(), n.resolveBinding() instanceof IProblemBinding);
|
||||
}
|
||||
checkBindings(strategy.getAst(i));
|
||||
}
|
||||
}
|
||||
|
||||
protected final void checkBindings(IASTTranslationUnit ast) {
|
||||
NameCollector col = new NameCollector();
|
||||
ast.accept(col);
|
||||
for (IASTName n : col.nameList) {
|
||||
assertFalse("ProblemBinding for " + n.getRawSignature(), n.resolveBinding() instanceof IProblemBinding);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,6 +429,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
|
||||
if (testData.length < 2)
|
||||
fail("Insufficient test data");
|
||||
testData[1].insert(0, "#include \"header.h\" " + END_OF_ADDED_CODE_MARKER + "\n");
|
||||
|
||||
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
|
||||
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||
waitForIndexer(cproject);
|
||||
|
@ -504,6 +518,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
|
||||
if (testData.length < 2)
|
||||
fail("Insufficient test data");
|
||||
testData[1].insert(0, "#include \"header.h\" " + END_OF_ADDED_CODE_MARKER + "\n");
|
||||
|
||||
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
|
||||
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||
waitForIndexer(cproject);
|
||||
|
@ -709,6 +725,10 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
CProjectHelper.createCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
Bundle b= CTestPlugin.getDefault().getBundle();
|
||||
testData= TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
|
||||
if (testData.length < 2)
|
||||
fail("Insufficient test data");
|
||||
testData[1].insert(0, "#include \"header.h\" " + END_OF_ADDED_CODE_MARKER + "\n");
|
||||
|
||||
referenced = createReferencedContent();
|
||||
|
||||
TestScannerProvider.sIncludes= new String[] {referenced.getProject().getLocation().toOSString()};
|
||||
|
@ -724,7 +744,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
waitForIndexer(cproject);
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println("Online: "+getName());
|
||||
System.out.println("Online: " + getName());
|
||||
((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
|
||||
}
|
||||
|
||||
|
@ -746,7 +766,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
waitForIndexer(referenced);
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println("Referenced: "+getName());
|
||||
System.out.println("Referenced: " + getName());
|
||||
((PDOM) CCoreInternals.getPDOMManager().getPDOM(referenced)).accept(new PDOMPrettyPrinter());
|
||||
}
|
||||
|
||||
|
|
|
@ -233,7 +233,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// class B {};
|
||||
// }
|
||||
|
||||
// #include "header.h"
|
||||
// namespace n { class C{}; }
|
||||
// m::C c;
|
||||
public void testUsingNamingDirective_177917_1b() {
|
||||
|
@ -268,7 +267,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// class B {};
|
||||
// }
|
||||
|
||||
// #include "header.h"
|
||||
// b::A aa;
|
||||
// b::B bb;
|
||||
public void testUsingTypeDeclaration_177917_2() {
|
||||
|
@ -290,7 +288,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// using header::clh;
|
||||
// using header::fh;
|
||||
|
||||
// #include "header.h"
|
||||
// namespace source {
|
||||
// class cls {
|
||||
// };
|
||||
|
@ -361,7 +358,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
assertInstance(f1.getParameterTypes()[0], ICPPBasicType.class);
|
||||
}
|
||||
|
||||
// // header file
|
||||
// class Base {public: int field; void foo() {}};
|
||||
// class C : public Base {
|
||||
// public:
|
||||
|
@ -373,9 +369,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// C* (CS::*method)(CS **);
|
||||
// };
|
||||
|
||||
// // referencing file
|
||||
// #include "header.h"
|
||||
//
|
||||
// C *cp = new C(); /*b0, b1*/
|
||||
// void references() {
|
||||
// long l = 5, *lp;
|
||||
|
@ -420,15 +413,12 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
assertPTM(((ICPPField)b3).getType(), "C::CS", null);
|
||||
}
|
||||
|
||||
// // header file
|
||||
// class C {}; struct S {}; union U {}; enum E {ER1,ER2,ER3};
|
||||
// int var1; C var2; S *var3; void func(E); void func(C);
|
||||
// namespace ns {}
|
||||
// typedef int Int; typedef int *IntPtr;
|
||||
// void func(int*); void func(int);
|
||||
|
||||
// // referencing file
|
||||
// #include "header.h"
|
||||
// void references() {
|
||||
// C c; /*c*/ S s; /*s*/ U u; /*u*/ E e; /*e*/
|
||||
// var1 = 1; /*var1*/ var2 = c; /*var2*/ var3 = &s; /*var3*/
|
||||
|
@ -844,33 +834,26 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
IBinding b2 = getBindingFromASTName("ER2; }", 3);
|
||||
}
|
||||
|
||||
// // the header
|
||||
// void foo(int a=2, int b=3);
|
||||
|
||||
// #include "header.h"
|
||||
// void ref() { foo(); }
|
||||
public void testFunctionDefaultArguments() {
|
||||
IBinding b0 = getBindingFromASTName("foo();", 3);
|
||||
}
|
||||
|
||||
// // the header
|
||||
// typedef int TYPE;
|
||||
// namespace ns {
|
||||
// const TYPE* foo(int a);
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// const TYPE* ns::foo(int a) { return 0; }
|
||||
public void testTypeQualifier() {
|
||||
IBinding b0 = getBindingFromASTName("foo(", 3);
|
||||
}
|
||||
|
||||
// // header
|
||||
// class Base { public: void foo(int i) {} };
|
||||
// class Derived : public Base { public: void foo(long l) {} };
|
||||
|
||||
// // references
|
||||
// #include "header.h"
|
||||
// void references() {
|
||||
// Derived d; /*d*/
|
||||
// d.foo(55L); // calls long version
|
||||
|
@ -883,11 +866,8 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
IBinding b2 = getBindingFromASTName("foo(4);", 3);
|
||||
}
|
||||
|
||||
// // header content
|
||||
// namespace x { namespace y { int i; } }
|
||||
|
||||
// // the references
|
||||
// #include "header.h"
|
||||
// class C { public:
|
||||
// class x { public:
|
||||
// class y { public:
|
||||
|
@ -963,15 +943,12 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
IBinding b18 = getBindingFromASTName("i/*18*/", 1);
|
||||
}
|
||||
|
||||
// // header file
|
||||
// class C {public: C* cp;};
|
||||
// C foo(C c);
|
||||
// C* foo(C* c);
|
||||
// int foo(int i);
|
||||
// int foo(int i, C c);
|
||||
|
||||
// // referencing content
|
||||
// #include "header.h"
|
||||
// void references() {
|
||||
// C c, *cp;
|
||||
// foo/*a*/(cp[1]); // IASTArraySubscriptExpression
|
||||
|
@ -1036,7 +1013,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// IBinding b13 = getBindingFromASTName(ast, "foo/*n*/", 3);
|
||||
}
|
||||
|
||||
// // header content
|
||||
// class C { public:
|
||||
// typedef int i1; typedef long *lp1;
|
||||
// class C1 {}; struct S1 {}; union U1 {}; enum E1 {A1};
|
||||
|
@ -1062,8 +1038,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// void f(n::i4); void f(n::lp4); void f(n::S4); void f(n::U4); void f(n::E4);
|
||||
// void f(E);
|
||||
|
||||
// // reference content
|
||||
// #include "header.h"
|
||||
// void references() {
|
||||
// void (*fintptr)(int), (*flongptr)(long);
|
||||
// void (*fC)(C), (*fCi1)(C::i1), (*fClp1)(C::lp1), (*fCS1)(C::S1), (*fCU1)(C::U1), (*fCE1)(C::E1);
|
||||
|
@ -1124,12 +1098,10 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
assertNotSame(fn1, fn2);
|
||||
}
|
||||
|
||||
// // the header
|
||||
// void f_int(int);
|
||||
// void f_const_int(const int);
|
||||
// void f_int_ptr(int*);
|
||||
|
||||
// #include "header.h"
|
||||
// void ref() {
|
||||
// int i = 0;
|
||||
// const int const_int = 0;
|
||||
|
@ -1151,7 +1123,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
getProblemFromASTName("f_int_ptr(&const_int)", 9);
|
||||
}
|
||||
|
||||
// // the header
|
||||
// void f_int_ptr(int*);
|
||||
// void f_const_int_ptr(const int*);
|
||||
// void f_int_const_ptr(int const*);
|
||||
|
@ -1159,7 +1130,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// void f_const_int_ptr_const(const int*const);
|
||||
// void f_int_const_ptr_const(int const*const);
|
||||
|
||||
// #include "header.h"
|
||||
// void ref() {
|
||||
// int* int_ptr = 0;
|
||||
// const int* const_int_ptr = 0;
|
||||
|
@ -1321,7 +1291,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
assertEquals(binding2, getBindingFromASTName("f(int_const_ptr_const)", 1));
|
||||
}
|
||||
|
||||
// // the header
|
||||
// void f(int*); // b1
|
||||
// void f(const int*); // b2
|
||||
// void f(int const*); // b2
|
||||
|
@ -1329,7 +1298,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// void f(const int*const); // b2
|
||||
// void f(int const*const); // b2
|
||||
|
||||
// #include "header.h"
|
||||
// void f(int*){} // b1
|
||||
// void f(const int*){} // b2
|
||||
//
|
||||
|
@ -1393,7 +1361,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// using namespace x;
|
||||
// using x::a;
|
||||
|
||||
// #include "header.h"
|
||||
// void test() {
|
||||
// a(1);
|
||||
// }
|
||||
|
@ -1465,7 +1432,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// }}
|
||||
// using namespace ns1::ns2;
|
||||
|
||||
// #include "header.h"
|
||||
// A a;
|
||||
public void testUsingDirectiveWithQualifiedName_269727() throws Exception {
|
||||
getBindingFromASTName("A a", 1, ICPPClassType.class);
|
||||
|
@ -1659,7 +1625,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// }
|
||||
// }
|
||||
|
||||
// #include "header.h"
|
||||
// void test() {
|
||||
// ::f(1);
|
||||
// ::g(1);
|
||||
|
@ -1684,7 +1649,6 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// }
|
||||
// }
|
||||
|
||||
// #include "header.h"
|
||||
// namespace out {}
|
||||
// namespace out2 {}
|
||||
// namespace in {}
|
||||
|
|
|
@ -247,7 +247,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// void m2(const StrT<T> s) {}
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// void main() {
|
||||
// C1<char> c1;
|
||||
// c1.m1("aaa"); // OK
|
||||
|
@ -282,7 +281,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// public: void assign(const T* s) {}
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// void main() {
|
||||
// StrT<char> x;
|
||||
// x.assign("aaa");
|
||||
|
@ -364,7 +362,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// void m3();
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// void C1::m3() {
|
||||
// m1("aaa"); // OK
|
||||
// m2("aaa"); // problem
|
||||
|
@ -609,7 +606,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// B<int>::a;
|
||||
// }
|
||||
public void testInstanceInheritance_258745() throws Exception {
|
||||
getBindingFromASTName("a", 1, ICPPField.class);
|
||||
getBindingFromFirstIdentifier("a", ICPPField.class);
|
||||
}
|
||||
|
||||
// class A {}; class B {}; class C {};
|
||||
|
@ -619,7 +616,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// template<typename T3>
|
||||
// class D<A, T3> {};
|
||||
|
||||
// #include "header.h"
|
||||
// template<typename T3> class D<A, T3>; // harmless declaration for test purposes
|
||||
// template<typename T3> class D<B, T3> {};
|
||||
// template<typename T3> class D<C, T3> {};
|
||||
|
@ -1231,7 +1227,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// class B {};
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// void refs() {
|
||||
// A<C>::B acb;
|
||||
// A<D>::B adb;
|
||||
|
@ -1687,7 +1682,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
|
||||
// template <typename T= int> class XT;
|
||||
|
||||
// #include "header.h"
|
||||
// template <typename T> class XT {};
|
||||
// void test() {
|
||||
// XT<> x;
|
||||
|
@ -1946,7 +1940,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// B<float> b;
|
||||
// C<float> c;
|
||||
|
||||
// #include "header.h"
|
||||
// void test() {
|
||||
// b.f();
|
||||
// b.f(1);
|
||||
|
@ -1979,7 +1972,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// typedef int type;
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// template <typename> struct foo {};
|
||||
// int main() {
|
||||
// typedef foo<int>::type type; // ERROR HERE: 'foo<int>::type' could not be
|
||||
|
@ -1993,7 +1985,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// typedef int type;
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// template <typename> struct foo {};
|
||||
// int main() {
|
||||
// typedef foo<int*>::type type; // ERROR HERE: 'foo<int>::type' could not be
|
||||
|
@ -2444,7 +2435,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// template <typename = void>
|
||||
// struct S;
|
||||
|
||||
// #include "header.h"
|
||||
// template <>
|
||||
// struct S<void> {
|
||||
// typedef int type;
|
||||
|
@ -2473,7 +2463,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// friend T operator *(const T& lhs, const T& rhs);
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// struct overloaded : multipliable1<overloaded> {};
|
||||
//
|
||||
// int foo(overloaded);
|
||||
|
@ -2499,7 +2488,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// friend T operator *(const T& lhs, const T& rhs) {}
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// struct overloaded : multipliable1 <overloaded> {};
|
||||
//
|
||||
// int foo(overloaded);
|
||||
|
@ -2569,13 +2557,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// template <typename T>
|
||||
// class Derived : public Base<B<S>, f<T> > {};
|
||||
|
||||
// #include "header.h"
|
||||
// const Derived<S> decl;
|
||||
//
|
||||
// void bar(const B<S>&);
|
||||
//
|
||||
// void foo()
|
||||
// {
|
||||
// void foo() {
|
||||
// bar(decl()); // ERROR HERE: Invalid arguments
|
||||
// }
|
||||
public void testInstantiationOfFunctionInstance_437675() throws Exception {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2014 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
|
@ -17,19 +18,26 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
*/
|
||||
public interface IArrayType extends IType {
|
||||
/**
|
||||
* get the type that this is an array of
|
||||
* Returns the type that this is an array of.
|
||||
*/
|
||||
IType getType();
|
||||
|
||||
/**
|
||||
* Returns the value for the size of the array type, or <code>null</code> if it is unspecified.
|
||||
* Returns the value for the size of the array type, or {@code null} if it is unspecified.
|
||||
* @since 5.2
|
||||
*/
|
||||
IValue getSize();
|
||||
|
||||
|
||||
/**
|
||||
* get the expression that represents the size of this array
|
||||
* Checks is the array type has specified size.
|
||||
* @since 5.9
|
||||
*/
|
||||
boolean hasSize();
|
||||
|
||||
/**
|
||||
* Returns the expression that represents the size of this array
|
||||
* @throws DOMException
|
||||
*/
|
||||
@Deprecated
|
||||
IASTExpression getArraySizeExpression() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -177,22 +177,13 @@ public class ASTQueries {
|
|||
return type1.isSameType(type2);
|
||||
}
|
||||
|
||||
protected static IType isCompatibleArray(IType t1, IType t2) {
|
||||
protected static boolean areArraysOfTheSameElementType(IType t1, IType t2) {
|
||||
if (t1 instanceof IArrayType && t2 instanceof IArrayType) {
|
||||
IArrayType a1 = (IArrayType) t1;
|
||||
IArrayType a2 = (IArrayType) t2;
|
||||
if (!isSameType(a1.getType(), a2.getType())) {
|
||||
return null;
|
||||
}
|
||||
if (a1.getSize() == null) {
|
||||
if (a2.getSize() != null) {
|
||||
return a2;
|
||||
}
|
||||
} else if (a2.getSize() == null) {
|
||||
return a1;
|
||||
}
|
||||
return isSameType(a1.getType(), a2.getType());
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,9 +84,6 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
|
|||
return CharArrayUtils.equals(s1.getSignature(), s2.getSignature());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IArrayType#getType()
|
||||
*/
|
||||
@Override
|
||||
public IType getType() {
|
||||
return type;
|
||||
|
@ -142,6 +139,11 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
|
|||
return value= Value.create(sizeExpression, Value.MAX_RECURSION_DEPTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSize() {
|
||||
return value == Value.NOT_INITIALIZED ? sizeExpression != null : value != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
IType t = null;
|
||||
|
@ -210,8 +212,6 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
|
|||
@Override
|
||||
@Deprecated
|
||||
public IASTExpression getArraySizeExpression() {
|
||||
if (sizeExpression != null)
|
||||
return sizeExpression;
|
||||
return null;
|
||||
return sizeExpression;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -797,8 +797,8 @@ public class CVisitor extends ASTQueries {
|
|||
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION, name.toCharArray());
|
||||
} else if (binding instanceof IVariable) {
|
||||
t2 = ((IVariable) binding).getType();
|
||||
if (t1 != null && t2 != null && (
|
||||
t1.isSameType(t2) || isCompatibleArray(t1, t2) != null)) {
|
||||
if (t1 != null && t2 != null &&
|
||||
(areArraysOfTheSameElementType(t1, t2) || t1.isSameType(t2))) {
|
||||
if (binding instanceof CVariable)
|
||||
((CVariable) binding).addDeclaration(name);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2014 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -86,7 +86,12 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
|
|||
|
||||
return value= Value.create(sizeExpression, Value.MAX_RECURSION_DEPTH);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasSize() {
|
||||
return value == Value.NOT_INITIALIZED ? sizeExpression != null : value != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IASTExpression getArraySizeExpression() {
|
||||
|
|
|
@ -225,7 +225,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
|
|||
public IBinding[] getBindingsInAST(ScopeLookupData lookup) {
|
||||
populateCache();
|
||||
final char[] c = lookup.getLookupKey();
|
||||
IBinding[] result = null;
|
||||
IBinding[] result = IBinding.EMPTY_BINDING_ARRAY;
|
||||
|
||||
Object obj = null;
|
||||
if (lookup.isPrefixLookup()) {
|
||||
|
@ -257,7 +257,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
|
|||
result = addCandidate(obj, lookup, result);
|
||||
}
|
||||
}
|
||||
return ArrayUtil.trim(IBinding.class, result);
|
||||
return ArrayUtil.trim(result);
|
||||
}
|
||||
|
||||
private IBinding[] addCandidate(Object candidate, ScopeLookupData lookup, IBinding[] result) {
|
||||
|
@ -287,7 +287,9 @@ abstract public class CPPScope implements ICPPASTInternalScope {
|
|||
binding= (IBinding) candidate;
|
||||
}
|
||||
|
||||
return ArrayUtil.append(IBinding.class, result, binding);
|
||||
if (binding != null)
|
||||
result = ArrayUtil.append(result, binding);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,7 +47,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
|||
private boolean fAllResolved;
|
||||
|
||||
public CPPVariable(IASTName name) {
|
||||
boolean isDef = name == null ? false : name.isDefinition();
|
||||
boolean isDef = name != null && name.isDefinition();
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
name = name.getLastName();
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
|||
IASTNode node = n.getParent();
|
||||
if (node instanceof IASTDeclarator) {
|
||||
IType t= CPPVisitor.createType((IASTDeclarator) node);
|
||||
if (t instanceof IArrayType && ((IArrayType) t).getSize() == null) {
|
||||
if (t instanceof IArrayType && !((IArrayType) t).hasSize()) {
|
||||
if (firstCandidate == null) {
|
||||
firstCandidate= (IArrayType) t;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2014 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -23,7 +24,10 @@ public interface ICPPInternalBinding extends ICPPBinding {
|
|||
*/
|
||||
IASTNode getDefinition();
|
||||
|
||||
/** Implementors must keep the node with the lowest offset in declarations[0] */
|
||||
/**
|
||||
* Returns an array of declarations or {@code null} if the binding has no declarations.
|
||||
* Implementors must keep the node with the lowest offset in declarations[0].
|
||||
*/
|
||||
IASTNode[] getDeclarations();
|
||||
|
||||
void addDefinition(IASTNode node);
|
||||
|
|
|
@ -872,7 +872,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
t2 = ((IVariable) binding).getType();
|
||||
}
|
||||
if (t1 != null && t2 != null) {
|
||||
if (t1.isSameType(t2) || isCompatibleArray(t1, t2) != null) {
|
||||
if (areArraysOfTheSameElementType(t1, t2) || t1.isSameType(t2)) {
|
||||
ASTInternal.addDeclaration(binding, name);
|
||||
} else {
|
||||
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="old"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#Wed Apr 30 13:42:53 EDT 2008
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
|
@ -62,4 +67,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enab
|
|||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2014 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
|
||||
|
@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
|
||||
@SuppressWarnings("restriction")
|
||||
public class C99ArrayType implements ICArrayType, ITypeContainer {
|
||||
|
||||
private boolean isConst;
|
||||
private boolean isRestrict;
|
||||
private boolean isStatic;
|
||||
|
@ -37,6 +36,7 @@ public class C99ArrayType implements ICArrayType, ITypeContainer {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConst() {
|
||||
return isConst;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public class C99ArrayType implements ICArrayType, ITypeContainer {
|
|||
this.isConst = isConst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRestrict() {
|
||||
return isRestrict;
|
||||
}
|
||||
|
@ -53,6 +54,7 @@ public class C99ArrayType implements ICArrayType, ITypeContainer {
|
|||
this.isRestrict = isRestrict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return isStatic;
|
||||
}
|
||||
|
@ -61,6 +63,7 @@ public class C99ArrayType implements ICArrayType, ITypeContainer {
|
|||
this.isStatic = isStatic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVolatile() {
|
||||
return isVolatile;
|
||||
}
|
||||
|
@ -69,6 +72,7 @@ public class C99ArrayType implements ICArrayType, ITypeContainer {
|
|||
this.isVolatile = isVolatile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVariableLength() {
|
||||
return isVariableLength;
|
||||
}
|
||||
|
@ -77,38 +81,52 @@ public class C99ArrayType implements ICArrayType, ITypeContainer {
|
|||
this.isVariableLength = isVariableLength;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public IASTExpression getArraySizeExpression() throws DOMException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType t) {
|
||||
if(t == this)
|
||||
if (t == this)
|
||||
return true;
|
||||
if(t instanceof ITypedef)
|
||||
if (t instanceof ITypedef)
|
||||
return t.isSameType(this);
|
||||
if(t instanceof ICArrayType) {
|
||||
if (t instanceof ICArrayType) {
|
||||
ICArrayType at = (ICArrayType)t;
|
||||
if(at.isConst() == isConst &&
|
||||
at.isRestrict() == isRestrict &&
|
||||
at.isStatic() == isStatic &&
|
||||
at.isVolatile() == isVolatile &&
|
||||
at.isVariableLength() == isVariableLength) {
|
||||
if (at.isConst() == isConst &&
|
||||
at.isRestrict() == isRestrict &&
|
||||
at.isStatic() == isStatic &&
|
||||
at.isVolatile() == isVolatile &&
|
||||
at.isVariableLength() == isVariableLength) {
|
||||
return at.isSameType(type);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public IValue getSize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSize() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public C99ArrayType clone() {
|
||||
C99ArrayType clone = null;
|
||||
try {
|
||||
|
@ -119,10 +137,4 @@ public class C99ArrayType implements ICArrayType, ITypeContainer {
|
|||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
public IValue getSize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue