diff --git a/org.eclipse.triquetrum.commands.xtext.ide/META-INF/MANIFEST.MF b/org.eclipse.triquetrum.commands.xtext.ide/META-INF/MANIFEST.MF index 642004cc..ac5d63ae 100644 --- a/org.eclipse.triquetrum.commands.xtext.ide/META-INF/MANIFEST.MF +++ b/org.eclipse.triquetrum.commands.xtext.ide/META-INF/MANIFEST.MF @@ -13,5 +13,6 @@ Require-Bundle: org.eclipse.xtext.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" + org.eclipse.core.runtime;bundle-version="3.12.0", + org.eclipse.ui.console;bundle-version="3.6.200" diff --git a/org.eclipse.triquetrum.commands.xtext.ide/src/main/java/org/eclipse/triquetrum/commands/xtext/ide/TqCLLaunchShortcut.java b/org.eclipse.triquetrum.commands.xtext.ide/src/main/java/org/eclipse/triquetrum/commands/xtext/ide/TqCLLaunchShortcut.java index 60dd85ee..72d29747 100644 --- a/org.eclipse.triquetrum.commands.xtext.ide/src/main/java/org/eclipse/triquetrum/commands/xtext/ide/TqCLLaunchShortcut.java +++ b/org.eclipse.triquetrum.commands.xtext.ide/src/main/java/org/eclipse/triquetrum/commands/xtext/ide/TqCLLaunchShortcut.java @@ -1,5 +1,7 @@ package org.eclipse.triquetrum.commands.xtext.ide; +import java.util.Arrays; + import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.ui.ILaunchShortcut; @@ -8,6 +10,12 @@ import org.eclipse.triquetrum.commands.interpreter.TqclInterpreter; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.console.ConsolePlugin; +import org.eclipse.ui.console.IConsole; +import org.eclipse.ui.console.IConsoleManager; +import org.eclipse.ui.console.MessageConsole; +import org.eclipse.ui.console.MessageConsoleStream; public class TqCLLaunchShortcut implements ILaunchShortcut { @@ -18,6 +26,13 @@ public void launch(ISelection selection, String mode) { try { IFile file = (IFile) firstElement; java.net.URI rawLocationURI = file.getRawLocationURI(); + + IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); + MessageConsole messageConsole = new MessageConsole(file.getName(), "TqCL", null, true); + consoleManager.addConsoles(new IConsole[]{messageConsole}); + MessageConsoleStream newMessageStream = messageConsole.newMessageStream(); +// newMessageStream + TqclInterpreter interpreter = new TqclInterpreter(); interpreter.interpret(file.getName(),file.getContents(), rawLocationURI); } catch (CoreException e) { diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InsertInterpreterComponent.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InsertInterpreterComponent.java index 96b08a26..acd80908 100644 --- a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InsertInterpreterComponent.java +++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/InsertInterpreterComponent.java @@ -22,7 +22,7 @@ public void interpret(EObject element, InterpretContext context) { if (element instanceof Insert) { Insert insert = (Insert) element; Category category = insert.getCategory(); - String entityClass = insert.getEntityClass(); + String entityClass = TqCLUtils.cleanEntityClassName(insert.getEntityClass()); String name = insert.getName(); Map params = extractParameterMap(insert); switch (category) { diff --git a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java index 072a01a3..35779ef7 100644 --- a/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java +++ b/org.eclipse.triquetrum.commands.xtext/src/main/java/org/eclipse/triquetrum/commands/interpreter/TqclInterpreter.java @@ -2,28 +2,35 @@ import java.io.IOException; import java.io.InputStream; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.triquetrum.commands.TqclRuntimeModule; import org.eclipse.triquetrum.commands.TqclStandaloneSetup; import org.eclipse.triquetrum.commands.api.TqCLServices; import org.eclipse.triquetrum.commands.api.services.ModelBuilderService; import org.eclipse.triquetrum.commands.api.services.TcQLException; import org.eclipse.xtext.EcoreUtil2; +import org.eclipse.xtext.linking.lazy.LazyLinkingResource; +import org.eclipse.xtext.nodemodel.INode; import org.eclipse.xtext.parser.IParseResult; import org.eclipse.xtext.resource.IResourceFactory; import org.eclipse.xtext.resource.XtextResource; import org.eclipse.xtext.util.CancelIndicator; +import org.eclipse.xtext.validation.IConcreteSyntaxDiagnosticProvider.IConcreteSyntaxDiagnostic; +import org.eclipse.xtext.validation.IConcreteSyntaxValidator.IDiagnosticAcceptor; import com.google.inject.Injector; public class TqclInterpreter { - private static Map components = new HashMap<>(); + private static Map components = new HashMap<>(); static { @@ -34,6 +41,8 @@ public class TqclInterpreter { addComponent(new ConnectInterpreterComponent()); } + + private static void addComponent(TqclInterpreterComponent component){ for (EClass eClass : component.intepretedEClasses()) { components.put(eClass, component); @@ -47,14 +56,32 @@ public void interpret(String modelName,InputStream script, java.net.URI uri) { XtextResource resource = (XtextResource) resourceFactory.createResource(URI.createURI(uri.getPath())); resource.load(script, null); -// resource. -// EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl); IParseResult parseResult = resource.getParseResult(); - EObject root = parseResult.getRootASTElement(); -// EcoreUtil2.resolveAll(resource, monitor); + if(parseResult.hasSyntaxErrors()){ + Iterable syntaxErrors = parseResult.getSyntaxErrors(); + //TODO: log them + } + + if (resource instanceof LazyLinkingResource) { + LazyLinkingResource lazyLinkingResource = (LazyLinkingResource) resource; + lazyLinkingResource.resolveLazyCrossReferences(CancelIndicator.NullImpl); + } + else + { + EcoreUtil.resolveAll(resource); + } + EObject root = parseResult.getRootASTElement(); + + resource.getConcreteSyntaxValidator().validateRecursive(root, new IDiagnosticAcceptor() + { + @Override + public void accept(IConcreteSyntaxDiagnostic arg0) { + // TODO Auto-generated method stub + + } + }, Collections.EMPTY_MAP); - //TODO:get model builder ModelBuilderService modelBuilderService = TqCLServices.getInstance().getModelBuilderService(org.eclipse.triquetrum.workflow.model.CompositeActor.class); CompositeActor model = null; interpret(root, new InterpretContext(this,model,modelBuilderService));