forked from eclipse-archived/triquetrum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eclipse-archived#190 In progress TqCL - interpreter
- Loading branch information
Showing
12 changed files
with
129 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ source.. = src/,\ | |
src-gen/,\ | ||
xtend-gen/ | ||
bin.includes = .,\ | ||
META-INF/ | ||
META-INF/,\ | ||
plugin.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension | ||
point="org.eclipse.debug.core.launchConfigurationTypes"> | ||
<launchConfigurationType | ||
id="org.eclipse.triquetrum.commands.xtext.launchConfigurationType2" | ||
modes="run" | ||
name="TCQL" | ||
public="true"> | ||
</launchConfigurationType> | ||
</extension> | ||
<extension | ||
point="org.eclipse.debug.ui.launchShortcuts"> | ||
<shortcut | ||
class="org.eclipse.triquetrum.commands.xtext.ide.TqCLLaunchShortcut" | ||
id="org.eclipse.triquetrum.commands.xtext.shortcut.tqcl" | ||
label="Tqcl macro" | ||
modes="run"> | ||
<contextualLaunch> | ||
<enablement> | ||
<with | ||
variable="selection"> | ||
<count | ||
value="1"> | ||
</count> | ||
<iterate | ||
ifEmpty="false" | ||
operator="or"> | ||
<test | ||
property="org.eclipse.debug.ui.matchesPattern" | ||
value="*.tqcl"> | ||
</test> | ||
</iterate> | ||
</with> | ||
</enablement> | ||
</contextualLaunch> | ||
</shortcut> | ||
</extension> | ||
|
||
</plugin> |
40 changes: 40 additions & 0 deletions
40
...xtext.ide/src/main/java/org/eclipse/triquetrum/commands/xtext/ide/TqCLLaunchShortcut.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.eclipse.triquetrum.commands.xtext.ide; | ||
|
||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.debug.ui.ILaunchShortcut; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.triquetrum.commands.interpreter.TqclInterpreter; | ||
import org.eclipse.ui.IEditorInput; | ||
import org.eclipse.ui.IEditorPart; | ||
|
||
public class TqCLLaunchShortcut implements ILaunchShortcut { | ||
|
||
@Override | ||
public void launch(ISelection selection, String mode) { | ||
Object firstElement = ((IStructuredSelection) selection).getFirstElement(); | ||
if (firstElement instanceof IFile) { | ||
try { | ||
IFile file = (IFile) firstElement; | ||
java.net.URI rawLocationURI = file.getRawLocationURI(); | ||
TqclInterpreter interpreter = new TqclInterpreter(); | ||
interpreter.interpret(file.getContents(), rawLocationURI); | ||
} catch (CoreException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void launch(IEditorPart editor, String mode) { | ||
// TODO Auto-generated method stub | ||
IEditorInput firstElement = editor.getEditorInput(); | ||
if (firstElement instanceof IFile) { | ||
IFile file = (IFile) firstElement; | ||
|
||
} | ||
} | ||
|
||
} |
Binary file modified
BIN
+0 Bytes
(100%)
....tests/src/test/xtend-gen/org/eclipse/triquetrum/commands/tests/.TqclParsingTest.xtendbin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...nd-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclDescriptionLabelProvider.xtendbin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...rc/main/xtend-gen/org/eclipse/triquetrum/commands/ui/labeling/.TqclLabelProvider.xtendbin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...in/xtend-gen/org/eclipse/triquetrum/commands/ui/outline/.TqclOutlineTreeProvider.xtendbin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...main/xtend-gen/org/eclipse/triquetrum/commands/ui/quickfix/.TqclQuickfixProvider.xtendbin
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.eclipse.triquetrum.commands.interpreter; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.triquetrum.commands.TqclStandaloneSetup; | ||
import org.eclipse.xtext.parser.IParseResult; | ||
import org.eclipse.xtext.resource.IResourceFactory; | ||
import org.eclipse.xtext.resource.XtextResource; | ||
|
||
import com.google.inject.Injector; | ||
|
||
public class TqclInterpreter { | ||
|
||
public void interpret(InputStream script, java.net.URI uri) { | ||
try { | ||
Injector injector = new TqclStandaloneSetup().createInjectorAndDoEMFRegistration(); | ||
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class); | ||
|
||
XtextResource resource = (XtextResource) resourceFactory.createResource(URI.createURI(uri.getPath())); | ||
resource.load(script, null); | ||
IParseResult parseResult = resource.getParseResult(); | ||
EObject rootASTElement = parseResult.getRootASTElement(); | ||
System.out.println(""); | ||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |