Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » DLTK indexes' load is not being performed(DLTK indexes' load is not being performed due to H2Cache.load())
DLTK indexes' load is not being performed [message #1446192] |
Thu, 16 October 2014 09:28  |
Eclipse User |
|
|
|
DLTK's org.eclipse.dltk.internal.core.index.sql.h2.H2Cache.load() method has a hardcoded reference to PHPNature. Due to that the already indexed files are not being loaded.
Do I have implemented something wrong ? Or, Is it an issue ?
public static void load() {
loadedLock.acquire();
try {
if (!isLoaded) {
try {
DbFactory dbFactory = DbFactory.getInstance();
Connection connection = dbFactory.createConnection();
try {
IElementDao elementDao = dbFactory.getElementDao();
elementDao.search(connection, null, MatchRule.PREFIX,
IModelElement.FIELD, 0, 0, null, null, null,
null, "org.eclipse.php.core.PHPNature", 0,
false, new IElementHandler() {
public void handle(Element element) {
}
}, new NullProgressMonitor());
elementDao.search(connection, null, MatchRule.PREFIX,
IModelElement.TYPE, 0, 0, null, null, null,
null, "org.eclipse.php.core.PHPNature", 0,
false, new IElementHandler() {
public void handle(Element element) {
}
}, new NullProgressMonitor());
elementDao.search(connection, null, MatchRule.PREFIX,
IModelElement.METHOD, 0, 0, null, null, null,
null, "org.eclipse.php.core.PHPNature", 0,
false, new IElementHandler() {
public void handle(Element element) {
}
}, new NullProgressMonitor());
elementDao.search(connection, null, MatchRule.PREFIX,
IModelElement.IMPORT_DECLARATION, 0, 0, null,
null, null, null,
"org.eclipse.php.core.PHPNature", 0, false,
new IElementHandler() {
public void handle(Element element) {
}
}, new NullProgressMonitor());
} finally {
connection.close();
}
} catch (SQLException e) {
if (H2Index.DEBUG) {
e.printStackTrace();
}
} finally {
isLoaded = true;
}
}
} finally {
loadedLock.release();
}
}
|
|
| |
Re: DLTK indexes' load is not being performed [message #1477868 is a reply to message #1476974] |
Tue, 18 November 2014 02:15   |
Eclipse User |
|
|
|
I found a way around these problem in our language IDE, at least it works for us.
In the plugin.xml I disable all the other indexers
<extension
point="org.eclipse.dltk.core.projectIndexer">
<projectIndexer
class="com.basis.bdt.eclipse.core.indexer.BDTSqlProjectIndexerFactory"
id="com.basis.bdt.eclipse.core.project.indexer">
</projectIndexer>
<enable
indexer="com.basis.bdt.eclipse.core.project.indexer"
nature="com.basis.bdt.eclipse.core.nature">
</enable>
<disable
indexer="org.eclipse.dltk.core.indexer.mixin"
nature="com.basis.bdt.eclipse.core.nature">
</disable>
<disable
indexer="org.eclipse.dltk.core.indexer.structure"
nature="com.basis.bdt.eclipse.core.nature">
</disable>
<disable
indexer="org.eclipse.dltk.core.indexer.index2"
nature="com.basis.bdt.eclipse.core.nature">
</disable>
</extension>
I created my own BDTSqlProjectIndexer (created through a factory extension so I could have guice inject it) and enabled it.
BDTSqlProjectIIndexer extends ProjectIndexer2
in the method wantRefreshOnStart() you return true. So dltk calls your
startIndexing() method on waking up.
Here I grab the IScriptProjects open in the workspace, submit them to be removed, and then submit them to be indexed
@Override
public void startIndexing()
{
super.startIndexing();
try
{
final IScriptProject[] projects =
ScriptModelHelper
.getOpenedScriptProjects(DLTKCore
.create(ResourcesPlugin.getWorkspace().getRoot()),
BasisNature.NATURE_ID);
for (IScriptProject scriptProject : projects)
super.removeProject(scriptProject.getPath());
for (IScriptProject scriptProject : projects)
super.indexProject(scriptProject);
}
catch (ModelException e)
{
logService.logError(BBCore.PLUGIN_ID, getClass(), "Error Indexing", e);
}
}
This means they're all indexed every time on workspace wakeup. This is a crude brute force method, I'm sure I can do some checking for this or that to see if the index for a project already exists ... if that project has dirty changes from the last time it was indexed etc.
I see the other language IDEs you can download and get source for : Ruby, Tcl, Python, JavaScript, and to some extent php's PDT - they're all quite comfortable using dltk classes in internal packages ... having run into problems in eclipse before doing this we hope to avoid that.
An advantage using ProjectIndexer2 here is that it is in a public package, using its own internal packages to do its job.
|
|
| | | |
Goto Forum:
Current Time: Wed Apr 30 11:01:35 EDT 2025
Powered by FUDForum. Page generated in 0.07819 seconds
|