diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index bdd14109afa..e987b504d50 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2004-08-03 Bogdan Gheorghe + Updated indexer and dependency tests to work for indexing standalone headers + 2004-06-09 Alain Magloire Patch from Sam Rob to resolve 64022 diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java index 7abe6c4cd27..2dfd006bdda 100644 --- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java +++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java @@ -221,7 +221,7 @@ import org.eclipse.core.runtime.Platform; PathCollector pathCollector = new PathCollector(); getTableRefs(dH, pathCollector); - String[] dHModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest2.cpp", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp"}; + String[] dHModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest2.cpp", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest2.h"}; String[] iPath = pathCollector.getPaths(); if (dHModel.length != iPath.length) @@ -238,7 +238,7 @@ import org.eclipse.core.runtime.Platform; pathCollector = new PathCollector(); getTableRefs(Inc1H, pathCollector); - String[] Inc1HModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp"}; + String[] Inc1HModel = {IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp",IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.h"}; iPath = pathCollector.getPaths(); if (Inc1HModel.length != iPath.length) @@ -283,22 +283,23 @@ import org.eclipse.core.runtime.Platform; getTableRefs(Inc1H, pathCollector); iPath = pathCollector.getPaths(); - - compareArrays(iPath,beforeModel); + String[] inc1Model = {Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.cpp",Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest.h"}; + compareArrays(iPath,inc1Model); pathCollector = new PathCollector(); getTableRefs(aH, pathCollector); iPath = pathCollector.getPaths(); - compareArrays(iPath,beforeModel); + compareArrays(iPath,inc1Model); pathCollector = new PathCollector(); getTableRefs(cH, pathCollector); iPath = pathCollector.getPaths(); - - compareArrays(iPath,beforeModel); + + String[] cHModel = {Path.SEPARATOR + "DepTestProject" + Path.SEPARATOR + "Inc1.h", Path.SEPARATOR + "DepTestProject" + Path.SEPARATOR + "DepTest.cpp", Path.SEPARATOR + "DepTestProject" + Path.SEPARATOR + "a.h", Path.SEPARATOR + "DepTestProject" + Path.SEPARATOR + "DepTest.h"}; + compareArrays(iPath,cHModel); editCode(depTestC,"#include \"DepTest.h\"","//#include \"DepTest.h\""); @@ -324,7 +325,7 @@ import org.eclipse.core.runtime.Platform; iPath = pathCollector.getPaths(); - if (iPath.length != 0) + if (iPath.length != 1) fail("Number of included files differs from model"); pathCollector = new PathCollector(); @@ -332,7 +333,7 @@ import org.eclipse.core.runtime.Platform; iPath = pathCollector.getPaths(); - if (iPath.length != 0) + if (iPath.length != 1) fail("Number of included files differs from model"); @@ -341,7 +342,7 @@ import org.eclipse.core.runtime.Platform; iPath = pathCollector.getPaths(); - if (iPath.length != 0) + if (iPath.length != 3) fail("Number of included files differs from model"); } @@ -491,8 +492,9 @@ import org.eclipse.core.runtime.Platform; IFile depTest3H = importFile("DepTest3.h","resources/dependency/DepTest3.h"); IFile depTest3C = importFile("DepTest3.cpp","resources/dependency/DepTest3.cpp"); - String[] beforeModel = {Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest3.cpp"}; - + String[] beforeModel = {Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest3.cpp"}; + String[] cHModel = {Path.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest3.cpp", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "a.h", IPath.SEPARATOR + "DepTestProject" + IPath.SEPARATOR + "DepTest3.h"}; + String[] aHModel = {Path.SEPARATOR + "DepTestProject" + Path.SEPARATOR + "DepTest3.cpp", Path.SEPARATOR + "DepTestProject" + Path.SEPARATOR + "DepTest3.h"}; PathCollector pathCollector = new PathCollector(); getTableRefs(depTest3H, pathCollector); @@ -505,14 +507,14 @@ import org.eclipse.core.runtime.Platform; iPath = pathCollector.getPaths(); - compareArrays(iPath,beforeModel); + compareArrays(iPath,cHModel); pathCollector = new PathCollector(); getTableRefs(aH, pathCollector); iPath = pathCollector.getPaths(); - compareArrays(iPath,beforeModel); + compareArrays(iPath,aHModel); editCode(aH,"#include \"c.h\"","//#include \"c.h\""); @@ -537,7 +539,7 @@ import org.eclipse.core.runtime.Platform; iPath = pathCollector.getPaths(); - compareArrays(iPath,beforeModel); + compareArrays(iPath,aHModel); } @@ -579,7 +581,7 @@ import org.eclipse.core.runtime.Platform; resultSet = resultCollector.getSearchResults(); - if (resultSet.size() != 0) + if (resultSet.size() != 1) fail("Expected no matches"); } diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java index 1ec06cbbdca..4519f15cbdc 100644 --- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java +++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java @@ -206,7 +206,7 @@ public class IndexManagerTests extends TestCase { ind = indexManager.getIndex(testProjectPath,true,true); char[] prefix = "typeDecl/C/CDocumentManager".toCharArray(); - String [] entryResultModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1 }"}; + String [] entryResultModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1, 2 }"}; IEntryResult[] eresults =ind.queryEntries(prefix); assertTrue("Entry Result exists", eresults != null); @@ -271,7 +271,7 @@ public class IndexManagerTests extends TestCase { IEntryResult[] eresults = ind.queryEntries(prefix); assertTrue("Entry result found for typdeDecl/", eresults != null); - String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1 }", "EntryResult: word=typeDecl/C/Mail, refs={ 2 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 2 }", "EntryResult: word=typeDecl/C/container, refs={ 2 }", "EntryResult: word=typeDecl/C/first_class, refs={ 2 }", "EntryResult: word=typeDecl/C/postcard, refs={ 2 }", "EntryResult: word=typeDecl/D/Mail, refs={ 2 }", "EntryResult: word=typeDecl/D/first_class, refs={ 2 }", "EntryResult: word=typeDecl/D/postcard, refs={ 2 }", "EntryResult: word=typeDecl/V/, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 2 }", "EntryResult: word=typeDecl/V/index, refs={ 2 }", "EntryResult: word=typeDecl/V/mail, refs={ 2 }", "EntryResult: word=typeDecl/V/size, refs={ 2 }", "EntryResult: word=typeDecl/V/temp, refs={ 2 }", "EntryResult: word=typeDecl/V/x, refs={ 2 }"}; + String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1, 2 }", "EntryResult: word=typeDecl/C/Mail, refs={ 3 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 3 }", "EntryResult: word=typeDecl/C/container, refs={ 3 }", "EntryResult: word=typeDecl/C/first_class, refs={ 3 }", "EntryResult: word=typeDecl/C/postcard, refs={ 3 }", "EntryResult: word=typeDecl/D/Mail, refs={ 3 }", "EntryResult: word=typeDecl/D/first_class, refs={ 3 }", "EntryResult: word=typeDecl/D/postcard, refs={ 3 }", "EntryResult: word=typeDecl/V/, refs={ 1, 2 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 3 }", "EntryResult: word=typeDecl/V/index, refs={ 3 }", "EntryResult: word=typeDecl/V/mail, refs={ 3 }", "EntryResult: word=typeDecl/V/size, refs={ 3 }", "EntryResult: word=typeDecl/V/temp, refs={ 3 }", "EntryResult: word=typeDecl/V/x, refs={ 3 }"}; if (eresults.length != entryResultBeforeModel.length) fail("Entry Result length different from model"); @@ -291,7 +291,7 @@ public class IndexManagerTests extends TestCase { eresults = ind.queryEntries(prefix); assertTrue("Entry exists", eresults != null); - String [] entryResultAfterModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1 }", "EntryResult: word=typeDecl/V/, refs={ 1 }"}; + String [] entryResultAfterModel ={"EntryResult: word=typeDecl/C/CDocumentManager, refs={ 1, 2 }", "EntryResult: word=typeDecl/V/, refs={ 1, 2 }"}; if (eresults.length != entryResultAfterModel.length) fail("Entry Result length different from model"); diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog index db19f71493f..0688f6eff76 100644 --- a/core/org.eclipse.cdt.core/index/ChangeLog +++ b/core/org.eclipse.cdt.core/index/ChangeLog @@ -1,3 +1,7 @@ +2004-08-03 Bogdan Gheorghe + + Fix for Bug 60948: Indexer should pick up all headers in include path + 2004-07-12 Bogdan Gheorghe Fix for Bug 69166: NPE in IndexerModelListener.processDelta diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java index 8c0b3106315..d2b8997b185 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java @@ -468,12 +468,14 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe public boolean shouldIndex(IFile fileToBeIndexed) { if (fileToBeIndexed != null){ ICFileType type = CCorePlugin.getDefault().getFileType(fileToBeIndexed.getProject(),fileToBeIndexed.getName()); - if (type.isSource()){ + if (type.isSource() || type.isHeader()){ String id = type.getId(); if (id.equals(AbstractIndexer.C_SOURCE_ID) || - id.equals(AbstractIndexer.CPP_SOURCE_ID)) + id.equals(AbstractIndexer.CPP_SOURCE_ID) || + id.equals(AbstractIndexer.C_HEADER_ID) || + id.equals(AbstractIndexer.CPP_HEADER_ID)) return true; - } + } } return false;