mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Bogdan Gheorghe
Fixed Bug 42685, Bug 43474. This patch: - removes the old CTags Indexer - removes the remaining Indexer block UI item under Project Properties - enables the Indexer on all projects
This commit is contained in:
parent
183a84fce3
commit
9eab565dd0
30 changed files with 320 additions and 1911 deletions
|
@ -1,3 +1,9 @@
|
|||
2003-09-22 Bogdan Gheorghe
|
||||
- modified CompletionProposalsTests, BaseSearchTest
|
||||
to avoid using isEnabled for the IndexManager
|
||||
- Reordered the IndexManagerTests suite to allow all
|
||||
tests to be run
|
||||
|
||||
2003-09-22 Andrew Niefer
|
||||
- modified resources/cfiles/CompletionProposalsTestStart.cpp
|
||||
- modified CompletionProposalsTest.testCompletionProposals
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
@ -25,6 +26,10 @@ import junit.framework.TestSuite;
|
|||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IQueryResult;
|
||||
|
@ -33,6 +38,7 @@ import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
|||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
|
||||
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
|
||||
import org.eclipse.core.internal.resources.ResourceException;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -52,13 +58,13 @@ import org.eclipse.core.runtime.Platform;
|
|||
* @author bgheorgh
|
||||
*/
|
||||
public class IndexManagerTests extends TestCase {
|
||||
IFile file;
|
||||
IFileDocument fileDoc;
|
||||
IProject testProject;
|
||||
NullProgressMonitor monitor;
|
||||
IndexManager indexManager;
|
||||
|
||||
public static final int TIMEOUT = 10000;
|
||||
IFile file;
|
||||
IFileDocument fileDoc;
|
||||
IProject testProject;
|
||||
NullProgressMonitor monitor;
|
||||
IndexManager indexManager;
|
||||
|
||||
public static final int TIMEOUT = 5000;
|
||||
/**
|
||||
* Constructor for IndexManagerTest.
|
||||
* @param name
|
||||
|
@ -78,8 +84,9 @@ public class IndexManagerTests extends TestCase {
|
|||
testProject = createProject("IndexerTestProject");
|
||||
if (testProject==null)
|
||||
fail("Unable to create project");
|
||||
|
||||
|
||||
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.reset();
|
||||
}
|
||||
/*
|
||||
* @see TestCase#tearDown()
|
||||
|
@ -103,17 +110,18 @@ public class IndexManagerTests extends TestCase {
|
|||
TestSuite suite = new TestSuite(IndexManagerTests.class.getName());
|
||||
|
||||
suite.addTest(new IndexManagerTests("testAddNewFileToIndex"));
|
||||
suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex"));
|
||||
suite.addTest(new IndexManagerTests("testRefs"));
|
||||
suite.addTest(new IndexManagerTests("testMacros"));
|
||||
suite.addTest(new IndexManagerTests("testForwardDeclarations"));
|
||||
//suite.addTest(new IndexManagerTests("testIndexContents"));
|
||||
//suite.addTest(new IndexManagerTests("testIndexAll"));
|
||||
suite.addTest(new IndexManagerTests("testDependencyTree"));
|
||||
suite.addTest(new IndexManagerTests("testIndexAll"));
|
||||
suite.addTest(new IndexManagerTests("testIndexContents"));
|
||||
suite.addTest(new IndexManagerTests("testMacros"));
|
||||
suite.addTest(new IndexManagerTests("testRefs"));
|
||||
suite.addTest(new IndexManagerTests("testRemoveFileFromIndex"));
|
||||
suite.addTest(new IndexManagerTests("testRemoveProjectFromIndex"));
|
||||
suite.addTest(new IndexManagerTests("testIndexShutdown"));
|
||||
|
||||
suite.addTest(new IndexManagerTests("testDependencyTree"));
|
||||
|
||||
return suite;
|
||||
// return new TestSuite(IndexManagerTests.class);
|
||||
|
||||
}
|
||||
/*
|
||||
* Utils
|
||||
|
@ -127,13 +135,13 @@ public class IndexManagerTests extends TestCase {
|
|||
if (!project.exists()) {
|
||||
project.create(null);
|
||||
} else {
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
}
|
||||
if (!project.isOpen()) {
|
||||
project.open(null);
|
||||
}
|
||||
|
||||
//Fill out a project description
|
||||
//Fill out a project description
|
||||
IPath defaultPath = Platform.getLocation();
|
||||
IPath newPath = project.getFullPath();
|
||||
if (defaultPath.equals(newPath))
|
||||
|
@ -159,7 +167,7 @@ public class IndexManagerTests extends TestCase {
|
|||
|
||||
private IFile importFile(String fileName, String resourceLocation)throws Exception{
|
||||
//Obtain file handle
|
||||
file = testProject.getProject().getFile(fileName);
|
||||
file = testProject.getProject().getFile(fileName);
|
||||
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
|
||||
//Create file input stream
|
||||
monitor = new NullProgressMonitor();
|
||||
|
@ -185,11 +193,7 @@ public class IndexManagerTests extends TestCase {
|
|||
public void testIndexAll() throws Exception {
|
||||
//Add a file to the project
|
||||
importFile("mail.cpp","resources/indexer/mail.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
Thread.sleep(1500);
|
||||
Thread.sleep(5000);
|
||||
IIndex ind = indexManager.getIndex(testProject.getFullPath(),true,true);
|
||||
assertTrue("Index exists for project",ind != null);
|
||||
|
||||
|
@ -201,7 +205,7 @@ public class IndexManagerTests extends TestCase {
|
|||
assertTrue("Entry Results exist", eresults != null);
|
||||
|
||||
String [] queryResultModel = {"IndexedFile(1: /IndexerTestProject/mail.cpp)"};
|
||||
String [] entryResultModel ={"EntryResult: word=typeDecl/C/Mail, refs={ 1 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 1 }", "EntryResult: word=typeDecl/C/container, refs={ 1 }", "EntryResult: word=typeDecl/C/first_class, refs={ 1 }", "EntryResult: word=typeDecl/C/postcard, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }"};
|
||||
String [] entryResultModel ={"EntryResult: word=typeDecl/C/Mail, refs={ 1 }", "EntryResult: word=typeDecl/C/Unknown, refs={ 1 }", "EntryResult: word=typeDecl/C/container, refs={ 1 }", "EntryResult: word=typeDecl/C/first_class, refs={ 1 }", "EntryResult: word=typeDecl/C/postcard, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/size, refs={ 1 }", "EntryResult: word=typeDecl/V/temp, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }"};
|
||||
|
||||
if (qresults.length != queryResultModel.length)
|
||||
fail("Query Result length different from model");
|
||||
|
@ -225,9 +229,8 @@ public class IndexManagerTests extends TestCase {
|
|||
importFile("mail.cpp","resources/indexer/mail.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
Thread.sleep(TIMEOUT);
|
||||
|
||||
Thread.sleep(10000);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
|
||||
|
@ -235,6 +238,7 @@ public class IndexManagerTests extends TestCase {
|
|||
//Add a new file to the project, give it some time to index
|
||||
importFile("DocumentManager.h","resources/indexer/DocumentManager.h");
|
||||
importFile("DocumentManager.cpp","resources/indexer/DocumentManager.cpp");
|
||||
|
||||
Thread.sleep(10000);
|
||||
ind = indexManager.getIndex(testProjectPath,true,true);
|
||||
|
||||
|
@ -256,10 +260,7 @@ public class IndexManagerTests extends TestCase {
|
|||
public void testRemoveProjectFromIndex() throws Exception{
|
||||
//Add a file to the project
|
||||
importFile("mail.cpp","resources/indexer/mail.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
|
||||
Thread.sleep(TIMEOUT);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
|
@ -289,10 +290,7 @@ public class IndexManagerTests extends TestCase {
|
|||
public void testRemoveFileFromIndex() throws Exception{
|
||||
//Add a file to the project
|
||||
importFile("mail.cpp","resources/indexer/mail.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
|
||||
Thread.sleep(TIMEOUT);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
|
@ -300,6 +298,7 @@ public class IndexManagerTests extends TestCase {
|
|||
assertTrue("Index exists for project",ind != null);
|
||||
//Add a new file to the project
|
||||
importFile("DocumentManager.h","resources/indexer/DocumentManager.h");
|
||||
importFile("DocumentManager.cpp","resources/indexer/DocumentManager.cpp");
|
||||
Thread.sleep(10000);
|
||||
//Do a "before" deletion comparison
|
||||
ind = indexManager.getIndex(testProjectPath,true,true);
|
||||
|
@ -307,7 +306,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 }"};
|
||||
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/V/PO_Box, refs={ 2 }", "EntryResult: word=typeDecl/V/size, refs={ 2 }", "EntryResult: word=typeDecl/V/temp, refs={ 2 }", "EntryResult: word=typeDecl/V/x, refs={ 2 }"};
|
||||
if (eresults.length != entryResultBeforeModel.length)
|
||||
fail("Entry Result length different from model");
|
||||
|
||||
|
@ -329,7 +328,7 @@ public class IndexManagerTests extends TestCase {
|
|||
fail("Entry Result length different from model");
|
||||
|
||||
for (int i=0;i<eresults.length; i++)
|
||||
{
|
||||
{
|
||||
assertEquals(entryResultAfterModel[i],eresults[i].toString());
|
||||
}
|
||||
}
|
||||
|
@ -337,10 +336,7 @@ public class IndexManagerTests extends TestCase {
|
|||
public void testIndexContents() throws Exception{
|
||||
//Add a new file to the project, give it some time to index
|
||||
importFile("extramail.cpp","resources/indexer/extramail.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
|
||||
Thread.sleep(TIMEOUT);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
|
@ -350,7 +346,8 @@ public class IndexManagerTests extends TestCase {
|
|||
IEntryResult[] typerefreesults = ind.queryEntries(IIndexConstants.TYPE_REF);
|
||||
assertTrue("Type Ref Results exist", typerefreesults != null);
|
||||
|
||||
String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/T/int32, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }", "EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"};
|
||||
String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/T/int32, refs={ 1 }", "EntryResult: word=typeDecl/V/PO_Box, refs={ 1 }", "EntryResult: word=typeDecl/V/size, refs={ 1 }", "EntryResult: word=typeDecl/V/temp, refs={ 1 }", "EntryResult: word=typeDecl/V/x, refs={ 1 }", "EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"};
|
||||
|
||||
IEntryResult[] typedeclresults =ind.queryEntries(IIndexConstants.TYPE_DECL);
|
||||
assertTrue("Type Decl Results exist", typedeclresults != null);
|
||||
|
||||
|
@ -409,21 +406,19 @@ public class IndexManagerTests extends TestCase {
|
|||
assertEquals(functionResultModel[i],functionresults[i].toString());
|
||||
}
|
||||
|
||||
String [] methodResultModel = {"EntryResult: word=methodDecl/Mail/Mail/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/Unknown/Unknown/Y/X/Z, refs={ 1 }",
|
||||
String [] methodResultModel = {"EntryResult: word=methodDecl/Mail/Mail/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/Unknown/Unknown/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/container/container/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/first_class/first_class/Y/X/Z, refs={ 1 }",
|
||||
//"EntryResult: word=methodDecl/operator=/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/operator=/container/Y/X/Z, refs={ 1 }",
|
||||
//"EntryResult: word=methodDecl/operator[]/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/operator[]/container/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/first_class/first_class/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/operator =/container/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/operator []/container/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/postcard/postcard/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/print/Mail/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/print/Unknown/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/print/Unknown/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/print/first_class/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/print/postcard/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/size/container/Y/X/Z, refs={ 1 }",
|
||||
"EntryResult: word=methodDecl/~container/container/Y/X/Z, refs={ 1 }" };
|
||||
"EntryResult: word=methodDecl/~container/container/Y/X/Z, refs={ 1 }"};
|
||||
|
||||
|
||||
|
||||
|
@ -443,10 +438,7 @@ public class IndexManagerTests extends TestCase {
|
|||
public void testRefs() throws Exception{
|
||||
//Add a new file to the project, give it some time to index
|
||||
importFile("reftest.cpp","resources/indexer/reftest.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
|
||||
Thread.sleep(TIMEOUT);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
|
@ -518,10 +510,7 @@ public class IndexManagerTests extends TestCase {
|
|||
{
|
||||
//Add a new file to the project, give it some time to index
|
||||
importFile("extramail.cpp","resources/indexer/extramail.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
|
||||
Thread.sleep(TIMEOUT);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
|
@ -545,10 +534,7 @@ public class IndexManagerTests extends TestCase {
|
|||
public void testIndexShutdown() throws Exception{
|
||||
//Add a new file to the project, give it some time to index
|
||||
importFile("reftest.cpp","resources/indexer/reftest.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
|
||||
Thread.sleep(TIMEOUT);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
|
@ -578,22 +564,20 @@ public class IndexManagerTests extends TestCase {
|
|||
fail("Shutdown did not delete .index file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testForwardDeclarations() throws Exception{
|
||||
//Add a new file to the project, give it some time to index
|
||||
importFile("reftest.cpp","resources/indexer/reftest.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
|
||||
Thread.sleep(TIMEOUT);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
|
||||
assertTrue("Index exists for project",ind != null);
|
||||
|
||||
//IEntryResult[] fwdDclResults = ind.queryEntries("typeDecl/C/ForwardA/A".toCharArray());
|
||||
IEntryResult[] fwdDclResults = ind.queryEntries("typeDecl/C/ForwardA/A".toCharArray());
|
||||
assertTrue("Entry exists",fwdDclResults != null);
|
||||
|
||||
|
@ -621,11 +605,6 @@ public class IndexManagerTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testFunctionDeclarations2() throws Exception{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testDependencyTree() throws Exception{
|
||||
//Add a file to the project
|
||||
IFile depTest = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
|
||||
|
@ -639,7 +618,7 @@ public class IndexManagerTests extends TestCase {
|
|||
//Enable indexing on the created project
|
||||
//By doing this, we force the Dependency Manager to do a g()
|
||||
DependencyManager dependencyManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
|
||||
dependencyManager.setEnabled(testProject,true);
|
||||
//dependencyManager.setEnabled(testProject,true);
|
||||
Thread.sleep(10000);
|
||||
String[] depTestModel = {File.separator + "IndexerTestProject" + File.separator + "d.h", File.separator + "IndexerTestProject" + File.separator + "Inc1.h", File.separator + "IndexerTestProject" + File.separator + "c.h", File.separator + "IndexerTestProject" + File.separator + "a.h", File.separator + "IndexerTestProject" + File.separator + "DepTest.h"};
|
||||
String[] depTest2Model = {File.separator + "IndexerTestProject" + File.separator + "d.h", File.separator + "IndexerTestProject" + File.separator + "DepTest2.h"};
|
||||
|
@ -706,4 +685,5 @@ public class IndexManagerTests extends TestCase {
|
|||
}
|
||||
return tempLocalArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class CompletionProposalsTest extends TestCase{
|
|||
|
||||
// use the new indexer
|
||||
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(fCProject.getProject(),true);
|
||||
indexManager.reset();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,14 +50,14 @@ import org.eclipse.core.runtime.Platform;
|
|||
*/
|
||||
public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
||||
|
||||
ICSearchScope scope;
|
||||
ICSearchScope scope;
|
||||
IFile file;
|
||||
IProject testProject;
|
||||
NullProgressMonitor monitor;
|
||||
IWorkspace workspace;
|
||||
CSearchResultCollector resultCollector;
|
||||
SearchEngine searchEngine;
|
||||
FileManager fileManager;
|
||||
FileManager fileManager;
|
||||
|
||||
public BaseSearchTest(String name) {
|
||||
super(name);
|
||||
|
@ -65,7 +65,7 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
|||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
@ -85,10 +85,7 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
|||
importFile("include.h", "resources/search/include.h");
|
||||
|
||||
scope = SearchEngine.createWorkspaceScope();
|
||||
|
||||
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
|
||||
|
||||
resultCollector = new CSearchResultCollector();
|
||||
resultCollector.setProgressMonitor( monitor );
|
||||
|
||||
|
@ -149,8 +146,8 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
|||
}
|
||||
}
|
||||
catch (CoreException e){
|
||||
cproject = project;
|
||||
cproject.open(null);
|
||||
cproject = project;
|
||||
cproject.open(null);
|
||||
}
|
||||
|
||||
return cproject;
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2003-09-22 Bogdan Gheorghe
|
||||
|
||||
Took out old CTags code from CCorePlugin
|
||||
|
||||
* org.eclipse.cdt.core.CCorePlugin
|
||||
|
||||
2003-09-19 Hoda Amer
|
||||
Solution to bug#43162 : Code Assist not showing the right return value:
|
||||
Saved a function return value string in the BasicSearchMatch object.
|
||||
|
@ -6,7 +12,7 @@
|
|||
return type from IASTAbstractDeclaration to String. Note that this was
|
||||
previously implemented in the CModelBuilder. I just moved it to a common
|
||||
library for others (BasicSearchMatch) to use.
|
||||
|
||||
|
||||
2003-09-16 Alain Magloire
|
||||
|
||||
Putting the draft work to do a special binary parser
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2003-09-22 Bogdan Gheorghe
|
||||
- Took out enable section for DependencyManager
|
||||
|
||||
2003-09-11 Bogdan Gheorghe
|
||||
- Added null guard to DependencyManager.getDependencyTree(),
|
||||
DependencyTree.getFileDependencies()
|
||||
|
|
|
@ -247,10 +247,10 @@ public class DependencyManager extends JobManager implements ISourceDependency {
|
|||
if (CCorePlugin.getDefault() == null) return;
|
||||
|
||||
/******
|
||||
*TODO: Remove these methods once the depTree is
|
||||
*TODO: BOG Remove these methods once the depTree is
|
||||
*fully integrated
|
||||
*/
|
||||
if (!isEnabled(project)) return;
|
||||
// if (!isEnabled(project)) return;
|
||||
|
||||
// check if the same request is not already in the queue
|
||||
DependencyRequest request = new EntireProjectDependencyTree(project, this);
|
||||
|
@ -378,46 +378,46 @@ public class DependencyManager extends JobManager implements ISourceDependency {
|
|||
request(job);
|
||||
}
|
||||
|
||||
/*************
|
||||
*TODO: Remove these methods once the depTree is
|
||||
*fully integrated
|
||||
* START OF TEMP D-TREE ENABLE SECTION
|
||||
*/
|
||||
final static String DEP_MODEL_ID = CCorePlugin.PLUGIN_ID + ".dependencytree";
|
||||
final static String ACTIVATION = "enable";
|
||||
|
||||
static QualifiedName activationKey = new QualifiedName(DEP_MODEL_ID, ACTIVATION);
|
||||
|
||||
public boolean isEnabled(IProject project) {
|
||||
String prop = null;
|
||||
try {
|
||||
if (project != null) {
|
||||
prop = project.getPersistentProperty(activationKey);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return ((prop != null) && prop.equalsIgnoreCase("true"));
|
||||
}
|
||||
|
||||
public void setEnabled(IProject project, boolean on) {
|
||||
try {
|
||||
if (project != null) {
|
||||
Boolean newValue = new Boolean(on);
|
||||
Boolean oldValue = new Boolean(isEnabled(project));
|
||||
if (!oldValue.equals(newValue)) {
|
||||
project.setPersistentProperty(activationKey, newValue.toString());
|
||||
if (on) {
|
||||
generateEntireDependencyTree(project);
|
||||
} else {
|
||||
//remove(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/************
|
||||
* END OF TEMP D-TREE ENABLE SECTION
|
||||
*/
|
||||
// /*************
|
||||
// *TODO: Remove these methods once the depTree is
|
||||
// *fully integrated
|
||||
// * START OF TEMP D-TREE ENABLE SECTION
|
||||
// */
|
||||
// final static String DEP_MODEL_ID = CCorePlugin.PLUGIN_ID + ".dependencytree";
|
||||
// final static String ACTIVATION = "enable";
|
||||
//
|
||||
// static QualifiedName activationKey = new QualifiedName(DEP_MODEL_ID, ACTIVATION);
|
||||
//
|
||||
// public boolean isEnabled(IProject project) {
|
||||
// String prop = null;
|
||||
// try {
|
||||
// if (project != null) {
|
||||
// prop = project.getPersistentProperty(activationKey);
|
||||
// }
|
||||
// } catch (CoreException e) {
|
||||
// }
|
||||
// return ((prop != null) && prop.equalsIgnoreCase("true"));
|
||||
// }
|
||||
//
|
||||
// public void setEnabled(IProject project, boolean on) {
|
||||
// try {
|
||||
// if (project != null) {
|
||||
// Boolean newValue = new Boolean(on);
|
||||
// Boolean oldValue = new Boolean(isEnabled(project));
|
||||
// if (!oldValue.equals(newValue)) {
|
||||
// project.setPersistentProperty(activationKey, newValue.toString());
|
||||
// if (on) {
|
||||
// generateEntireDependencyTree(project);
|
||||
// } else {
|
||||
// //remove(project);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (CoreException e) {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /************
|
||||
// * END OF TEMP D-TREE ENABLE SECTION
|
||||
// */
|
||||
}
|
||||
|
|
|
@ -1,3 +1,26 @@
|
|||
2003-09-22 Bogdan Gheorghe
|
||||
|
||||
Took out the old CTags Indexer. Modified IndexAllProject to get
|
||||
the project path straight from the resource (bypassing the CModelManager).
|
||||
Commented out the enable section in IndexManager.
|
||||
|
||||
Modified
|
||||
* org.eclipse.cdt.internal.core.search.indexing.IndexAllProject
|
||||
* org.eclipse.cdt.internal.core.search.indexing.IndexManager
|
||||
|
||||
Deleted
|
||||
* org.eclipse.cdt.core.index.IndexModel
|
||||
* org.eclipse.cdt.core.index.ITagEntry
|
||||
* org.eclipse.cdt.core.index.TagFlags
|
||||
* org.eclipse.cdt.internal.core.index.CTagsCmd
|
||||
* org.eclipse.cdt.internal.core.index.CTagsEntry
|
||||
* org.eclipse.cdt.internal.core.index.CTagsFileReader
|
||||
* org.eclipse.cdt.internal.core.index.CTagsFileWriter
|
||||
* org.eclipse.cdt.internal.core.index.CTagsHeader
|
||||
* org.eclipse.cdt.internal.core.index.CTagsRunner
|
||||
* org.eclipse.cdt.internal.core.index.IndexManager
|
||||
* org.eclipse.cdt.internal.core.index.RequestList
|
||||
|
||||
2003-09-16 Andrew Niefer
|
||||
- add parameter references to index
|
||||
- modify CharOperation.match to allow escaping wildcards (bug43063)
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
package org.eclipse.cdt.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
||||
|
||||
public interface ITagEntry {
|
||||
|
||||
/**
|
||||
* Name of tag.
|
||||
*/
|
||||
public String getTagName();
|
||||
|
||||
/**
|
||||
* Path of source file containing definition of tag.
|
||||
*/
|
||||
public String getFileName();
|
||||
|
||||
/**
|
||||
* IFile of source file containing definition of tag.
|
||||
*/
|
||||
public IFile getIFile();
|
||||
|
||||
/**
|
||||
* Address for locating tag in source file
|
||||
* (may be null if not present).
|
||||
*/
|
||||
public String getPattern();
|
||||
|
||||
/**
|
||||
* line number in source file of tag definition
|
||||
* (may be zero if not known).
|
||||
*/
|
||||
public int getLineNumber();
|
||||
|
||||
/**
|
||||
* Kind of tag.
|
||||
*/
|
||||
public int getKind();
|
||||
|
||||
/**
|
||||
* Language of the file.
|
||||
*/
|
||||
public String getLanguage();
|
||||
|
||||
/**
|
||||
* Is tag of file-limited scope?
|
||||
*/
|
||||
public boolean hasFileScope();
|
||||
|
||||
/**
|
||||
* Return base classes.
|
||||
*/
|
||||
public String[] getInherits();
|
||||
|
||||
/**
|
||||
* Access Control of structure/class/union members.
|
||||
*/
|
||||
public int getAccessControl();
|
||||
|
||||
// implementation:
|
||||
public int getImplementation();
|
||||
|
||||
/**
|
||||
* Class name of the tag if a member,
|
||||
* null if not a member of a struct/class/union.
|
||||
*/
|
||||
public String getClassName();
|
||||
|
||||
/**
|
||||
* Return the original tag line.
|
||||
*/
|
||||
public String getLine();
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
package org.eclipse.cdt.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.internal.core.index.IndexManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
|
||||
public class IndexModel {
|
||||
|
||||
static IndexModel indexModel = null;
|
||||
static IndexManager manager = null;
|
||||
final static String INDEX_MODEL_ID = CCorePlugin.PLUGIN_ID + ".indexmodel";
|
||||
final static String ACTIVATION = "enable";
|
||||
|
||||
static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
|
||||
|
||||
public boolean isEnabled(IProject project) {
|
||||
String prop = null;
|
||||
try {
|
||||
if (project != null) {
|
||||
prop = project.getPersistentProperty(activationKey);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return ((prop != null) && prop.equalsIgnoreCase("true"));
|
||||
}
|
||||
|
||||
public void setEnabled(IProject project, boolean on) {
|
||||
try {
|
||||
if (project != null) {
|
||||
Boolean newValue = new Boolean(on);
|
||||
Boolean oldValue = new Boolean(isEnabled(project));
|
||||
if (!oldValue.equals(newValue)) {
|
||||
project.setPersistentProperty(activationKey, newValue.toString());
|
||||
if (on) {
|
||||
addResource(project);
|
||||
} else {
|
||||
removeResource(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Project for tag symbol.
|
||||
*/
|
||||
public ITagEntry[] query (IProject project, String tag) {
|
||||
return manager.query(project, tag, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Project for tag symbol.
|
||||
*/
|
||||
public ITagEntry[] query (IProject project, String tag, boolean ignoreCase, boolean exactMatch) {
|
||||
return manager.query(project, tag, ignoreCase, exactMatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a resource to be index. Containers(Folder, projects)
|
||||
* resources are recursively search for C Files as define by
|
||||
* CoreModel.isTranslationUnit().
|
||||
*/
|
||||
public void addResource(IResource resource) {
|
||||
manager.addResource(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the resource from the indexer list.
|
||||
*/
|
||||
public void removeResource(IResource resource) {
|
||||
manager.removeResource(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the C files recurively going to all projects
|
||||
* identified as C Projects by CoreModel.
|
||||
*/
|
||||
public void addAll () {
|
||||
manager.addAll();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void startup() {
|
||||
manager.startup();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void shutdown() {
|
||||
manager.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize default index Model.
|
||||
*/
|
||||
public static IndexModel getDefault() {
|
||||
if (indexModel == null) {
|
||||
indexModel = new IndexModel();
|
||||
manager = IndexManager.getDefault();
|
||||
}
|
||||
return indexModel;
|
||||
}
|
||||
|
||||
private IndexModel () {
|
||||
}
|
||||
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
package org.eclipse.cdt.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
public class TagFlags {
|
||||
|
||||
public final static int T_UNKNOWN = 0;
|
||||
public final static int T_CLASS = 1;
|
||||
public final static int T_MACRO = 2;
|
||||
public final static int T_ENUMERATOR = 3;
|
||||
public final static int T_FUNCTION = 4;
|
||||
public final static int T_ENUM = 5;
|
||||
public final static int T_MEMBER = 6;
|
||||
public final static int T_NAMESPACE = 7;
|
||||
public final static int T_PROTOTYPE = 8;
|
||||
public final static int T_STRUCT = 9;
|
||||
public final static int T_TYPEDEF = 10;
|
||||
public final static int T_UNION = 11;
|
||||
public final static int T_VARIABLE = 12;
|
||||
public final static int T_EXTERNVAR = 13;
|
||||
|
||||
public final static int T_PRIVATE = 14;
|
||||
public final static int T_PROTECTED = 15;
|
||||
public final static int T_PUBLIC = 16;
|
||||
public final static int T_FRIEND = 17;
|
||||
public final static int T_VIRTUAL = 18;
|
||||
public final static int T_ABSTRACT = 19;
|
||||
|
||||
private TagFlags() {
|
||||
}
|
||||
|
||||
public static boolean isUnknown(int k) {
|
||||
return k == T_UNKNOWN;
|
||||
}
|
||||
|
||||
public static boolean isClass(int k) {
|
||||
return k == T_CLASS;
|
||||
}
|
||||
|
||||
public static boolean isMacro(int k) {
|
||||
return k == T_MACRO;
|
||||
}
|
||||
|
||||
public static boolean isEnumerator(int k) {
|
||||
return k == T_ENUMERATOR;
|
||||
}
|
||||
|
||||
public static boolean isFunction(int k) {
|
||||
return k == T_FUNCTION;
|
||||
}
|
||||
|
||||
public static boolean isEnum(int k) {
|
||||
return k == T_ENUM;
|
||||
}
|
||||
|
||||
public static boolean isMember(int k) {
|
||||
return k == T_MEMBER;
|
||||
}
|
||||
|
||||
public static boolean isNamespace(int k) {
|
||||
return k == T_NAMESPACE;
|
||||
}
|
||||
|
||||
public static boolean isPrototype(int k) {
|
||||
return k == T_PROTOTYPE;
|
||||
}
|
||||
|
||||
public static boolean isStruct(int k) {
|
||||
return k == T_STRUCT;
|
||||
}
|
||||
|
||||
public static boolean isTypedef(int k) {
|
||||
return k == T_TYPEDEF;
|
||||
}
|
||||
|
||||
public static boolean isUnion(int k) {
|
||||
return k == T_UNION;
|
||||
}
|
||||
|
||||
public static boolean isVariable(int k) {
|
||||
return k == T_VARIABLE;
|
||||
}
|
||||
|
||||
public static boolean isExternVar(int k) {
|
||||
return k == T_EXTERNVAR;
|
||||
}
|
||||
|
||||
public static int value(String flag) {
|
||||
if (flag == null) {
|
||||
return T_UNKNOWN;
|
||||
} else if (flag.equals("class")) {
|
||||
return T_CLASS;
|
||||
} else if (flag.equals("macro")) {
|
||||
return T_MACRO;
|
||||
} else if (flag.equals("enumerator")) {
|
||||
return T_ENUMERATOR;
|
||||
} else if (flag.equals("function")) {
|
||||
return T_FUNCTION;
|
||||
} else if (flag.equals("enum")) {
|
||||
return T_ENUM;
|
||||
} else if (flag.equals("member")) {
|
||||
return T_MEMBER;
|
||||
} else if (flag.equals("namespace")) {
|
||||
return T_NAMESPACE;
|
||||
} else if (flag.equals("prototype")) {
|
||||
return T_PROTOTYPE;
|
||||
} else if (flag.equals("struct")) {
|
||||
return T_STRUCT;
|
||||
} else if (flag.equals("typedef")) {
|
||||
return T_TYPEDEF;
|
||||
} else if (flag.equals("union")) {
|
||||
return T_UNION;
|
||||
} else if (flag.equals("variable")) {
|
||||
return T_VARIABLE;
|
||||
} else if (flag.equals("externvar")) {
|
||||
return T_EXTERNVAR;
|
||||
} else if (flag.equals("public")) {
|
||||
return T_PUBLIC;
|
||||
} else if (flag.equals("private")) {
|
||||
return T_PRIVATE;
|
||||
} else if (flag.equals("protected")) {
|
||||
return T_PROTECTED;
|
||||
} else if (flag.equals("virtual")) {
|
||||
return T_VIRTUAL;
|
||||
} else if (flag.equals("abstract")) {
|
||||
return T_ABSTRACT;
|
||||
} else if (flag.equals("friend")) {
|
||||
return T_FRIEND;
|
||||
}
|
||||
return T_UNKNOWN;
|
||||
}
|
||||
|
||||
public static String value(int flag) {
|
||||
if (flag == T_CLASS) {
|
||||
return "class";
|
||||
} else if (flag == T_MACRO) {
|
||||
return "macro";
|
||||
} else if (flag == T_ENUMERATOR) {
|
||||
return "enumerator";
|
||||
} else if (flag == T_FUNCTION) {
|
||||
return "function";
|
||||
} else if (flag == T_ENUM) {
|
||||
return "enum";
|
||||
} else if (flag == T_MEMBER) {
|
||||
return "member";
|
||||
} else if (flag == T_NAMESPACE) {
|
||||
return "namespace";
|
||||
} else if (flag == T_PROTOTYPE) {
|
||||
return "prototype";
|
||||
} else if (flag == T_STRUCT) {
|
||||
return "struct";
|
||||
} else if (flag == T_TYPEDEF) {
|
||||
return "typedef";
|
||||
} else if (flag == T_UNION) {
|
||||
return "union";
|
||||
} else if (flag == T_VARIABLE) {
|
||||
return "variable";
|
||||
} else if (flag == T_EXTERNVAR) {
|
||||
return "externvar";
|
||||
} else if (flag == T_PUBLIC) {
|
||||
return "public";
|
||||
} else if (flag == T_PRIVATE) {
|
||||
return "private";
|
||||
} else if (flag == T_PROTECTED) {
|
||||
return "protected";
|
||||
} else if (flag == T_VIRTUAL) {
|
||||
return "virtual";
|
||||
} else if (flag == T_ABSTRACT) {
|
||||
return "abstract";
|
||||
} else if (flag == T_FRIEND) {
|
||||
return "friend";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.cdt.core.index.ITagEntry;
|
||||
import org.eclipse.cdt.utils.spawner.ProcessFactory;
|
||||
|
||||
public class CTagsCmd {
|
||||
|
||||
public CTagsCmd() {
|
||||
}
|
||||
|
||||
private void process(String filename, List list, IFile file) throws IOException {
|
||||
|
||||
BufferedReader stdout;
|
||||
|
||||
String[] args = {"ctags", "--excmd=pattern", "--format=2",
|
||||
"--if0=yes", "--sort=no", "--extra=q",
|
||||
"--fields=aiKlmnsz", "--line-directives=yes",
|
||||
"--sort=no", "--kind-long",
|
||||
"--c-types=cdefgmnpstuvx",
|
||||
"-f", "-", filename};
|
||||
|
||||
//Process ctags = Runtime.getRuntime().exec(args);
|
||||
Process ctags = ProcessFactory.getFactory().exec(args);
|
||||
//stdin = new BufferedWriter(new OutputStreamWriter(ctags.getOutputStream()));
|
||||
stdout = new BufferedReader(new InputStreamReader(ctags.getInputStream()));
|
||||
|
||||
//System.out.println("Processing");
|
||||
String line;
|
||||
try {
|
||||
while ((line = stdout.readLine()) != null) {
|
||||
//System.out.println("ProcessingLine " + line);
|
||||
CTagsEntry entry = new CTagsEntry(line, file);
|
||||
list.add(entry);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
// Force an explicit close even if
|
||||
// we call destroy()
|
||||
try {
|
||||
stdout.close();
|
||||
ctags.getOutputStream().close();
|
||||
ctags.getErrorStream().close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
ctags.destroy();
|
||||
}
|
||||
|
||||
public ITagEntry[] getTagEntries(IFile file, String filename) throws IOException {
|
||||
List list = new LinkedList();
|
||||
process(filename, list, file);
|
||||
return (ITagEntry[])list.toArray(new ITagEntry[0]);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
CTagsCmd cmd = new CTagsCmd();
|
||||
ITagEntry[] entries = cmd.getTagEntries(null, args[0]);
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (entries[i] instanceof CTagsEntry) {
|
||||
CTagsEntry entry = (CTagsEntry)entries[i];
|
||||
System.out.println(entry.getLine() + "\n");
|
||||
entry.print();
|
||||
System.out.println("\n");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,291 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.cdt.core.index.ITagEntry;
|
||||
import org.eclipse.cdt.core.index.TagFlags;
|
||||
|
||||
public class CTagsEntry implements ITagEntry {
|
||||
|
||||
final static String TAB_SEPARATOR = "\t";
|
||||
final static String PATTERN_SEPARATOR = ";\"";
|
||||
final static String LANGUAGE = "language";
|
||||
final static String KIND = "kind";
|
||||
final static String LINE = "line";
|
||||
final static String FILE = "file";
|
||||
final static String INHERITS = "inherits";
|
||||
final static String ACCESS = "access";
|
||||
final static String IMPLEMENTATION = "implementation";
|
||||
final static String CLASS = "class";
|
||||
|
||||
final String[] NONE = new String[0];
|
||||
|
||||
String tagName;
|
||||
|
||||
/* Path of source file containing definition of tag. */
|
||||
String fileName;
|
||||
|
||||
/* IFile of parsed file */
|
||||
IFile file;
|
||||
|
||||
/* pattern for locating source line
|
||||
* (may be NULL if not present) */
|
||||
String pattern;
|
||||
|
||||
int lineNumber;
|
||||
|
||||
/* Miscellaneous extension fields */
|
||||
HashMap tagExtensionField;
|
||||
|
||||
String line;
|
||||
|
||||
public CTagsEntry(String line, IFile file) {
|
||||
this.line = line;
|
||||
this.file = file;
|
||||
tagName = "";
|
||||
fileName ="";
|
||||
pattern = null;
|
||||
lineNumber = 0;
|
||||
tagExtensionField = new HashMap();
|
||||
parse();
|
||||
}
|
||||
|
||||
void parse () {
|
||||
String delim = TAB_SEPARATOR;
|
||||
StringTokenizer st = new StringTokenizer(line, delim);
|
||||
for (int state = 0; st.hasMoreTokens(); state++) {
|
||||
String token = st.nextToken();
|
||||
switch (state) {
|
||||
case 0: // TAG_NAME:
|
||||
tagName = token;
|
||||
break;
|
||||
|
||||
case 1: // FILE_NAME:
|
||||
fileName = token;
|
||||
break;
|
||||
|
||||
case 2: // PATTERN;
|
||||
try {
|
||||
String sub = token.trim();
|
||||
if (Character.isDigit(sub.charAt(0))) {
|
||||
lineNumber = Integer.parseInt(sub);
|
||||
} else {
|
||||
// Filter out the prepend delimeter.
|
||||
if (sub.startsWith("/") || sub.startsWith("?")) {
|
||||
sub = sub.substring(1);
|
||||
}
|
||||
if (sub.startsWith("^")) {
|
||||
sub = sub.substring(1);
|
||||
}
|
||||
|
||||
// Filter out the delimiters
|
||||
if (sub.endsWith("\"")) {
|
||||
int j = sub.lastIndexOf('"');
|
||||
sub = sub.substring(0, j);
|
||||
}
|
||||
if (sub.endsWith(";")) {
|
||||
int j = sub.lastIndexOf(';');
|
||||
sub = sub.substring(0, j);
|
||||
}
|
||||
if (sub.endsWith("?")) {
|
||||
int j = sub.lastIndexOf('?');
|
||||
sub = sub.substring(0, j);
|
||||
}
|
||||
if (sub.endsWith("/")) {
|
||||
int j = sub.lastIndexOf('/');
|
||||
sub = sub.substring(0, j);
|
||||
}
|
||||
if (sub.endsWith("$")) {
|
||||
int j = sub.lastIndexOf('$');
|
||||
sub = sub.substring(0, j);
|
||||
}
|
||||
pattern = sub;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
pattern = token;
|
||||
//e.printStackTrace();
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
pattern = token;
|
||||
//e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
|
||||
default: // EXTENSION_FIELDS:
|
||||
int i = token.indexOf(':');
|
||||
if (i != -1) {
|
||||
String key = token.substring(0, i);
|
||||
String value = token.substring(i + 1);
|
||||
tagExtensionField.put(key, value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getTagName () {
|
||||
return tagName;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
public IFile getIFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public String getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
// line:
|
||||
public int getLineNumber() {
|
||||
try {
|
||||
String sub = (String)tagExtensionField.get(LINE);
|
||||
if (sub != null) {
|
||||
lineNumber = Integer.parseInt(sub);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
//System.out.println(e);
|
||||
}
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
// kind:
|
||||
public int getKind() {
|
||||
String kind = (String)tagExtensionField.get(KIND);
|
||||
return TagFlags.value(kind);
|
||||
}
|
||||
|
||||
// language:
|
||||
public String getLanguage() {
|
||||
return (String)tagExtensionField.get(LANGUAGE);
|
||||
}
|
||||
|
||||
// Implementation:
|
||||
public int getImplementation() {
|
||||
String impl = (String)tagExtensionField.get(IMPLEMENTATION);
|
||||
return TagFlags.value(impl);
|
||||
}
|
||||
|
||||
// Class:
|
||||
public String getClassName() {
|
||||
return (String)tagExtensionField.get(CLASS);
|
||||
}
|
||||
|
||||
// file:
|
||||
public boolean hasFileScope() {
|
||||
return (tagExtensionField.get(FILE) != null);
|
||||
}
|
||||
|
||||
// inherits:
|
||||
public String[] getInherits() {
|
||||
String base = (String)tagExtensionField.get(INHERITS);
|
||||
if (base != null) {
|
||||
StringTokenizer st = new StringTokenizer(base, ",");
|
||||
List list = new ArrayList();
|
||||
while (st.hasMoreTokens()) {
|
||||
list.add(st.nextToken());
|
||||
}
|
||||
return (String[])list.toArray(new String[0]);
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
// access:
|
||||
public int getAccessControl() {
|
||||
String access = (String)tagExtensionField.get(ACCESS);
|
||||
return TagFlags.value(access);
|
||||
}
|
||||
|
||||
public String getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
public static String makeTagLine(ITagEntry tagEntry) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(tagEntry.getTagName());
|
||||
buffer.append("\t");
|
||||
buffer.append(tagEntry.getFileName());
|
||||
buffer.append("\t");
|
||||
String pat = tagEntry.getPattern();
|
||||
if (pat != null) {
|
||||
buffer.append(pat);
|
||||
} else {
|
||||
buffer.append(tagEntry.getLineNumber());
|
||||
}
|
||||
buffer.append(";\"");
|
||||
buffer.append("\t");
|
||||
|
||||
String kind = TagFlags.value(tagEntry.getKind());
|
||||
if (kind != null) {
|
||||
buffer.append(KIND + ":" + tagEntry.getKind());
|
||||
buffer.append("\t");
|
||||
}
|
||||
|
||||
String lang = tagEntry.getLanguage();
|
||||
if (lang != null) {
|
||||
buffer.append(LANGUAGE + ":" + tagEntry.getLanguage());
|
||||
buffer.append("\t");
|
||||
}
|
||||
|
||||
if (tagEntry.hasFileScope()) {
|
||||
buffer.append(FILE + ":");
|
||||
buffer.append("\t");
|
||||
}
|
||||
|
||||
String[] inherits = tagEntry.getInherits();
|
||||
for (int i = 0; i < inherits.length; i++) {
|
||||
if (i == 0) {
|
||||
buffer.append(INHERITS + ":");
|
||||
} else {
|
||||
buffer.append(",");
|
||||
}
|
||||
buffer.append(inherits[i]);
|
||||
}
|
||||
|
||||
String access = TagFlags.value(tagEntry.getAccessControl());
|
||||
if (access != null) {
|
||||
buffer.append(ACCESS + ":" + access);
|
||||
buffer.append("\t");
|
||||
}
|
||||
|
||||
String impl = TagFlags.value(tagEntry.getImplementation());
|
||||
if (impl != null) {
|
||||
buffer.append(IMPLEMENTATION + ":" + impl);
|
||||
buffer.append("\t");
|
||||
}
|
||||
|
||||
String clazz = tagEntry.getClassName();
|
||||
if (clazz != null) {
|
||||
buffer.append(CLASS + ":" + clazz);
|
||||
buffer.append("\t");
|
||||
}
|
||||
return buffer.toString().trim();
|
||||
}
|
||||
|
||||
public void print() {
|
||||
System.out.println("TagName " + getTagName());
|
||||
System.out.println("FileName " + getFileName());
|
||||
System.out.println("Pattern " + getPattern());
|
||||
System.out.println("LineNumber " + getLineNumber());
|
||||
System.out.println("Kind " + getKind());
|
||||
System.out.println("Language " + getLanguage());
|
||||
System.out.println("FileScope " + hasFileScope());
|
||||
String[] inherits = getInherits();
|
||||
for (int i = 0; i < inherits.length; i++) {
|
||||
System.out.println("Inherit " + inherits[i]);
|
||||
}
|
||||
System.out.println("AccessControl " + getAccessControl());
|
||||
System.out.println("Implementation " + getImplementation());
|
||||
System.out.println("ClassName " + getClassName());
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.index.ITagEntry;
|
||||
|
||||
public class CTagsFileReader {
|
||||
String filename = null;
|
||||
List list = null;
|
||||
|
||||
public CTagsFileReader(String name) {
|
||||
filename = name;
|
||||
}
|
||||
|
||||
private void parse(BufferedReader reader) throws IOException {
|
||||
CTagsHeader header = new CTagsHeader();
|
||||
// Skip the header.
|
||||
header.parse(reader);
|
||||
String s;
|
||||
while ((s = reader.readLine()) != null) {
|
||||
ITagEntry entry = new CTagsEntry(s, null);
|
||||
list.add(entry);
|
||||
// System.out.println (entry.getLine() + "\n\n");
|
||||
// entry.print(); System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
public ITagEntry[] getTagEntries() throws IOException {
|
||||
if (list == null) {
|
||||
list = new LinkedList();
|
||||
BufferedReader reader = new BufferedReader(new FileReader(filename));
|
||||
parse(reader);
|
||||
}
|
||||
return (ITagEntry[])list.toArray(new ITagEntry[0]);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
CTagsFileReader tagfile = new CTagsFileReader(args[0]);
|
||||
ITagEntry[] entries = tagfile.getTagEntries();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (entries[i] instanceof CTagsEntry) {
|
||||
CTagsEntry entry = (CTagsEntry)entries[i];
|
||||
System.out.println(entry.getLine() + "\n\n");
|
||||
entry.print();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.eclipse.cdt.core.index.ITagEntry;
|
||||
|
||||
public class CTagsFileWriter {
|
||||
BufferedWriter writer = null;
|
||||
ITagEntry [] entries = null;
|
||||
|
||||
public CTagsFileWriter(String tagfile) throws IOException {
|
||||
writer = new BufferedWriter(new FileWriter(tagfile));
|
||||
}
|
||||
|
||||
public CTagsFileWriter(Writer outfile) {
|
||||
writer = new BufferedWriter(outfile);
|
||||
}
|
||||
|
||||
public void save(ITagEntry[] ent) throws IOException {
|
||||
setTagEntries(ent);
|
||||
save();
|
||||
}
|
||||
|
||||
public void save() throws IOException {
|
||||
if (entries != null) {
|
||||
String header = CTagsHeader.header();
|
||||
writer.write(header, 0, header.length());
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
String entry = entries[i].getLine();
|
||||
writer.write(entry, 0, entry.length());
|
||||
writer.newLine();
|
||||
}
|
||||
writer.flush();
|
||||
entries = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTagEntries(ITagEntry[] ent) {
|
||||
entries = ent;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
CTagsFileReader inFile = new CTagsFileReader(args[0]);
|
||||
ITagEntry[] entries = inFile.getTagEntries();
|
||||
CTagsFileWriter outFile = new CTagsFileWriter(args[0] + ".back");
|
||||
outFile.save(entries);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.BufferedReader;
|
||||
|
||||
|
||||
/* This structure contains information about the tag file. */
|
||||
public class CTagsHeader {
|
||||
|
||||
final static String TAG_FILE_FORMAT =
|
||||
"!_TAG_FILE_FORMAT\t2\t/extended format; --format=1 will not append ;\" to lines/";
|
||||
final static String TAG_FILE_SORTED =
|
||||
"!_TAG_FILE_SORTED\t0\t/0=unsorted, 1=sorted/";
|
||||
final static String TAG_PROGRAM_AUTHOR =
|
||||
"!_TAG_PROGRAM_AUTHOR\tDarren Hiebert\t/dhiebert@users.sourceforge.net/";
|
||||
final static String TAG_PROGRAM_NAME =
|
||||
"!_TAG_PROGRAM_NAME\tExuberant Ctags\t//";
|
||||
final static String TAG_PROGRAM_URL =
|
||||
"!_TAG_PROGRAM_URL\thttp://ctags.sourceforge.net\t/official site/";
|
||||
final static String TAG_PROGRAM_VERSION =
|
||||
"!_TAG_PROGRAM_VERSION\t5.2.3\t//";
|
||||
|
||||
/* information about the structure of the tag file */
|
||||
|
||||
final String TAGS_PREFIX = "!_";
|
||||
|
||||
/* Format of tag file (1 = original, 2 = extended) */
|
||||
String format;
|
||||
|
||||
/* Is the tag file sorted? (0 = unsorted, 1 = sorted) */
|
||||
String sorted;
|
||||
|
||||
/* Information about the program which created this tag file */
|
||||
|
||||
/* Name of author of generating program (may be null) */
|
||||
String author;
|
||||
|
||||
/* Name of program (may be null) */
|
||||
String name;
|
||||
|
||||
/* URL of distribution (may be null) */
|
||||
String url;
|
||||
|
||||
/* program version (may be null) */
|
||||
String version;
|
||||
|
||||
void parse (BufferedReader in) throws IOException {
|
||||
// !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
||||
format = in.readLine();
|
||||
if (format == null || !format.equals(TAG_FILE_FORMAT)) {
|
||||
throw new IOException("Wrong Tag Format Header");
|
||||
}
|
||||
|
||||
// !_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted/
|
||||
sorted = in.readLine();
|
||||
if (sorted == null || !sorted.equals(TAG_FILE_SORTED)) {
|
||||
throw new IOException("Wrong Tag Format Header");
|
||||
}
|
||||
|
||||
// !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
|
||||
author = in.readLine();
|
||||
if (author == null || !author.equals(TAG_PROGRAM_AUTHOR)) {
|
||||
throw new IOException("Wrong Tag Format Header");
|
||||
}
|
||||
|
||||
// !_TAG_PROGRAM_NAME Exuberant Ctags //
|
||||
name = in.readLine();
|
||||
if (name == null || !name.equals(TAG_PROGRAM_NAME)) {
|
||||
throw new IOException("Wrong Tag Format Header");
|
||||
}
|
||||
|
||||
// !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
||||
url = in.readLine();
|
||||
if (url == null || !url.equals(TAG_PROGRAM_URL)) {
|
||||
throw new IOException("Wrong Tag Format Header");
|
||||
}
|
||||
|
||||
// !_TAG_PROGRAM_VERSION 5.2.3 //
|
||||
version = in.readLine();
|
||||
if (version == null || !version.equals(TAG_PROGRAM_VERSION)) {
|
||||
throw new IOException("Wrong Tag Format Header");
|
||||
}
|
||||
}
|
||||
|
||||
public static String header() {
|
||||
return
|
||||
TAG_FILE_FORMAT + "\n" + TAG_FILE_SORTED + "\n" +
|
||||
TAG_PROGRAM_AUTHOR + "\n" + TAG_PROGRAM_NAME + "\n" +
|
||||
TAG_PROGRAM_URL + "\n" + TAG_PROGRAM_VERSION + "\n";
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
import org.eclipse.cdt.core.index.ITagEntry;
|
||||
|
||||
public class CTagsRunner implements Runnable {
|
||||
|
||||
IndexManager manager;
|
||||
|
||||
public CTagsRunner(IndexManager indexManager) {
|
||||
manager = indexManager;
|
||||
}
|
||||
|
||||
public void run () {
|
||||
// It should be ok since we are being started on startup
|
||||
// the delay should allow things to settle down.
|
||||
manager.delay();
|
||||
while (true) {
|
||||
IResource resource = null;
|
||||
RequestList requestList = manager.getRequestList();
|
||||
try {
|
||||
resource = requestList.removeItem();
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
if (resource != null) {
|
||||
switch (resource.getType()) {
|
||||
case IResource.FILE:
|
||||
IProject project = resource.getProject();
|
||||
Map projectsMap = manager.getProjectsMap();
|
||||
Map filesMap = (Map)projectsMap.get(project.getLocation());
|
||||
if (filesMap == null) {
|
||||
filesMap = Collections.synchronizedMap(new HashMap());
|
||||
projectsMap.put(project.getLocation(), filesMap);
|
||||
}
|
||||
|
||||
try {
|
||||
CTagsCmd cmd = new CTagsCmd();
|
||||
IFile file = (IFile)resource;
|
||||
IPath path = file.getLocation();
|
||||
if (path != null) {
|
||||
ITagEntry[] entries = cmd.getTagEntries(file, path.toOSString());
|
||||
filesMap.put(resource.getLocation(), entries);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
//System.out.println("indexing " + resource.getName());
|
||||
break;
|
||||
|
||||
case IResource.FOLDER:
|
||||
case IResource.PROJECT:
|
||||
System.out.println("Can not index folders " + resource.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
//System.out.println("Indexing " + filename);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,309 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright IBM Corp. 2000, 2001.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.index.ITagEntry;
|
||||
import org.eclipse.cdt.core.index.IndexModel;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
public class IndexManager implements IElementChangedListener {
|
||||
|
||||
RequestList requestList = null;
|
||||
Thread thread = null;
|
||||
Map projectsMap = null;
|
||||
|
||||
private static IndexManager indexManager = null;
|
||||
|
||||
private IndexManager() {
|
||||
}
|
||||
|
||||
public ITagEntry[] query(IProject project, String pattern, boolean ignoreCase, boolean exactMatch) {
|
||||
Map filesMap = (Map)projectsMap.get(project.getLocation());
|
||||
// try to kick start.
|
||||
if (filesMap == null) {
|
||||
addContainer(project);
|
||||
}
|
||||
List result = new ArrayList();
|
||||
filesMap = (Map)projectsMap.get(project.getLocation());
|
||||
if (filesMap != null) {
|
||||
if (pattern == null)
|
||||
pattern = "*"; //FIXME: is this right null matching all?
|
||||
// Compile the pattern
|
||||
StringMatcher matcher = new StringMatcher(pattern, ignoreCase, exactMatch);
|
||||
Iterator values = filesMap.values().iterator();
|
||||
while (values.hasNext()) {
|
||||
ITagEntry[] entries = (ITagEntry[])values.next();
|
||||
for (int j = 0; j < entries.length; j++) {
|
||||
String tagName = entries[j].getTagName();
|
||||
if (tagName != null && matcher.match(tagName)) {
|
||||
result.add(entries[j]);
|
||||
}
|
||||
//if (tagName != null && (pattern == null || tagName.equals(pattern))) {
|
||||
// result.add(entries[j]);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ITagEntry[])result.toArray(new ITagEntry[0]);
|
||||
}
|
||||
|
||||
protected RequestList getRequestList() {
|
||||
return requestList;
|
||||
}
|
||||
|
||||
protected Map getProjectsMap() {
|
||||
return projectsMap;
|
||||
}
|
||||
|
||||
public void startup () {
|
||||
requestList = new RequestList();
|
||||
projectsMap = Collections.synchronizedMap(new HashMap());
|
||||
CTagsRunner ctags = new CTagsRunner(this);
|
||||
thread = new Thread(ctags, "C Tags indexer");
|
||||
thread.setDaemon(true);
|
||||
thread.setPriority (Thread.NORM_PRIORITY - 1);
|
||||
thread.start();
|
||||
addAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Before processing all jobs, need to ensure that the indexes are up to date.
|
||||
*/
|
||||
protected void delay() {
|
||||
try {
|
||||
// wait 10 seconds so as not to interfere with plugin startup
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* About to delete a project.
|
||||
*/
|
||||
public void removeResource(IResource resource) {
|
||||
Map filesMap = (Map)projectsMap.get(resource.getProject().getLocation());
|
||||
if (filesMap == null)
|
||||
return;
|
||||
|
||||
clearRequestList(resource);
|
||||
switch (resource.getType()) {
|
||||
case IResource.ROOT:
|
||||
// PROBLEM?
|
||||
break;
|
||||
|
||||
case IResource.PROJECT:
|
||||
projectsMap.remove(resource.getLocation());
|
||||
// FALL_THROUGHT
|
||||
|
||||
case IResource.FOLDER:
|
||||
removeContainer((IContainer)resource);
|
||||
break;
|
||||
|
||||
case IResource.FILE:
|
||||
removeFile((IFile)resource);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeContainer(IContainer container) {
|
||||
Map filesMap = (Map)projectsMap.get(container.getProject().getLocation());
|
||||
if (filesMap == null)
|
||||
return;
|
||||
|
||||
IPath folderPath = container.getLocation();
|
||||
if (filesMap != null) {
|
||||
Iterator keys = filesMap.keySet().iterator();
|
||||
while (keys.hasNext()) {
|
||||
IPath p = (IPath)keys.next();
|
||||
if (p != null && folderPath.isPrefixOf(p)) {
|
||||
//System.out.println("Removing [" + folderPath + "] " + p);
|
||||
filesMap.remove(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFile(IFile file) {
|
||||
Map filesMap = (Map)projectsMap.get(file.getProject().getLocation());
|
||||
if (filesMap != null) {
|
||||
filesMap.remove(file.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
public void clearRequestList(IResource resource) {
|
||||
if (resource instanceof IFile) {
|
||||
if (requestList != null) {
|
||||
requestList.removeItem(resource);
|
||||
}
|
||||
} else if (resource instanceof IContainer) {
|
||||
try {
|
||||
IContainer container = (IContainer)resource;
|
||||
IResource[] resources = container.members(false);
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
clearRequestList(resources[i]);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addResource(IResource resource) {
|
||||
switch (resource.getType()) {
|
||||
case IResource.ROOT:
|
||||
case IResource.PROJECT:
|
||||
case IResource.FOLDER:
|
||||
addContainer((IContainer)resource);
|
||||
break;
|
||||
|
||||
case IResource.FILE:
|
||||
addFile((IFile)resource);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger addition of a resource to an index
|
||||
* Note: the actual operation is performed in background
|
||||
*/
|
||||
public void addFile(IFile file) {
|
||||
if (CoreModel.getDefault().isTranslationUnit(file) &&
|
||||
IndexModel.getDefault().isEnabled(file.getProject())) {
|
||||
if (requestList != null) {
|
||||
requestList.addItem(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger addition of the entire content of a project
|
||||
* Note: the actual operation is performed in background
|
||||
*/
|
||||
public void addContainer(IContainer container) {
|
||||
if (container != null && container.exists()) {
|
||||
try {
|
||||
IResource[] resources = container.members(false);
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
IResource res = resources[i];
|
||||
switch(res.getType()) {
|
||||
case IResource.ROOT:
|
||||
break;
|
||||
|
||||
case IResource.PROJECT:
|
||||
if (CoreModel.getDefault().hasCNature((IProject)res) &&
|
||||
IndexModel.getDefault().isEnabled((IProject)res)) {
|
||||
addContainer((IContainer)res);
|
||||
}
|
||||
break;
|
||||
|
||||
case IResource.FOLDER:
|
||||
addContainer((IContainer)res);
|
||||
break;
|
||||
|
||||
case IResource.FILE:
|
||||
addFile((IFile)res);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addAll() {
|
||||
addResource(ResourcesPlugin.getWorkspace().getRoot());
|
||||
}
|
||||
|
||||
public void saveIndexes() {
|
||||
}
|
||||
|
||||
public void saveIndex(IProject project) {
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
if (thread != null)
|
||||
thread.interrupt();
|
||||
CoreModel.getDefault().removeElementChangedListener(this);
|
||||
}
|
||||
|
||||
public static IndexManager getDefault() {
|
||||
if (indexManager == null) {
|
||||
indexManager = new IndexManager();
|
||||
// Register to the C Core Model for C specific changes.
|
||||
CoreModel.getDefault().addElementChangedListener(indexManager);
|
||||
}
|
||||
return indexManager;
|
||||
}
|
||||
|
||||
protected void processDelta(ICElementDelta delta) throws CModelException {
|
||||
int kind= delta.getKind();
|
||||
int flags= delta.getFlags();
|
||||
ICElement element= delta.getElement();
|
||||
|
||||
//System.out.println("Index Processing Delta " + element);
|
||||
// handle open and closing of a solution or project
|
||||
if (((flags & ICElementDelta.F_CLOSED) != 0)
|
||||
|| ((flags & ICElementDelta.F_OPENED) != 0)) {
|
||||
}
|
||||
|
||||
if (kind == ICElementDelta.REMOVED) {
|
||||
IResource resource = element.getResource();
|
||||
removeResource(resource);
|
||||
}
|
||||
|
||||
// if (kind == ICElementDelta.ADDED) {
|
||||
// try {
|
||||
// IResource resource = ((ICResource)element).getResource();
|
||||
// addResource(resource);
|
||||
// } catch (CModelException e) {
|
||||
// }
|
||||
// }
|
||||
|
||||
if (element instanceof ITranslationUnit) {
|
||||
if (kind == ICElementDelta.CHANGED) {
|
||||
IResource resource = element.getResource();
|
||||
addResource(resource);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ICElementDelta[] affectedChildren= delta.getAffectedChildren();
|
||||
for (int i= 0; i < affectedChildren.length; i++) {
|
||||
processDelta(affectedChildren[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Cdoc)
|
||||
* Method declared on IElementChangedListener.
|
||||
*/
|
||||
public void elementChanged(final ElementChangedEvent event) {
|
||||
try {
|
||||
processDelta(event.getDelta());
|
||||
} catch(CModelException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.eclipse.core.resources.*;
|
||||
|
||||
public class RequestList {
|
||||
|
||||
private List list;
|
||||
|
||||
public RequestList() {
|
||||
list = Collections.synchronizedList(new LinkedList());
|
||||
}
|
||||
|
||||
public IResource removeItem() throws InterruptedException {
|
||||
//print("in removeItem() - entering");
|
||||
synchronized (list) {
|
||||
while (list.isEmpty()) {
|
||||
//print("in removeItem() - about to wait()");
|
||||
list.wait();
|
||||
//print("in removeItem() - done with wait()");
|
||||
}
|
||||
|
||||
// extract the new first item
|
||||
IResource item = (IResource)list.remove(0);
|
||||
|
||||
//print("in removeItem() - leaving");
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeItem(Object key) {
|
||||
return list.remove(key);
|
||||
}
|
||||
|
||||
public void addItem(IResource item) {
|
||||
//print("in addItem() - entering");
|
||||
synchronized (list) {
|
||||
// There will always be room to add to this List
|
||||
// because it expands as needed.
|
||||
list.add(item);
|
||||
//print("in addItem - just added: '" + item + "'");
|
||||
|
||||
// After adding, notify any and all waiting
|
||||
// threads that the list has changed.
|
||||
list.notifyAll();
|
||||
//print("in addItem() - just notified");
|
||||
}
|
||||
//print("in addItem() - leaving");
|
||||
}
|
||||
|
||||
// private static void print(String msg) {
|
||||
// String name = Thread.currentThread().getName();
|
||||
// System.out.println(name + ": " + msg);
|
||||
// }
|
||||
}
|
|
@ -76,10 +76,10 @@ public class IndexAllProject extends IndexRequest {
|
|||
indexedFileNames.put(results[i].getPath(), DELETED);
|
||||
final long indexLastModified = max == 0 ? 0L : index.getIndexFile().lastModified();
|
||||
|
||||
CModel model = (CModel) CModelManager.getDefault().getCModel();
|
||||
ICProject cProject = model.getCProject(project.getName());
|
||||
ICElement[] kids = cProject.getChildren();
|
||||
IPath cProjectPath = cProject.getPath();
|
||||
// CModel model = (CModel) CModelManager.getDefault().getCModel();
|
||||
// ICProject cProject = model.getCProject(project.getName());
|
||||
// ICElement[] kids = cProject.getChildren();
|
||||
IPath cProjectPath = project.getFullPath();
|
||||
|
||||
IWorkspaceRoot root = this.project.getWorkspace().getRoot();
|
||||
IResource sourceFolder = root.findMember(cProjectPath);
|
||||
|
|
|
@ -107,11 +107,11 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
|||
public void addSource(IFile resource, IPath indexedContainer){
|
||||
|
||||
/******
|
||||
*TODO: Remove these methods once the new indexer is
|
||||
*TODO: BOG Remove these methods once the new indexer is
|
||||
*fully integrated
|
||||
*/
|
||||
IProject project= resource.getProject();
|
||||
if (!isEnabled(project)) return;
|
||||
// IProject project= resource.getProject();
|
||||
// if (!isEnabled(project)) return;
|
||||
|
||||
if (CCorePlugin.getDefault() == null) return;
|
||||
AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, indexedContainer, this);
|
||||
|
@ -242,10 +242,10 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
|||
if (CCorePlugin.getDefault() == null) return;
|
||||
|
||||
/******
|
||||
*TODO: Remove these methods once the new indexer is
|
||||
*TODO: BOG Remove these methods once the new indexer is
|
||||
*fully integrated
|
||||
*/
|
||||
if (!isEnabled(project)) return;
|
||||
// if (!isEnabled(project)) return;
|
||||
|
||||
// check if the same request is not already in the queue
|
||||
IndexRequest request = new IndexAllProject(project, this);
|
||||
|
@ -259,10 +259,10 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
|||
public void indexSourceFolder(CProject javaProject, IPath sourceFolder, final char[][] exclusionPattern) {
|
||||
IProject project = javaProject.getProject();
|
||||
/******
|
||||
*TODO: Remove these methods once the new indexer is
|
||||
*TODO: BOG Remove these methods once the new indexer is
|
||||
*fully integrated
|
||||
*/
|
||||
if (!isEnabled(project)) return;
|
||||
// if (!isEnabled(project)) return;
|
||||
|
||||
if (this.jobEnd > this.jobStart) {
|
||||
// check if a job to index the project is not already in the queue
|
||||
|
@ -321,10 +321,10 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
|||
if (target instanceof IProject) {
|
||||
IProject p = (IProject) target;
|
||||
/******
|
||||
*TODO: Remove these methods once the new indexer is
|
||||
*TODO: BOG Remove these methods once the new indexer is
|
||||
*fully integrated
|
||||
*/
|
||||
if (!isEnabled(p)) return;
|
||||
// if (!isEnabled(p)) return;
|
||||
|
||||
//if (JavaProject.hasJavaNature(p))
|
||||
request = new IndexAllProject(p, this);
|
||||
|
@ -410,10 +410,10 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
|||
public void removeSourceFolderFromIndex(CProject javaProject, IPath sourceFolder, char[][] exclusionPatterns) {
|
||||
IProject project = javaProject.getProject();
|
||||
/******
|
||||
*TODO: Remove these methods once the new indexer is
|
||||
*TODO: BOG Remove these methods once the new indexer is
|
||||
*fully integrated
|
||||
*/
|
||||
if (!isEnabled(project)) return;
|
||||
// if (!isEnabled(project)) return;
|
||||
|
||||
if (this.jobEnd > this.jobStart) {
|
||||
// check if a job to index the project is not already in the queue
|
||||
|
@ -599,43 +599,43 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
|||
}
|
||||
|
||||
/*************
|
||||
*TODO: Remove these methods once the new indexer is
|
||||
*TODO: BOG Remove these methods once the new indexer is
|
||||
*fully integrated
|
||||
* START OF TEMP INDEXER ENABLE SECTION
|
||||
*/
|
||||
final static String INDEX_MODEL_ID = CCorePlugin.PLUGIN_ID + ".newindexmodel";
|
||||
final static String ACTIVATION = "enable";
|
||||
|
||||
static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
|
||||
|
||||
public boolean isEnabled(IProject project) {
|
||||
String prop = null;
|
||||
try {
|
||||
if (project != null) {
|
||||
prop = project.getPersistentProperty(activationKey);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return ((prop != null) && prop.equalsIgnoreCase("true"));
|
||||
}
|
||||
|
||||
public void setEnabled(IProject project, boolean on) {
|
||||
try {
|
||||
if (project != null) {
|
||||
Boolean newValue = new Boolean(on);
|
||||
Boolean oldValue = new Boolean(isEnabled(project));
|
||||
if (!oldValue.equals(newValue)) {
|
||||
project.setPersistentProperty(activationKey, newValue.toString());
|
||||
if (on) {
|
||||
indexAll(project);
|
||||
} else {
|
||||
//remove(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
// final static String INDEX_MODEL_ID = CCorePlugin.PLUGIN_ID + ".newindexmodel";
|
||||
// final static String ACTIVATION = "enable";
|
||||
//
|
||||
// static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
|
||||
//
|
||||
// public boolean isEnabled(IProject project) {
|
||||
// String prop = null;
|
||||
// try {
|
||||
// if (project != null) {
|
||||
// prop = project.getPersistentProperty(activationKey);
|
||||
// }
|
||||
// } catch (CoreException e) {
|
||||
// }
|
||||
// return ((prop != null) && prop.equalsIgnoreCase("true"));
|
||||
// }
|
||||
//
|
||||
// public void setEnabled(IProject project, boolean on) {
|
||||
// try {
|
||||
// if (project != null) {
|
||||
// Boolean newValue = new Boolean(on);
|
||||
// Boolean oldValue = new Boolean(isEnabled(project));
|
||||
// if (!oldValue.equals(newValue)) {
|
||||
// project.setPersistentProperty(activationKey, newValue.toString());
|
||||
// if (on) {
|
||||
// indexAll(project);
|
||||
// } else {
|
||||
// //remove(project);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (CoreException e) {
|
||||
// }
|
||||
// }
|
||||
|
||||
/************
|
||||
* END OF TEMP INDEXER ENABLE SECTION
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Map;
|
|||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.cdt.core.index.IndexModel;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.resources.IConsole;
|
||||
|
@ -122,7 +121,6 @@ public class CCorePlugin extends Plugin {
|
|||
|
||||
private CDescriptorManager fDescriptorManager;
|
||||
private CoreModel fCoreModel;
|
||||
private IndexModel fIndexModel;
|
||||
|
||||
// -------- static methods --------
|
||||
|
||||
|
@ -210,9 +208,7 @@ public class CCorePlugin extends Plugin {
|
|||
if (fDescriptorManager != null) {
|
||||
fDescriptorManager.shutdown();
|
||||
}
|
||||
if (fIndexModel != null) {
|
||||
fIndexModel.shutdown();
|
||||
}
|
||||
|
||||
if (fCoreModel != null) {
|
||||
fCoreModel.shutdown();
|
||||
}
|
||||
|
@ -231,11 +227,7 @@ public class CCorePlugin extends Plugin {
|
|||
fCoreModel = CoreModel.getDefault();
|
||||
fCoreModel.startup();
|
||||
|
||||
// Fired up the indexer. It should delay itself for 10 seconds
|
||||
fIndexModel = IndexModel.getDefault();
|
||||
fIndexModel.startup();
|
||||
|
||||
//Fired up the new indexer
|
||||
//Fired up the indexer
|
||||
fCoreModel.startIndexing();
|
||||
|
||||
//Fire up dependency manager
|
||||
|
@ -517,10 +509,6 @@ public class CCorePlugin extends Plugin {
|
|||
return fCoreModel;
|
||||
}
|
||||
|
||||
public IndexModel getIndexModel() {
|
||||
return fIndexModel;
|
||||
}
|
||||
|
||||
public ICDescriptor getCProjectDescription(IProject project) throws CoreException {
|
||||
return fDescriptorManager.getDescriptor(project);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,27 @@
|
|||
<<<<<<< ChangeLog
|
||||
<<<<<<< ChangeLog
|
||||
2003-09-19 Hoda Amer
|
||||
2003-09-22 Bogdan Gheorghe
|
||||
Got rid of the C/C++ Project property page (only the indexer tab
|
||||
was left). Here are the changes:
|
||||
|
||||
Modified:
|
||||
* plugin.xml
|
||||
* org.eclipse.cdt.internal.ui.text.CCompletionProcessor
|
||||
* org.eclipse.cdt.internal.ui.editor.DefaultCEditorTextHover
|
||||
|
||||
Deleted:
|
||||
* org.eclipse.cdt.ui.wizards.IndexerBlock
|
||||
|
||||
Slated for deletion before 1.2 GA:
|
||||
* org.eclipse.cdt.internal.ui.preferences.CProjectPropertyPage
|
||||
* org.eclipse.cdt.internal.ui.preferences.CProjectOptionBlock
|
||||
* org.eclipse.cdt.ui.dialogs.IndexerBlock
|
||||
|
||||
2003-09-22 Hoda Amer
|
||||
Solutions to
|
||||
bug#43162 : Code Assist not showing the right return value
|
||||
Bug#43145 : foo function still showing in Code Assist even if "f" is deleted
|
||||
Bug#42810 : Code Assist adding characters after pressing <enter>
|
||||
Bug#42861 : Code Assist should be case insensitive.
|
||||
|
||||
=======
|
||||
=======
|
||||
2003-09-22 Andrew Niefer
|
||||
fix for bug 43327 Code Complete finds local variables
|
||||
- update calls to SearchEngine.search. CodeCompletion passes true for excludeLocalDeclarations
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
<extension-point id="CElementFilters" name="%elementFiltersName"/>
|
||||
<extension-point id="BinaryParserPage" name="Binary Parser Page"/>
|
||||
<!-- =========================================================================== -->
|
||||
<!-- Extension point: org.eclipse.cdt.ui.textHovers -->
|
||||
<!-- Purpose: Provide a perspective specific text hovering for CEditor files -->
|
||||
<!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover -->
|
||||
<!-- Purpose: Provide a perspective specific text hovering for CEditor files -->
|
||||
<!-- Extension point: org.eclipse.cdt.ui.textHovers -->
|
||||
<!-- =========================================================================== -->
|
||||
<extension-point id="textHovers" name="%textHoversName"/>
|
||||
|
||||
|
@ -130,8 +130,8 @@
|
|||
id="org.eclipse.cdt.ui.CView">
|
||||
</view>
|
||||
</extension>
|
||||
<!-- For C Wizards -->
|
||||
<!-- The wizards -->
|
||||
<!-- For C Wizards -->
|
||||
<extension
|
||||
point="org.eclipse.ui.newWizards">
|
||||
<category
|
||||
|
@ -235,40 +235,6 @@
|
|||
class="org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage"
|
||||
id="org.eclipse.cdt.ui.preferneces.CBuildConsolePreferernces">
|
||||
</page>
|
||||
<!-- This code is disable for CDT-1.2: Alain
|
||||
<page
|
||||
name="%todoTaskPrefName"
|
||||
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
||||
class="org.eclipse.cdt.internal.ui.preferences.TodoTaskPreferencePage"
|
||||
id="org.eclipse.cdt.ui.preferences.TodoTaskPreferencePage">
|
||||
</page>
|
||||
-->
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.propertyPages">
|
||||
<page
|
||||
objectClass="org.eclipse.core.resources.IProject"
|
||||
adaptable="true"
|
||||
name="%CProjectPropertyPage.name"
|
||||
class="org.eclipse.cdt.internal.ui.preferences.CProjectPropertyPage"
|
||||
id="org.eclipse.cdt.ui.preferences.CProjectPropertyPage">
|
||||
<filter
|
||||
name="nature"
|
||||
value="org.eclipse.cdt.core.cnature">
|
||||
</filter>
|
||||
</page>
|
||||
<!-- This code is disable for CDT-1.2, does not work correctly: Alain
|
||||
<page
|
||||
objectClass="org.eclipse.core.resources.IProject"
|
||||
name="%todoPageName"
|
||||
class="org.eclipse.cdt.internal.ui.preferences.TodoTaskPropertyPage"
|
||||
id="org.eclipse.cdt.ui.propertyPages.TodoTaskPropertyPage">
|
||||
<filter
|
||||
name="nature"
|
||||
value="org.eclipse.cdt.core.cnature">
|
||||
</filter>
|
||||
</page>
|
||||
-->
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.editorActions">
|
||||
|
|
|
@ -18,9 +18,7 @@ import org.eclipse.ui.IEditorInput;
|
|||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
|
||||
import org.eclipse.cdt.core.index.ITagEntry;
|
||||
import org.eclipse.cdt.core.index.IndexModel;
|
||||
import org.eclipse.cdt.core.index.TagFlags;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
|
||||
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
||||
import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
|
||||
|
@ -43,88 +41,88 @@ public class DefaultCEditorTextHover implements ITextHover
|
|||
*/
|
||||
public String getHoverInfo( ITextViewer viewer, IRegion region )
|
||||
{
|
||||
String expression = null;
|
||||
|
||||
if(fEditor == null)
|
||||
return null;
|
||||
try
|
||||
{
|
||||
expression = viewer.getDocument().get( region.getOffset(), region.getLength() );
|
||||
expression = expression.trim();
|
||||
if ( expression.length() == 0 )
|
||||
return null;
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
// We are just doing some C, call the Help to get info
|
||||
|
||||
IFunctionSummary fs = CCompletionContributorManager.getDefault().getFunctionInfo(expression);
|
||||
if(fs != null) {
|
||||
buffer.append("<b>");
|
||||
buffer.append(HTMLPrinter.convertToHTMLContent(fs.getName()));
|
||||
buffer.append("()</b>");
|
||||
buffer.append(HTMLPrinter.convertToHTMLContent(fs.getPrototype().getPrototypeString(false)));
|
||||
if(fs.getDescription() != null) {
|
||||
buffer.append("<br><br>");
|
||||
buffer.append(HTMLPrinter.convertToHTMLContent(fs.getDescription()));
|
||||
}
|
||||
int i;
|
||||
for(i = 0; i < buffer.length(); i++) {
|
||||
if(buffer.charAt(i) == '\\') {
|
||||
if((i + 1 < buffer.length()) && buffer.charAt(i+1) == 'n') {
|
||||
buffer.replace(i, i + 2, "<br>");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Query the C model
|
||||
IndexModel model = IndexModel.getDefault();
|
||||
IEditorInput input = fEditor.getEditorInput();
|
||||
if(input instanceof IFileEditorInput) {
|
||||
IProject project = ((IFileEditorInput)input).getFile().getProject();
|
||||
|
||||
// Bail out quickly, if the project was deleted.
|
||||
if (!project.exists())
|
||||
throw new CoreException(new Status(0, "", 0, "", null));
|
||||
|
||||
IProject[] refs = project.getReferencedProjects();
|
||||
|
||||
ITagEntry[] tags= model.query(project, expression, false, true);
|
||||
|
||||
if(tags == null || tags.length == 0) {
|
||||
for ( int j= 0; j < refs.length; j++ ) {
|
||||
if (!refs[j].exists())
|
||||
continue;
|
||||
tags= model.query(refs[j], expression, false, true);
|
||||
if(tags != null && tags.length > 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(tags != null && tags.length > 0) {
|
||||
ITagEntry selectedTag = selectTag(tags);
|
||||
// Show only the first element
|
||||
buffer.append("<b> " + TagFlags.value(selectedTag.getKind()) + " " + HTMLPrinter.convertToHTMLContent(expression) +
|
||||
"</b> - " + selectedTag.getIFile().getFullPath().toString() + "[" + selectedTag.getLineNumber()+"]" );
|
||||
// Now add the pattern
|
||||
buffer.append("<br><br>" + HTMLPrinter.convertToHTMLContent(selectedTag.getPattern()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buffer.length() > 0) {
|
||||
HTMLPrinter.insertPageProlog(buffer, 0);
|
||||
HTMLPrinter.addPageEpilog(buffer);
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
catch( BadLocationException x )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
catch( CoreException x )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
// String expression = null;
|
||||
//
|
||||
// if(fEditor == null)
|
||||
// return null;
|
||||
// try
|
||||
// {
|
||||
// expression = viewer.getDocument().get( region.getOffset(), region.getLength() );
|
||||
// expression = expression.trim();
|
||||
// if ( expression.length() == 0 )
|
||||
// return null;
|
||||
//
|
||||
// StringBuffer buffer = new StringBuffer();
|
||||
//
|
||||
// // We are just doing some C, call the Help to get info
|
||||
//
|
||||
// IFunctionSummary fs = CCompletionContributorManager.getDefault().getFunctionInfo(expression);
|
||||
// if(fs != null) {
|
||||
// buffer.append("<b>");
|
||||
// buffer.append(HTMLPrinter.convertToHTMLContent(fs.getName()));
|
||||
// buffer.append("()</b>");
|
||||
// buffer.append(HTMLPrinter.convertToHTMLContent(fs.getPrototype().getPrototypeString(false)));
|
||||
// if(fs.getDescription() != null) {
|
||||
// buffer.append("<br><br>");
|
||||
// buffer.append(HTMLPrinter.convertToHTMLContent(fs.getDescription()));
|
||||
// }
|
||||
// int i;
|
||||
// for(i = 0; i < buffer.length(); i++) {
|
||||
// if(buffer.charAt(i) == '\\') {
|
||||
// if((i + 1 < buffer.length()) && buffer.charAt(i+1) == 'n') {
|
||||
// buffer.replace(i, i + 2, "<br>");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // Query the C model
|
||||
// IndexModel model = IndexModel.getDefault();
|
||||
// IEditorInput input = fEditor.getEditorInput();
|
||||
// if(input instanceof IFileEditorInput) {
|
||||
// IProject project = ((IFileEditorInput)input).getFile().getProject();
|
||||
//
|
||||
// // Bail out quickly, if the project was deleted.
|
||||
// if (!project.exists())
|
||||
// throw new CoreException(new Status(0, "", 0, "", null));
|
||||
//
|
||||
// IProject[] refs = project.getReferencedProjects();
|
||||
//
|
||||
// ITagEntry[] tags= model.query(project, expression, false, true);
|
||||
//
|
||||
// if(tags == null || tags.length == 0) {
|
||||
// for ( int j= 0; j < refs.length; j++ ) {
|
||||
// if (!refs[j].exists())
|
||||
// continue;
|
||||
// tags= model.query(refs[j], expression, false, true);
|
||||
// if(tags != null && tags.length > 0)
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(tags != null && tags.length > 0) {
|
||||
// ITagEntry selectedTag = selectTag(tags);
|
||||
// // Show only the first element
|
||||
// buffer.append("<b> " + TagFlags.value(selectedTag.getKind()) + " " + HTMLPrinter.convertToHTMLContent(expression) +
|
||||
// "</b> - " + selectedTag.getIFile().getFullPath().toString() + "[" + selectedTag.getLineNumber()+"]" );
|
||||
// // Now add the pattern
|
||||
// buffer.append("<br><br>" + HTMLPrinter.convertToHTMLContent(selectedTag.getPattern()));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (buffer.length() > 0) {
|
||||
// HTMLPrinter.insertPageProlog(buffer, 0);
|
||||
// HTMLPrinter.addPageEpilog(buffer);
|
||||
// return buffer.toString();
|
||||
// }
|
||||
// }
|
||||
// catch( BadLocationException x )
|
||||
// {
|
||||
// // ignore
|
||||
// }
|
||||
// catch( CoreException x )
|
||||
// {
|
||||
// // ignore
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -144,20 +142,5 @@ public class DefaultCEditorTextHover implements ITextHover
|
|||
return null;
|
||||
}
|
||||
|
||||
private ITagEntry selectTag(ITagEntry[] tags) {
|
||||
// Rules are to return a function prototype/declaration, and if
|
||||
// not found first entry
|
||||
for(int i = 0; i < tags.length; i++) {
|
||||
if(tags[i].getKind() == TagFlags.T_PROTOTYPE) {
|
||||
return tags[i];
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < tags.length; i++) {
|
||||
if(tags[i].getKind() == TagFlags.T_FUNCTION) {
|
||||
return tags[i];
|
||||
}
|
||||
}
|
||||
return tags[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ package org.eclipse.cdt.internal.ui.preferences;
|
|||
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||
import org.eclipse.cdt.ui.dialogs.IndexerBlock;
|
||||
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
|
||||
|
||||
//TODO: BOG UI Get rid before final 1.2
|
||||
public class CProjectOptionBlock extends TabFolderOptionBlock {
|
||||
|
||||
public CProjectOptionBlock(ICOptionContainer parent) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.swt.widgets.Label;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
|
||||
import org.eclipse.ui.dialogs.PropertyPage;
|
||||
|
||||
//TODO: BOG UI Get rid before final 1.2
|
||||
public class CProjectPropertyPage extends PropertyPage implements ICOptionContainer {
|
||||
|
||||
private CProjectOptionBlock fOptionBlock;
|
||||
|
|
|
@ -601,4 +601,5 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
proposal.setAdditionalProposalInfo(infoString.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ package org.eclipse.cdt.ui.dialogs;
|
|||
***********************************************************************/
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.index.IndexModel;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
@ -22,13 +21,12 @@ import org.eclipse.swt.SWT;
|
|||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
//TODO: BOG UI Get rid before final 1.2
|
||||
public class IndexerBlock extends AbstractCOptionPage {
|
||||
private static final String PREFIX = "IndexerBlock"; // $NON-NLS-1$
|
||||
private static final String LABEL = PREFIX + ".label"; // $NON-NLS-1$
|
||||
private static final String DESC = PREFIX + ".desc"; // $NON-NLS-1$
|
||||
|
||||
private Button indexerSwitch;
|
||||
private Button indexerSwitch2;
|
||||
private Button dTreeSwitch;
|
||||
|
||||
|
@ -43,10 +41,6 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
grid.numColumns = 1;
|
||||
composite.setLayout(grid);
|
||||
|
||||
indexerSwitch = new Button(composite, SWT.CHECK | SWT.RIGHT);
|
||||
indexerSwitch.setAlignment(SWT.LEFT);
|
||||
indexerSwitch.setText("Enable CTAGS indexing service for this project");
|
||||
|
||||
indexerSwitch2 = new Button(composite, SWT.CHECK | SWT.RIGHT);
|
||||
indexerSwitch2.setAlignment(SWT.LEFT);
|
||||
indexerSwitch2.setText("Enable NEW indexing service for this project");
|
||||
|
@ -57,23 +51,18 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
|
||||
IProject project = getContainer().getProject();
|
||||
if (project != null) {
|
||||
IndexModel indexer = CCorePlugin.getDefault().getIndexModel();
|
||||
IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
if (indexerSwitch != null) {
|
||||
//indexerSwitch.setAlignment(SWT.LEFT);
|
||||
//indexerSwitch.setText("Enable indexing service for this project");
|
||||
indexerSwitch.setSelection(indexer.isEnabled(project));
|
||||
}
|
||||
|
||||
// IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
//
|
||||
// if (indexerSwitch2 != null) {
|
||||
// indexerSwitch2.setSelection(newIndexer.isEnabled(project));
|
||||
// }
|
||||
|
||||
if (indexerSwitch2 != null) {
|
||||
indexerSwitch2.setSelection(newIndexer.isEnabled(project));
|
||||
}
|
||||
|
||||
DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
|
||||
|
||||
if (dTreeSwitch != null) {
|
||||
dTreeSwitch.setSelection(depManager.isEnabled(project));
|
||||
}
|
||||
// DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
|
||||
//
|
||||
// if (dTreeSwitch != null) {
|
||||
// dTreeSwitch.setSelection(depManager.isEnabled(project));
|
||||
// }
|
||||
}
|
||||
setControl(composite);
|
||||
}
|
||||
|
@ -81,20 +70,16 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||
IProject project = getContainer().getProject();
|
||||
if (project != null) {
|
||||
IndexModel indexer = CCorePlugin.getDefault().getIndexModel();
|
||||
indexer.setEnabled(project, indexerSwitch.getSelection());
|
||||
// IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
// newIndexer.setEnabled(project, indexerSwitch2.getSelection());
|
||||
|
||||
IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
newIndexer.setEnabled(project, indexerSwitch2.getSelection());
|
||||
|
||||
DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
|
||||
depManager.setEnabled(project, dTreeSwitch.getSelection());
|
||||
// DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
|
||||
// depManager.setEnabled(project, dTreeSwitch.getSelection());
|
||||
}
|
||||
}
|
||||
|
||||
public void performDefaults() {
|
||||
if (getContainer().getProject() != null) {
|
||||
indexerSwitch.setSelection(false);
|
||||
indexerSwitch2.setSelection(false);
|
||||
dTreeSwitch.setSelection(false);
|
||||
}
|
||||
|
|
|
@ -1,128 +0,0 @@
|
|||
package org.eclipse.cdt.ui.wizards;
|
||||
|
||||
/*
|
||||
* (c) Copyright IBM Corp. 2000, 2001.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.index.IndexModel;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.core.sourcedependency.DependencyManager;
|
||||
import org.eclipse.cdt.utils.ui.swt.IValidation;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
public class IndexerBlock implements IWizardTab {
|
||||
private Button indexerSwitch;
|
||||
private Button indexerSwitch2;
|
||||
private Button dTreeSwitch;
|
||||
IProject project;
|
||||
IValidation page;
|
||||
|
||||
public IndexerBlock(IValidation valid, IProject p) {
|
||||
page = valid;
|
||||
project = p;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#getControl(Composite)
|
||||
*/
|
||||
public Composite getControl(Composite parent) {
|
||||
Composite composite= new Composite(parent, SWT.NONE);
|
||||
GridLayout grid = new GridLayout();
|
||||
grid.numColumns = 1;
|
||||
composite.setLayout(grid);
|
||||
|
||||
IndexModel indexer = CCorePlugin.getDefault().getIndexModel();
|
||||
|
||||
indexerSwitch = new Button(composite, SWT.CHECK | SWT.RIGHT);
|
||||
indexerSwitch.setAlignment(SWT.LEFT);
|
||||
indexerSwitch.setText("Enable CTAGS indexing service for this project");
|
||||
indexerSwitch.setSelection(indexer.isEnabled(project));
|
||||
|
||||
indexerSwitch2 = new Button(composite, SWT.CHECK | SWT.RIGHT);
|
||||
indexerSwitch2.setAlignment(SWT.LEFT);
|
||||
indexerSwitch2.setText("Enable NEW indexing service for this project");
|
||||
indexerSwitch2.setSelection(false);
|
||||
|
||||
dTreeSwitch = new Button(composite, SWT.CHECK | SWT.RIGHT);
|
||||
dTreeSwitch.setAlignment(SWT.LEFT);
|
||||
dTreeSwitch.setText("Enable dependency tree service for this project");
|
||||
dTreeSwitch.setSelection(false);
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#doRun(IProject, IProgressMonitor)
|
||||
*/
|
||||
public void doRun(IProject project, IProgressMonitor monitor) {
|
||||
IndexModel indexer = CCorePlugin.getDefault().getIndexModel();
|
||||
indexer.setEnabled(project, indexerSwitch.getSelection());
|
||||
|
||||
IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
newIndexer.setEnabled(project, indexerSwitch2.getSelection());
|
||||
|
||||
DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
|
||||
depManager.setEnabled(project, dTreeSwitch.getSelection());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#getImage()
|
||||
*/
|
||||
public Image getImage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#getLabel()
|
||||
*/
|
||||
public String getLabel() {
|
||||
return "Indexer";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#isValid()
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#setVisible(boolean)
|
||||
*/
|
||||
public void setVisible(boolean visible) {
|
||||
IndexModel indexer = CCorePlugin.getDefault().getIndexModel();
|
||||
IndexManager newIndexer = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
|
||||
if (indexerSwitch != null) {
|
||||
//indexerSwitch.setAlignment(SWT.LEFT);
|
||||
//indexerSwitch.setText("Enable indexing service for this project");
|
||||
indexerSwitch.setSelection(indexer.isEnabled(project));
|
||||
}
|
||||
|
||||
if (indexerSwitch2 != null) {
|
||||
indexerSwitch2.setSelection(newIndexer.isEnabled(project));
|
||||
}
|
||||
|
||||
DependencyManager depManager = CCorePlugin.getDefault().getCoreModel().getDependencyManager();
|
||||
|
||||
if (dTreeSwitch != null) {
|
||||
dTreeSwitch.setSelection(depManager.isEnabled(project));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue