Skip to content

Commit

Permalink
eclipse-archived#190 In progress TqCL - interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
rtotaro committed Jan 16, 2017
1 parent b0e24be commit c7e6956
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 9 deletions.
1 change: 1 addition & 0 deletions org.eclipse.triquetrum.commands.xtext.ide/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java-gen"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/classes"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ Export-Package: org.eclipse.triquetrum.commands.ide.contentassist.antlr,
org.eclipse.triquetrum.commands.ide.contentassist.antlr.internal
Require-Bundle: org.eclipse.xtext.ide;bundle-version="2.10.0",
org.eclipse.triquetrum.commands.xtext;bundle-version="1.0.0",
org.eclipse.xtext.xbase.ide;bundle-version="2.10.0"
org.eclipse.xtext.xbase.ide;bundle-version="2.10.0",
org.eclipse.debug.core;bundle-version="3.10.100",
org.eclipse.debug.ui;bundle-version="3.11.200",
org.eclipse.ui;bundle-version="3.108.0",
org.eclipse.core.runtime;bundle-version="3.12.0"

3 changes: 2 additions & 1 deletion org.eclipse.triquetrum.commands.xtext.ide/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ source.. = src/,\
src-gen/,\
xtend-gen/
bin.includes = .,\
META-INF/
META-INF/,\
plugin.xml
41 changes: 41 additions & 0 deletions org.eclipse.triquetrum.commands.xtext.ide/plugin.xml
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>
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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 8 additions & 7 deletions org.eclipse.triquetrum.commands.xtext/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ Require-Bundle: org.eclipse.xtext,
org.eclipse.triquetrum.commands.api
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.apache.log4j
Export-Package: org.eclipse.triquetrum.commands.tqcl,
org.eclipse.triquetrum.commands.validation,
Export-Package: org.eclipse.triquetrum.commands,
org.eclipse.triquetrum.commands.generator,
org.eclipse.triquetrum.commands.interpreter,
org.eclipse.triquetrum.commands.parser.antlr,
org.eclipse.triquetrum.commands.parser.antlr.internal,
org.eclipse.triquetrum.commands.scoping,
org.eclipse.triquetrum.commands.serializer,
org.eclipse.triquetrum.commands.generator,
org.eclipse.triquetrum.commands,
org.eclipse.triquetrum.commands.tqcl.impl,
org.eclipse.triquetrum.commands.services,
org.eclipse.triquetrum.commands.scoping,
org.eclipse.triquetrum.commands.tqcl.util
org.eclipse.triquetrum.commands.tqcl,
org.eclipse.triquetrum.commands.tqcl.impl,
org.eclipse.triquetrum.commands.tqcl.util,
org.eclipse.triquetrum.commands.validation
Bundle-Vendor: Eclipse Triquetrum
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();
}
}
}

0 comments on commit c7e6956

Please sign in to comment.