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