diff options
Diffstat (limited to 'plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice')
8 files changed, 402 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhys.xtext b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhys.xtext new file mode 100644 index 000000000..32f2b2f6b --- /dev/null +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhys.xtext @@ -0,0 +1,84 @@ +/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+grammar org.eclipse.etrice.core.etphys.ETPhys with org.eclipse.xtext.common.Terminals
+
+generate eTPhys "http://www.eclipse.org/etrice/core/etphys/ETPhys"
+
+import "http://www.eclipse.org/emf/2002/Ecore" as ecore
+
+PhysicalModel:
+ 'PhysicalModel' name=FQN '{'
+ (imports+=Import)*
+ (
+ systems+=PhysicalSystem |
+ nodeClasses+=NodeClass |
+ runtimeClasses+=RuntimeClass
+ )*
+ '}'
+;
+
+PhysicalSystem:
+ 'PhysicalSystem' name=ID (docu=Documentation)? '{'
+ nodeRefs+=NodeRef*
+ '}'
+;
+
+NodeRef:
+ 'NodeRef' name=ID ':' type=[NodeClass|FQN] (docu=Documentation)?
+;
+
+NodeClass:
+ 'NodeClass'name=ID (docu=Documentation)? '{'
+ 'runtime' '=' runtime=[RuntimeClass|FQN]
+ threads+=Thread*
+ '}'
+;
+
+Thread:
+ (default?='DefaultThread' | 'Thread') name=ID '{'
+ 'execmode' '=' execmode=ExecMode
+ ('prio' '=' prio=PRIO)?
+ ('stacksize' '=' stacksize=INT)?
+ '}'
+;
+
+enum ExecMode:
+ POLLED='polled' |
+ BLOCKED='blocked' |
+ MIXED='mixed'
+;
+
+RuntimeClass:
+ 'RuntimeClass' name=ID (docu=Documentation)? '{'
+ 'model' '=' threadModel=ThreadModel
+ '}'
+;
+
+enum ThreadModel:
+ SINGLE_THREADED='singleThreaded' |
+ MULTI_THREADED='multiThreaded'
+;
+
+Documentation: '['
+ text+=STRING+
+ ']';
+
+PRIO returns ecore::EInt hidden(): ('+'|'-')? INT;
+
+Import :
+ 'import' (importedNamespace=ImportedFQN 'from' | 'model') importURI=STRING;
+
+ImportedFQN:
+ FQN ('.*')?;
+
+FQN:
+ ID ('.' ID)*;
diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhysRuntimeModule.java b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhysRuntimeModule.java new file mode 100644 index 000000000..582b2cd97 --- /dev/null +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhysRuntimeModule.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2012 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Henrik Rentz-Reichert (initial contribution) + * + *******************************************************************************/ + +package org.eclipse.etrice.core.etphys; + +import org.eclipse.etrice.core.scoping.PlatformRelativeUriResolver; +import org.eclipse.xtext.scoping.impl.ImportUriResolver; + +import com.google.inject.Binder; + +/** + * Use this class to register components to be used at runtime / without the Equinox extension registry. + */ +public class ETPhysRuntimeModule extends org.eclipse.etrice.core.etphys.AbstractETPhysRuntimeModule { + + @Override + public void configureIScopeProviderDelegate(Binder binder) { + binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class) + .annotatedWith( + com.google.inject.name.Names + .named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)) + .to(org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.class); + } + + public Class<? extends ImportUriResolver> bindImportUriResolver() { + return PlatformRelativeUriResolver.class; + } +} diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhysStandaloneSetup.java b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhysStandaloneSetup.java new file mode 100644 index 000000000..25388e200 --- /dev/null +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhysStandaloneSetup.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Henrik Rentz-Reichert (initial contribution) + * + *******************************************************************************/ + +package org.eclipse.etrice.core.etphys; + +/** + * Initialization support for running Xtext languages + * without equinox extension registry + */ +public class ETPhysStandaloneSetup extends ETPhysStandaloneSetupGenerated{ + + public static void doSetup() { + new ETPhysStandaloneSetup().createInjectorAndDoEMFRegistration(); + } +} + diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/GenerateETPhys.mwe2 b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/GenerateETPhys.mwe2 new file mode 100644 index 000000000..196d3da01 --- /dev/null +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/GenerateETPhys.mwe2 @@ -0,0 +1,149 @@ +/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+module org.eclipse.etrice.core.etphys.GenerateETPhys
+
+import org.eclipse.emf.mwe.utils.*
+import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.ui.generator.*
+
+var grammarURI = "classpath:/org/eclipse/etrice/core/etphys/ETPhys.xtext"
+var file.extensions = "etphys"
+var projectName = "org.eclipse.etrice.core.etphys"
+var runtimeProject = "../${projectName}"
+
+Workflow {
+ bean = StandaloneSetup {
+ scanClassPath = true
+ platformUri = "${runtimeProject}/.."
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}/src-gen"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}.ui/src-gen"
+ }
+
+ component = Generator {
+ pathRtProject = runtimeProject
+ pathUiProject = "${runtimeProject}.ui"
+ pathTestProject = "../../tests/${projectName}.tests"
+ projectNameRt = projectName
+ projectNameUi = "${projectName}.ui"
+ language = {
+ uri = grammarURI
+ fileExtensions = file.extensions
+
+ // Java API to access grammar elements (required by several other fragments)
+ fragment = grammarAccess.GrammarAccessFragment {}
+
+ // generates Java API for the generated EPackages
+ fragment = ecore.EcoreGeneratorFragment {
+ // referencedGenModels = "
+ // platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,
+ // platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel
+ // "
+ }
+
+ // Serializer 2.0
+ fragment = serializer.SerializerFragment {
+ generateStub = false
+ }
+
+ // the serialization component (1.0)
+ // fragment = parseTreeConstructor.ParseTreeConstructorFragment {}
+
+ // a custom ResourceFactory for use with EMF
+ fragment = resourceFactory.ResourceFactoryFragment {
+ fileExtensions = file.extensions
+ }
+
+ // The antlr parser generator fragment.
+ fragment = parser.antlr.XtextAntlrGeneratorFragment {
+ // options = {
+ // backtrack = true
+ // }
+ }
+
+ // java-based API for validation
+ fragment = validation.JavaValidatorFragment {
+ composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
+ composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
+ }
+
+ // scoping and exporting API
+ // fragment = scoping.ImportURIScopingFragment {}
+ // fragment = exporting.SimpleNamesFragment {}
+
+ // scoping and exporting API
+ fragment = scoping.ImportURIScopingFragment {}
+ //fragment = scoping.ImportNamespacesScopingFragment {}
+ fragment = exporting.QualifiedNamesFragment {}
+ fragment = builder.BuilderIntegrationFragment {}
+
+ // generator API
+ fragment = generator.GeneratorFragment {
+ generateMwe = false
+ generateJavaMain = false
+ }
+
+ // formatter API
+ fragment = formatting.FormatterFragment {}
+
+ // labeling API
+ fragment = labeling.LabelProviderFragment {}
+
+ // outline API
+ fragment = outline.OutlineTreeProviderFragment {}
+ fragment = outline.QuickOutlineFragment {}
+
+ // quickfix API
+ fragment = quickfix.QuickfixProviderFragment {}
+
+ // content assist API
+ fragment = contentAssist.JavaBasedContentAssistFragment {}
+
+ // generates a more lightweight Antlr parser and lexer tailored for content assist
+ fragment = parser.antlr.XtextAntlrUiGeneratorFragment {}
+
+ // generates junit test support classes into Generator#pathTestProject
+ fragment = junit.Junit4Fragment {}
+
+ // project wizard (optional)
+ // fragment = projectWizard.SimpleProjectWizardFragment {
+ // generatorProjectName = "${projectName}"
+ // modelFileExtension = file.extensions
+ // }
+
+ // rename refactoring
+ fragment = refactoring.RefactorElementNameFragment {}
+
+ // provides the necessary bindings for java types integration
+ //fragment = types.TypesGeneratorFragment {}
+
+ // generates the required bindings only if the grammar inherits from Xbase
+ fragment = xbase.XbaseGeneratorFragment {}
+
+ // provides a preference page for template proposals
+ fragment = templates.CodetemplatesGeneratorFragment {}
+
+ // provides a compare view
+ fragment = compare.CompareFragment {
+ fileExtensions = file.extensions
+ }
+
+ }
+ }
+}
+
diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/formatting/ETPhysFormatter.java b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/formatting/ETPhysFormatter.java new file mode 100644 index 000000000..8112152ef --- /dev/null +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/formatting/ETPhysFormatter.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2012 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * CONTRIBUTORS: + * Henrik Rentz-Reichert (initial contribution) + * + *******************************************************************************/ + +package org.eclipse.etrice.core.etphys.formatting; + +import org.eclipse.etrice.core.etphys.services.ETPhysGrammarAccess; +import org.eclipse.xtext.Keyword; +import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter; +import org.eclipse.xtext.formatting.impl.FormattingConfig; +import org.eclipse.xtext.util.Pair; + +/** + * This class contains custom formatting description. + * + * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting + * on how and when to use it + * + * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example + */ +public class ETPhysFormatter extends AbstractDeclarativeFormatter { + + @Override + protected void configureFormatting(FormattingConfig c) { + ETPhysGrammarAccess f = (ETPhysGrammarAccess) getGrammarAccess(); + + // general + + c.setAutoLinewrap(120); + c.setLinewrap(1).before(f.getSL_COMMENTRule()); + c.setLinewrap(2).before(f.getML_COMMENTRule()); + + for (Pair<Keyword, Keyword> pair : f.findKeywordPairs("{", "}")) { + c.setLinewrap().after(pair.getFirst()); + c.setIndentationIncrement().after(pair.getFirst()); + c.setLinewrap().before(pair.getSecond()); + c.setIndentationDecrement().before(pair.getSecond()); + c.setSpace(" ").between(pair.getFirst(), pair.getSecond()); + } + + for (Keyword k: f.findKeywords("runtime","execmode", "prio", "stacksize")) { + c.setLinewrap().before(k); + } + + c.setLinewrap(1).after(f.getImportRule()); + + c.setLinewrap(2).after(f.getPhysicalSystemRule()); + c.setLinewrap(2).after(f.getNodeClassRule()); + c.setLinewrap(2).after(f.getRuntimeClassRule()); + + c.setLinewrap(1).after(f.getNodeRefRule()); + c.setLinewrap(1).around(f.getThreadRule()); + } +} diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/generator/ETPhysGenerator.xtend b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/generator/ETPhysGenerator.xtend new file mode 100644 index 000000000..cff196e02 --- /dev/null +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/generator/ETPhysGenerator.xtend @@ -0,0 +1,15 @@ +/* + * generated by Xtext + */ +package org.eclipse.etrice.core.etphys.generator + +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.xtext.generator.IGenerator +import org.eclipse.xtext.generator.IFileSystemAccess + +class ETPhysGenerator implements IGenerator { + + override void doGenerate(Resource resource, IFileSystemAccess fsa) { + //TODO implement me + } +} diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/scoping/ETPhysScopeProvider.java b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/scoping/ETPhysScopeProvider.java new file mode 100644 index 000000000..8d978ff5f --- /dev/null +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/scoping/ETPhysScopeProvider.java @@ -0,0 +1,17 @@ +/* + * generated by Xtext + */ +package org.eclipse.etrice.core.etphys.scoping; + +import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider; + +/** + * This class contains custom scoping description. + * + * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping + * on how and when to use it + * + */ +public class ETPhysScopeProvider extends AbstractDeclarativeScopeProvider { + +} diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/validation/ETPhysJavaValidator.java b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/validation/ETPhysJavaValidator.java new file mode 100644 index 000000000..99c25baec --- /dev/null +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/validation/ETPhysJavaValidator.java @@ -0,0 +1,13 @@ +package org.eclipse.etrice.core.etphys.validation; + + +public class ETPhysJavaValidator extends AbstractETPhysJavaValidator { + +// @Check +// public void checkGreetingStartsWithCapital(Greeting greeting) { +// if (!Character.isUpperCase(greeting.getName().charAt(0))) { +// warning("Name should start with a capital", MyDslPackage.Literals.GREETING__NAME); +// } +// } + +} |