【发布时间】:2015-04-13 14:57:54
【问题描述】:
我为一种新语言创建了一个插件,并使用 DLTK 进行索引和搜索功能。
我正在使用 Eclipse Luna (PDE 3.10.1) 和 DLTK (5.0)
我的问题是: 如何在选项卡之间切换时手动重新索引文件并刷新编辑器?
因为现在发生的情况是,如果重新打开文件时重新索引文件并更新错误标记,但在切换时不会更新错误标记,因为在其他选项卡中更改了相关文件。
我尝试如下:它正在索引但不刷新编辑器。
我添加了一个 IPartListener2,在 partBroughtToTop() 方法中我有以下代码用于索引和刷新。
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) {
}
}
提前致谢。
【问题讨论】:
-
有点不清楚你的代码在做什么。项目应该具有您的语言性质,并且其中的文件将在每次更改后自动编制索引。
-
@AlexPanchenko 我有一种语言,其中有不同类型的文件。例如,在 C++ 程序中,我们有 .cpp 和 .h 文件。如果我更改依赖 .h 文件中的变量,当我切换选项卡时,它不会反映在 cpp 文件中。但如果我重新打开 cpp 文件,它会反映更改。所以,当我在 Eclipse 中切换选项卡时,我想从代码中手动刷新。
标签: eclipse eclipse-plugin eclipse-rcp eclipse-pde dltk