eclipse / xtext-eclipse

xtext-eclipse
Eclipse Public License 2.0
49 stars 73 forks source link

[tracing] Open Generated File Handler does not work for custom JvmModelGenerator #663

Closed miklossy closed 6 years ago

miklossy commented 6 years ago
  1. Create the Xtext Home Automation Example Project
  2. Create the RuleEngineGenerator class
    
    package org.eclipse.xtext.example.homeautomation.generator

import org.eclipse.xtext.xbase.compiler.JvmModelGenerator import org.eclipse.emf.ecore.resource.Resource import org.eclipse.xtext.generator.IFileSystemAccess

class RuleEngineGenerator extends JvmModelGenerator {

override void doGenerate(Resource input, IFileSystemAccess fsa) {
    fsa.generateFile("output.txt", "content")
}

}


3. Add binding into the RuleEngineRuntimeModule

class RuleEngineRuntimeModule extends AbstractRuleEngineRuntimeModule {

override Class<? extends IGenerator> bindIGenerator() {
    RuleEngineGenerator
}

}



4. In the Runtime Eclipse the output.txt file is generated, the **Open Generated File** context menu is available, but does not open the output.txt file.
![screenshot](https://user-images.githubusercontent.com/20393472/39671163-58029d00-5113-11e8-81a0-13d27fb7b457.png)

Hint: While debugging the org.eclipse.xtext.ui.generator.trace.TraceOrMarkerBasedOpenerContributor class
https://github.com/eclipse/xtext-eclipse/blob/7c7f3628b15e6d9880d631a4bcc8e0b4fdc0dece/org.eclipse.xtext.ui/src/org/eclipse/xtext/ui/generator/trace/TraceOrMarkerBasedOpenerContributor.java#L26-L31
I found out that the traceBasedOpenerCollector.collectGeneratedFileOpeners method gets called, but does not populate the acceptor. Because of the early return the derivedResourceMarkerBasedOpenerCollector.collectGeneratedFileOpeners method does not get called. When removing the early return, the **Open Generated File** context menu works as desired.

Since the name of the class TraceOrMarkerBasedOpenerContributor indicates that both trace-based and marker-based Generated File Openers should be collected, using an early return may be bug there.
cdietrich commented 6 years ago

did you find out why org.eclipse.xtext.ui.generator.trace.TraceBasedOpenerContributor does not populate the acceptor org.eclipse.xtext.ui.generator.trace.TraceBasedOpenerContributor.collectOpeners(IEclipseTrace, ITextRegion, IAcceptor<FileOpener>) should call back the acceptor

cdietrich commented 6 years ago

and: if you customize the generator and dont create traces i think you should disable the creation of the trace files

cdietrich commented 6 years ago

p.s. i could not reproduce this in 2.14 is it possbile you have old trace files flying around

miklossy commented 6 years ago

Yes, I had some obsolete trace files created by the original JvmModelGenerator.

screenshot

After removing them the problem has been solved.

Thank you very much for your assistant!

cdietrich commented 6 years ago

@szarnekow do we consider this as a usecase where the traces should be deleted or is switching from a trace based dsl to a non trace based dsl a usecase where the dsl developer has to take care

szarnekow commented 6 years ago

No, I don't think this is an important case.