eclipse插件:打开编辑器,以编程方式突出显示python语法

时间:2016-04-23 21:53:40

标签: python eclipse plugins

我正在开发一个eclipse插件,我可以在这样的eclipse编辑器中打开外部文件:

            IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
        FileStoreEditorInput editorInput = new FileStoreEditorInput(fileStore);
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

        try {
            page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEditor");
            TextEditor editor = (TextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
            IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
            editor.selectAndReveal(document.getLineOffset(line - 1), document.getLineLength(line-1));

        } catch ( PartInitException e ) {
            //Put your exception handler here if you wish to
        } catch (BadLocationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

这实际上很好。但是有些文件是* .py文件,Python代码,我希望在PyDev编辑器中突出显示文本。

我想我需要打开另一个编辑器?!但我不知道如何或在哪里找到它。

非常感谢任何提示!感谢!!!

1 个答案:

答案 0 :(得分:0)

pyDev python编辑器的编辑器ID似乎是org.python.pydev.editor.PythonEditor。因此,如果您安装了pyDev,则可以尝试指定该编辑器。

注意:并非所有编辑者都支持编辑外部文件。有些只处理工作区中的文件或者在非工作区文件上具有减少的功能。

相关问题