DevBoost / JaMoPP

JaMoPP can parse Java source and byte code into EMF-based models and vice versa. It preserves source formatting and can be used for code analysis and refactoring.
17 stars 18 forks source link

LocationMap is empty before selecting elements in the editor but populated afterwards #6

Open jreimone opened 11 years ago

jreimone commented 11 years ago

It's hard to describe it as JaMoPP-specific as possible. Refactory hooks in when some one right-clicks in an open editor. The current selection is determined with the EMFTextEditorConnector. The connector calls locationMap.getElementsAt(..). The problem for JaMoPP is that this map is empty while right-clicking in the editor (selecting some elements). But the map is populated after the call to locationMap.getElementsAt(..). It seems that the workflow is a little bit distinct to other EMFText-generated languages. @jjohannes, can something be done here?

mirkoseifert commented 11 years ago

The LocationMap is populated during parsing. If you find it empty, you might be requesting information from the LocationMap in an invalid state (e.g., between two parse runs). Do you think that could be the case?

jreimone commented 11 years ago

Well, I have the editor open, putting the cursor to arbitrary position reveals the outline to the right node. Thus, the locationmap must be valid somehow. But when I right-click and call getElementsAt it's empty for some reason. In other EMFText-generated editors the same scenario works as expected. With "between two parse runs" you mean just right before another parse run? I assume a parse run is only initiated as a consequence of ocurred changes, isn't it? In this case I must answer with no because I'm just selecting some text without changing something.

mirkoseifert commented 11 years ago

Parse runs are initiated when a document is changed and when the editor receives focus. The latter is required to make sure that changes made in other editors are reflected when the editor is changed (e.g., error markers must be removed if references to external resource can be suddenly resolved).

Maybe you can add some debug output to the respective methods (e.g., reload()) to figure out when the resource content is actually parsed and when the location map is reset?

jreimone commented 11 years ago

which reload() method do you mean?

mirkoseifert commented 11 years ago

I meant JavaResource.reload(InputStream inputStream, Map<?,?> options)