I'm trying to make a simple DSL with Xtext
and execute it with an interpreter, the grammar is the initial Hello Word project.
I can can execute the .Text
file successfully.
In the org.xtext.example.mydsl.ui
project I write this in the plugin.xml
file To run the Project from my class LaunchMydslShortcut
.
<extension
point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
class="org.xtext.example.mydsl.ui.MyDslExecutableExtensionFactory:org.xtext.example.mydsl.ui.launch.LaunchMydslShortcut"
icon="icon/sample.gif"
id="org.xtext.example.mydsl.u.launchMyDsl"
label="MyDsll"
modes="run">
<contextualLaunch>
<enablement>
<with variable="selection">
<count value="1"/>
<iterate
ifEmpty="false"
operator="and">
<adapt type="org.eclipse.core.resources.IFile"/>
<test property="org.eclipse.debug.ui.matchesPattern"
value="*.mydsl"/>
</iterate>
</with>
</enablement>
<contextLabel
mode="run"
label="Run Mydsl"/>
</contextualLaunch>
</shortcut>
</extension>
This is my LaunchMydslShortcut
class :
class LaunchMydslShortcut implements ILaunchShortcut {
@Inject
private IResourceForEditorInputFactory resourceFactory;
override launch(ISelection selection, String mode) {
println("launch from selection")
}
override launch(IEditorPart editor, String mode) {
val input = editor.editorInput
if (editor instanceof XtextEditor && input instanceof FileEditorInput) {
val resource = resourceFactory.createResource(input)
resource.load(newHashMap())
println("launch Doooone")
}
}
}
However, I'm expecting to use launch(IEditorPart editor, String mode)
function, but it executes the launch(ISelection selection, String mode)
.
so the question would be, what's the différence between the two? why my project is using the first? and how do I use the second?