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