diff options
author | Thomas Schuetz | 2013-07-12 08:40:15 +0000 |
---|---|---|
committer | Thomas Schuetz | 2013-07-12 08:40:15 +0000 |
commit | 12cda553738ca88662624b6f47066b5564549648 (patch) | |
tree | bfa65b6c38aa566a5f1cc98395da6546a6c6e282 /plugins/org.eclipse.etrice.generator.fsmtest/src | |
parent | 3447749b1a453735ac54fc09ea7680acdbb19b69 (diff) | |
parent | d65e1d1bdd43feadb43261b85aac2d8aef5e089c (diff) | |
download | org.eclipse.etrice-12cda553738ca88662624b6f47066b5564549648.tar.gz org.eclipse.etrice-12cda553738ca88662624b6f47066b5564549648.tar.xz org.eclipse.etrice-12cda553738ca88662624b6f47066b5564549648.zip |
Merge remote-tracking branch 'origin/master'
Conflicts:
plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip
plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
Change-Id: I98e2df3ab57d6e7e8f27e5b0aee7eaa189bfbc33
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.fsmtest/src')
7 files changed, 457 insertions, 457 deletions
diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtest.xtext b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtest.xtext index 3950f9f70..624c2e64a 100644 --- a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtest.xtext +++ b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtest.xtext @@ -1,93 +1,93 @@ -/*******************************************************************************
- * 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.generator.FSMtest with org.eclipse.xtext.common.Terminals
-
-generate fsmtest "http://www.eclipse.org/etrice/generator/FSMtest"
-
-Model:
- (
- FsmDefinitions+=FsmDefinition |
- RandomTests+=RandomTest
- )*;
-
-FsmDefinition:
- 'fsmdefinition' name=ID
- 'initial' states+=StateDeclaration
- (states+=StateDeclaration)*
- ';'
-;
-
-RandomTest:
- 'randomtest' name=ID
- 'fsm:' fsm=[FsmDefinition|ID]
- loopsDeclaration = LoopsDeclaration
- (seedDeclaration = SeedDeclaration)?
- ';'
-;
-
-GuardDeclaration:
- signal=SignalDeclaration
-;
-
-TransitionDeclaration:
- 'transition' name=ID 'to' destination=[StateDeclaration|ID]
- (
- 'trigger:' trigger=SignalDeclaration
- )?
- (
- 'guards:'
- (triggers+=GuardDeclaration)+
- )?
- (
- 'constraints:'
- (
- precondition+=PreconditionDeclaration |
- postcondition+=PostconditionDeclaration
- )+
- )?
- ';'
-;
-
-ConditionDeclaration:
- 'condition' signal=SignalDeclaration
-;
-
-PreconditionDeclaration:
- 'precondition' signal=SignalDeclaration
-;
-
-PostconditionDeclaration:
- 'postcondition' signal=SignalDeclaration
-;
-
-StateDeclaration:
- 'state' name=ID
- (
- 'constraints:'
- (condition+=ConditionDeclaration)+
- )?
- (transitions+=TransitionDeclaration)+
- ';'
-;
-
-LoopsDeclaration:
- 'loops:' val=INT
-;
-
-SeedDeclaration:
- 'randseed:' val=INT
-;
-
-SignalDeclaration:
- (port=ID '.')? signame=ID (('=' intVal=INT) | ('=' strVal=STRING))?
-;
+/******************************************************************************* + * 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.generator.FSMtest with org.eclipse.xtext.common.Terminals + +generate fsmtest "http://www.eclipse.org/etrice/generator/FSMtest" + +Model: + ( + FsmDefinitions+=FsmDefinition | + RandomTests+=RandomTest + )*; + +FsmDefinition: + 'fsmdefinition' name=ID + 'initial' states+=StateDeclaration + (states+=StateDeclaration)* + ';' +; + +RandomTest: + 'randomtest' name=ID + 'fsm:' fsm=[FsmDefinition|ID] + loopsDeclaration = LoopsDeclaration + (seedDeclaration = SeedDeclaration)? + ';' +; + +GuardDeclaration: + signal=SignalDeclaration +; + +TransitionDeclaration: + 'transition' name=ID 'to' destination=[StateDeclaration|ID] + ( + 'trigger:' trigger=SignalDeclaration + )? + ( + 'guards:' + (triggers+=GuardDeclaration)+ + )? + ( + 'constraints:' + ( + precondition+=PreconditionDeclaration | + postcondition+=PostconditionDeclaration + )+ + )? + ';' +; + +ConditionDeclaration: + 'condition' signal=SignalDeclaration +; + +PreconditionDeclaration: + 'precondition' signal=SignalDeclaration +; + +PostconditionDeclaration: + 'postcondition' signal=SignalDeclaration +; + +StateDeclaration: + 'state' name=ID + ( + 'constraints:' + (condition+=ConditionDeclaration)+ + )? + (transitions+=TransitionDeclaration)+ + ';' +; + +LoopsDeclaration: + 'loops:' val=INT +; + +SeedDeclaration: + 'randseed:' val=INT +; + +SignalDeclaration: + (port=ID '.')? signame=ID (('=' intVal=INT) | ('=' strVal=STRING))? +; diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtestRuntimeModule.java b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtestRuntimeModule.java index 68f0b3d13..d4ffc28c8 100644 --- a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtestRuntimeModule.java +++ b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtestRuntimeModule.java @@ -1,20 +1,20 @@ -/*******************************************************************************
- * 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.generator;
-
-/**
- * Use this class to register components to be used at runtime / without the Equinox extension registry.
- */
-public class FSMtestRuntimeModule extends org.eclipse.etrice.generator.AbstractFSMtestRuntimeModule {
-
-}
+/******************************************************************************* + * 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.generator; + +/** + * Use this class to register components to be used at runtime / without the Equinox extension registry. + */ +public class FSMtestRuntimeModule extends org.eclipse.etrice.generator.AbstractFSMtestRuntimeModule { + +} diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtestStandaloneSetup.java b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtestStandaloneSetup.java index 3862047da..52b178089 100644 --- a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtestStandaloneSetup.java +++ b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/FSMtestStandaloneSetup.java @@ -1,25 +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.generator;
-
-/**
- * Initialization support for running Xtext languages
- * without equinox extension registry
- */
-public class FSMtestStandaloneSetup extends FSMtestStandaloneSetupGenerated{
-
- public static void doSetup() {
- new FSMtestStandaloneSetup().createInjectorAndDoEMFRegistration();
- }
-}
-
+/******************************************************************************* + * 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.generator; + +/** + * Initialization support for running Xtext languages + * without equinox extension registry + */ +public class FSMtestStandaloneSetup extends FSMtestStandaloneSetupGenerated{ + + public static void doSetup() { + new FSMtestStandaloneSetup().createInjectorAndDoEMFRegistration(); + } +} + diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/GenerateFSMtest.mwe2 b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/GenerateFSMtest.mwe2 index c678cdc82..6ef6b8887 100644 --- a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/GenerateFSMtest.mwe2 +++ b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/GenerateFSMtest.mwe2 @@ -1,151 +1,151 @@ -/*******************************************************************************
- * 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.generator.GenerateFSMtest
-
-import org.eclipse.emf.mwe.utils.*
-import org.eclipse.xtext.generator.*
-import org.eclipse.xtext.ui.generator.*
-
-var grammarURI = "classpath:/org/eclipse/etrice/generator/FSMtest.xtext"
-var file.extensions = "fsmtest"
-var projectName = "org.eclipse.etrice.generator.fsmtest"
-var runtimeProject = "../${projectName}"
-
-Workflow {
- bean = StandaloneSetup {
- scanClassPath = true
- platformUri = "${runtimeProject}/.."
- // The following two lines can be removed, if Xbase is not used.
- registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
- registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
- }
-
- 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.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
- }
-
- }
- }
-}
-
+/******************************************************************************* + * 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.generator.GenerateFSMtest + +import org.eclipse.emf.mwe.utils.* +import org.eclipse.xtext.generator.* +import org.eclipse.xtext.ui.generator.* + +var grammarURI = "classpath:/org/eclipse/etrice/generator/FSMtest.xtext" +var file.extensions = "fsmtest" +var projectName = "org.eclipse.etrice.generator.fsmtest" +var runtimeProject = "../${projectName}" + +Workflow { + bean = StandaloneSetup { + scanClassPath = true + platformUri = "${runtimeProject}/.." + // The following two lines can be removed, if Xbase is not used. + registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage" + registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel" + } + + 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.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.generator.fsmtest/src/org/eclipse/etrice/generator/formatting/FSMtestFormatter.java b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/formatting/FSMtestFormatter.java index ba336900d..1a8d54d4a 100644 --- a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/formatting/FSMtestFormatter.java +++ b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/formatting/FSMtestFormatter.java @@ -1,80 +1,80 @@ -/*******************************************************************************
- * 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.generator.formatting;
-
-import org.eclipse.etrice.generator.services.FSMtestGrammarAccess;
-import org.eclipse.xtext.Keyword;
-import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
-import org.eclipse.xtext.formatting.impl.FormattingConfig;
-
-/**
- * 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 FSMtestFormatter extends AbstractDeclarativeFormatter {
-
- @Override
- protected void configureFormatting(FormattingConfig c) {
- FSMtestGrammarAccess grammarAccess = (FSMtestGrammarAccess) getGrammarAccess();
- c.setLinewrap(0, 1, 2).before(grammarAccess.getSL_COMMENTRule());
- c.setLinewrap(0, 1, 2).before(grammarAccess.getML_COMMENTRule());
- c.setLinewrap(0, 1, 1).after(grammarAccess.getML_COMMENTRule());
-
- for (Keyword k: grammarAccess.findKeywords(";")) {
- c.setIndentationDecrement().before(k);
- c.setLinewrap().before(k);
- }
-
- for (Keyword k: grammarAccess.findKeywords("initial","state","constraints:", "condition", "transition",
- "trigger:", "guards:", "fsm:", "loops:", "randseed:", "precondition", "postcondition", "randomtest")) {
- c.setLinewrap().before(k);
- }
-
- for (Keyword k: grammarAccess.findKeywords("randomtest", "fsmdefinition")) {
- c.setIndentationIncrement().after(k);
- c.setLinewrap(2).before(k);
- }
-
- for (Keyword k: grammarAccess.findKeywords("state", "transition")) {
- c.setIndentationIncrement().after(k);
- }
-
- for (Keyword k: grammarAccess.findKeywords(".")) {
- c.setNoSpace().around(k);
- }
-
- for (Keyword k: grammarAccess.findKeywords("initial")) {
- c.setNoLinewrap().after(k);
- }
-
- c.setIndentationIncrement().before(grammarAccess.getPostconditionDeclarationRule());
- c.setIndentationDecrement().after(grammarAccess.getPostconditionDeclarationRule());
- c.setLinewrap().before(grammarAccess.getPostconditionDeclarationRule());
-
- c.setIndentationIncrement().before(grammarAccess.getPreconditionDeclarationRule());
- c.setIndentationDecrement().after(grammarAccess.getPreconditionDeclarationRule());
- c.setLinewrap().before(grammarAccess.getPreconditionDeclarationRule());
-
- c.setIndentationIncrement().before(grammarAccess.getConditionDeclarationRule());
- c.setIndentationDecrement().after(grammarAccess.getConditionDeclarationRule());
- c.setLinewrap().before(grammarAccess.getConditionDeclarationRule());
-
- c.setIndentationIncrement().before(grammarAccess.getGuardDeclarationRule());
- c.setIndentationDecrement().after(grammarAccess.getGuardDeclarationRule());
- c.setLinewrap().before(grammarAccess.getGuardDeclarationRule());
- }
-}
+/******************************************************************************* + * 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.generator.formatting; + +import org.eclipse.etrice.generator.services.FSMtestGrammarAccess; +import org.eclipse.xtext.Keyword; +import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter; +import org.eclipse.xtext.formatting.impl.FormattingConfig; + +/** + * 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 FSMtestFormatter extends AbstractDeclarativeFormatter { + + @Override + protected void configureFormatting(FormattingConfig c) { + FSMtestGrammarAccess grammarAccess = (FSMtestGrammarAccess) getGrammarAccess(); + c.setLinewrap(0, 1, 2).before(grammarAccess.getSL_COMMENTRule()); + c.setLinewrap(0, 1, 2).before(grammarAccess.getML_COMMENTRule()); + c.setLinewrap(0, 1, 1).after(grammarAccess.getML_COMMENTRule()); + + for (Keyword k: grammarAccess.findKeywords(";")) { + c.setIndentationDecrement().before(k); + c.setLinewrap().before(k); + } + + for (Keyword k: grammarAccess.findKeywords("initial","state","constraints:", "condition", "transition", + "trigger:", "guards:", "fsm:", "loops:", "randseed:", "precondition", "postcondition", "randomtest")) { + c.setLinewrap().before(k); + } + + for (Keyword k: grammarAccess.findKeywords("randomtest", "fsmdefinition")) { + c.setIndentationIncrement().after(k); + c.setLinewrap(2).before(k); + } + + for (Keyword k: grammarAccess.findKeywords("state", "transition")) { + c.setIndentationIncrement().after(k); + } + + for (Keyword k: grammarAccess.findKeywords(".")) { + c.setNoSpace().around(k); + } + + for (Keyword k: grammarAccess.findKeywords("initial")) { + c.setNoLinewrap().after(k); + } + + c.setIndentationIncrement().before(grammarAccess.getPostconditionDeclarationRule()); + c.setIndentationDecrement().after(grammarAccess.getPostconditionDeclarationRule()); + c.setLinewrap().before(grammarAccess.getPostconditionDeclarationRule()); + + c.setIndentationIncrement().before(grammarAccess.getPreconditionDeclarationRule()); + c.setIndentationDecrement().after(grammarAccess.getPreconditionDeclarationRule()); + c.setLinewrap().before(grammarAccess.getPreconditionDeclarationRule()); + + c.setIndentationIncrement().before(grammarAccess.getConditionDeclarationRule()); + c.setIndentationDecrement().after(grammarAccess.getConditionDeclarationRule()); + c.setLinewrap().before(grammarAccess.getConditionDeclarationRule()); + + c.setIndentationIncrement().before(grammarAccess.getGuardDeclarationRule()); + c.setIndentationDecrement().after(grammarAccess.getGuardDeclarationRule()); + c.setLinewrap().before(grammarAccess.getGuardDeclarationRule()); + } +} diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/scoping/FSMtestScopeProvider.java b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/scoping/FSMtestScopeProvider.java index 87607588e..7f0a0bd85 100644 --- a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/scoping/FSMtestScopeProvider.java +++ b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/scoping/FSMtestScopeProvider.java @@ -1,26 +1,26 @@ -/*******************************************************************************
- * 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.generator.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 FSMtestScopeProvider extends AbstractDeclarativeScopeProvider {
-
-}
+/******************************************************************************* + * 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.generator.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 FSMtestScopeProvider extends AbstractDeclarativeScopeProvider { + +} diff --git a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/validation/FSMtestJavaValidator.java b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/validation/FSMtestJavaValidator.java index bfac1d20a..d678c04d3 100644 --- a/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/validation/FSMtestJavaValidator.java +++ b/plugins/org.eclipse.etrice.generator.fsmtest/src/org/eclipse/etrice/generator/validation/FSMtestJavaValidator.java @@ -1,62 +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.generator.validation;
-
-import org.eclipse.etrice.generator.fsmtest.FsmDefinition;
-import org.eclipse.etrice.generator.fsmtest.FsmtestPackage;
-import org.eclipse.etrice.generator.fsmtest.StateDeclaration;
-import org.eclipse.etrice.generator.fsmtest.TransitionDeclaration;
-import org.eclipse.xtext.validation.Check;
-
-
-public class FSMtestJavaValidator extends AbstractFSMtestJavaValidator {
-
-
- @Check
- public void CheckStateDeclaration(StateDeclaration s) {
- FsmDefinition f = (FsmDefinition) s.eContainer();
- for (StateDeclaration s1:f.getStates()) {
- if (s1 != s && s1.getName().equals(s.getName()))
- error("State names must be unique", FsmtestPackage.Literals.STATE_DECLARATION__NAME);
- }
- if (f.getStates().size()>1) {
- boolean found = false;
- for (TransitionDeclaration t1:s.getTransitions()) {
- if (t1.getDestination() != s)
- found = true;
- }
- if (!found)
- error("you cannot leave this state", FsmtestPackage.Literals.STATE_DECLARATION__NAME);
- }
- for (StateDeclaration s1:f.getStates()) {
- for (TransitionDeclaration t1:s1.getTransitions()) {
- if (t1.getDestination() == s && s1!=s)
- return;
- }
- }
- if (f.getStates().indexOf(s) != 0)
- error("State cannot be reached", FsmtestPackage.Literals.STATE_DECLARATION__NAME);
- }
-
- @Check
- public void CheckTransitionDeclaration(TransitionDeclaration t) {
- FsmDefinition f = (FsmDefinition) t.eContainer().eContainer();
- for (StateDeclaration s1:f.getStates()) {
- for (TransitionDeclaration t1:s1.getTransitions()) {
- if (t1 != t && t1.getName().equals(t.getName()))
- error("Transition names must be unique", FsmtestPackage.Literals.TRANSITION_DECLARATION__NAME);
- }
- }
- }
-
-}
+/******************************************************************************* + * 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.generator.validation; + +import org.eclipse.etrice.generator.fsmtest.FsmDefinition; +import org.eclipse.etrice.generator.fsmtest.FsmtestPackage; +import org.eclipse.etrice.generator.fsmtest.StateDeclaration; +import org.eclipse.etrice.generator.fsmtest.TransitionDeclaration; +import org.eclipse.xtext.validation.Check; + + +public class FSMtestJavaValidator extends AbstractFSMtestJavaValidator { + + + @Check + public void CheckStateDeclaration(StateDeclaration s) { + FsmDefinition f = (FsmDefinition) s.eContainer(); + for (StateDeclaration s1:f.getStates()) { + if (s1 != s && s1.getName().equals(s.getName())) + error("State names must be unique", FsmtestPackage.Literals.STATE_DECLARATION__NAME); + } + if (f.getStates().size()>1) { + boolean found = false; + for (TransitionDeclaration t1:s.getTransitions()) { + if (t1.getDestination() != s) + found = true; + } + if (!found) + error("you cannot leave this state", FsmtestPackage.Literals.STATE_DECLARATION__NAME); + } + for (StateDeclaration s1:f.getStates()) { + for (TransitionDeclaration t1:s1.getTransitions()) { + if (t1.getDestination() == s && s1!=s) + return; + } + } + if (f.getStates().indexOf(s) != 0) + error("State cannot be reached", FsmtestPackage.Literals.STATE_DECLARATION__NAME); + } + + @Check + public void CheckTransitionDeclaration(TransitionDeclaration t) { + FsmDefinition f = (FsmDefinition) t.eContainer().eContainer(); + for (StateDeclaration s1:f.getStates()) { + for (TransitionDeclaration t1:s1.getTransitions()) { + if (t1 != t && t1.getName().equals(t.getName())) + error("Transition names must be unique", FsmtestPackage.Literals.TRANSITION_DECLARATION__NAME); + } + } + } + +} |