GEGlobalResearch / DARPA-ASKE-TA1

ANSWER Project to demonstrate knowledge-driven extraction of scientific models from code and texts
Other
8 stars 5 forks source link

Fold dialog window statements programmatically? #35

Closed crapo closed 4 years ago

crapo commented 5 years ago

When equations are extracted from code and displayed in the Dialog window, there is sometimes a lot of text in the scripts. It would be nice to make it available on-demand but not make the big picture obscure by displaying it all. A promising solution is to fold the statements that give equation details. Is it possible to do this programmatically?

kittaakos commented 5 years ago

A promising solution is to fold the statements that give equation details.

Great idea.

Is it possible to do this programmatically?

I am pretty sure it is feasible, I never did this before, I need to check how this works.

kittaakos commented 5 years ago

It was easy. We need to do something like this when opening the editor:

((org.eclipse.ui.texteditor.AbstractDecoratedTextEditor)partRef.getPart(false)).getAction("FoldingCollapseAll").run();

But, as we have seen during our remote debugging session, we cannot always expand the folded ranges. I think it is an Eclipse bug. I can implement it, but if you cannot expand the folded regions during the demo, that could be wrong.

We can decide on this later because the code is a single line.

kittaakos commented 5 years ago

It is an Xtext bug that was fixed in 2.17.0 See here: https://github.com/eclipse/xtext-eclipse/issues/863

kittaakos commented 5 years ago

The change set for the fix in Xtext was pretty small: https://github.com/eclipse/xtext-eclipse/pull/944/files

We can do the followings:

What do you think, @crapo?

crapo commented 5 years ago

That seems like a good approach to me. Then when we do upgrade we can remove.

kittaakos commented 5 years ago

OK, let's do this way. I would need one thing for this issue, when do you want to fold the regions:

Please specify, thank you!

crapo commented 5 years ago

only in a dialog file, and really only the long-winded "answer" from code or text extraction. So is it possible to fold a region after insertion if a flag passed in says to fold the region? The particular case that currently would benefit from folding is in AnswerCurationManager, runInferenceDisplayInterestingCodeModelResults. An outer for loop (line 450) with an inner for loop (line 492) output all of the SADL-syntax lines of the extracted methods. It would be desirable to fold this entire region. I imagine that it could be done one insertion (call to notifyUser, line 497) at a time if there were a flag on the call to control folding?

kittaakos commented 5 years ago

in AnswerCurationManager, runInferenceDisplayInterestingCodeModelResults

For some reason, the ResultSet is always null for me, hence I never hit the notifyUser code.

The query is:

select ?m ?b ?e ?s where {?m <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sadl.org/CodeExtractionModel.sadl#Method> . ?m <http://sadl.org/CodeExtractionModel.sadl#doesComputation> true . OPTIONAL {?m <http://sadl.org/CodeExtractionModel.sadl#beginsAt> ?b . ?m <http://sadl.org/CodeExtractionModel.sadl#endsAt> ?e . OPTIONAL{?m <http://sadl.org/CodeExtractionModel.sadl#serialization> ?s}} .
        MINUS {
            {?ref <http://sadl.org/CodeExtractionModel.sadl#codeBlock> ?m . ?ref <http://sadl.org/CodeExtractionModel.sadl#isImplicit> true}
            UNION {?m <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sadl.org/CodeExtractionModel.sadl#ExternalMethod>} } }

We ask the JenaReasonerPlugin but this line always returns with null as the result set has zero elements.

Maybe that's the reason I could not use the Java importer so far.

My project setup is: dummy.sadl:

 uri "http://sadl.org/dummy.sadl".

x.dialog:

 uri "http://sadl.org/x.dialog".

The x.dialog file is opened in the editor, I use Import... > Java Model Importer > Java Files and I try to import Mach.java.

Could this be a Windows/macOS query mismatch similarily to this 2ad9822?

crapo commented 5 years ago

I also get a null ResultSet if I create a project and content as you describe. Looking into it.

crapo commented 5 years ago

Humm... This isn't going to work because to convert to the SADL equations and associated information the service to convert Java to Python is called, and it will fail for you as it is service within our firewall. I can give you the resulting statements that are inserted into the Dialog window, if you don't already have them. Would that help?

crapo commented 5 years ago

WRT the original issue of the null ResultSet, I discovered (thanks to you) that the CodeExtractionModel built for new projects was out-of-date. I've updated in ASKE TA1 master.

crapo commented 5 years ago

I have improved error handling somewhat. At least now you will get a message about connection error instead of a stack trace. Perhaps we can work on the folding usage in a pair programming session?

kittaakos commented 5 years ago

usage in a pair programming session

Please schedule a call.