mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Cosmetics.
Change-Id: I307cff37a52a60606d150b708d53adfcb3c456e3
This commit is contained in:
parent
b3f03996de
commit
315fc0f5ef
24 changed files with 534 additions and 536 deletions
|
@ -133,7 +133,7 @@ public class EmptyIndexFragment implements IIndexFragment {
|
|||
throws CoreException {
|
||||
return IIndexFragmentFile.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIndexFragmentFile[] getFiles(IIndexFileLocation location) throws CoreException {
|
||||
return IIndexFragmentFile.EMPTY_ARRAY;
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||
|
@ -19,8 +18,8 @@ public class FakeIndexer extends AbstractPDOMIndexer {
|
|||
static final String ID = "org.eclipse.cdt.core.tests.FakeIndexer";
|
||||
|
||||
@Override
|
||||
public IPDOMIndexerTask createTask(ITranslationUnit[] added,
|
||||
ITranslationUnit[] changed, ITranslationUnit[] removed) {
|
||||
public IPDOMIndexerTask createTask(ITranslationUnit[] added, ITranslationUnit[] changed,
|
||||
ITranslationUnit[] removed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -28,5 +27,4 @@ public class FakeIndexer extends AbstractPDOMIndexer {
|
|||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -119,11 +119,11 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected IASTName findName(String section, int offset, int len) {
|
||||
return findName(section, offset, len, false);
|
||||
}
|
||||
|
||||
|
||||
protected IASTName findName(String section, int len) {
|
||||
return findName(section, 0, len);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
* </ul>
|
||||
* @param section the code fragment to search for in the AST. The first occurrence of an identical
|
||||
* section is used.
|
||||
* @param offset the offset of the name within the section
|
||||
* @param offset the offset of the name within the section
|
||||
* @param len the length of the name. This can also be useful for distinguishing between template names
|
||||
* and template ids.
|
||||
* @param clazz an expected class type or interface that the binding should extend/implement
|
||||
|
@ -166,13 +166,13 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
assertInstance(binding, clazz, cs);
|
||||
return clazz.cast(binding);
|
||||
}
|
||||
|
||||
|
||||
protected <T> T getBindingFromASTName(String section, int len, Class<T> clazz, Class... cs) {
|
||||
return getBindingFromASTName(section, 0, len, clazz, cs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get an IBinding attached to an implicit name from the initial specified
|
||||
* Attempts to get an IBinding attached to an implicit name from the initial specified
|
||||
* number of characters from the specified code fragment. Fails the test if
|
||||
* <ul>
|
||||
* <li> There is not a unique implicit name with the specified criteria
|
||||
|
@ -181,7 +181,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
* </ul>
|
||||
* @param section the code fragment to search for in the AST. The first occurrence of an identical
|
||||
* section is used.
|
||||
* @param offset the offset of the name within the section
|
||||
* @param offset the offset of the name within the section
|
||||
* @param len the length of the name
|
||||
* @param clazz an expected class type or interface that the binding should extend/implement
|
||||
* @return the associated implicit name's binding
|
||||
|
@ -419,7 +419,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
public ICProject getCProject();
|
||||
public boolean isCompositeIndex();
|
||||
}
|
||||
|
||||
|
||||
private abstract class BaseTestStrategy implements ITestStrategy {
|
||||
// This method allows tests to specify test-specific flags by including special strings
|
||||
// in the test source (presumably in a comment).
|
||||
|
@ -486,10 +486,10 @@ 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");
|
||||
|
||||
|
||||
String headerContents = testData[0].toString();
|
||||
String sourceContents = testData[1].toString();
|
||||
|
||||
|
||||
setTestSpecificFlags(sourceContents);
|
||||
|
||||
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), headerContents);
|
||||
|
@ -583,9 +583,9 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
|
||||
String headerContents = testData[0].toString();
|
||||
String sourceContents = testData[1].toString();
|
||||
|
||||
|
||||
setTestSpecificFlags(sourceContents);
|
||||
|
||||
|
||||
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), headerContents);
|
||||
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
|
||||
waitForIndexer(cproject);
|
||||
|
@ -796,7 +796,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
testData[1].insert(0, "#include \"header.h\" " + END_OF_ADDED_CODE_MARKER + "\n");
|
||||
|
||||
String sourceContents = testData[1].toString();
|
||||
|
||||
|
||||
setTestSpecificFlags(sourceContents);
|
||||
|
||||
referenced = createReferencedContent();
|
||||
|
@ -901,7 +901,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
fail("Artificially failing - see IndexBindingResolutionTestBase.fakeFailForReferenced()");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static void assertSameType(IType first, IType second){
|
||||
assertNotNull(first);
|
||||
assertNotNull(second);
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
|
@ -108,6 +106,8 @@ import org.eclipse.core.runtime.Path;
|
|||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class IndexBugsTests extends BaseTestCase {
|
||||
private ICProject fCProject;
|
||||
protected IIndex fIndex;
|
||||
|
@ -294,14 +294,14 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
private IIndexFile getIndexFile(IFile file) throws CoreException {
|
||||
return getIndexFile(fIndex, file);
|
||||
}
|
||||
}
|
||||
|
||||
private IIndexFile getIndexFile(IIndex index, IFile file) throws CoreException {
|
||||
IIndexFile[] files = index.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||
assertTrue("Can't find " + file.getLocation(), files.length > 0);
|
||||
assertEquals("Found " + files.length + " files for " + file.getLocation() + " instead of one", 1, files.length);
|
||||
return files[0];
|
||||
}
|
||||
}
|
||||
|
||||
private void waitForIndexer() throws InterruptedException {
|
||||
waitForIndexer(fCProject);
|
||||
|
@ -2446,7 +2446,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
index.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// // context.c
|
||||
// #define A B
|
||||
// #include "b.h" // file name is important to reproduce the issue
|
||||
|
@ -2470,7 +2470,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
final CoreModel coreModel = CCorePlugin.getDefault().getCoreModel();
|
||||
ICElement[] selection = new ICElement[] {coreModel.create(ah), coreModel.create(bh)};
|
||||
indexManager.update(selection, IIndexManager.UPDATE_ALL);
|
||||
|
@ -2516,7 +2516,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
IFile bh= TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[2]);
|
||||
indexManager.update(new ICElement[] { fCProject }, IIndexManager.UPDATE_UNRESOLVED_INCLUDES);
|
||||
waitForIndexer();
|
||||
|
|
|
@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.index.tests;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
|
@ -27,6 +25,8 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
|||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* For testing PDOM binding C language resolution
|
||||
*/
|
||||
|
@ -45,26 +45,26 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
public ProjectWithDepProj() {setStrategy(new ReferencedProject(false));}
|
||||
public static TestSuite suite() {return suite(ProjectWithDepProj.class);}
|
||||
}
|
||||
|
||||
public static void addTests(TestSuite suite) {
|
||||
|
||||
public static void addTests(TestSuite suite) {
|
||||
suite.addTest(SingleProject.suite());
|
||||
suite.addTest(ProjectWithDepProj.suite());
|
||||
}
|
||||
|
||||
|
||||
public IndexCBindingResolutionTest() {
|
||||
setStrategy(new SinglePDOMTestStrategy(false));
|
||||
}
|
||||
|
||||
|
||||
// int (*f)(int);
|
||||
// int g(int n){return n;}
|
||||
|
||||
|
||||
// void foo() {
|
||||
// f= g;
|
||||
// }
|
||||
public void testPointerToFunction() throws Exception {
|
||||
IBinding b0 = getBindingFromASTName("f= g;", 1);
|
||||
IBinding b0 = getBindingFromASTName("f= g;", 1);
|
||||
IBinding b1 = getBindingFromASTName("g;", 1);
|
||||
|
||||
|
||||
assertInstance(b0, IVariable.class);
|
||||
IVariable v0= (IVariable) b0;
|
||||
assertInstance(v0.getType(), IPointerType.class);
|
||||
|
@ -74,14 +74,14 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
assertInstance(f0.getReturnType(), IBasicType.class);
|
||||
assertEquals(1, f0.getParameterTypes().length);
|
||||
assertInstance(f0.getParameterTypes()[0], IBasicType.class);
|
||||
|
||||
|
||||
assertInstance(b1, IFunction.class);
|
||||
IFunctionType f1= ((IFunction)b1).getType();
|
||||
assertInstance(f1.getReturnType(), IBasicType.class);
|
||||
assertEquals(1, f1.getParameterTypes().length);
|
||||
assertInstance(f1.getParameterTypes()[0], IBasicType.class);
|
||||
}
|
||||
|
||||
|
||||
// // header file
|
||||
// struct S {int x;};
|
||||
// union U {int x;};
|
||||
|
@ -131,15 +131,15 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
IBinding b15 = getBindingFromASTName("a; ", 1);
|
||||
IBinding b16 = getBindingFromASTName("IntPtr b = &a; ", 6);
|
||||
IBinding b17 = getBindingFromASTName("b = &a; /*b*/", 1);
|
||||
IBinding b18 = getBindingFromASTName("func3(&b);", 5);
|
||||
IBinding b18 = getBindingFromASTName("func3(&b);", 5);
|
||||
IBinding b19 = getBindingFromASTName("b); /*func4*/", 1);
|
||||
IBinding b20 = getBindingFromASTName("func4(a);", 5);
|
||||
IBinding b21 = getBindingFromASTName("a); /*func5*/", 1);
|
||||
}
|
||||
|
||||
// // empty
|
||||
|
||||
// typedef struct S {int a;} S;
|
||||
// // empty
|
||||
|
||||
// typedef struct S {int a;} S;
|
||||
// typedef enum E {A,B} E;
|
||||
// struct A {
|
||||
// S *s;
|
||||
|
@ -152,27 +152,27 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
IBinding b4 = getBindingFromASTName("E;", 1);
|
||||
IBinding b5 = getBindingFromASTName("S *s", 1);
|
||||
IBinding b6 = getBindingFromASTName("E *e", 1);
|
||||
|
||||
|
||||
assertInstance(b1, ICompositeType.class);
|
||||
assertInstance(b2, ITypedef.class);
|
||||
|
||||
|
||||
assertInstance(b3, IEnumeration.class);
|
||||
assertInstance(b4, ITypedef.class);
|
||||
|
||||
|
||||
assertInstance(b5, ITypedef.class);
|
||||
ITypedef t5= (ITypedef) b5;
|
||||
assertInstance(t5.getType(), ICompositeType.class);
|
||||
assertEquals(ICompositeType.k_struct, ((ICompositeType)t5.getType()).getKey());
|
||||
|
||||
|
||||
assertInstance(b6, ITypedef.class);
|
||||
ITypedef t6= (ITypedef) b6;
|
||||
assertInstance(t6.getType(), IEnumeration.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// typedef struct S {int a;} S;
|
||||
// typedef enum E {A,B} E;
|
||||
|
||||
|
||||
// struct A {
|
||||
// S *s;
|
||||
// E *e;
|
||||
|
@ -180,17 +180,17 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
public void testTypedefB() throws Exception {
|
||||
IBinding b1 = getBindingFromASTName("S *s", 1);
|
||||
IBinding b2 = getBindingFromASTName("E *e", 1);
|
||||
|
||||
|
||||
assertInstance(b1, ITypedef.class);
|
||||
ITypedef t1= (ITypedef) b1;
|
||||
assertInstance(t1.getType(), ICompositeType.class);
|
||||
assertEquals(ICompositeType.k_struct, ((ICompositeType)t1.getType()).getKey());
|
||||
|
||||
|
||||
assertInstance(b2, ITypedef.class);
|
||||
ITypedef t2= (ITypedef) b2;
|
||||
assertInstance(t2.getType(), IEnumeration.class);
|
||||
}
|
||||
|
||||
|
||||
// union U {
|
||||
// int x;
|
||||
// int y;
|
||||
|
@ -200,7 +200,7 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
// int z;
|
||||
// };
|
||||
// typedef struct S TS;
|
||||
|
||||
|
||||
// void refs() {
|
||||
// union U b1;
|
||||
// struct S b2;
|
||||
|
@ -287,7 +287,7 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
IBinding b28 = getBindingFromASTName("z = 13",1);
|
||||
assertVariable(b28, "z", IBasicType.class, null);
|
||||
}
|
||||
|
||||
|
||||
// // header file
|
||||
// struct S {struct S* sp;};
|
||||
// struct S foo1(struct S s);
|
||||
|
@ -313,42 +313,42 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
public void testExpressionKindForFunctionCalls() {
|
||||
IBinding b0 = getBindingFromASTName("foo1/*a*/", 4);
|
||||
IBinding b0a = getBindingFromASTName("sp[1]", 2);
|
||||
|
||||
|
||||
IBinding b1 = getBindingFromASTName("foo2/*b*/", 4);
|
||||
IBinding b1a = getBindingFromASTName("sp+1);", 2);
|
||||
|
||||
|
||||
IBinding b2 = getBindingFromASTName("foo2/*c*/", 4);
|
||||
IBinding b2a = getBindingFromASTName("sp);/*1*/", 2);
|
||||
|
||||
|
||||
IBinding b3 = getBindingFromASTName("foo1/*d*/", 4);
|
||||
IBinding b3a = getBindingFromASTName("s : s);/*2*/", 1);
|
||||
IBinding b3b = getBindingFromASTName("s);/*2*/", 1);
|
||||
|
||||
|
||||
IBinding b4 = getBindingFromASTName("foo4/*e*/", 4);
|
||||
IBinding b4a = getBindingFromASTName("s);/*3*/", 1);
|
||||
|
||||
|
||||
IBinding b5 = getBindingFromASTName("foo2/*f*/", 4);
|
||||
IBinding b5a = getBindingFromASTName("s.sp);/*4*/", 1);
|
||||
IBinding b5b = getBindingFromASTName("sp);/*4*/", 2);
|
||||
IBinding b5c = getBindingFromASTName("sp->sp);/*5*/", 2);
|
||||
IBinding b5d = getBindingFromASTName("sp);/*5*/", 2);
|
||||
|
||||
|
||||
IBinding b6 = getBindingFromASTName("foo1/*g*/", 4);
|
||||
IBinding b6a = getBindingFromASTName("foo1(s));/*6*/", 4);
|
||||
IBinding b6b = getBindingFromASTName("s));/*6*/", 1);
|
||||
|
||||
|
||||
IBinding b7 = getBindingFromASTName("foo1/*h*/", 4);
|
||||
IBinding b7a = getBindingFromASTName("s);/*7*/", 1);
|
||||
|
||||
|
||||
IBinding b8 = getBindingFromASTName("foo3/*i*/", 4);
|
||||
|
||||
|
||||
IBinding b9 = getBindingFromASTName("foo3/*j*/", 4);
|
||||
IBinding b9a = getBindingFromASTName("S));/*8*/", 1);
|
||||
|
||||
|
||||
IBinding b10 = getBindingFromASTName("foo1/*k*/", 4);
|
||||
IBinding b10a = getBindingFromASTName("sp);/*9*/ ", 2);
|
||||
}
|
||||
|
||||
|
||||
// // header file
|
||||
// struct myStruct {
|
||||
// int a;
|
||||
|
@ -358,7 +358,7 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
// };
|
||||
|
||||
// // referencing content
|
||||
// struct myStruct;
|
||||
// struct myStruct;
|
||||
// union myUnion;
|
||||
// void test() {
|
||||
// struct myStruct* u;
|
||||
|
@ -370,12 +370,12 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
getBindingFromASTName("a= 1", 1);
|
||||
getBindingFromASTName("b= 1", 1);
|
||||
}
|
||||
|
||||
|
||||
// int a= 1+2-3*4+10/2; // -4
|
||||
// int b= a+4;
|
||||
// int* c= &b;
|
||||
// enum X {e0, e4=4, e5, e2=2, e3};
|
||||
|
||||
|
||||
// void ref() {
|
||||
// a; b; c; e0; e2; e3; e4; e5;
|
||||
// }
|
||||
|
@ -405,14 +405,14 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
assertNotNull(numericalValue);
|
||||
assertEquals(i, numericalValue.intValue());
|
||||
}
|
||||
|
||||
|
||||
// extern char TableValue[10];
|
||||
|
||||
|
||||
// char TableValue[sizeof TableValue];
|
||||
public void testNameLookupFromArrayModifier_435075() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
|
||||
// static union {
|
||||
// int a;
|
||||
// int b;
|
||||
|
|
|
@ -15,8 +15,6 @@ package org.eclipse.cdt.internal.index.tests;
|
|||
import java.util.Arrays;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
|
||||
|
@ -64,6 +62,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* For testing PDOM binding resolution
|
||||
*/
|
||||
|
@ -1361,7 +1361,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
IWorkingCopy workingCopy = tu.getWorkingCopy();
|
||||
IBuffer buffer = workingCopy.getBuffer();
|
||||
buffer.setContents(buffer.getContents().replace("E {", "E : public C<int> {"));
|
||||
// Release and re-acquire the index lock to clear the caches.
|
||||
// Release and re-acquire the index lock to clear the caches.
|
||||
getIndex().releaseReadLock();
|
||||
getIndex().acquireReadLock();
|
||||
ast = workingCopy.getAST(strategy.getIndex(), ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
@ -20,7 +20,7 @@ public class IndexCPPBindingResolutionBugsSingleProjectFirstAST extends IndexCPP
|
|||
public static TestSuite suite() {
|
||||
return suite(IndexCPPBindingResolutionBugsSingleProjectFirstAST.class);
|
||||
}
|
||||
|
||||
|
||||
// Invalid tests for this strategy, they assume that the second file is already indexed.
|
||||
@Override public void test_208558() {}
|
||||
@Override public void test_176708_CCE() {}
|
||||
|
|
|
@ -178,7 +178,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
assertNotNull(numericalValue);
|
||||
assertEquals(i, numericalValue.longValue());
|
||||
}
|
||||
|
||||
|
||||
private void assertUserDefinedLiteralType(String retName) {
|
||||
ICPPVariable v= getBindingFromFirstIdentifier("test =");
|
||||
assertEquals(retName, ASTTypeUtil.getType(v.getType()));
|
||||
|
@ -895,7 +895,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
public void testAnonymousUnion_377409() {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
|
||||
// void foo(int a=2, int b=3);
|
||||
|
||||
// void ref() { foo(); }
|
||||
|
@ -1810,6 +1810,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
public void testAnonymousNamespaces_418130() {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// struct A {
|
||||
// A(int);
|
||||
// };
|
||||
|
|
|
@ -607,7 +607,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testInstanceInheritance_258745() throws Exception {
|
||||
getBindingFromFirstIdentifier("a", ICPPField.class);
|
||||
}
|
||||
|
||||
|
||||
// template <typename>
|
||||
// struct Base {
|
||||
// virtual void foo() = 0;
|
||||
|
@ -616,7 +616,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// struct Derived : Base<int> {
|
||||
// virtual void foo();
|
||||
// };
|
||||
|
||||
|
||||
// Derived waldo;
|
||||
public void testMethodOveriddenFromTemplateInstanceBase_480892() throws Exception {
|
||||
IVariable waldo = getBindingFromFirstIdentifier("waldo");
|
||||
|
@ -2199,15 +2199,15 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertNotNull(num);
|
||||
assertEquals(1, num.longValue());
|
||||
}
|
||||
|
||||
|
||||
// template<typename T>
|
||||
// struct meta {
|
||||
// enum {
|
||||
// enum {
|
||||
// a = T::value,
|
||||
// b = a
|
||||
// };
|
||||
// };
|
||||
|
||||
|
||||
// struct S {
|
||||
// static const int value = 42;
|
||||
// };
|
||||
|
@ -2233,12 +2233,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
|
||||
// template<typename T>
|
||||
// struct meta {
|
||||
// enum {
|
||||
// enum {
|
||||
// b = T::value,
|
||||
// a = b
|
||||
// };
|
||||
// };
|
||||
|
||||
|
||||
// struct S {
|
||||
// static const int value = 42;
|
||||
// };
|
||||
|
@ -2630,7 +2630,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testSpecializationOfConstexprFunction_420995() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
|
||||
// template <typename>
|
||||
// struct S;
|
||||
//
|
||||
|
@ -2643,7 +2643,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// constexpr int foo() {
|
||||
// return S<T>::value;
|
||||
// }
|
||||
|
||||
|
||||
// constexpr int waldo = foo<int>();
|
||||
public void testInstantiationOfReturnExpression_484959() throws Exception {
|
||||
ICPPVariable waldo = getBindingFromASTName("waldo", 5);
|
||||
|
@ -2770,12 +2770,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IVariable var2 = getBindingFromASTName("var2", 4);
|
||||
assertSameType(var1.getType(), var2.getType());
|
||||
}
|
||||
|
||||
|
||||
// template <typename T>
|
||||
// struct allocator {
|
||||
// typedef T value_type;
|
||||
// };
|
||||
|
||||
|
||||
// template <typename> struct allocator;
|
||||
//
|
||||
// struct Item {
|
||||
|
@ -2790,25 +2790,25 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
checkBindings();
|
||||
}
|
||||
|
||||
// template<long _Ax> struct _GcdX {
|
||||
// template<long _Ax> struct _GcdX {
|
||||
// static const long value = _GcdX<_Ax - 1>::value;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// template<> struct _GcdX<0> {
|
||||
// static const long value = 0;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// template<long _Ax> struct R {
|
||||
// // static const long value = _Ax;
|
||||
// };
|
||||
//
|
||||
// template<class _R1> struct Operation {
|
||||
//
|
||||
// template<class _R1> struct Operation {
|
||||
// static const long _N1 = _R1::value;
|
||||
// typedef R<_GcdX<_N1>::value> value;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// typedef Operation< R<1> >::value MYTYPE;
|
||||
|
||||
|
||||
// // empty file
|
||||
public void testRecursiveTemplateInstantiation_479138a() throws Exception {
|
||||
// This tests that a template metaprogram whose termination depends on
|
||||
|
@ -2816,35 +2816,35 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// inputs are not known.
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// template<long _Ax, long _Bx> struct _GcdX {
|
||||
|
||||
// template<long _Ax, long _Bx> struct _GcdX {
|
||||
// static const long value = _GcdX<_Bx, _Ax % _Bx>::value;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// template<long _Ax> struct _GcdX<_Ax, 0> {
|
||||
// static const long value = _Ax;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// template<long _Ax, long _Bx> struct _Gcd {
|
||||
// static const long value = _GcdX<_Ax, _Bx>::value;
|
||||
// };
|
||||
//
|
||||
// template<> struct _Gcd<0, 0> {
|
||||
//
|
||||
// template<> struct _Gcd<0, 0> {
|
||||
// static const long value = 1;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// template<long _Ax> struct R {
|
||||
// // static const long value = _Ax;
|
||||
// };
|
||||
//
|
||||
// template<class _R1> struct Operation {
|
||||
//
|
||||
// template<class _R1> struct Operation {
|
||||
// static const long _N1 = _R1::value;
|
||||
// typedef R<_Gcd<_N1, _N1>::value> value;
|
||||
// };
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// typedef Operation< R<1> >::value MYTYPE;
|
||||
|
||||
|
||||
// // empty file
|
||||
public void testRecursiveTemplateInstantiation_479138b() throws Exception {
|
||||
// This is similar to 479138a, but the metaprogram additionally has
|
||||
|
@ -2852,22 +2852,22 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// intermediate results cannot be collapsed into a single value.
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// template<long _Ax> struct _GcdX {
|
||||
|
||||
// template<long _Ax> struct _GcdX {
|
||||
// static const long value = _GcdX<_Ax - 1>::value;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// template<long _Ax> struct R {
|
||||
// static const long value = _Ax;
|
||||
// };
|
||||
//
|
||||
// template<class _R1> struct Operation {
|
||||
//
|
||||
// template<class _R1> struct Operation {
|
||||
// static const long _N1 = _R1::value;
|
||||
// typedef R<_GcdX<_N1>::value> value;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// typedef Operation< R<1> >::value MYTYPE;
|
||||
|
||||
|
||||
// // empty file
|
||||
// // special:allowRecursionBindings
|
||||
public void testRecursiveTemplateInstantiation_479138c() throws Exception {
|
||||
|
@ -2888,7 +2888,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// auto Foo<Bar("")>() -> int {
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
|
||||
// // empty file
|
||||
public void testStackOverflow_462764() throws Exception {
|
||||
checkBindings();
|
||||
|
|
|
@ -58,7 +58,7 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
|
|||
checkBindings();
|
||||
ICPPVariableTemplate pi = getBindingFromASTName("pi", 0);
|
||||
ICPPVariableInstance piOfInt = getBindingFromASTName("pi<int>", 0);
|
||||
|
||||
|
||||
assertEquals(pi, piOfInt.getSpecializedBinding());
|
||||
}
|
||||
|
||||
|
@ -71,23 +71,23 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
|
|||
checkBindings();
|
||||
ICPPFieldTemplate pi = getBindingFromASTName("pi", 0);
|
||||
ICPPVariableInstance piOfInt = getBindingFromASTName("pi<int>", 0);
|
||||
|
||||
|
||||
assertEquals(pi, piOfInt.getSpecializedBinding());
|
||||
}
|
||||
|
||||
|
||||
// template<typename T> constexpr T pi = T(3);
|
||||
// template constexpr int pi<int>;
|
||||
|
||||
|
||||
// int f(){ return pi<int>; }
|
||||
public void testExplicitVariableInstance() {
|
||||
checkBindings();
|
||||
ICPPVariableTemplate pi = getBindingFromASTName("pi", 0);
|
||||
ICPPVariableInstance piOfInt =
|
||||
getBindingFromASTName("pi<int>", 0, ICPPVariableInstance.class, IIndexBinding.class);
|
||||
|
||||
|
||||
assertEquals(pi, piOfInt.getSpecializedBinding());
|
||||
}
|
||||
|
||||
|
||||
// struct S {
|
||||
// template<typename T> static constexpr T pi = T(3);
|
||||
// };
|
||||
|
@ -99,23 +99,23 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
|
|||
ICPPFieldTemplate pi = getBindingFromASTName("pi", 0);
|
||||
ICPPVariableInstance piOfDouble = getBindingFromASTName("pi<double>", 0,
|
||||
ICPPVariableInstance.class, ICPPField.class, IIndexBinding.class);
|
||||
|
||||
|
||||
assertEquals(pi, piOfDouble.getSpecializedBinding());
|
||||
}
|
||||
|
||||
|
||||
// template<typename T> constexpr T pi = T(3);
|
||||
// template<> constexpr int pi<int> = 4;
|
||||
|
||||
|
||||
// int f(){ return pi<int>; }
|
||||
public void testVariableSpecialization() {
|
||||
checkBindings();
|
||||
ICPPVariableTemplate pi = getBindingFromASTName("pi", 0);
|
||||
ICPPVariableInstance piOfInt =
|
||||
getBindingFromASTName("pi<int>", 0, ICPPVariableInstance.class, IIndexBinding.class);
|
||||
|
||||
|
||||
assertEquals(pi, piOfInt.getSpecializedBinding());
|
||||
}
|
||||
|
||||
|
||||
// struct S {
|
||||
// template<typename T> static constexpr T pi = T(3);
|
||||
// };
|
||||
|
@ -127,10 +127,10 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
|
|||
ICPPFieldTemplate pi = getBindingFromASTName("pi", 0);
|
||||
ICPPVariableInstance piOfDouble = getBindingFromASTName("pi<double>", 0,
|
||||
ICPPVariableInstance.class, ICPPField.class, IIndexBinding.class);
|
||||
|
||||
|
||||
assertEquals(pi, piOfDouble.getSpecializedBinding());
|
||||
}
|
||||
|
||||
|
||||
// struct S {
|
||||
// template<typename T> static constexpr T pi = T(3);
|
||||
// };
|
||||
|
@ -149,13 +149,13 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
|
|||
public void testVariableTemplatePartialSpecialization() {
|
||||
checkBindings();
|
||||
ICPPVariableTemplate c = getBindingFromASTName("c", 0);
|
||||
|
||||
ICPPVariableInstance cOfFloat = getBindingFromASTName("c<float, 100>", 0,
|
||||
|
||||
ICPPVariableInstance cOfFloat = getBindingFromASTName("c<float, 100>", 0,
|
||||
ICPPVariableInstance.class);
|
||||
|
||||
|
||||
assertInstance(cOfFloat.getSpecializedBinding(),
|
||||
ICPPVariableTemplatePartialSpecialization.class, IIndexBinding.class);
|
||||
|
||||
|
||||
assertEquals(c,
|
||||
((ICPPVariableTemplatePartialSpecialization) cOfFloat.getSpecializedBinding()).getPrimaryTemplate());
|
||||
}
|
||||
|
@ -167,13 +167,13 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
|
|||
public void testVariableTemplatePartialSpecialization2() {
|
||||
checkBindings();
|
||||
ICPPVariableTemplate c = getBindingFromASTName("c", 0);
|
||||
|
||||
ICPPVariableInstance cOfIntPtr = getBindingFromASTName("c<int*>", 0,
|
||||
|
||||
ICPPVariableInstance cOfIntPtr = getBindingFromASTName("c<int*>", 0,
|
||||
ICPPVariableInstance.class);
|
||||
|
||||
|
||||
assertInstance(cOfIntPtr.getSpecializedBinding(),
|
||||
ICPPVariableTemplatePartialSpecialization.class, IIndexBinding.class);
|
||||
|
||||
|
||||
assertEquals(c,
|
||||
((ICPPVariableTemplatePartialSpecialization) cOfIntPtr.getSpecializedBinding()).getPrimaryTemplate());
|
||||
}
|
||||
|
@ -182,18 +182,18 @@ public class IndexCPPVariableTemplateResolutionTest extends IndexBindingResoluti
|
|||
// template<typename T, int I> static constexpr T c = T(I);
|
||||
// };
|
||||
// template<int I> constexpr float S::c<float, I> = float(I);
|
||||
|
||||
|
||||
// float f() { return S::c<float, 100>; }
|
||||
public void testFieldTemplatePartialSpecialization() {
|
||||
checkBindings();
|
||||
ICPPVariableTemplate c = getBindingFromASTName("c", 0);
|
||||
|
||||
ICPPVariableInstance cOfIntPtr = getBindingFromASTName("c<float, 100>", 0,
|
||||
|
||||
ICPPVariableInstance cOfIntPtr = getBindingFromASTName("c<float, 100>", 0,
|
||||
ICPPVariableInstance.class, ICPPField.class);
|
||||
|
||||
|
||||
assertInstance(cOfIntPtr.getSpecializedBinding(),
|
||||
ICPPVariableTemplatePartialSpecialization.class, IIndexBinding.class, ICPPField.class);
|
||||
|
||||
|
||||
assertEquals(c.getClass(),
|
||||
((ICPPVariableTemplatePartialSpecialization) cOfIntPtr.getSpecializedBinding()).getPrimaryTemplate().getClass());
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
@ -44,6 +42,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
/**
|
||||
* Tests the behavior of the IIndex API when dealing with multiple projects
|
||||
*/
|
||||
|
@ -58,37 +58,37 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
private final boolean cpp;
|
||||
private List<IProject> dependencies = new ArrayList<IProject>();
|
||||
private Map<String, String> path2content = new HashMap<String, String>();
|
||||
|
||||
|
||||
ProjectBuilder(String name, boolean cpp) {
|
||||
this.name = name;
|
||||
this.cpp = cpp;
|
||||
}
|
||||
|
||||
|
||||
ProjectBuilder addDependency(IProject project) {
|
||||
dependencies.add(project);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
ProjectBuilder addFile(String relativePath, CharSequence content) {
|
||||
path2content.put(relativePath, content.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
ICProject create() throws Exception {
|
||||
ICProject result = cpp ?
|
||||
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER) :
|
||||
CProjectHelper.createCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
createdProjects.add(result.getProject());
|
||||
|
||||
|
||||
IFile lastFile= null;
|
||||
for (Map.Entry<String, String> entry : path2content.entrySet()) {
|
||||
lastFile= TestSourceReader.createFile(result.getProject(), new Path(entry.getKey()), entry.getValue());
|
||||
}
|
||||
|
||||
|
||||
IProjectDescription desc = result.getProject().getDescription();
|
||||
desc.setReferencedProjects(dependencies.toArray(new IProject[dependencies.size()]));
|
||||
result.getProject().setDescription(desc, new NullProgressMonitor());
|
||||
|
||||
|
||||
IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||
indexManager.setIndexerId(result, IPDOMManager.ID_FAST_INDEXER);
|
||||
if (lastFile != null) {
|
||||
|
@ -96,7 +96,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
indexManager.reindex(result);
|
||||
IIndex index= indexManager.getIndex(result);
|
||||
TestSourceReader.waitUntilFileIsIndexed(index, lastFile, INDEXER_TIMEOUT_SEC * 1000);
|
||||
}
|
||||
}
|
||||
BaseTestCase.waitForIndexer(result);
|
||||
return result;
|
||||
}
|
||||
|
@ -120,9 +120,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
IIndex index;
|
||||
|
||||
|
||||
protected StringBuilder[] getContentsForTest(int blocks) throws IOException {
|
||||
return TestSourceReader.getContentsForTest(
|
||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
||||
|
@ -208,24 +208,24 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
final int gC= 6, aC= gC + 2;
|
||||
final int gB= 6, aB= gB + 1;
|
||||
final int gA= 3, aA= gA + 3;
|
||||
|
||||
|
||||
final int gBC= gB + gC - 1, aBC= aB + aC - 1;
|
||||
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
|
||||
|
||||
|
||||
setIndex(cprojC, NONE);
|
||||
assertBCount(gC, aC); assertNamespaceXMemberCount(1);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojC, REFS);
|
||||
assertBCount(gC, aC);
|
||||
assertNamespaceXMemberCount(1);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojC, REFD);
|
||||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojC, BOTH);
|
||||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
|
@ -235,37 +235,37 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertBCount(gBC, aBC);
|
||||
assertNamespaceXMemberCount(2);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojB, REFS);
|
||||
assertBCount(gBC, aBC);
|
||||
assertNamespaceXMemberCount(2);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojB, REFD);
|
||||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojB, BOTH);
|
||||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojA, NONE);
|
||||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
// binding C1 is not referenced by cprojA
|
||||
|
||||
|
||||
setIndex(cprojA, REFS);
|
||||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
assertFieldCount("C1", 1);
|
||||
|
||||
|
||||
setIndex(cprojA, REFD);
|
||||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
// binding C1 is not referenced by cprojA
|
||||
|
||||
|
||||
setIndex(cprojA, BOTH);
|
||||
assertBCount(gABC, aABC);
|
||||
assertNamespaceXMemberCount(5);
|
||||
|
@ -297,7 +297,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
public void testTripleUpwardV() throws Exception {
|
||||
CharSequence[] contents = getContentsForTest(3);
|
||||
List<ICProject> projects = new ArrayList<ICProject>();
|
||||
|
||||
|
||||
try {
|
||||
ProjectBuilder pb = new ProjectBuilder("projB_" + getName(), true);
|
||||
pb.addFile("h2.h", contents[0]);
|
||||
|
@ -317,17 +317,17 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
/* A C |
|
||||
* \ / | Depends On / References
|
||||
* B V
|
||||
*
|
||||
*
|
||||
* Defines Global, Defines Namespace, Ext. References Global, Ext. References Namespace
|
||||
* projC: 7, 2, 1, 1
|
||||
* projB: 4, 1, 0, 0
|
||||
* projA: 4, 1, 1, 1
|
||||
*/
|
||||
|
||||
|
||||
final int gC= 7, aC= gC + 2;
|
||||
final int gB= 4, aB= gB + 1;
|
||||
final int gA= 4, aA= gA + 1;
|
||||
|
||||
|
||||
final int gBC= gB + gC - 1, aBC= aB + aC - 1;
|
||||
final int gAB= gA + gB - 1, aAB= aA + aB - 1;
|
||||
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
|
||||
|
@ -388,7 +388,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
// namespace X { class B2 {}; C1 c; }
|
||||
// void foo(A1 c) {}
|
||||
// void foo(X::A2 c, B1 c) {}
|
||||
|
||||
|
||||
// class A1 {};
|
||||
// void foo(A1 a, A1 b) {}
|
||||
// namespace X { class A2 {}; }
|
||||
|
@ -415,7 +415,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
/* B |
|
||||
* / \ | Depends On / References
|
||||
* A C V
|
||||
*
|
||||
*
|
||||
* Defines Global, Defines Namespace, References Global, References Namespace
|
||||
* projC: 6, 1, 0, 0
|
||||
* projB: 4, 2, 2, 1
|
||||
|
@ -425,7 +425,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
final int gC= 6, aC= gC + 1;
|
||||
final int gB= 4, aB= gB + 2;
|
||||
final int gA= 3, aA= gA + 1;
|
||||
|
||||
|
||||
final int gBC= gB + gC - 1, aBC= aB + aC - 1;
|
||||
final int gAB= gA + gB - 1, aAB= aA + aB - 1;
|
||||
final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
|
||||
|
@ -474,7 +474,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Asserts binding counts, and returns the index tested against
|
||||
* @param global the number of bindings expected to be found at global scope
|
||||
|
@ -489,19 +489,19 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertEquals(all, bindings.length);
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
private void assertNamespaceXMemberCount(int count) throws CoreException, DOMException {
|
||||
IBinding[] bindings = index.findBindings(Pattern.compile("X"), true, FILTER, new NullProgressMonitor());
|
||||
assertEquals(1, bindings.length);
|
||||
assertEquals(count, ((ICPPNamespace) bindings[0]).getMemberBindings().length);
|
||||
}
|
||||
|
||||
|
||||
private void assertFieldCount(String qnPattern, int count) throws CoreException, DOMException {
|
||||
IBinding[] bindings = index.findBindings(Pattern.compile(qnPattern), true, FILTER, new NullProgressMonitor());
|
||||
assertEquals(1, bindings.length);
|
||||
assertEquals(count, ((ICompositeType) bindings[0]).getFields().length);
|
||||
}
|
||||
|
||||
|
||||
private void setIndex(ICProject project, int options) throws CoreException, InterruptedException {
|
||||
if (index != null) {
|
||||
index.releaseReadLock();
|
||||
|
@ -509,7 +509,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
index = CCorePlugin.getIndexManager().getIndex(project, options);
|
||||
index.acquireReadLock();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (index != null) {
|
||||
|
|
|
@ -26,22 +26,22 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti
|
|||
TestScannerProvider.sDefinedSymbols.put("__GNUC__", Integer.toString(GCC_MAJOR_VERSION_FOR_TESTS));
|
||||
TestScannerProvider.sDefinedSymbols.put("__GNUC_MINOR__", Integer.toString(GCC_MINOR_VERSION_FOR_TESTS));
|
||||
}
|
||||
|
||||
|
||||
private static void gnuTearDown() {
|
||||
TestScannerProvider.clear();
|
||||
}
|
||||
|
||||
|
||||
public class GPPReferencedProject extends ReferencedProject {
|
||||
public GPPReferencedProject() {
|
||||
super(true /* cpp */);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
gnuSetUp();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
|
@ -53,13 +53,13 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti
|
|||
public GPPSinglePDOMTestStrategy() {
|
||||
super(true /* cpp */);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
gnuSetUp();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
|
@ -107,7 +107,7 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti
|
|||
// enum e_int { a2 = -1, b2 = 1 };
|
||||
// enum e_ulong { a3 = 5000000000, b3 };
|
||||
// enum e_long { a4 = -5000000000, b4 = 5000000000 };
|
||||
|
||||
|
||||
// typedef underlying_type<e_fixed_short1>::type short1_type;
|
||||
// typedef underlying_type<e_fixed_short2>::type short2_type;
|
||||
//
|
||||
|
@ -122,7 +122,7 @@ public abstract class IndexGPPBindingResolutionTest extends IndexBindingResoluti
|
|||
assertSameType((ITypedef) getBindingFromASTName("short2_type", 0), CPPBasicType.SHORT);
|
||||
|
||||
assertSameType((ITypedef) getBindingFromASTName("scoped_type", 0), CPPBasicType.INT);
|
||||
|
||||
|
||||
assertSameType((ITypedef) getBindingFromASTName("unsigned_type", 0), CPPBasicType.UNSIGNED_INT);
|
||||
assertSameType((ITypedef) getBindingFromASTName("int_type", 0), CPPBasicType.INT);
|
||||
assertSameType((ITypedef) getBindingFromASTName("ulong_type", 0), CPPBasicType.UNSIGNED_LONG);
|
||||
|
|
|
@ -8,14 +8,12 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
|
@ -41,6 +39,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class IndexIncludeTest extends IndexTestBase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
|
@ -51,7 +51,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
|
||||
private ICProject fProject;
|
||||
private IIndex fIndex;
|
||||
|
||||
|
||||
public IndexIncludeTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
@ -69,18 +69,18 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
}
|
||||
fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
public void deleteProject() {
|
||||
if (fProject != null) {
|
||||
CProjectHelper.delete(fProject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testFastIndexer() throws Exception {
|
||||
CCorePlugin.getIndexManager().setIndexerId(fProject, IPDOMManager.ID_FAST_INDEXER);
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
|
||||
|
@ -90,7 +90,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
|
||||
waitForIndexer();
|
||||
checkHeader(true);
|
||||
|
||||
|
||||
checkContext();
|
||||
}
|
||||
|
||||
|
@ -107,18 +107,18 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkContext() throws Exception {
|
||||
final long timestamp= System.currentTimeMillis();
|
||||
final IFile file= (IFile) fProject.getProject().findMember(new Path("included.h"));
|
||||
assertNotNull("Can't find included.h", file);
|
||||
waitForIndexer();
|
||||
|
||||
|
||||
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
file.setContents(new ByteArrayInputStream("int included; int CONTEXT;\n".getBytes()), false, false, npm());
|
||||
file.setLocalTimeStamp(timestamp + 1000);
|
||||
file.setLocalTimeStamp(timestamp + 1000);
|
||||
}
|
||||
}, npm());
|
||||
assertTrue("Timestamp was not increased", file.getLocalTimeStamp() >= timestamp);
|
||||
|
@ -143,7 +143,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
assertTrue("Can't find " + file.getLocation(), files.length > 0);
|
||||
assertEquals("Found " + files.length + " files for " + file.getLocation() + " instead of one", 1, files.length);
|
||||
return files[0];
|
||||
}
|
||||
}
|
||||
|
||||
// {source20061107}
|
||||
// #include "user20061107.h"
|
||||
|
@ -169,7 +169,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testIncludeProperties_2() throws Exception {
|
||||
TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
|
||||
TestSourceReader.createFile(fProject.getProject(), "header20061107.h", "");
|
||||
|
@ -238,7 +238,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
assertEquals(offset, include.getNameOffset());
|
||||
assertEquals(includeName.length(), include.getNameLength());
|
||||
assertEquals(isSystem, include.isSystemInclude());
|
||||
}
|
||||
}
|
||||
|
||||
public void testUpdateOfIncluded() throws Exception {
|
||||
String content1 = "int CONTEXT_20070404(x);\n";
|
||||
|
@ -264,7 +264,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
Thread.sleep(1000);
|
||||
// now change the header and see whether it gets parsed
|
||||
TestSourceReader.createFile(fProject.getProject(), "included_20070404.h", content2);
|
||||
|
@ -282,12 +282,12 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #define SOME_MACRO1 ok_1_220358
|
||||
// #define SOME_MACRO2 ok_2_220358
|
||||
|
||||
|
||||
// int SOME_MACRO1;
|
||||
|
||||
|
||||
// int SOME_MACRO2;
|
||||
|
||||
// #include "header1.h"
|
||||
|
@ -310,7 +310,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
// change header2:
|
||||
h2= TestSourceReader.createFile(fProject.getProject(), "header2.h", sources[2].toString());
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, h2, INDEXER_TIMEOUT_MILLISEC);
|
||||
|
@ -321,9 +321,9 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
assertTrue(binding[0] instanceof IVariable);
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #include "resolved20070426.h"
|
||||
public void testFixedContext() throws Exception {
|
||||
TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
|
||||
|
@ -343,7 +343,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
IIndexFile ifile= getIndexFile(header);
|
||||
IIndexInclude[] includes= fIndex.findIncludedBy(ifile);
|
||||
assertEquals(2, includes.length);
|
||||
|
||||
|
||||
IIndexInclude context= ifile.getParsedInContext();
|
||||
assertNotNull(context);
|
||||
assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath());
|
||||
|
@ -353,7 +353,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", source + "\nint a20070426;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
fIndex.acquireReadLock();
|
||||
|
@ -412,42 +412,42 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
|
||||
CharSequence[] source= getContentsForTest(4);
|
||||
IFile header= TestSourceReader.createFile(fProject.getProject(), "resolved20070427.h", "");
|
||||
IFile s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
IFile s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
source[0].toString() + "\nint a20070427;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
standardCheckUpdateIncludes(header, s1, "a20070427");
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
source[0].toString() + "\nint b20070427;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
standardCheckUpdateIncludes(header, s1, "b20070427");
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
source[1].toString() + "\nint c20070427;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
checkUpdateIncludes1(header, s1, "c20070427");
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
source[0].toString() + "\nint d20070427;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
standardCheckUpdateIncludes(header, s1, "d20070427");
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
source[2].toString() + "\nint e20070427;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
checkUpdateIncludes2(header, s1, "e20070427");
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
source[0].toString() + "\nint f20070427;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
standardCheckUpdateIncludes(header, s1, "f20070427");
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
source[3].toString() + "\nint g20070427;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
checkUpdateIncludes3(header, s1, "g20070427");
|
||||
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
|
||||
source[0].toString() + "\nint h20070427;");
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_TIMEOUT_MILLISEC);
|
||||
standardCheckUpdateIncludes(header, s1, "h20070427");
|
||||
|
@ -505,7 +505,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
h1.setContents(new ByteArrayInputStream(h1Contents.toString().getBytes()), false, false, npm());
|
||||
h1.setLocalTimeStamp(timestamp + 1000);
|
||||
h1.setLocalTimeStamp(timestamp + 1000);
|
||||
}
|
||||
}, npm());
|
||||
waitForIndexer();
|
||||
|
@ -580,14 +580,14 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
// Change h1.h so that it has the pragma-once semantics.
|
||||
// Change h1.h so that it has the pragma-once semantics.
|
||||
final long t1= System.currentTimeMillis();
|
||||
final String changedContents = contents[4].toString();
|
||||
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
h1.setContents(new ByteArrayInputStream(changedContents.getBytes()), false, false, npm());
|
||||
h1.setLocalTimeStamp(t1 + 1000);
|
||||
h1.setLocalTimeStamp(t1 + 1000);
|
||||
}
|
||||
}, npm());
|
||||
waitForIndexer();
|
||||
|
@ -606,13 +606,13 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
// Change h1.h back to the original state without the pragma-once semantics.
|
||||
// Change h1.h back to the original state without the pragma-once semantics.
|
||||
final long t2= System.currentTimeMillis();
|
||||
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
h1.setContents(new ByteArrayInputStream(h1Contents.toString().getBytes()), false, false, npm());
|
||||
h1.setLocalTimeStamp(t2 + 2000);
|
||||
h1.setLocalTimeStamp(t2 + 2000);
|
||||
}
|
||||
}, npm());
|
||||
waitForIndexer();
|
||||
|
@ -668,7 +668,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpdateIncludes1(IFile header, IFile s1, String tag) throws Exception {
|
||||
fIndex.acquireReadLock();
|
||||
|
@ -697,7 +697,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpdateIncludes2(IFile header, IFile s1, String tag) throws Exception {
|
||||
fIndex.acquireReadLock();
|
||||
|
@ -730,7 +730,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpdateIncludes3(IFile header, IFile s1, String tag) throws Exception {
|
||||
fIndex.acquireReadLock();
|
||||
|
@ -763,5 +763,5 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ package org.eclipse.cdt.internal.index.tests;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.index.IIndexChangeEvent;
|
||||
|
@ -29,6 +27,8 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
|||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
public class IndexListenerTest extends BaseTestCase {
|
||||
private ICProject fProject1;
|
||||
private ICProject fProject2;
|
||||
|
@ -57,7 +57,7 @@ public class IndexListenerTest extends BaseTestCase {
|
|||
IIndexManager im= CCorePlugin.getIndexManager();
|
||||
waitForIndexer(fProject1);
|
||||
waitForIndexer(fProject2);
|
||||
|
||||
|
||||
IIndexerStateListener listener = new IIndexerStateListener() {
|
||||
@Override
|
||||
public void indexChanged(IIndexerStateEvent event) {
|
||||
|
@ -74,7 +74,7 @@ public class IndexListenerTest extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
im.addIndexerStateListener(listener);
|
||||
try {
|
||||
IFile file= TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;");
|
||||
|
@ -94,12 +94,12 @@ public class IndexListenerTest extends BaseTestCase {
|
|||
im.removeIndexerStateListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testChangeListener() throws Exception {
|
||||
final Object mutex= new Object();
|
||||
final List projects= new ArrayList();
|
||||
IIndexManager im= CCorePlugin.getIndexManager();
|
||||
|
||||
|
||||
waitForIndexer(fProject1);
|
||||
waitForIndexer(fProject2);
|
||||
IIndexChangeListener listener = new IIndexChangeListener() {
|
||||
|
@ -113,11 +113,11 @@ public class IndexListenerTest extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
im.addIndexChangeListener(listener);
|
||||
try {
|
||||
IFile file= TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;");
|
||||
|
||||
|
||||
synchronized (mutex) {
|
||||
mutex.wait(8000);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -48,11 +46,13 @@ import org.eclipse.core.runtime.Path;
|
|||
import org.eclipse.core.runtime.Platform;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
public class IndexLocationTest extends BaseTestCase {
|
||||
private static final boolean isWin= Platform.getOS().equals(Platform.OS_WIN32);
|
||||
protected List projects= new ArrayList();
|
||||
protected ICProject cproject;
|
||||
|
||||
|
||||
public static Test suite() {
|
||||
return suite(IndexLocationTest.class);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
ICProject ptd= (ICProject) i.next();
|
||||
if (ptd != null) {
|
||||
ptd.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
@ -92,12 +92,12 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
Bundle b = CTestPlugin.getDefault().getBundle();
|
||||
CharSequence[] testData = TestSourceReader.getContentsForTest(b, "parser", getClass(), getName(), 3);
|
||||
|
||||
IFile file1 = TestSourceReader.createFile(cproject.getProject(), "header.h", testData[0].toString());
|
||||
IFile file1 = TestSourceReader.createFile(cproject.getProject(), "header.h", testData[0].toString());
|
||||
createExternalFile(externalHeader, testData[1].toString());
|
||||
String content = testData[2].toString().replaceAll("ABS_EXTERNAL", externalHeader.getAbsolutePath().replaceAll("\\\\","\\\\\\\\"));
|
||||
IFile file3 = TestSourceReader.createFile(cproject.getProject(), "source.cpp", content);
|
||||
|
||||
CCorePlugin.getIndexManager().reindex(cproject);
|
||||
CCorePlugin.getIndexManager().reindex(cproject);
|
||||
waitForIndexer(cproject);
|
||||
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
|
@ -125,7 +125,7 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
assertEquals(
|
||||
ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(cproject.getProject().getName()+"/header.h")).getLocationURI(),
|
||||
nms1[0].getFile().getLocation().getURI()
|
||||
);
|
||||
);
|
||||
assertEquals(
|
||||
externalHeader.toURI(),
|
||||
nms2[0].getFile().getLocation().getURI()
|
||||
|
@ -155,15 +155,15 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
externalHeader.getParentFile().delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testLinkedFilesIndexedAsWithinProject() throws Exception {
|
||||
File location = new File(CProjectHelper.freshDir(), "external2.h");
|
||||
File location = new File(CProjectHelper.freshDir(), "external2.h");
|
||||
createExternalFile(location, "struct External {};\n");
|
||||
IFolder content= cproject.getProject().getFolder("content");
|
||||
content.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, npm());
|
||||
|
||||
|
||||
CCorePlugin.getIndexManager().reindex(cproject);
|
||||
|
||||
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
waitUntilFileIsIndexed(index, content.getFile("external2.h"));
|
||||
index.acquireReadLock();
|
||||
|
@ -178,20 +178,20 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
index.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testSameFileLinkedToOnceInTwoProjects_186214() throws Exception {
|
||||
File location = new File(CProjectHelper.freshDir(),"external2.h");
|
||||
File location = new File(CProjectHelper.freshDir(),"external2.h");
|
||||
createExternalFile(location, "struct External {};\n");
|
||||
assertTrue(location.isFile());
|
||||
|
||||
|
||||
IFolder content= cproject.getProject().getFolder("content");
|
||||
content.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null);
|
||||
final IFile file = content.getFile("external2.h");
|
||||
assertTrue(file.exists());
|
||||
|
||||
|
||||
ICProject cproject2= CProjectHelper.createCProject("LocationTests2"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
deleteOnTearDown(cproject2);
|
||||
|
||||
|
||||
IFolder content2= cproject2.getProject().getFolder("content");
|
||||
content2.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null);
|
||||
assertTrue(content2.getFile("external2.h").exists());
|
||||
|
@ -212,11 +212,11 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
index.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testResourceContainerRelativeLocationConverter() throws Exception {
|
||||
ICProject emptyCProject= CProjectHelper.createCProject("Empty", "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
deleteOnTearDown(emptyCProject);
|
||||
|
||||
|
||||
String[] paths = new String[] {"this.cpp", "inc/header.h", "a b c/d/e f/g.h", "a \\b /c.d"};
|
||||
for (String path : paths) {
|
||||
IFile file= cproject.getProject().getFile(path);
|
||||
|
@ -233,7 +233,7 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testURLC_RCRLC_Interaction1() throws Exception {
|
||||
String[] winPaths = new String[] {
|
||||
"c:/foo/bar/baz.cpp",
|
||||
|
@ -272,7 +272,7 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
assertEquals(root.getFile(new Path(expectedFullPaths[i])).getLocationURI(), ifl2.getURI());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testURLC_RCRLC_Interaction2() throws Exception {
|
||||
String[] winPaths = new String[] {
|
||||
"a b c/d/e f/g.h",
|
||||
|
@ -308,7 +308,7 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
assertEquals(URIUtil.toURI(basePath+paths[i]).normalize(), ifl2.getURI());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testURLC_RCRLC_Interaction3() throws Exception {
|
||||
IFolder linkedFolder= cproject.getProject().getFolder("linkedFolder");
|
||||
String[] winPaths = new String[] {
|
||||
|
@ -345,13 +345,13 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
assertEquals(URIUtil.toURI(basePath+paths[i]).normalize(), ifl2.getURI());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void deleteOnTearDown(ICProject cproject) {
|
||||
if (cproject != null) {
|
||||
projects.add(cproject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createExternalFile(File dest, String content) throws IOException {
|
||||
FileOutputStream fos = new FileOutputStream(dest);
|
||||
fos.write(content.getBytes());
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Tests for header files included in multiple variants.
|
||||
*
|
||||
|
@ -34,7 +34,7 @@ public class IndexMultiVariantHeaderTest extends IndexBindingResolutionTestBase
|
|||
public static TestSuite suite() {
|
||||
return suite(IndexMultiVariantHeaderTest.class);
|
||||
}
|
||||
|
||||
|
||||
// test.h
|
||||
// #ifdef func
|
||||
// #undef func
|
||||
|
@ -138,13 +138,13 @@ public class IndexMultiVariantHeaderTest extends IndexBindingResolutionTestBase
|
|||
getBindingFromASTName("y = 0", 1, ICPPVariable.class);
|
||||
getBindingFromASTName("z = 0", 1, ICPPVariable.class);
|
||||
}
|
||||
|
||||
|
||||
// b.h
|
||||
// #ifndef _B
|
||||
// #define _B
|
||||
// #define SIG // This internal modification is not propagated
|
||||
// #endif
|
||||
|
||||
|
||||
// a.h
|
||||
// #include "b.h"
|
||||
// #ifdef SIG // Not significant, because it is defined in "b.h"
|
||||
|
@ -159,16 +159,16 @@ public class IndexMultiVariantHeaderTest extends IndexBindingResolutionTestBase
|
|||
assertEquals("{}", inc.getSignificantMacros().toString());
|
||||
assertNotNull(inc.getImportedIndexFile());
|
||||
}
|
||||
|
||||
|
||||
// c.h
|
||||
// #define SIG // This internal modification is not propagated
|
||||
|
||||
|
||||
// b.h
|
||||
// #ifndef _B
|
||||
// #define _B
|
||||
// #include "c.h"
|
||||
// #include "c.h"
|
||||
// #endif
|
||||
|
||||
|
||||
// a.h
|
||||
// #include "b.h"
|
||||
// #ifdef SIG // Not significant, because it is defined in "c.h"
|
||||
|
|
|
@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.index.tests;
|
|||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
|
@ -36,6 +34,8 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class IndexNamesTests extends BaseTestCase {
|
||||
private ICProject fCProject;
|
||||
protected IIndex fIndex;
|
||||
|
@ -84,7 +84,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
String[] parts= qname.split("::");
|
||||
Pattern[] result= new Pattern[parts.length];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i]= Pattern.compile(parts[i]);
|
||||
result[i]= Pattern.compile(parts[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
protected void waitUntilFileIsIndexed(IFile file, int time) throws Exception {
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, time);
|
||||
}
|
||||
|
||||
|
||||
// void func();
|
||||
// int var;
|
||||
//
|
||||
|
@ -112,30 +112,30 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
String content= getComment();
|
||||
IFile file= createFile(getProject().getProject(), "test.cpp", content);
|
||||
waitUntilFileIsIndexed(file, 4000);
|
||||
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
IIndexBinding[] mainBS= fIndex.findBindings(getPattern("main"), true, IndexFilter.ALL, npm());
|
||||
assertLength(1, mainBS);
|
||||
IIndexBinding mainB= mainBS[0];
|
||||
|
||||
|
||||
IIndexName[] names= fIndex.findDefinitions(mainB);
|
||||
assertLength(1, names);
|
||||
IIndexName main= names[0];
|
||||
|
||||
|
||||
assertNull(main.getEnclosingDefinition());
|
||||
IIndexName[] enclosed= main.getEnclosedNames();
|
||||
assertLength(2, enclosed);
|
||||
assertName("func", enclosed[0]);
|
||||
assertName("var", enclosed[1]);
|
||||
|
||||
|
||||
IIndexName enclosing= enclosed[0].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
assertName("main", enclosing);
|
||||
|
||||
enclosing= enclosed[1].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
assertName("main", enclosing);
|
||||
assertName("main", enclosing);
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
assertNotNull(array);
|
||||
assertEquals(length, array.length);
|
||||
}
|
||||
|
||||
|
||||
// class C {
|
||||
// public:
|
||||
// void func();
|
||||
|
@ -170,17 +170,17 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
String content= getComment();
|
||||
IFile file= createFile(getProject().getProject(), "test.cpp", content);
|
||||
waitUntilFileIsIndexed(file, 4000);
|
||||
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
IIndexBinding[] mainBS= fIndex.findBindings(getPattern("main"), true, IndexFilter.ALL, npm());
|
||||
assertLength(1, mainBS);
|
||||
IIndexBinding mainB= mainBS[0];
|
||||
|
||||
|
||||
IIndexName[] names= fIndex.findDefinitions(mainB);
|
||||
assertLength(1, names);
|
||||
IIndexName main= names[0];
|
||||
|
||||
|
||||
assertNull(main.getEnclosingDefinition());
|
||||
IIndexName[] enclosed= main.getEnclosedNames();
|
||||
assertLength(4, enclosed);
|
||||
|
@ -188,14 +188,14 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
assertName("C", enclosed[1]); // Implicit ctor call
|
||||
assertName("func", enclosed[2]);
|
||||
assertName("var", enclosed[3]);
|
||||
|
||||
|
||||
IIndexName enclosing= enclosed[0].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
assertName("main", enclosing);
|
||||
|
||||
enclosing= enclosed[1].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
assertName("main", enclosing);
|
||||
assertName("main", enclosing);
|
||||
|
||||
enclosing= enclosed[2].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
|
@ -203,32 +203,32 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
|
||||
enclosing= enclosed[3].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
assertName("main", enclosing);
|
||||
assertName("main", enclosing);
|
||||
|
||||
IIndexBinding funcB= fIndex.findBinding(enclosed[2]);
|
||||
assertNotNull(funcB);
|
||||
names= fIndex.findDefinitions(funcB);
|
||||
assertLength(1, names);
|
||||
IIndexName funcdef= names[0];
|
||||
|
||||
|
||||
assertNull(funcdef.getEnclosingDefinition());
|
||||
enclosed= funcdef.getEnclosedNames();
|
||||
assertLength(3, enclosed);
|
||||
assertName("C", enclosed[0]);
|
||||
assertName("func", enclosed[1]);
|
||||
assertName("var", enclosed[2]);
|
||||
|
||||
|
||||
enclosing= enclosed[0].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
assertName("func", enclosing);
|
||||
|
||||
enclosing= enclosed[1].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
assertName("func", enclosing);
|
||||
assertName("func", enclosing);
|
||||
|
||||
enclosing= enclosed[2].getEnclosingDefinition();
|
||||
assertNotNull(enclosing);
|
||||
assertName("func", enclosing);
|
||||
assertName("func", enclosing);
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
@ -243,14 +243,14 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
// class Y : public X {
|
||||
// public:
|
||||
// virtual void vm() {
|
||||
// }
|
||||
// }
|
||||
// void test();
|
||||
// };
|
||||
// void Y::test() {
|
||||
// X* x= this;
|
||||
// X& xr= *this;
|
||||
// X xc= *this;
|
||||
//
|
||||
//
|
||||
// vm(); // polymorphic
|
||||
// X::vm(); // call to X::vm()
|
||||
// x->vm(); // polymorphic
|
||||
|
@ -267,7 +267,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
waitUntilFileIsIndexed(file, 4000);
|
||||
|
||||
boolean[] couldbepolymorphic= {true, false, true, false, true, false, false, false};
|
||||
String[] container= {"Y", "X", "X", "X", "X", "X", "X", "X" };
|
||||
String[] container= {"Y", "X", "X", "X", "X", "X", "X", "X" };
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -288,9 +288,9 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// class A {
|
||||
// virtual void foo(){}
|
||||
// virtual void foo(){}
|
||||
// template<typename C> void SetCallback(C callback){}
|
||||
// void InitCallback() {
|
||||
// SetCallback(&A::foo); // Can be A::foo or B::foo
|
||||
|
@ -338,11 +338,11 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
// void fcpcp(int const *const*);
|
||||
//
|
||||
// void test() {
|
||||
// _i;
|
||||
// wi= ri, _i, _i;
|
||||
// rwi %= ri;
|
||||
// ri ? _i : _i;
|
||||
// (ri ? wi : wi)= ri;
|
||||
// _i;
|
||||
// wi= ri, _i, _i;
|
||||
// rwi %= ri;
|
||||
// ri ? _i : _i;
|
||||
// (ri ? wi : wi)= ri;
|
||||
// if (ri) _i;
|
||||
// for(wi=1; ri>ri; rwi++) _i;
|
||||
// do {_i;} while (ri);
|
||||
|
@ -373,7 +373,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
final char c0= name.length() > 0 ? name.charAt(0) : 0;
|
||||
if ((c0 == '_' || c0 == 'r' || c0 == 'w') && indexName.isReference()) {
|
||||
boolean isRead= name.charAt(0) == 'r';
|
||||
boolean isWrite= c0 == 'w' || (isRead && name.length() > 1 && name.charAt(1) == 'w');
|
||||
boolean isWrite= c0 == 'w' || (isRead && name.length() > 1 && name.charAt(1) == 'w');
|
||||
String msg= name + "(j=" + j + "):";
|
||||
assertEquals("Read access for " + msg, isRead, indexName.isReadAccess());
|
||||
assertEquals("Write access for " + msg, isWrite, indexName.isWriteAccess());
|
||||
|
@ -433,7 +433,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
checkReadWriteFlags(file, ILinkage.CPP_LINKAGE_ID, 48);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// int _i, ri, wi, rwi;
|
||||
// void f(int&, int);
|
||||
// void g(int, int&);
|
||||
|
@ -449,7 +449,7 @@ public class IndexNamesTests extends BaseTestCase {
|
|||
|
||||
checkReadWriteFlags(file, ILinkage.CPP_LINKAGE_ID, 4);
|
||||
}
|
||||
|
||||
|
||||
// struct A {
|
||||
// A(int p) {}
|
||||
// };
|
||||
|
|
|
@ -17,8 +17,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
|
@ -66,12 +64,14 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.osgi.service.resolver.VersionRange;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Example usage and test for IIndexProvider
|
||||
*/
|
||||
public class IndexProviderManagerTest extends IndexTestBase {
|
||||
private static final int A_FRAGMENT_OPTION = IIndexManager.ADD_EXTENSION_FRAGMENTS_NAVIGATION;
|
||||
|
||||
|
||||
final static DummyProviderTraces DPT= DummyProviderTraces.getInstance();
|
||||
final static Class DP1= Providers.Dummy1.class;
|
||||
final static Class DP2= Providers.Dummy2.class;
|
||||
|
@ -79,7 +79,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
final static Class DP4= Providers.Dummy4.class;
|
||||
final static Class DP5= Providers.Dummy5.class;
|
||||
final static Class[] DPS= new Class[] {DP4, DP2, DP1, DP3, DP5};
|
||||
|
||||
|
||||
/*
|
||||
* Fictional compatibility ranges for testing
|
||||
*/
|
||||
|
@ -87,9 +87,9 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
final static VersionRange VERSION_401= new VersionRange("[36,37]");
|
||||
final static VersionRange VERSION_405= new VersionRange("[37,39]");
|
||||
final static VersionRange VERSION_502= new VersionRange("[89,91]");
|
||||
|
||||
|
||||
final CCorePlugin core= CCorePlugin.getDefault();
|
||||
|
||||
|
||||
public IndexProviderManagerTest() {
|
||||
super("IndexProviderManagerTest");
|
||||
}
|
||||
|
@ -110,11 +110,11 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager();
|
||||
ipm.reset(); ipm.startup();
|
||||
}
|
||||
|
||||
|
||||
public void testProvider_SimpleLifeCycle_200958() throws Exception {
|
||||
for (Class element : DPS)
|
||||
DPT.reset(element);
|
||||
|
||||
|
||||
List cprojects = new ArrayList(), expectedTrace = new ArrayList();
|
||||
try {
|
||||
for(int i=0; i<3; i++) {
|
||||
|
@ -141,7 +141,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
|
||||
public void testProvider_OverDeleteAndAdd() throws Exception {
|
||||
DPT.reset(DP1);
|
||||
|
||||
|
||||
List expectedTrace = new ArrayList();
|
||||
ICProject cproject = null;
|
||||
try {
|
||||
|
@ -184,7 +184,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
File newLocation = CProjectHelper.freshDir();
|
||||
IProjectDescription description = cproject.getProject().getDescription();
|
||||
description.setLocationURI(newLocation.toURI());
|
||||
cproject.getProject().move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
|
||||
cproject.getProject().move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor());
|
||||
|
||||
index = CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
assertEquals(expectedTrace, DPT.getProjectsTrace(DP1));
|
||||
|
@ -194,19 +194,19 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testVersioning_IncompatibleIgnored() throws Exception {
|
||||
IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager();
|
||||
|
||||
|
||||
ICProject cproject = null;
|
||||
try {
|
||||
cproject= CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER);
|
||||
IProject project= cproject.getProject();
|
||||
|
||||
|
||||
|
||||
|
||||
MockState mockState = new MockState(cproject);
|
||||
mockState.setConfig(MockState.REL_V1_ID);
|
||||
|
||||
|
||||
IIndexProvider provider1= new IIndexFragmentProvider() {
|
||||
IIndexFragment[] fragments= new IIndexFragment[] {
|
||||
new MockPDOM("contentID.contentA", "36"),
|
||||
|
@ -240,10 +240,10 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
};
|
||||
waitForIndexer(cproject);
|
||||
setExpectedNumberOfLoggedNonOKStatusObjects(3); // foo, bar and baz have no compatible fragments available
|
||||
|
||||
|
||||
ipm.reset(VERSION_405); ipm.startup();
|
||||
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
|
||||
|
||||
|
||||
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(1, actual.length);
|
||||
assertFragmentPresent("contentID.contentA", "38", actual);
|
||||
|
@ -253,19 +253,19 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testVersioning_NoCompatibleVersionsFound() throws Exception {
|
||||
IndexProviderManager ipm= ((PDOMManager)CCorePlugin.getIndexManager()).getIndexProviderManager();
|
||||
|
||||
|
||||
ICProject cproject = null;
|
||||
try {
|
||||
cproject= CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER);
|
||||
IProject project= cproject.getProject();
|
||||
|
||||
|
||||
|
||||
|
||||
MockState mockState = new MockState(cproject);
|
||||
mockState.setConfig(MockState.REL_V1_ID);
|
||||
|
||||
|
||||
IIndexProvider provider1= new IIndexFragmentProvider() {
|
||||
IIndexFragment[] fragments= new IIndexFragment[] {
|
||||
new MockPDOM("contentID.contentA", "36"),
|
||||
|
@ -296,13 +296,13 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
waitForIndexer(cproject);
|
||||
setExpectedNumberOfLoggedNonOKStatusObjects(1); // contentA has no compatible fragments available
|
||||
|
||||
|
||||
ipm.reset(VERSION_502); ipm.startup();
|
||||
ipm.addIndexProvider(provider1); ipm.addIndexProvider(provider2);
|
||||
|
||||
|
||||
IIndexFragment[] actual = ipm.getProvidedIndexFragments(mockState.getCurrentConfig(), -1);
|
||||
assertEquals(3, actual.length);
|
||||
assertFragmentPresent("contentID.foo", "90", actual);
|
||||
|
@ -314,7 +314,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void assertFragmentPresent(String id, String version, IIndexFragment[] fragments) throws Exception {
|
||||
for (IIndexFragment candidate : fragments) {
|
||||
String cid= null, csver= null;
|
||||
|
@ -330,49 +330,49 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
}
|
||||
fail("Fragment matching (id="+id+",version="+version+") was not present");
|
||||
}
|
||||
|
||||
|
||||
public void testIndexFactoryConfigurationUsage() throws Exception {
|
||||
IIndex index;
|
||||
|
||||
|
||||
ICProject cproject = null;
|
||||
// Modifying the .project file triggers an indexer job, suppress that:
|
||||
DeltaAnalyzer.sSuppressPotentialTUs= true;
|
||||
try {
|
||||
cproject = CProjectHelper.createCCProject("IndexFactoryConfigurationUsageTest", IPDOMManager.ID_NO_INDEXER);
|
||||
IProject project= cproject.getProject();
|
||||
|
||||
|
||||
ICProjectDescription pd= core.getProjectDescription(project);
|
||||
ICConfigurationDescription cfg1= newCfg(pd, "project", "config1");
|
||||
ICConfigurationDescription cfg2= newCfg(pd, "project", "config2");
|
||||
core.setProjectDescription(project, pd);
|
||||
|
||||
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
waitForIndexer(cproject);
|
||||
|
||||
|
||||
DPT.reset(DP1);
|
||||
changeConfigRelations(cproject, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
|
||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||
assertEquals(0, DPT.getCfgsTrace(DP1).size());
|
||||
|
||||
|
||||
changeActiveConfiguration(cproject, cfg1);
|
||||
DPT.reset(DP1);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||
assertEquals("project.config1", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
||||
|
||||
|
||||
changeActiveConfiguration(cproject, cfg2);
|
||||
DPT.reset(DP1);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||
assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
||||
|
||||
|
||||
DPT.reset(DP1);
|
||||
changeConfigRelations(cproject, ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT);
|
||||
assertEquals(0, DPT.getProjectsTrace(DP1).size());
|
||||
assertEquals(0, DPT.getCfgsTrace(DP1).size());
|
||||
|
||||
|
||||
changeActiveConfiguration(cproject, cfg1);
|
||||
DPT.reset(DP1);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
|
@ -380,7 +380,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
assertEquals(1, DPT.getCfgsTrace(DP1).size());
|
||||
// should still be config2, as the change in active configuration does not matter
|
||||
assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
|
||||
|
||||
|
||||
changeActiveConfiguration(cproject, cfg2);
|
||||
DPT.reset(DP1);
|
||||
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
|
||||
|
@ -395,7 +395,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testGetProvidedFragments() throws Exception {
|
||||
ICProject cproject= CProjectHelper.createCProject("IndexProviderManagerTest", "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
|
||||
|
@ -502,7 +502,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testProviderUsageFilter() throws Exception {
|
||||
// The provider 'Providers.Counter' is registered 7 times with different usage filters.
|
||||
ICProject cproject= null;
|
||||
|
@ -548,20 +548,20 @@ public class IndexProviderManagerTest extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config) throws CoreException {
|
||||
CDefaultConfigurationData data= new CDefaultConfigurationData(project+"."+config, project+" "+config+" name", null);
|
||||
data.initEmptyData();
|
||||
return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data);
|
||||
return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data);
|
||||
}
|
||||
|
||||
|
||||
private void changeActiveConfiguration(ICProject cproject, ICConfigurationDescription cfg) throws CoreException, InterruptedException {
|
||||
ICProjectDescription pd= core.getProjectDescription(cproject.getProject());
|
||||
pd.setActiveConfiguration(pd.getConfigurationById(cfg.getId()));
|
||||
core.setProjectDescription(cproject.getProject(), pd);
|
||||
waitForIndexer(cproject);
|
||||
}
|
||||
|
||||
|
||||
private void changeConfigRelations(ICProject cproject, int option) throws CoreException, InterruptedException {
|
||||
ICProjectDescription pd= core.getProjectDescription(cproject.getProject());
|
||||
pd.setConfigurationRelations(option);
|
||||
|
@ -586,7 +586,7 @@ class MockStateIndexProvider implements IIndexProvider {
|
|||
class MockStateIndexFragmentProvider extends MockStateIndexProvider implements IIndexFragmentProvider {
|
||||
private boolean invert;
|
||||
final IIndexFragment[] fragments;
|
||||
|
||||
|
||||
public void invert() {
|
||||
invert = !invert;
|
||||
}
|
||||
|
@ -849,12 +849,12 @@ class MockState {
|
|||
class MockPDOM extends EmptyIndexFragment {
|
||||
String id;
|
||||
String version;
|
||||
|
||||
|
||||
MockPDOM(String id, String version) {
|
||||
this.id= id;
|
||||
this.version= version;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProperty(String propertyName) throws CoreException {
|
||||
if(IIndexFragment.PROPERTY_FRAGMENT_ID.equals(propertyName)) {
|
||||
|
@ -868,7 +868,7 @@ class MockPDOM extends EmptyIndexFragment {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[Mock index fragment "+id+"."+System.identityHashCode(this)+"]";
|
||||
|
|
|
@ -7,14 +7,12 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
|
@ -36,6 +34,8 @@ import org.eclipse.cdt.internal.core.pdom.PDOM;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class IndexSearchTest extends IndexTestBase {
|
||||
private static final IndexFilter INDEX_FILTER = IndexFilter.ALL_DECLARED;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
|
||||
private ICProject fProject;
|
||||
private IIndex fIndex;
|
||||
|
||||
|
||||
public IndexSearchTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
|
||||
fIndex.acquireReadLock();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
fIndex.releaseReadLock();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
public void deleteProject() {
|
||||
if (fProject != null) {
|
||||
CProjectHelper.delete(fProject);
|
||||
|
@ -105,9 +105,9 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
Pattern pcl= Pattern.compile(scl);
|
||||
String sns = "ns160913";
|
||||
Pattern pns= Pattern.compile(sns);
|
||||
|
||||
|
||||
IIndexBinding[] bindings;
|
||||
|
||||
|
||||
bindings= fIndex.findBindings(pcl, true, INDEX_FILTER, npm());
|
||||
assertEquals(1, bindings.length);
|
||||
checkIsClass(bindings[0]);
|
||||
|
@ -147,13 +147,13 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
assertEquals(1, bindings.length);
|
||||
checkIsClass(bindings[0]);
|
||||
}
|
||||
|
||||
|
||||
public void testFindNamespaceInNamespace() throws CoreException {
|
||||
Pattern pcl= Pattern.compile("C160913");
|
||||
Pattern pns= Pattern.compile("ns160913");
|
||||
char[] scl= pcl.pattern().toCharArray();
|
||||
char[] sns= pns.pattern().toCharArray();
|
||||
|
||||
|
||||
IIndexBinding[] bindings;
|
||||
|
||||
bindings= fIndex.findBindings(pns, true, INDEX_FILTER, npm());
|
||||
|
@ -184,7 +184,7 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
|
||||
public void testClassInUnnamedNamespace() throws CoreException {
|
||||
Pattern pcl= Pattern.compile("CInUnnamed160913");
|
||||
|
||||
|
||||
IIndexBinding[] bindings;
|
||||
|
||||
// The binding in the unnamed namespace is not visible in global scope.
|
||||
|
@ -204,7 +204,7 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
char[] sEnumerator= pEnumerator.pattern().toCharArray();
|
||||
|
||||
IIndexBinding[] bindings;
|
||||
|
||||
|
||||
// Enumerators are found in global scope.
|
||||
bindings= fIndex.findBindings(pEnumerator, true, INDEX_FILTER, npm());
|
||||
assertEquals(1, bindings.length);
|
||||
|
@ -222,7 +222,7 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
|
||||
bindings= fIndex.findBindings(new Pattern[]{pEnumeration, pEnumerator}, false, INDEX_FILTER, npm());
|
||||
assertEquals(1, bindings.length);
|
||||
|
||||
|
||||
bindings= fIndex.findBindings(pEnumeration, true, INDEX_FILTER, npm());
|
||||
assertEquals(1, bindings.length);
|
||||
checkIsEnumeration(bindings[0]);
|
||||
|
@ -252,7 +252,7 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
assertEquals(2, bindings.length);
|
||||
bindings= fIndex.findBindings(pEnumeration, true, INDEX_FILTER, npm());
|
||||
assertEquals(1, bindings.length);
|
||||
|
||||
|
||||
Pattern macro1= Pattern.compile("Foo", Pattern.CASE_INSENSITIVE);
|
||||
Pattern macro2= Pattern.compile("Foo");
|
||||
bindings= fIndex.findMacroContainers(macro1, INDEX_FILTER, npm());
|
||||
|
@ -268,13 +268,13 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
assertEquals(1, bindings.length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testFindStatic_161216() throws CoreException {
|
||||
Pattern pFunc= Pattern.compile("staticFunc20061017");
|
||||
Pattern pVar= Pattern.compile("staticVar20061017");
|
||||
|
||||
|
||||
IIndexBinding[] bindings;
|
||||
|
||||
|
||||
bindings= fIndex.findBindings(pFunc, false, INDEX_FILTER, npm());
|
||||
assertEquals(2, bindings.length);
|
||||
checkIsFunction(bindings[0]);
|
||||
|
@ -285,7 +285,7 @@ public class IndexSearchTest extends IndexTestBase {
|
|||
checkIsVariable(bindings[0]);
|
||||
checkIsVariable(bindings[1]);
|
||||
}
|
||||
|
||||
|
||||
public void testSanityOfMayHaveChildren() throws CoreException {
|
||||
PDOM pdom= (PDOM) ((CIndex) fIndex).getFragments()[0];
|
||||
pdom.accept(new IPDOMVisitor() {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -42,20 +42,20 @@ public class IndexTestBase extends BaseTestCase {
|
|||
result[0]= CProjectHelper.createCCProject(name, null, IPDOMManager.ID_NO_INDEXER);
|
||||
} else {
|
||||
result[0]= CProjectHelper.createCProject(name, null, IPDOMManager.ID_NO_INDEXER);
|
||||
}
|
||||
}
|
||||
CProjectHelper.importSourcesFromPlugin(result[0], CTestPlugin.getDefault().getBundle(), importSource);
|
||||
}
|
||||
}, null);
|
||||
CCorePlugin.getIndexManager().setIndexerId(result[0], IPDOMManager.ID_FAST_INDEXER);
|
||||
CCorePlugin.getIndexManager().setIndexerId(result[0], IPDOMManager.ID_FAST_INDEXER);
|
||||
// wait until the indexer is done
|
||||
waitForIndexer(result[0]);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
|
||||
protected String readTaggedComment(String tag) throws Exception {
|
||||
return TestSourceReader.readTaggedComment(CTestPlugin.getDefault().getBundle(), "parser", getClass(), tag);
|
||||
}
|
||||
|
||||
|
||||
protected StringBuilder[] getContentsForTest(int blocks) throws IOException {
|
||||
return TestSourceReader.getContentsForTest(
|
||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
@ -20,7 +20,7 @@ import junit.framework.TestSuite;
|
|||
public class IndexTests extends TestSuite {
|
||||
public static Test suite() {
|
||||
TestSuite suite = new IndexTests();
|
||||
|
||||
|
||||
suite.addTest(IndexCompositeTests.suite());
|
||||
suite.addTest(IndexListenerTest.suite());
|
||||
suite.addTest(IndexLocationTest.suite());
|
||||
|
@ -34,7 +34,7 @@ public class IndexTests extends TestSuite {
|
|||
suite.addTest(IndexProviderManagerTest.suite());
|
||||
suite.addTest(IndexMultiVariantHeaderTest.suite());
|
||||
suite.addTest(IndexMultiFileTest.suite());
|
||||
|
||||
|
||||
IndexCPPBindingResolutionBugs.addTests(suite);
|
||||
IndexCPPBindingResolutionTest.addTests(suite);
|
||||
IndexGPPBindingResolutionTest.addTests(suite);
|
||||
|
@ -42,7 +42,7 @@ public class IndexTests extends TestSuite {
|
|||
IndexCBindingResolutionBugs.addTests(suite);
|
||||
IndexCBindingResolutionTest.addTests(suite);
|
||||
IndexCPPVariableTemplateResolutionTest.addTests(suite);
|
||||
|
||||
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,11 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
|
@ -59,6 +57,8 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class IndexUpdateTests extends IndexTestBase {
|
||||
private static final String EXPLICIT = "explicit";
|
||||
private static final String VIRTUAL = "virtual";
|
||||
|
@ -89,7 +89,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
private IFile fFile;
|
||||
private IFile fHeader;
|
||||
private int fContentUsed;
|
||||
|
||||
|
||||
public IndexUpdateTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
@ -121,10 +121,10 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
|
||||
private void updateHeader() throws Exception {
|
||||
// Append variable comment to the end of the file to change its contents.
|
||||
// Indexer would not reindex the file if its contents remain the same.
|
||||
// Indexer would not reindex the file if its contents remain the same.
|
||||
IProject project= fHeader.getProject();
|
||||
fHeader= TestSourceReader.createFile(project, "header.h",
|
||||
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
|
||||
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
|
||||
waitUntilFileIsIndexed(fIndex, fHeader);
|
||||
}
|
||||
|
||||
|
@ -138,12 +138,12 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_TIMEOUT_MILLISEC);
|
||||
waitForIndexer(cproject);
|
||||
}
|
||||
|
||||
|
||||
private void updateFile() throws Exception {
|
||||
// Append variable comment to the end of the file to change its contents.
|
||||
// Indexer would not reindex the file if its contents remain the same.
|
||||
// Indexer would not reindex the file if its contents remain the same.
|
||||
fFile= TestSourceReader.createFile(fFile.getParent(), fFile.getName(),
|
||||
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
|
||||
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
|
||||
waitUntilFileIsIndexed(fIndex, fFile);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
public void deleteProject() {
|
||||
if (fCProject != null) {
|
||||
CProjectHelper.delete(fCProject);
|
||||
|
@ -169,13 +169,13 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fCppProject= null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// int globalVar;
|
||||
|
||||
|
||||
// short globalVar;
|
||||
|
||||
|
||||
// auto int globalVar;
|
||||
|
||||
|
||||
// register int globalVar;
|
||||
public void testGlobalCVariable() throws Exception {
|
||||
setupFile(4, false);
|
||||
|
@ -203,16 +203,16 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
try {
|
||||
IBinding b = findBinding(name);
|
||||
IValue v= null;
|
||||
if (b instanceof IVariable)
|
||||
if (b instanceof IVariable)
|
||||
v= ((IVariable) b).getInitialValue();
|
||||
else if (b instanceof IEnumerator)
|
||||
else if (b instanceof IEnumerator)
|
||||
v= ((IEnumerator) b).getValue();
|
||||
else
|
||||
else
|
||||
fail();
|
||||
|
||||
|
||||
if (value == null)
|
||||
assertNull(v);
|
||||
else
|
||||
else
|
||||
assertEquals(value, v.numericalValue());
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
|
@ -282,7 +282,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
|
||||
// int globalFunction(int a, int b){};
|
||||
|
||||
|
||||
// short globalFunction(int a, int b){};
|
||||
|
||||
// int globalFunction(char a){};
|
||||
|
@ -322,9 +322,9 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
checkModifier(modifiers, STATIC, func.isStatic());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// int globalFunction(int a, int b){};
|
||||
|
||||
|
||||
// short globalFunction(int a, int b){};
|
||||
|
||||
// int globalFunction(char a){};
|
||||
|
@ -340,10 +340,10 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
updateFile();
|
||||
checkFunction("globalFunction", new String[] {INT, CHAR}, new String[]{INLINE});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// struct my_struct {int fField;};
|
||||
|
||||
|
||||
// struct my_struct {short fField;};
|
||||
public void testCField() throws Exception {
|
||||
setupFile(2, false);
|
||||
|
@ -352,11 +352,11 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
checkVariable("my_struct::fField", SHORT, new String[]{});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// class MyClass {int fField;};
|
||||
|
||||
|
||||
// class MyClass {short fField;};
|
||||
|
||||
|
||||
// class MyClass {mutable int fField;};
|
||||
|
||||
// class MyClass {public: int fField;};
|
||||
|
@ -402,11 +402,11 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
|
||||
// class MyClass {int method(int a, int b);};
|
||||
|
||||
|
||||
// class MyClass {short method(int a, int b);};
|
||||
|
||||
|
||||
// class MyClass {int method(char a);};
|
||||
|
||||
|
||||
// class MyClass {inline int method(char a);};
|
||||
|
||||
// class MyClass {virtual int method(char a);};
|
||||
|
@ -418,7 +418,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
// class MyClass {private: int method(char a);};
|
||||
|
||||
// class MyClass {int method(char a){};};
|
||||
|
||||
|
||||
// class MyClass {virtual int method(char a) = 0;};
|
||||
public void testCppMethod() throws Exception {
|
||||
setupFile(10, true);
|
||||
|
@ -444,10 +444,10 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
|
||||
// class MyClass {protected: int method(int a, int b);};
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// int MyClass::method(int a, int b);
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// char MyClass::method(int a, int b);
|
||||
public void testFixedCppMethod() throws Exception {
|
||||
|
@ -477,13 +477,13 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
checkModifier(modifiers, PURE_VIRTUAL, method.isPureVirtual());
|
||||
checkModifier(modifiers, IMPLICIT, method.isImplicit());
|
||||
}
|
||||
|
||||
|
||||
// class MyClass {MyClass(int a, int b);};
|
||||
|
||||
|
||||
// class MyClass {MyClass(char a, int b);};
|
||||
|
||||
|
||||
// class MyClass {explicit MyClass(char a, int b);};
|
||||
|
||||
|
||||
// class MyClass {public: MyClass(char a, int b);};
|
||||
|
||||
// class MyClass {protected: MyClass(char a, int b);};
|
||||
|
@ -521,38 +521,38 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
|
||||
// class MyClass {};
|
||||
|
||||
|
||||
// class MyClass {protected: MyClass(void);};
|
||||
|
||||
|
||||
// class MyClass {explicit MyClass(const MyClass& rhs);};
|
||||
|
||||
|
||||
// class MyClass {public: MyClass& operator=(const MyClass& rhs) {}};
|
||||
|
||||
// class MyClass {};
|
||||
public void testImplicitMethods() throws Exception {
|
||||
setupFile(5, true);
|
||||
checkImplicitMethods("MyClass",
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
checkImplicitMethods("MyClass",
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
new String[] {IMPLICIT, PUBLIC});
|
||||
updateFile();
|
||||
checkImplicitMethods("MyClass",
|
||||
new String[] {PROTECTED},
|
||||
checkImplicitMethods("MyClass",
|
||||
new String[] {PROTECTED},
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
new String[] {IMPLICIT, PUBLIC});
|
||||
updateFile();
|
||||
checkImplicitMethods("MyClass",
|
||||
checkImplicitMethods("MyClass",
|
||||
null, // no default constructor, because we declared the copy constructor.
|
||||
new String[] {EXPLICIT, PRIVATE},
|
||||
new String[] {IMPLICIT, PUBLIC});
|
||||
updateFile();
|
||||
checkImplicitMethods("MyClass",
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
checkImplicitMethods("MyClass",
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
new String[] {INLINE, PUBLIC});
|
||||
updateFile();
|
||||
checkImplicitMethods("MyClass",
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
checkImplicitMethods("MyClass",
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
new String[] {IMPLICIT, PUBLIC},
|
||||
new String[] {IMPLICIT, PUBLIC});
|
||||
}
|
||||
|
@ -597,9 +597,9 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// typedef int myType;
|
||||
|
||||
|
||||
// typedef short myType;
|
||||
public void testCTypedef() throws Exception {
|
||||
setupFile(2, false);
|
||||
|
@ -621,9 +621,9 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
private void checkTypedef(ITypedef var, String type) throws DOMException {
|
||||
assertEquals(msg(), type, ASTTypeUtil.getType(var.getType()));
|
||||
}
|
||||
|
||||
|
||||
// typedef int myType;
|
||||
|
||||
|
||||
// typedef short myType;
|
||||
public void testCppTypedef() throws Exception {
|
||||
setupFile(2, true);
|
||||
|
@ -633,9 +633,9 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
|
||||
// namespace aNs {
|
||||
// }
|
||||
// }
|
||||
// namespace nsAlias= aNs;
|
||||
|
||||
|
||||
// namespace bNs {
|
||||
// }
|
||||
// namespace nsAlias= bNs;
|
||||
|
@ -654,12 +654,12 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// struct myType {
|
||||
// int a;
|
||||
// };
|
||||
|
||||
|
||||
// union myType {
|
||||
// int a;
|
||||
// };
|
||||
|
@ -680,7 +680,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -691,7 +691,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -702,7 +702,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -712,15 +712,15 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// class myType {
|
||||
// int a;
|
||||
// };
|
||||
|
||||
|
||||
// struct myType {
|
||||
// int a;
|
||||
// };
|
||||
|
||||
|
||||
// union myType {
|
||||
// int a;
|
||||
// };
|
||||
|
@ -741,7 +741,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -752,7 +752,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -763,7 +763,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -781,7 +781,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
// template<typename T=char> class CT {};
|
||||
|
||||
// template<int U, typename T> struct CT {};
|
||||
|
||||
|
||||
// template<template<typename T> class V> class CT {};
|
||||
|
||||
// template<template<template<typename I> class T> class V> class CT {};
|
||||
|
@ -853,7 +853,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -909,7 +909,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
|
||||
// int globalVar;
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void test() {
|
||||
// globalVar= 1;
|
||||
|
@ -931,7 +931,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
|
||||
fFile= TestSourceReader.createFile(fFile.getParent(), fFile.getName(), fContents[1].toString().replaceAll("globalVar", "newVar"));
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_TIMEOUT_MILLISEC);
|
||||
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
binding = findBinding("globalVar");
|
||||
|
@ -953,19 +953,19 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// int globalVar;
|
||||
// void func();
|
||||
|
||||
|
||||
// extern "C" {
|
||||
// int globalVar;
|
||||
// void func();
|
||||
// }
|
||||
|
||||
|
||||
// int globalVar;
|
||||
// void func();
|
||||
|
||||
|
||||
// extern "C" int globalVar;
|
||||
// extern "C" void func();
|
||||
|
||||
|
@ -995,15 +995,15 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// int global;
|
||||
// struct C {int mem;};
|
||||
// enum E {e0};
|
||||
|
||||
|
||||
// int global=1;
|
||||
// struct C {int mem=1;};
|
||||
// enum E {e0=1};
|
||||
|
||||
|
||||
// int global;
|
||||
// struct C {int mem;};
|
||||
// enum E {e0};
|
||||
|
@ -1021,7 +1021,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
checkValue("C::mem", null);
|
||||
checkValue("e0", 0L);
|
||||
}
|
||||
|
||||
|
||||
// class A {
|
||||
// public: void foo();
|
||||
// };
|
||||
|
@ -1053,7 +1053,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -1101,11 +1101,11 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
// int global;
|
||||
// struct C {int mem;};
|
||||
// enum E {e0};
|
||||
|
||||
|
||||
// int global=1;
|
||||
// struct C {int mem=1;};
|
||||
// enum E {e0=1};
|
||||
|
||||
|
||||
// int global;
|
||||
// struct C {int mem;};
|
||||
// enum E {e0};
|
||||
|
@ -1123,7 +1123,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
checkValue("C::mem", null);
|
||||
checkValue("e0", 0L);
|
||||
}
|
||||
|
||||
|
||||
//class A {};
|
||||
//class B {friend class A;};
|
||||
|
||||
|
@ -1132,7 +1132,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
setupFile(2, true);
|
||||
assertFriendRemoval("B", "A");
|
||||
}
|
||||
|
||||
|
||||
// class X {public: char* foo(int);};
|
||||
// class Y {friend char* X::foo(int);};
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
setupFile(2, true);
|
||||
assertFriendRemoval("Y", "X::foo");
|
||||
}
|
||||
|
||||
|
||||
// class X {friend void friend_set(X*, int);};
|
||||
// void friend_set(X* p, int i) {}
|
||||
|
||||
|
@ -1150,7 +1150,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
setupFile(2, true);
|
||||
assertFriendRemoval("X", "friend_set");
|
||||
}
|
||||
|
||||
|
||||
private void assertFriendRemoval(String clientClassBinding, String supplierBinding) throws Exception {
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -1164,7 +1164,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
|
@ -1177,7 +1177,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// void funcTypeDeletion(int);
|
||||
|
||||
// #include "header.h"
|
||||
|
@ -1200,7 +1200,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
// void ref() {
|
||||
// f(1);
|
||||
// }
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void f(int a, int b) {}
|
||||
// void ref() {
|
||||
|
@ -1216,24 +1216,24 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
|
||||
private void checkReferenceCount(String name, int count) throws InterruptedException, CoreException {
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
IBinding func = findBinding(name);
|
||||
assertEquals(count, fIndex.findReferences(func).length);
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// enum E {e0};
|
||||
|
||||
|
||||
// enum class E;
|
||||
|
||||
// enum E : short {e1};
|
||||
|
||||
|
||||
// enum class E {e2};
|
||||
|
||||
|
||||
// enum class E : short {e1};
|
||||
|
||||
|
||||
// enum E : int;
|
||||
public void testEnumCPP() throws Exception {
|
||||
setupFile(6, true);
|
||||
|
@ -1252,7 +1252,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
|
||||
private void checkEnum(boolean scoped, String fixedType, String enumItem) throws Exception {
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
ICPPEnumeration enumType = (ICPPEnumeration) findBinding("E");
|
||||
assertEquals(scoped, enumType.isScoped());
|
||||
if (fixedType == null) {
|
||||
|
@ -1271,7 +1271,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// class X {};
|
||||
|
||||
// class X {};
|
||||
|
@ -1285,7 +1285,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
|
@ -1296,7 +1296,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
assertEquals(id1, id2);
|
||||
}
|
||||
|
||||
|
||||
// namespace ns {
|
||||
// namespace m {}
|
||||
// }
|
||||
|
@ -1311,7 +1311,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
public void testInlineNamespaces_305980() throws Exception {
|
||||
setupFile(3, true);
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final ICPPNamespace ns = (ICPPNamespace) findBinding("ns");
|
||||
assertFalse(ns.isInline());
|
||||
final ICPPNamespace m = (ICPPNamespace) findBinding("ns::m");
|
||||
|
@ -1319,10 +1319,10 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final ICPPNamespace ns = (ICPPNamespace) findBinding("ns");
|
||||
assertTrue(ns.isInline());
|
||||
final ICPPNamespace m = (ICPPNamespace) findBinding("ns::m");
|
||||
|
@ -1333,7 +1333,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
|
||||
updateFile();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final ICPPNamespace ns = (ICPPNamespace) findBinding("ns");
|
||||
assertFalse(ns.isInline());
|
||||
final ICPPNamespace m = (ICPPNamespace) findBinding("ns::m");
|
||||
|
@ -1342,14 +1342,14 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// typedef enum {
|
||||
// AE_ON = 0
|
||||
// } Adaptiv_T;
|
||||
// struct mystruct {
|
||||
// Adaptiv_T eAdapt;
|
||||
// };
|
||||
|
||||
|
||||
// int main() {
|
||||
// mystruct ms;
|
||||
// ms.eAdapt = AE_ON;
|
||||
|
@ -1367,7 +1367,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
setupFile(3, true);
|
||||
String name1;
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
|
||||
assertNotNull(e);
|
||||
name1= e.getOwner().getName();
|
||||
|
@ -1376,7 +1376,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
updateHeader();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
|
||||
assertNotNull(e);
|
||||
assertFalse(name1.equals(e.getOwner().getName()));
|
||||
|
@ -1391,7 +1391,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
// struct mystruct {
|
||||
// Adaptiv_T eAdapt;
|
||||
// };
|
||||
|
||||
|
||||
// int main() {
|
||||
// mystruct ms;
|
||||
// ms.eAdapt = AE_ON;
|
||||
|
@ -1409,7 +1409,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
setupFile(3, false);
|
||||
String name1;
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
|
||||
assertNotNull(e);
|
||||
name1= e.getOwner().getName();
|
||||
|
@ -1418,7 +1418,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
}
|
||||
updateHeader();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final IEnumerator e = (IEnumerator) findBinding("AE_ON");
|
||||
assertNotNull(e);
|
||||
assertFalse(name1.equals(e.getOwner().getName()));
|
||||
|
@ -1426,14 +1426,14 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// struct S {};
|
||||
|
||||
|
||||
// struct S {S(int){}};
|
||||
public void testImplicitDefaultCtor_Bug359376() throws Exception {
|
||||
setupFile(2, true);
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final ICPPClassType s = (ICPPClassType) findBinding("S");
|
||||
assertNotNull(s);
|
||||
final ICPPConstructor[] ctors = s.getConstructors();
|
||||
|
@ -1444,9 +1444,9 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
updateFile();
|
||||
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final ICPPClassType s = (ICPPClassType) findBinding("S");
|
||||
assertNotNull(s);
|
||||
final ICPPConstructor[] ctors = s.getConstructors();
|
||||
|
@ -1456,7 +1456,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// struct Base {
|
||||
// void foo() {}
|
||||
// };
|
||||
|
@ -1473,23 +1473,23 @@ public class IndexUpdateTests extends IndexTestBase {
|
|||
public void testBaseClass_Bug391284() throws Exception {
|
||||
setupFile(2, true);
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final ICPPClassType s = (ICPPClassType) findBinding("Derived");
|
||||
assertNotNull(s);
|
||||
final ICPPBase[] bases = s.getBases();
|
||||
assertEquals(1, bases.length);
|
||||
assertEquals(1, bases.length);
|
||||
assertEquals("Base", bases[0].getBaseClass().getName());
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
updateFile();
|
||||
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
try {
|
||||
final ICPPClassType s = (ICPPClassType) findBinding("Derived");
|
||||
assertNotNull(s);
|
||||
final ICPPBase[] bases = s.getBases();
|
||||
assertEquals(1, bases.length);
|
||||
assertEquals(1, bases.length);
|
||||
assertEquals("Base", bases[0].getBaseClass().getName());
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -17,8 +16,6 @@ import java.util.Collection;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -42,6 +39,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class TeamSharedIndexTest extends IndexTestBase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
|
@ -60,7 +59,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
super.setUp();
|
||||
fProjects.clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
for (Iterator iterator = fProjects.iterator(); iterator.hasNext();) {
|
||||
|
@ -69,14 +68,14 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
private void registerProject(ICProject prj) {
|
||||
fProjects.add(prj);
|
||||
}
|
||||
private void unregisterProject(ICProject prj) {
|
||||
fProjects.remove(prj);
|
||||
}
|
||||
|
||||
|
||||
private ICProject createProject(String name) throws CoreException, InterruptedException {
|
||||
ModelJoiner mj= new ModelJoiner();
|
||||
try {
|
||||
|
@ -94,7 +93,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
mj.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICProject recreateProject(final String prjName) throws Exception {
|
||||
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
ModelJoiner pj= new ModelJoiner();
|
||||
|
@ -134,7 +133,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testDefaultExport() throws Exception {
|
||||
String prjName= "__testDefaultExport__";
|
||||
|
@ -146,20 +145,20 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
|
||||
// export the project.
|
||||
fPDOMManager.export(prj, loc, 0, npm());
|
||||
|
||||
|
||||
// set indexer to the fake one.
|
||||
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
|
||||
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
|
||||
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
|
||||
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
waitForIndexer(prj);
|
||||
checkVariable(prj, "a", 0);
|
||||
checkVariable(prj, "b", 0);
|
||||
checkVariable(prj, "c", 0);
|
||||
|
||||
|
||||
// delete project
|
||||
deleteAndWait(prj);
|
||||
unregisterProject(prj);
|
||||
|
||||
|
||||
// import project
|
||||
prj = recreateProject(prjName);
|
||||
assertEquals(FakeIndexer.ID, fPDOMManager.getIndexerId(prj));
|
||||
|
@ -169,7 +168,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
checkVariable(prj, "b", 1);
|
||||
checkVariable(prj, "c", 1);
|
||||
}
|
||||
|
||||
|
||||
public void testExportWithFileChange() throws Exception {
|
||||
String prjName= "__testExportWithChange__";
|
||||
ICProject prj= createProject(prjName);
|
||||
|
@ -177,18 +176,18 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
checkVariable(prj, "a", 1);
|
||||
checkVariable(prj, "b", 1);
|
||||
checkVariable(prj, "c", 1);
|
||||
|
||||
|
||||
// export the project.
|
||||
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
|
||||
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
fPDOMManager.export(prj, loc, 0, npm());
|
||||
waitForIndexer(prj);
|
||||
|
||||
|
||||
// change file
|
||||
changeFile(prj);
|
||||
deleteAndWait(prj);
|
||||
unregisterProject(prj);
|
||||
|
||||
|
||||
// import project
|
||||
prj = recreateProject(prjName);
|
||||
registerProject(prj);
|
||||
|
@ -207,7 +206,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
location.setLastModified(lm+1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void deleteAndWait(ICProject prj) throws CoreException {
|
||||
ModelJoiner dj= new ModelJoiner();
|
||||
try {
|
||||
|
@ -225,24 +224,24 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
checkVariable(prj, "a", 1);
|
||||
checkVariable(prj, "b", 1);
|
||||
checkVariable(prj, "c", 1);
|
||||
|
||||
|
||||
// export the project.
|
||||
fPDOMManager.export(prj, loc, 0, npm());
|
||||
waitForIndexer(prj);
|
||||
|
||||
|
||||
// set indexer to the fake one.
|
||||
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
|
||||
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
|
||||
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
|
||||
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
waitForIndexer(prj);
|
||||
checkVariable(prj, "a", 0);
|
||||
checkVariable(prj, "b", 0);
|
||||
checkVariable(prj, "c", 0);
|
||||
|
||||
|
||||
changeFile(prj);
|
||||
deleteAndWait(prj);
|
||||
unregisterProject(prj);
|
||||
|
||||
|
||||
// import project
|
||||
prj = recreateProject(prjName);
|
||||
registerProject(prj);
|
||||
|
@ -259,18 +258,18 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
checkVariable(prj, "a", 1);
|
||||
checkVariable(prj, "b", 1);
|
||||
checkVariable(prj, "c", 1);
|
||||
|
||||
|
||||
// export the project.
|
||||
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
|
||||
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
fPDOMManager.export(prj, loc, 0, npm());
|
||||
waitForIndexer(prj);
|
||||
|
||||
|
||||
// add file
|
||||
TestSourceReader.createFile(prj.getProject(), "d.cpp", "int d;");
|
||||
deleteAndWait(prj);
|
||||
unregisterProject(prj);
|
||||
|
||||
|
||||
// import project
|
||||
prj = recreateProject(prjName);
|
||||
registerProject(prj);
|
||||
|
@ -287,13 +286,13 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
checkVariable(prj, "a", 1);
|
||||
checkVariable(prj, "b", 1);
|
||||
checkVariable(prj, "c", 1);
|
||||
|
||||
|
||||
// export the project.
|
||||
fPDOMManager.export(prj, loc, 0, npm());
|
||||
waitForIndexer(prj);
|
||||
|
||||
|
||||
// set indexer to the fake one.
|
||||
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
|
||||
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
|
||||
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
|
||||
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
waitForIndexer(prj);
|
||||
|
@ -305,7 +304,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
TestSourceReader.createFile(prj.getProject(), "d.cpp", "int d;");
|
||||
deleteAndWait(prj);
|
||||
unregisterProject(prj);
|
||||
|
||||
|
||||
// import project
|
||||
prj = recreateProject(prjName);
|
||||
registerProject(prj);
|
||||
|
@ -322,18 +321,18 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
checkVariable(prj, "a", 1);
|
||||
checkVariable(prj, "b", 1);
|
||||
checkVariable(prj, "c", 1);
|
||||
|
||||
|
||||
// export the project.
|
||||
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
|
||||
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
fPDOMManager.export(prj, loc, 0, npm());
|
||||
waitForIndexer(prj);
|
||||
|
||||
|
||||
// delete file
|
||||
prj.getProject().getFile("a.cpp").delete(true, npm());
|
||||
deleteAndWait(prj);
|
||||
unregisterProject(prj);
|
||||
|
||||
|
||||
// import project
|
||||
prj = recreateProject(prjName);
|
||||
registerProject(prj);
|
||||
|
@ -349,13 +348,13 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
checkVariable(prj, "a", 1);
|
||||
checkVariable(prj, "b", 1);
|
||||
checkVariable(prj, "c", 1);
|
||||
|
||||
|
||||
// export the project.
|
||||
fPDOMManager.export(prj, loc, 0, npm());
|
||||
waitForIndexer(prj);
|
||||
|
||||
|
||||
// set indexer to the fake one.
|
||||
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
|
||||
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
|
||||
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
|
||||
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
waitForIndexer(prj);
|
||||
|
@ -367,7 +366,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
|
|||
prj.getProject().getFile("a.cpp").delete(true, npm());
|
||||
deleteAndWait(prj);
|
||||
unregisterProject(prj);
|
||||
|
||||
|
||||
// import project
|
||||
prj = recreateProject(prjName);
|
||||
registerProject(prj);
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.osgi.framework.Bundle;
|
|||
|
||||
/**
|
||||
* aftodo - it would be nice to have this as a real performance test
|
||||
*
|
||||
*
|
||||
* n.b. this is intentionally not added to any test suite at the moment
|
||||
*/
|
||||
public class TrilogyPerformanceTest extends IndexTestBase {
|
||||
|
@ -56,7 +56,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
|||
|
||||
// you must have the Windows SDK installed and the INETSDK env var setup
|
||||
public void testIndexTrilogyPerformanceTimes() throws CoreException, InterruptedException {
|
||||
if(Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
if(Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
waitForIndexer(cproject);
|
||||
TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"};
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
|
||||
|
|
Loading…
Add table
Reference in a new issue