简体   繁体   中英

DLTK indexing and refreshing editor

I have created a plugin for a new language and used DLTK for indexing and searching feature.

I am using Eclipse Luna (PDE 3.10.1) and DLTK (5.0)

My question is: How can I manually re-index a file and refresh the editor when I switch between tabs?

Because what happens now is if a file is reopened that time it gets re-indexed and error markers are updated, but while switching it doesn't update the error markers as dependent files are changed in other tabs.

I tried as below: It's indexing but not refreshing the editor.

I added a IPartListener2 and in partBroughtToTop() method i have following code for indexing and refreshing.

IModelElement model = EditorUtility.getEditorInputModelElement(partRef.getPage().getActiveEditor(), true);

if (model instanceof ISourceModule) {
    ProblemCollector prob = new ProblemCollector();
    SourceParserUtil.clearCache();
    // get cache entry
    final ISourceModuleInfo cacheEntry = ModelManager.getModelManager().getSourceModuleInfoCache().get((ISourceModule)model);
    ModuleDeclaration mod = (ModuleDeclaration)SourceParserUtil.parse((ISourceModule)model, prob);
    SourceParserUtil.putModuleToCache(cacheEntry, mod, prob);
    SourceParserUtil.enableCache();

    IEditorPart editor = partRef.getPage().getActiveEditor();
    IEditorInput input = editor.getEditorInput();
    try {
     ((ScriptEditor)editor).getDocumentProvider().resetDocument(input);
    }
    catch (CoreException e) {
    }
}

Thanks in advance.

If I understand correctly, the issue is about re-validating files after changing dependencies. 1. It is not related to indexer (it just records that a file contains some elements) 2. It is not related to parser (which produces AST).

It should happen in a builder. You could try DLTK support for that by implementing IBuildParticipant or IScriptBuilder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM