简体   繁体   中英

get IEditorInput in xtext JavaValidator

I need to do some validation on my grammar based on the association of the file with a specific object I called MyResource. The command for opening the xtext editor is handled when user is right clicking on MyResource, hence I extended the FileEditorInput (called it MyEditorInput) and store the Myresource instance for the editor input there. However, I cannot get the instance of MyEditorInput in the MyGrammarJavaEditor code. I tried using PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput() assuming the validation is happening on the active editor, but this it throw NullPointerException. Do you know any ways to get the editor input in validator? Do you think my solution for associating an external object with the xtext editor/file/resource is correct? Any other suggestions?

The validation is executed by the Eclipse builder, too. That one is independent of any editors and checks the saved files in the project for consistency. I don't see any way to assume that the currently opened editor is the one that is attached to the currently validated resource.

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