mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Cosmetics.
This commit is contained in:
parent
64c383952a
commit
beeef2d87c
1 changed files with 144 additions and 152 deletions
|
@ -9,7 +9,7 @@
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* 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;
|
||||||
|
@ -116,28 +116,28 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
protected class BindingAssertionHelper {
|
protected class BindingAssertionHelper {
|
||||||
protected IASTTranslationUnit tu;
|
protected IASTTranslationUnit tu;
|
||||||
protected String contents;
|
protected String contents;
|
||||||
|
|
||||||
public BindingAssertionHelper(IFile file, String contents, IIndex index) throws CModelException, CoreException {
|
public BindingAssertionHelper(IFile file, String contents, IIndex index) throws CModelException, CoreException {
|
||||||
this.contents= contents;
|
this.contents= contents;
|
||||||
this.tu= TestSourceReader.createIndexBasedAST(index, fCProject, file);
|
this.tu= TestSourceReader.createIndexBasedAST(index, fCProject, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTTranslationUnit getTranslationUnit() {
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding assertProblem(String section, int len) {
|
public IBinding assertProblem(String section, int len) {
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
||||||
binding instanceof IProblemBinding);
|
binding instanceof IProblemBinding);
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem= (IProblemBinding) binding;
|
IProblemBinding problem= (IProblemBinding) binding;
|
||||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")");
|
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")");
|
||||||
}
|
}
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
fail("Null binding resolved for name: " + section.substring(0, len));
|
fail("Null binding resolved for name: " + section.substring(0, len));
|
||||||
|
@ -146,7 +146,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertNoName(String section, int len) {
|
public void assertNoName(String section, int len) {
|
||||||
IASTName name= findName(section,len,false);
|
IASTName name= findName(section, len, false);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
String selection = section.substring(0, len);
|
String selection = section.substring(0, len);
|
||||||
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
|
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
|
||||||
|
@ -158,15 +158,15 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
* it resolves to the given type of binding.
|
* it resolves to the given type of binding.
|
||||||
*/
|
*/
|
||||||
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
|
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
|
||||||
IASTName name = findName(section,len,true);
|
IASTName name = findName(section, len, true);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("did not find \""+selection+"\"", name);
|
assertNotNull("did not find \""+selection+"\"", name);
|
||||||
|
|
||||||
assertInstance(name, IASTImplicitName.class);
|
assertInstance(name, IASTImplicitName.class);
|
||||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||||
assertNotNull(implicits);
|
assertNotNull(implicits);
|
||||||
|
|
||||||
if (implicits.length > 1) {
|
if (implicits.length > 1) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (IASTImplicitName n : implicits) {
|
for (IASTImplicitName n : implicits) {
|
||||||
|
@ -177,27 +177,27 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
assertTrue(found);
|
assertTrue(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(selection, name.getRawSignature());
|
assertEquals(selection, name.getRawSignature());
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull(binding);
|
assertNotNull(binding);
|
||||||
assertInstance(binding, bindingClass);
|
assertInstance(binding, bindingClass);
|
||||||
return (IASTImplicitName) name;
|
return (IASTImplicitName) name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertNoImplicitName(String section, int len) {
|
public void assertNoImplicitName(String section, int len) {
|
||||||
IASTName name = findName(section,len,true);
|
IASTName name = findName(section, len, true);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNull("found name \""+selection+"\"", name);
|
assertNull("found name \""+selection+"\"", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
||||||
IASTName name = findName(section,len,true);
|
IASTName name = findName(section, len, true);
|
||||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||||
return implicits;
|
return implicits;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTName findName(String section, int len, boolean implicit) {
|
private IASTName findName(String section, int len, boolean implicit) {
|
||||||
final int offset = contents.indexOf(section);
|
final int offset = contents.indexOf(section);
|
||||||
assertTrue(offset >= 0);
|
assertTrue(offset >= 0);
|
||||||
|
@ -222,7 +222,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
return "Unknown problem ID";
|
return "Unknown problem ID";
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||||
|
@ -233,16 +233,16 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
return type.cast(binding);
|
return type.cast(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBinding binding(String section, int len) {
|
private IBinding binding(String section, int len) {
|
||||||
IASTName name = findName(section, len,false);
|
IASTName name = findName(section, len, false);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("Did not find \"" + selection + "\"", name);
|
assertNotNull("Did not find \"" + selection + "\"", name);
|
||||||
assertEquals(selection, name.getRawSignature());
|
assertEquals(selection, name.getRawSignature());
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||||
|
|
||||||
return name.resolveBinding();
|
return name.resolveBinding();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if (fCProject != null) {
|
if (fCProject != null) {
|
||||||
|
@ -269,11 +269,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IProject getProject() {
|
protected IProject getProject() {
|
||||||
return fCProject.getProject();
|
return fCProject.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getContentsForTest(int blocks) throws IOException {
|
protected String[] getContentsForTest(int blocks) throws IOException {
|
||||||
CharSequence[] help= TestSourceReader.getContentsForTest(
|
CharSequence[] help= TestSourceReader.getContentsForTest(
|
||||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
||||||
|
@ -284,7 +284,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
||||||
return TestSourceReader.createFile(container, new Path(fileName), contents);
|
return TestSourceReader.createFile(container, new Path(fileName), contents);
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ public class IndexBugsTests 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;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
IASTName name= ast.getNodeSelector(null).findName(source.indexOf(section), len);
|
IASTName name= ast.getNodeSelector(null).findName(source.indexOf(section), len);
|
||||||
assertNotNull("Name not found for \"" + section + "\"", name);
|
assertNotNull("Name not found for \"" + section + "\"", name);
|
||||||
assertEquals(section.substring(0, len), name.getRawSignature());
|
assertEquals(section.substring(0, len), name.getRawSignature());
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull("No binding for " + section.substring(0, len), binding);
|
assertNotNull("No binding for " + section.substring(0, len), binding);
|
||||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||||
|
@ -357,7 +357,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// public:
|
// public:
|
||||||
// void one() {}
|
// void one() {}
|
||||||
// void two() {}
|
// void two() {}
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// class A {
|
// class A {
|
||||||
// public:
|
// public:
|
||||||
|
@ -369,29 +369,29 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// Because of fix for http://bugs.eclipse.org/193779 this test case passes.
|
// Because of fix for http://bugs.eclipse.org/193779 this test case passes.
|
||||||
// However http://bugs.eclipse.org/154563 remains to be fixed.
|
// However http://bugs.eclipse.org/154563 remains to be fixed.
|
||||||
String[] content= getContentsForTest(2);
|
String[] content= getContentsForTest(2);
|
||||||
|
|
||||||
IFile file= createFile(getProject(), "header.h", content[0]);
|
IFile file= createFile(getProject(), "header.h", content[0]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
assertTrue(bs[0] instanceof ICPPClassType);
|
assertTrue(bs[0] instanceof ICPPClassType);
|
||||||
assertEquals(2, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
assertEquals(2, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file= createFile(getProject(), "header.h", content[1]);
|
file= createFile(getProject(), "header.h", content[1]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
IBinding[] bs= index.findBindings("A".toCharArray(), IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
assertTrue(bs[0] instanceof ICPPClassType);
|
assertTrue(bs[0] instanceof ICPPClassType);
|
||||||
assertEquals(3, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
assertEquals(3, ((ICPPClassType)bs[0]).getDeclaredMethods().length);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -419,9 +419,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
IIndexBinding[] bindings= fIndex.findBindings(getPattern("arrayDataSize"), true, IndexFilter.ALL, npm());
|
IIndexBinding[] bindings= fIndex.findBindings(getPattern("arrayDataSize"), true, IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
||||||
IIndexBinding binding= bindings[0];
|
IIndexBinding binding= bindings[0];
|
||||||
|
|
||||||
// check if we have the definition
|
// check if we have the definition
|
||||||
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
|
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DEFINITIONS);
|
||||||
assertEquals(1, decls.length);
|
assertEquals(1, decls.length);
|
||||||
|
@ -504,7 +504,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// namespace ns162011 {
|
// namespace ns162011 {
|
||||||
// class Class162011 {
|
// class Class162011 {
|
||||||
// friend void function162011(Class162011);
|
// friend void function162011(Class162011);
|
||||||
// };
|
// };
|
||||||
// void function162011(Class162011 x){};
|
// void function162011(Class162011 x){};
|
||||||
// }
|
// }
|
||||||
|
@ -517,7 +517,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
int indexOfDef = content.indexOf(funcName, indexOfDecl+1);
|
int indexOfDef = content.indexOf(funcName, indexOfDecl+1);
|
||||||
IFile file= createFile(getProject(), fileName, content);
|
IFile file= createFile(getProject(), fileName, content);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
// make sure the ast is correct
|
// make sure the ast is correct
|
||||||
ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path(fileName));
|
ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path(fileName));
|
||||||
IASTTranslationUnit ast= tu.getAST();
|
IASTTranslationUnit ast= tu.getAST();
|
||||||
|
@ -535,9 +535,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
IIndexBinding[] bindings= fIndex.findBindings(getPattern("ns162011::function162011"), true, IndexFilter.ALL, npm());
|
IIndexBinding[] bindings= fIndex.findBindings(getPattern("ns162011::function162011"), true, IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
||||||
IIndexBinding binding= bindings[0];
|
IIndexBinding binding= bindings[0];
|
||||||
|
|
||||||
// check if we have the declaration
|
// check if we have the declaration
|
||||||
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DECLARATIONS);
|
IIndexName[] decls= fIndex.findNames(binding, IIndex.FIND_DECLARATIONS);
|
||||||
assertEquals(1, decls.length);
|
assertEquals(1, decls.length);
|
||||||
|
@ -630,11 +630,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // header.h
|
// // header.h
|
||||||
// class E {};
|
// class E {};
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// E var;
|
// E var;
|
||||||
|
|
||||||
// // header.h
|
// // header.h
|
||||||
// enum E {A,B,C};
|
// enum E {A,B,C};
|
||||||
public void test171834() throws Exception {
|
public void test171834() throws Exception {
|
||||||
CModelListener.sSuppressUpdateOfLastRecentlyUsed= false;
|
CModelListener.sSuppressUpdateOfLastRecentlyUsed= false;
|
||||||
|
@ -659,7 +659,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream in = new ByteArrayInputStream(testData[2].getBytes());
|
InputStream in = new ByteArrayInputStream(testData[2].getBytes());
|
||||||
header.setContents(in, IResource.FORCE, null);
|
header.setContents(in, IResource.FORCE, null);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(index, header, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(index, header, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.C_LINKAGE_ID), npm());
|
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.C_LINKAGE_ID), npm());
|
||||||
assertEquals(2, bindings.length);
|
assertEquals(2, bindings.length);
|
||||||
|
|
||||||
IBinding struct, typedef;
|
IBinding struct, typedef;
|
||||||
if (bindings[0] instanceof ICompositeType) {
|
if (bindings[0] instanceof ICompositeType) {
|
||||||
struct= bindings[0];
|
struct= bindings[0];
|
||||||
|
@ -701,7 +701,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
struct= bindings[1];
|
struct= bindings[1];
|
||||||
typedef= bindings[0];
|
typedef= bindings[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(struct instanceof ICompositeType);
|
assertTrue(struct instanceof ICompositeType);
|
||||||
assertTrue(typedef instanceof ITypedef);
|
assertTrue(typedef instanceof ITypedef);
|
||||||
assertTrue(((ITypedef) typedef).getType() instanceof ICompositeType);
|
assertTrue(((ITypedef) typedef).getType() instanceof ICompositeType);
|
||||||
|
@ -725,7 +725,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
IBinding[] bindings= fIndex.findBindings("S20070201".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||||
assertEquals(2, bindings.length);
|
assertEquals(2, bindings.length);
|
||||||
|
|
||||||
IBinding struct, typedef;
|
IBinding struct, typedef;
|
||||||
if (bindings[0] instanceof ICPPClassType) {
|
if (bindings[0] instanceof ICPPClassType) {
|
||||||
struct= bindings[0];
|
struct= bindings[0];
|
||||||
|
@ -734,7 +734,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
struct= bindings[1];
|
struct= bindings[1];
|
||||||
typedef= bindings[0];
|
typedef= bindings[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(struct instanceof ICPPClassType);
|
assertTrue(struct instanceof ICPPClassType);
|
||||||
assertTrue(((ICPPClassType)struct).getKey()==ICompositeType.k_struct);
|
assertTrue(((ICPPClassType)struct).getKey()==ICompositeType.k_struct);
|
||||||
assertTrue(typedef instanceof ITypedef);
|
assertTrue(typedef instanceof ITypedef);
|
||||||
|
@ -768,7 +768,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
long timestamp= file.getLocalTimeStamp();
|
long timestamp= file.getLocalTimeStamp();
|
||||||
content= "int UPDATED20070213;\n" + content.replaceFirst("int", "float");
|
content= "int UPDATED20070213;\n" + content.replaceFirst("int", "float");
|
||||||
file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
||||||
|
@ -779,7 +779,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// double check if file was indexed
|
// double check if file was indexed
|
||||||
IBinding[] bindings= fIndex.findBindings("UPDATED20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
IBinding[] bindings= fIndex.findBindings("UPDATED20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
||||||
bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), npm());
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertTrue(bindings[0] instanceof ITypedef);
|
assertTrue(bindings[0] instanceof ITypedef);
|
||||||
|
@ -797,36 +797,36 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// class A {};
|
// class A {};
|
||||||
// class B {};
|
// class B {};
|
||||||
// A var;
|
// A var;
|
||||||
|
|
||||||
// class A {};
|
// class A {};
|
||||||
// class B {};
|
// class B {};
|
||||||
// B var;
|
// B var;
|
||||||
public void test173997_2() throws Exception {
|
public void test173997_2() throws Exception {
|
||||||
String[] content= getContentsForTest(2);
|
String[] content= getContentsForTest(2);
|
||||||
|
|
||||||
IFile file= createFile(getProject(), "header.h", content[0]);
|
IFile file= createFile(getProject(), "header.h", content[0]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
assertTrue(bs[0] instanceof ICPPVariable);
|
assertTrue(bs[0] instanceof ICPPVariable);
|
||||||
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
||||||
assertEquals("A", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
assertEquals("A", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file= createFile(getProject(), "header.h", content[1]);
|
file= createFile(getProject(), "header.h", content[1]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, npm());
|
||||||
assertEquals(1, bs.length);
|
assertEquals(1, bs.length);
|
||||||
assertTrue(bs[0] instanceof ICPPVariable);
|
assertTrue(bs[0] instanceof ICPPVariable);
|
||||||
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
|
||||||
assertEquals("B", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
assertEquals("B", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
|
||||||
|
@ -838,7 +838,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// // header.h
|
// // header.h
|
||||||
// template <class T1> class Test {};
|
// template <class T1> class Test {};
|
||||||
// template <class T2> void f() {}
|
// template <class T2> void f() {}
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// struct A {};
|
// struct A {};
|
||||||
// Test<A> a;
|
// Test<A> a;
|
||||||
|
@ -956,7 +956,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
/* Check that when a project is deleted, its index contents do not
|
/* Check that when a project is deleted, its index contents do not
|
||||||
* appear in the initial index of a newly created project of the same name */
|
* appear in the initial index of a newly created project of the same name */
|
||||||
|
|
||||||
String pname = "deleteTest"+System.currentTimeMillis();
|
String pname = "deleteTest"+System.currentTimeMillis();
|
||||||
ICProject cproject = CProjectHelper.createCCProject(pname, "bin", IPDOMManager.ID_FAST_INDEXER);
|
ICProject cproject = CProjectHelper.createCCProject(pname, "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
|
@ -994,8 +994,8 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
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);
|
index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1031,23 +1031,23 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
return !(binding instanceof IFunction);
|
return !(binding instanceof IFunction);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IBinding[] bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, true, NON_FUNCTIONS, null);
|
IBinding[] bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, true, NON_FUNCTIONS, null);
|
||||||
assertEquals(3,bindings.length);
|
assertEquals(3, bindings.length);
|
||||||
|
|
||||||
bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, false, NON_FUNCTIONS, null);
|
bindings= fIndex.findBindingsForPrefix(new char[] {'a'}, false, NON_FUNCTIONS, null);
|
||||||
assertEquals(6,bindings.length);
|
assertEquals(6, bindings.length);
|
||||||
|
|
||||||
bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, true, NON_FUNCTIONS, null);
|
bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, true, NON_FUNCTIONS, null);
|
||||||
assertEquals(1,bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
||||||
bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, false, NON_FUNCTIONS, null);
|
bindings= fIndex.findBindingsForPrefix(new char[] {'a','A'}, false, NON_FUNCTIONS, null);
|
||||||
assertEquals(2, bindings.length);
|
assertEquals(2, bindings.length);
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class a { class b { class c { void f(); }; }; };
|
// class a { class b { class c { void f(); }; }; };
|
||||||
public void testFilterFindBindingsFQCharArray() throws Exception {
|
public void testFilterFindBindingsFQCharArray() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
@ -1064,27 +1064,27 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
return !(binding instanceof ICPPClassType);
|
return !(binding instanceof ICPPClassType);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IBinding[] bindings= fIndex.findBindings(new char[][]{{'a'},{'b'},{'c'},{'f'}}, NON_CLASS, npm());
|
IBinding[] bindings= fIndex.findBindings(new char[][]{{'a'},{'b'},{'c'},{'f'}}, NON_CLASS, npm());
|
||||||
assertEquals(1,bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef struct {
|
// typedef struct {
|
||||||
// float fNumber;
|
// float fNumber;
|
||||||
// int iIdx;
|
// int iIdx;
|
||||||
// } StructA_T;
|
// } StructA_T;
|
||||||
|
|
||||||
// #include "../__bugsTest__/common.h"
|
// #include "../__bugsTest__/common.h"
|
||||||
// StructA_T gvar1;
|
// StructA_T gvar1;
|
||||||
|
|
||||||
// #include "../__bugsTest__/common.h"
|
// #include "../__bugsTest__/common.h"
|
||||||
// StructA_T gvar2;
|
// StructA_T gvar2;
|
||||||
public void testFileInMultipleFragments_bug192352() throws Exception {
|
public void testFileInMultipleFragments_bug192352() throws Exception {
|
||||||
String[] contents= getContentsForTest(3);
|
String[] contents= getContentsForTest(3);
|
||||||
|
|
||||||
ICProject p2 = CProjectHelper.createCCProject("__bugsTest_2_", "bin", IPDOMManager.ID_FAST_INDEXER);
|
ICProject p2 = CProjectHelper.createCCProject("__bugsTest_2_", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
try {
|
try {
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
|
||||||
|
@ -1109,22 +1109,22 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
CProjectHelper.delete(p2);
|
CProjectHelper.delete(p2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifndef _h1
|
// #ifndef _h1
|
||||||
// #define _h1
|
// #define _h1
|
||||||
// #define M v
|
// #define M v
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef _h1
|
// #ifndef _h1
|
||||||
// #include "header1.h"
|
// #include "header1.h"
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #include "header1.h"
|
// #include "header1.h"
|
||||||
// #include "header2.h"
|
// #include "header2.h"
|
||||||
|
|
||||||
// #include "header2.h"
|
// #include "header2.h"
|
||||||
// int M;
|
// int M;
|
||||||
|
|
||||||
// #include "header2.h"
|
// #include "header2.h"
|
||||||
// #ifndef _h1
|
// #ifndef _h1
|
||||||
// #include "header1.h"
|
// #include "header1.h"
|
||||||
|
@ -1140,7 +1140,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
IFile f4= TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3]);
|
IFile f4= TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3]);
|
||||||
IFile f5= TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4]);
|
IFile f5= TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
IIndex index= indexManager.getIndex(fCProject);
|
IIndex index= indexManager.getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1151,7 +1151,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
IIndexName[] names = index.findNames(binding, IIndex.FIND_ALL_OCCURRENCES);
|
IIndexName[] names = index.findNames(binding, IIndex.FIND_ALL_OCCURRENCES);
|
||||||
assertEquals(1, names.length);
|
assertEquals(1, names.length);
|
||||||
assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath());
|
assertEquals(f4.getFullPath().toString(), names[0].getFile().getLocation().getFullPath());
|
||||||
|
|
||||||
IIndexFile idxFile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f5));
|
IIndexFile idxFile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(f5));
|
||||||
IIndexInclude[] includes= idxFile.getIncludes();
|
IIndexInclude[] includes= idxFile.getIncludes();
|
||||||
assertEquals(2, includes.length);
|
assertEquals(2, includes.length);
|
||||||
|
@ -1163,10 +1163,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #define MAC(...) Bug200239
|
// #define MAC(...) Bug200239
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// int MAC(1);
|
// int MAC(1);
|
||||||
// void func() {
|
// void func() {
|
||||||
|
@ -1190,9 +1189,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #define GMAC(x...) Bug200239
|
// #define GMAC(x...) Bug200239
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// int GMAC(1);
|
// int GMAC(1);
|
||||||
// void func() {
|
// void func() {
|
||||||
|
@ -1217,7 +1216,6 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// typedef bug200553_A bug200553_B;
|
// typedef bug200553_A bug200553_B;
|
||||||
// typedef bug200553_B bug200553_A;
|
// typedef bug200553_B bug200553_A;
|
||||||
public void testTypedefRecursionCpp_Bug200553() throws Exception {
|
public void testTypedefRecursionCpp_Bug200553() throws Exception {
|
||||||
|
@ -1266,7 +1264,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
assertTrue(maxDepth > 0);
|
assertTrue(maxDepth > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef bug200553_A bug200553_B;
|
// typedef bug200553_A bug200553_B;
|
||||||
// typedef bug200553_B bug200553_A;
|
// typedef bug200553_B bug200553_A;
|
||||||
public void testTypedefRecursionC_Bug200553() throws Exception {
|
public void testTypedefRecursionC_Bug200553() throws Exception {
|
||||||
|
@ -1306,7 +1304,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifndef GUARD
|
// #ifndef GUARD
|
||||||
// #include "source.cpp"
|
// #include "source.cpp"
|
||||||
// #endif
|
// #endif
|
||||||
|
@ -1315,7 +1313,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
final ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
|
final ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
|
||||||
Thread th= new Thread() {
|
Thread th= new Thread() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1324,7 +1322,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
|
tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1357,9 +1355,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static inline void staticInHeader() {};
|
// static inline void staticInHeader() {};
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void f1() {
|
// void f1() {
|
||||||
// staticInHeader();
|
// staticInHeader();
|
||||||
|
@ -1384,9 +1382,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static const int staticConstInHeader= 12;
|
// static const int staticConstInHeader= 12;
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void f1() {
|
// void f1() {
|
||||||
// int a= staticConstInHeader;
|
// int a= staticConstInHeader;
|
||||||
|
@ -1413,7 +1411,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static inline void staticInHeader() {};
|
// static inline void staticInHeader() {};
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void f1() {
|
// void f1() {
|
||||||
// staticInHeader();
|
// staticInHeader();
|
||||||
|
@ -1438,9 +1436,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static const int staticConstInHeader= 12;
|
// static const int staticConstInHeader= 12;
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// void f1() {
|
// void f1() {
|
||||||
// int a= staticConstInHeader;
|
// int a= staticConstInHeader;
|
||||||
|
@ -1467,7 +1465,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// int ok;
|
// int ok;
|
||||||
|
|
||||||
// #include "header.x"
|
// #include "header.x"
|
||||||
public void testNonStandardSuffix_Bug205778() throws Exception {
|
public void testNonStandardSuffix_Bug205778() throws Exception {
|
||||||
String[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
|
@ -1484,14 +1482,14 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inline void MyClass::method() {}
|
// inline void MyClass::method() {}
|
||||||
|
|
||||||
// class MyClass {
|
// class MyClass {
|
||||||
// void method();
|
// void method();
|
||||||
// };
|
// };
|
||||||
// #include "MyClass_inline.h"
|
// #include "MyClass_inline.h"
|
||||||
|
|
||||||
// #include "MyClass.h"
|
// #include "MyClass.h"
|
||||||
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
|
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
|
||||||
String[] contents= getContentsForTest(3);
|
String[] contents= getContentsForTest(3);
|
||||||
|
@ -1512,14 +1510,13 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// typedef int unrelated;
|
// typedef int unrelated;
|
||||||
|
|
||||||
// class unrelated {
|
// class unrelated {
|
||||||
// public: int b;
|
// public: int b;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// #include "h1.h"
|
// #include "h1.h"
|
||||||
// void test() {
|
// void test() {
|
||||||
// unrelated a;
|
// unrelated a;
|
||||||
|
@ -1546,7 +1543,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// #undef BBB
|
// #undef BBB
|
||||||
|
|
||||||
// #define BBB
|
// #define BBB
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// #ifdef BBB
|
// #ifdef BBB
|
||||||
|
@ -1574,9 +1571,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #define BUG ok
|
// #define BUG ok
|
||||||
|
|
||||||
// int BUG;
|
// int BUG;
|
||||||
|
|
||||||
// #include "common.h"
|
// #include "common.h"
|
||||||
|
@ -1601,7 +1598,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "h2.h"
|
// #include "h2.h"
|
||||||
|
|
||||||
// int BUG;
|
// int BUG;
|
||||||
|
|
||||||
// #define BUG ok
|
// #define BUG ok
|
||||||
|
@ -1625,7 +1622,6 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #include <header.h>
|
// #include <header.h>
|
||||||
// #define _CONCAT(x,y) x##y
|
// #define _CONCAT(x,y) x##y
|
||||||
// #define CONCAT(x,y) _CONCAT(x,y)
|
// #define CONCAT(x,y) _CONCAT(x,y)
|
||||||
|
@ -1638,7 +1634,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n");
|
||||||
|
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1652,7 +1648,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIncludeHeuristicsFlag_Bug213562() throws Exception {
|
public void testIncludeHeuristicsFlag_Bug213562() throws Exception {
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/header.h", "");
|
TestSourceReader.createFile(fCProject.getProject(), "f1/header.h", "");
|
||||||
|
@ -1673,8 +1669,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #include "dir"
|
// #include "dir"
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
public void testInclusionOfFolders_Bug243682() throws Exception {
|
public void testInclusionOfFolders_Bug243682() throws Exception {
|
||||||
|
@ -1696,9 +1691,8 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #ifndef B_H
|
// #ifndef B_H
|
||||||
// #include "b.h"
|
// #include "b.h"
|
||||||
// #endif
|
// #endif
|
||||||
|
@ -1760,7 +1754,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// namespace ns {
|
// namespace ns {
|
||||||
// template<typename T> class X {};
|
// template<typename T> class X {};
|
||||||
// }
|
// }
|
||||||
|
@ -1788,8 +1782,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #include "B.cpp"
|
// #include "B.cpp"
|
||||||
|
|
||||||
// static int STATIC;
|
// static int STATIC;
|
||||||
|
@ -1812,9 +1805,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// int a;
|
// int a;
|
||||||
|
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// void test() {a=0;}
|
// void test() {a=0;}
|
||||||
public void testDeclarationForBinding_Bug254844() throws Exception {
|
public void testDeclarationForBinding_Bug254844() throws Exception {
|
||||||
|
@ -1857,7 +1850,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// int i;
|
// int i;
|
||||||
// };
|
// };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// using ns::A;
|
// using ns::A;
|
||||||
// void test() {
|
// void test() {
|
||||||
|
@ -1870,7 +1863,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// struct A {
|
// struct A {
|
||||||
// int j;
|
// int j;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// #include "b.h"
|
// #include "b.h"
|
||||||
// void test() {
|
// void test() {
|
||||||
// A a;
|
// A a;
|
||||||
|
@ -1908,14 +1901,14 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// namespace ns {
|
// namespace ns {
|
||||||
// enum E1 { e = 1 };
|
// enum E1 { e = 1 };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// using namespace ns;
|
// using namespace ns;
|
||||||
// int i = e;
|
// int i = e;
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// enum E2 { e = 2 };
|
// enum E2 { e = 2 };
|
||||||
|
|
||||||
// #include "b.h"
|
// #include "b.h"
|
||||||
// int i = e;
|
// int i = e;
|
||||||
public void testDisambiguationByReachability_268704_2() throws Exception {
|
public void testDisambiguationByReachability_268704_2() throws Exception {
|
||||||
|
@ -2016,7 +2009,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // header.h
|
// // header.h
|
||||||
// namespace ns2 { class A {}; }
|
// namespace ns2 { class A {}; }
|
||||||
|
|
||||||
// #include "header.h"
|
// #include "header.h"
|
||||||
// namespace ns1 {
|
// namespace ns1 {
|
||||||
// class B : public ns2::A {};
|
// class B : public ns2::A {};
|
||||||
|
@ -2049,7 +2042,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // a.h
|
// // a.h
|
||||||
// #undef AAA
|
// #undef AAA
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// #define AAA
|
// #define AAA
|
||||||
|
@ -2083,7 +2076,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // a.h
|
// // a.h
|
||||||
// #undef AAA
|
// #undef AAA
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// #define AAA
|
// #define AAA
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
|
@ -2153,7 +2146,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T> void f(T t) throw (T) {}
|
// template<typename T> void f(T t) throw (T) {}
|
||||||
public void testFunctionTemplateWithThrowsException_293021() throws Exception {
|
public void testFunctionTemplateWithThrowsException_293021() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
@ -2176,19 +2169,19 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // a.h
|
// // a.h
|
||||||
// class P {};
|
// class P {};
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// namespace P {class C {};}
|
// namespace P {class C {};}
|
||||||
|
|
||||||
// // source1.cpp
|
// // source1.cpp
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// P p;
|
// P p;
|
||||||
|
|
||||||
// // source2.cpp
|
// // source2.cpp
|
||||||
// #include "b.h"
|
// #include "b.h"
|
||||||
// P::C c;
|
// P::C c;
|
||||||
public void testDisambiguateClassVsNamespace_297686() throws Exception {
|
public void testDisambiguateClassVsNamespace_297686() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
@ -2221,12 +2214,12 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// // a.h
|
// // a.h
|
||||||
// struct Error{};
|
// struct Error{};
|
||||||
|
|
||||||
// // b.h
|
// // b.h
|
||||||
// void Error(int errCode) {}
|
// void Error(int errCode) {}
|
||||||
|
|
||||||
// // source1.cpp
|
// // source1.cpp
|
||||||
// #include "a.h"
|
// #include "a.h"
|
||||||
// Error d;
|
// Error d;
|
||||||
|
|
||||||
// // source2.cpp
|
// // source2.cpp
|
||||||
|
@ -2261,7 +2254,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
public void testUpdateNonSrcFolderHeader_283080() throws Exception {
|
public void testUpdateNonSrcFolderHeader_283080() throws Exception {
|
||||||
IIndexBinding[] r;
|
IIndexBinding[] r;
|
||||||
|
|
||||||
final IProject prj = fCProject.getProject();
|
final IProject prj = fCProject.getProject();
|
||||||
final IFolder src= prj.getFolder("src");
|
final IFolder src= prj.getFolder("src");
|
||||||
final IFolder h= prj.getFolder("h");
|
final IFolder h= prj.getFolder("h");
|
||||||
|
@ -2278,7 +2271,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
CCorePlugin.getDefault().setProjectDescription(prj, desc);
|
CCorePlugin.getDefault().setProjectDescription(prj, desc);
|
||||||
TestSourceReader.createFile(h, "a.h", "int version1;");
|
TestSourceReader.createFile(h, "a.h", "int version1;");
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
|
|
||||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -2287,7 +2280,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
IFile s= TestSourceReader.createFile(h, "a.h", "int version2;");
|
IFile s= TestSourceReader.createFile(h, "a.h", "int version2;");
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
@ -2307,7 +2300,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
s= TestSourceReader.createFile(h, "a.h", "int version3;");
|
s= TestSourceReader.createFile(h, "a.h", "int version3;");
|
||||||
waitUntilFileIsIndexed(s, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(s, INDEX_WAIT_TIME);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
@ -2323,12 +2316,12 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
public void testUpdateForContentTypeChange_283080() throws Exception {
|
public void testUpdateForContentTypeChange_283080() throws Exception {
|
||||||
IIndexBinding[] r;
|
IIndexBinding[] r;
|
||||||
|
|
||||||
final IProject prj = fCProject.getProject();
|
final IProject prj = fCProject.getProject();
|
||||||
IFile file= TestSourceReader.createFile(prj, "a.cpp", "// \u0110 \n int a;");
|
IFile file= TestSourceReader.createFile(prj, "a.cpp", "// \u0110 \n int a;");
|
||||||
file.setCharset("US-ASCII", new NullProgressMonitor());
|
file.setCharset("US-ASCII", new NullProgressMonitor());
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
|
|
||||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
int offset1= 0;
|
int offset1= 0;
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
@ -2341,7 +2334,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.setCharset("UTF-8", new NullProgressMonitor());
|
file.setCharset("UTF-8", new NullProgressMonitor());
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
int offset2= 0;
|
int offset2= 0;
|
||||||
|
@ -2355,13 +2348,13 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(offset1 != offset2);
|
assertTrue(offset1 != offset2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateOnFolderRemove_343538() throws Exception {
|
public void testUpdateOnFolderRemove_343538() throws Exception {
|
||||||
IIndexBinding[] r;
|
IIndexBinding[] r;
|
||||||
|
|
||||||
final IProject prj = fCProject.getProject();
|
final IProject prj = fCProject.getProject();
|
||||||
final IFolder root= prj.getFolder("root");
|
final IFolder root= prj.getFolder("root");
|
||||||
root.create(true, false, null);
|
root.create(true, false, null);
|
||||||
|
@ -2376,7 +2369,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
TestSourceReader.createFile(child1, "a.c", "void bug343538() {}");
|
TestSourceReader.createFile(child1, "a.c", "void bug343538() {}");
|
||||||
TestSourceReader.createFile(child2, "b.c", "void bug343538();");
|
TestSourceReader.createFile(child2, "b.c", "void bug343538();");
|
||||||
waitForIndexer(fCProject);
|
waitForIndexer(fCProject);
|
||||||
|
|
||||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
final IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -2387,7 +2380,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect files and folders
|
// Collect files and folders
|
||||||
final Set<IFile> files = new HashSet<IFile>();
|
final Set<IFile> files = new HashSet<IFile>();
|
||||||
final Set<IFolder> folders = new HashSet<IFolder>();
|
final Set<IFolder> folders = new HashSet<IFolder>();
|
||||||
|
@ -2430,5 +2423,4 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue