mdenet / platformtools

Education platform tool functions.
Eclipse Public License 2.0
0 stars 3 forks source link

Make Xtext editor code generation accessible via a platform panel button press. #52

Closed szschaler closed 9 months ago

szschaler commented 9 months ago

This should use the existing generate service generated as part of the Xtext web server.

To make this usable in our context, we need to:

  1. Provide alternative HttpServiceContext to deal with not URL-encoded parameters, possibly defaulting some things if needed
  2. Only use this in the specialised end point we provide for invoking the code generator
  3. Call the generator service using the regular service dispatcher (probably enough to override doPost, set up the new context, so we can get the ServiceDescriptor from the XtextServiceDispatcher and then call doService with that).
  4. We will need to support the following parameters:
    • "fullText": text of model (xtext file)
    • "allArtifacts": Boolean to indicate if we need all files
    • useful to also provide the resource name ("resource" parameter), which can be hard-coded in the activity file, so that code generator can access this in the file names it generates...
    • optionally: "includeContent": defaults to true to indicate we want to actually see the file contents in the response
  5. invoke XtextServlet.doService with the generator service, which will send back the appropriate JSON file, but will have a 'documents' collection rather than the collection we want and the elements therein may not be formatted correctly... So we may need to rewrite the response slightly, rather than using doService directly... That should just involve a simple iteration over the generated artifacts and encoding them suitably.
barnettwilliam commented 9 months ago

Generator activity is on this branch: https://github.com/mdenet/platform-examples-private/tree/xtext-generator-activity

The overridden run generator isn't being displayed for some reason.

szschaler commented 9 months ago

Thanks.

The overridden run generator isn't being displayed for some reason.

What do you mean?

barnettwilliam commented 9 months ago

There is a button specified in the activity file but it's not shown:

https://github.com/mdenet/platform-examples-private/blob/81d0375a8b9ee01cc151da061f0ca63c95f90204/xtext-turtles-generator/xtext_activity.json#L102-L108

szschaler commented 9 months ago

That button asks for function-xtext which isn't in a tool loaded for that activity. Might that be the problem? In any case, what's there is good enough and I should be able to adapt once I have the basic codegen stuff running.