私はXtext
で単純なDSLを作成し、それをインタプリタで実行しようとしていますが、文法は最初のHello Wordプロジェクトです。
.Text
ファイルを正常に実行できます。
org.xtext.example.mydsl.ui
プロジェクトでは、plugin.xml
ファイルに書き込みます。私のクラスLaunchMydslShortcut
からプロジェクトを実行するには。Xtext、LaunchMydslShortcutのIselection入力を取得
<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>
これは私のLaunchMydslShortcut
クラスです:
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")
}
}
}
はしかし、私はlaunch(IEditorPart editor, String mode)
機能を使用することを期待していますが、それはlaunch(ISelection selection, String mode)
を実行します。
質問があるので、両者の違いは何ですか?なぜ私のプロジェクトは最初のものを使用していますか?どのように私は2番目を使用するのですか?
githubリポジトリのリンクは次のとおりです。https://github.com/eclipse/xtext-eclipse/blob/master/org.eclipse.xtext.xtext.ui/src/org/eclipse/xtext/xtext/launcher/ WorkflowLaunchUtils.java –