From 5a6d1548c82fc9214616dbe276f5b7523fb8e49c Mon Sep 17 00:00:00 2001 From: Daedo Date: Thu, 23 May 2019 16:39:35 +0200 Subject: [PATCH 01/10] Added Objectif Grammar, Refactored XText util --- bundles/cnf/releaserepo/index.xml.sha | 1 - .../specmate-cause-effect-patterns/.classpath | 1 + .../resolve/GenerateMatcherUtil.java | 51 + .../resolve/XTextUtil.java | 70 -- bundles/specmate-integration-test/bnd.bnd | 8 +- .../resources/test_rules.objectif | 1 + .../integration/CauseEffectPatternTest.java | 6 +- .../test/integration/ObjectifTest.java | 31 + bundles/specmate-objectif/.classpath | 7 + bundles/specmate-objectif/.gitignore | 2 + bundles/specmate-objectif/.project | 23 + .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 11 + bundles/specmate-objectif/bnd.bnd | 33 + .../internal/AbstractDSLRuntimeModule.java | 201 ++++ .../specmate/objectif/internal/DSL.xtextbin | Bin 0 -> 2365 bytes .../objectif/internal/DSLRuntimeModule.java | 13 + .../objectif/internal/DSLStandaloneSetup.java | 16 + .../internal/DSLStandaloneSetupGenerated.java | 42 + .../objectif/internal/dSL/AND_Node.java | 106 ++ .../objectif/internal/dSL/BusinessRule.java | 106 ++ .../objectif/internal/dSL/DSLFactory.java | 80 ++ .../objectif/internal/dSL/DSLPackage.java | 589 ++++++++++ .../objectif/internal/dSL/Literal.java | 44 + .../specmate/objectif/internal/dSL/Model.java | 44 + .../objectif/internal/dSL/OR_Node.java | 106 ++ .../internal/dSL/impl/AND_NodeImpl.java | 337 ++++++ .../internal/dSL/impl/BusinessRuleImpl.java | 338 ++++++ .../internal/dSL/impl/DSLFactoryImpl.java | 155 +++ .../internal/dSL/impl/DSLPackageImpl.java | 395 +++++++ .../internal/dSL/impl/LiteralImpl.java | 164 +++ .../objectif/internal/dSL/impl/ModelImpl.java | 168 +++ .../internal/dSL/impl/OR_NodeImpl.java | 337 ++++++ .../internal/dSL/util/DSLAdapterFactory.java | 213 ++++ .../objectif/internal/dSL/util/DSLSwitch.java | 212 ++++ .../internal/generator/.DSLGenerator.xtendbin | Bin 0 -> 2285 bytes .../internal/generator/DSLGenerator.java | 21 + .../antlr/DSLAntlrTokenFileProvider.java | 16 + .../internal/parser/antlr/DSLParser.java | 40 + .../parser/antlr/internal/InternalDSL.g | 424 +++++++ .../parser/antlr/internal/InternalDSL.tokens | 20 + .../antlr/internal/InternalDSLLexer.java | 1045 +++++++++++++++++ .../antlr/internal/InternalDSLParser.java | 1011 ++++++++++++++++ .../scoping/AbstractDSLScopeProvider.java | 9 + .../internal/scoping/DSLScopeProvider.java | 16 + .../serializer/DSLSemanticSequencer.java | 117 ++ .../serializer/DSLSyntacticSequencer.java | 43 + .../internal/services/DSLGrammarAccess.java | 357 ++++++ .../validation/AbstractDSLValidator.java | 19 + .../DSLConfigurableIssueCodesProvider.java | 12 + .../internal/validation/DSLValidator.java | 15 + .../objectif/resolve/BusinessRuleUtil.java | 80 ++ .../com/specmate/objectif/resolve/packageinfo | 1 + .../objectif/resolve/rule/AndNode.java | 23 + .../resolve/rule/BusinessRuleNode.java | 43 + .../objectif/resolve/rule/LiteralNode.java | 21 + .../objectif/resolve/rule/ObjectifNode.java | 5 + .../objectif/resolve/rule/OrNode.java | 22 + .../objectif/resolve/rule/packageinfo | 1 + bundles/specmate-xtext/.classpath | 7 + bundles/specmate-xtext/.gitignore | 2 + bundles/specmate-xtext/.project | 23 + .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 11 + bundles/specmate-xtext/bnd.bnd | 12 + .../com/specmate/xtext}/XTextException.java | 2 +- .../xtext/XTextResourceProcessor.java | 21 + .../src/com/specmate/xtext/XTextUtil.java | 69 ++ .../src/com/specmate/xtext/packageinfo | 1 + 69 files changed, 7347 insertions(+), 77 deletions(-) delete mode 100644 bundles/cnf/releaserepo/index.xml.sha create mode 100644 bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/GenerateMatcherUtil.java delete mode 100644 bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/XTextUtil.java create mode 100644 bundles/specmate-integration-test/resources/test_rules.objectif create mode 100644 bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java create mode 100644 bundles/specmate-objectif/.classpath create mode 100644 bundles/specmate-objectif/.gitignore create mode 100644 bundles/specmate-objectif/.project create mode 100644 bundles/specmate-objectif/.settings/org.eclipse.core.resources.prefs create mode 100644 bundles/specmate-objectif/.settings/org.eclipse.jdt.core.prefs create mode 100644 bundles/specmate-objectif/bnd.bnd create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/AbstractDSLRuntimeModule.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/DSL.xtextbin create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/DSLRuntimeModule.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/DSLStandaloneSetup.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/DSLStandaloneSetupGenerated.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/AND_Node.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/BusinessRule.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/DSLFactory.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/DSLPackage.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/Literal.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/Model.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/OR_Node.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/AND_NodeImpl.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/BusinessRuleImpl.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/DSLFactoryImpl.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/DSLPackageImpl.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/LiteralImpl.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/ModelImpl.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/OR_NodeImpl.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/util/DSLAdapterFactory.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/util/DSLSwitch.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/generator/.DSLGenerator.xtendbin create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/generator/DSLGenerator.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/DSLAntlrTokenFileProvider.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/DSLParser.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSL.g create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSL.tokens create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSLLexer.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSLParser.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/scoping/AbstractDSLScopeProvider.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/scoping/DSLScopeProvider.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/serializer/DSLSemanticSequencer.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/serializer/DSLSyntacticSequencer.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/services/DSLGrammarAccess.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/AbstractDSLValidator.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/DSLConfigurableIssueCodesProvider.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/DSLValidator.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/resolve/BusinessRuleUtil.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/resolve/packageinfo create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/AndNode.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/BusinessRuleNode.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/LiteralNode.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/ObjectifNode.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/OrNode.java create mode 100644 bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/packageinfo create mode 100644 bundles/specmate-xtext/.classpath create mode 100644 bundles/specmate-xtext/.gitignore create mode 100644 bundles/specmate-xtext/.project create mode 100644 bundles/specmate-xtext/.settings/org.eclipse.core.resources.prefs create mode 100644 bundles/specmate-xtext/.settings/org.eclipse.jdt.core.prefs create mode 100644 bundles/specmate-xtext/bnd.bnd rename bundles/{specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve => specmate-xtext/src/com/specmate/xtext}/XTextException.java (77%) create mode 100644 bundles/specmate-xtext/src/com/specmate/xtext/XTextResourceProcessor.java create mode 100644 bundles/specmate-xtext/src/com/specmate/xtext/XTextUtil.java create mode 100644 bundles/specmate-xtext/src/com/specmate/xtext/packageinfo diff --git a/bundles/cnf/releaserepo/index.xml.sha b/bundles/cnf/releaserepo/index.xml.sha deleted file mode 100644 index 07ba11363..000000000 --- a/bundles/cnf/releaserepo/index.xml.sha +++ /dev/null @@ -1 +0,0 @@ -0400d6060920df51e4069b81cd760256a0e891a20f37e9dc0a06c4d05a97367b diff --git a/bundles/specmate-cause-effect-patterns/.classpath b/bundles/specmate-cause-effect-patterns/.classpath index 6483fc14f..0f02c123c 100644 --- a/bundles/specmate-cause-effect-patterns/.classpath +++ b/bundles/specmate-cause-effect-patterns/.classpath @@ -3,5 +3,6 @@ + diff --git a/bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/GenerateMatcherUtil.java b/bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/GenerateMatcherUtil.java new file mode 100644 index 000000000..319a97dab --- /dev/null +++ b/bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/GenerateMatcherUtil.java @@ -0,0 +1,51 @@ +package com.specmate.cause_effect_patterns.resolve; + +import java.util.List; +import java.util.Vector; +import java.util.stream.Collectors; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.ISetup; + +import com.specmate.cause_effect_patterns.internal.SpecDSLStandaloneSetup; +import com.specmate.cause_effect_patterns.internal.specDSL.Model; +import com.specmate.cause_effect_patterns.internal.specDSL.Rule; +import com.specmate.cause_effect_patterns.parse.matcher.MatchRule; +import com.specmate.cause_effect_patterns.parse.matcher.MatcherBase; +import com.specmate.cause_effect_patterns.parse.matcher.MatcherException; +import com.specmate.cause_effect_patterns.resolve.util.RuleUtility; +import com.specmate.xtext.XTextException; +import com.specmate.xtext.XTextResourceProcessor; + +public class GenerateMatcherUtil extends XTextResourceProcessor { + private static MatchRule resolveRule(Rule r) throws MatcherException { + MatcherBase match = RuleUtility.transform(r); + return new MatchRule(match, r.getName()); + } + + @Override + public ISetup getGrammar() { + return new SpecDSLStandaloneSetup(); + } + + @Override + public List process(EList data) throws XTextException { + List rules = data.stream() + .filter(e -> e instanceof Model) + .flatMap(m -> ((Model)m).getElements().stream()) + .filter(e -> e instanceof Rule) + .map(r -> (Rule) r) + .collect(Collectors.toList()); + List result = new Vector(); + for (Rule r:rules) { + try { + result.add(resolveRule(r)); + } catch (MatcherException e) { + throw new XTextException(e.getMessage()); + } + } + + return result; + } +} diff --git a/bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/XTextUtil.java b/bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/XTextUtil.java deleted file mode 100644 index 42a95105a..000000000 --- a/bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/XTextUtil.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.specmate.cause_effect_patterns.resolve; - -import java.util.List; -import java.util.Vector; -import java.util.stream.Collectors; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.xtext.resource.XtextResource; -import org.eclipse.xtext.resource.XtextResourceSet; -import org.eclipse.xtext.util.CancelIndicator; -import org.eclipse.xtext.validation.CheckMode; -import org.eclipse.xtext.validation.IResourceValidator; -import org.eclipse.xtext.validation.Issue; - -import com.google.inject.Injector; -import com.specmate.cause_effect_patterns.internal.SpecDSLStandaloneSetup; -import com.specmate.cause_effect_patterns.internal.specDSL.Model; -import com.specmate.cause_effect_patterns.internal.specDSL.Rule; -import com.specmate.cause_effect_patterns.parse.matcher.MatchRule; -import com.specmate.cause_effect_patterns.parse.matcher.MatcherBase; -import com.specmate.cause_effect_patterns.parse.matcher.MatcherException; -import com.specmate.cause_effect_patterns.resolve.util.RuleUtility; - -public class XTextUtil { - public static List generateMatchers(URI resourcePath, URI... definitionPaths) throws XTextException { - // do this only once per application - Injector injector = new SpecDSLStandaloneSetup().createInjectorAndDoEMFRegistration(); - - // obtain a resourceset from the injector - XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class); - - // load a resource by URI, in this case from the file system - Resource resource = resourceSet.getResource(resourcePath, true); - //Add any other models here - for(URI res: definitionPaths) { - resourceSet.getResource(res, true); - } - - // Validation - IResourceValidator validator = ((XtextResource)resource).getResourceServiceProvider().getResourceValidator(); - List issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl); - if(issues.size() > 0) { - String issueText = issues.stream().map(Issue::getMessage).collect(Collectors.joining("\n")); - throw new XTextException("Validation encountered issues:\n"+issueText); - } - - List rules = resource.getContents().stream() - .filter(e -> e instanceof Model) - .flatMap(m -> ((Model)m).getElements().stream()) - .filter(e -> e instanceof Rule) - .map(r -> (Rule) r) - .collect(Collectors.toList()); - List result = new Vector(); - for (Rule r:rules) { - try { - result.add(resolveRule(r)); - } catch (MatcherException e) { - throw new XTextException(e.getMessage()); - } - } - - return result; - } - - private static MatchRule resolveRule(Rule r) throws MatcherException { - MatcherBase match = RuleUtility.transform(r); - return new MatchRule(match, r.getName()); - } -} diff --git a/bundles/specmate-integration-test/bnd.bnd b/bundles/specmate-integration-test/bnd.bnd index 50a2e45b8..a06a45830 100644 --- a/bundles/specmate-integration-test/bnd.bnd +++ b/bundles/specmate-integration-test/bnd.bnd @@ -56,7 +56,9 @@ Test-Cases: \ org.apache.servicemix.bundles.automaton,\ specmate-nlp;version=latest,\ specmate-model-generation;version=latest,\ - specmate-cause-effect-patterns;version=latest + specmate-cause-effect-patterns;version=latest,\ + specmate-objectif;version=latest,\ + specmate-xtext -runee: JavaSE-1.8 -runfw: org.eclipse.osgi;version='[3.10.2.v20150203-1939,3.10.2.v20150203-1939]' @@ -277,7 +279,9 @@ Bundle-Version: 0.0.0.${tstamp} org.eclipse.xtext;version='[2.10.0,2.10.1)',\ org.eclipse.xtext.smap;version='[2.10.0,2.10.1)',\ org.eclipse.xtext.util;version='[2.10.0,2.10.1)',\ - org.eclipse.xtext.xbase.lib;version='[2.10.0,2.10.1)' + org.eclipse.xtext.xbase.lib;version='[2.10.0,2.10.1)',\ + specmate-objectif;version=snapshot,\ + specmate-xtext;version=snapshot -runproperties: \ jetty.http.port=8088,\ diff --git a/bundles/specmate-integration-test/resources/test_rules.objectif b/bundles/specmate-integration-test/resources/test_rules.objectif new file mode 100644 index 000000000..8a78cf82c --- /dev/null +++ b/bundles/specmate-integration-test/resources/test_rules.objectif @@ -0,0 +1 @@ +WENN A=5 UND B=3 DANN C=7 SONST D=5 ENDE-WENN \ No newline at end of file diff --git a/bundles/specmate-integration-test/src/com/specmate/test/integration/CauseEffectPatternTest.java b/bundles/specmate-integration-test/src/com/specmate/test/integration/CauseEffectPatternTest.java index cc03bfc65..4eeae7d64 100644 --- a/bundles/specmate-integration-test/src/com/specmate/test/integration/CauseEffectPatternTest.java +++ b/bundles/specmate-integration-test/src/com/specmate/test/integration/CauseEffectPatternTest.java @@ -19,11 +19,11 @@ import com.specmate.cause_effect_patterns.parse.matcher.MatchUtil; import com.specmate.cause_effect_patterns.parse.matcher.MatcherBase; import com.specmate.cause_effect_patterns.parse.matcher.MatcherException; -import com.specmate.cause_effect_patterns.resolve.XTextUtil; -import com.specmate.cause_effect_patterns.resolve.XTextException; +import com.specmate.cause_effect_patterns.resolve.GenerateMatcherUtil; import com.specmate.common.exception.SpecmateException; import com.specmate.nlp.api.ELanguage; import com.specmate.nlp.api.INLPService; +import com.specmate.xtext.XTextException; public class CauseEffectPatternTest { @@ -102,7 +102,7 @@ private List loadRules(String mainFile) throws URISyntaxException, XT URI main = getLocalFile(mainFile); URI pos = getLocalFile("/resources/pos_EN.spec"); URI dep = getLocalFile("/resources/dep_EN.spec"); - return XTextUtil.generateMatchers(main, pos, dep); + return new GenerateMatcherUtil().loadXTextResources(main, pos, dep); } private List convertMatchRule(List rules) { diff --git a/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java b/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java new file mode 100644 index 000000000..5f64e8d74 --- /dev/null +++ b/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java @@ -0,0 +1,31 @@ +package com.specmate.test.integration; + +import java.net.URISyntaxException; +import java.util.List; + +import org.eclipse.emf.common.util.URI; +import org.junit.Test; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +import com.specmate.objectif.resolve.BusinessRuleUtil; +import com.specmate.objectif.resolve.rule.BusinessRuleNode; +import com.specmate.xtext.XTextException; + +public class ObjectifTest { + @Test + public void testLoadRules() throws URISyntaxException, XTextException { + loadRules("/resources/test_rules.objectif"); + } + + private void loadRules(String mainFile) throws URISyntaxException, XTextException { + URI main = getLocalFile(mainFile); + List rules = new BusinessRuleUtil().loadXTextResources(main); + rules.forEach(System.out::println); + } + + private URI getLocalFile(String fileName) throws URISyntaxException { + Bundle bundle = FrameworkUtil.getBundle(NLPServiceTest.class); + return URI.createURI(bundle.getResource(fileName).toURI().toString()); + } +} diff --git a/bundles/specmate-objectif/.classpath b/bundles/specmate-objectif/.classpath new file mode 100644 index 000000000..6483fc14f --- /dev/null +++ b/bundles/specmate-objectif/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/specmate-objectif/.gitignore b/bundles/specmate-objectif/.gitignore new file mode 100644 index 000000000..57b341172 --- /dev/null +++ b/bundles/specmate-objectif/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/generated/ diff --git a/bundles/specmate-objectif/.project b/bundles/specmate-objectif/.project new file mode 100644 index 000000000..331976f59 --- /dev/null +++ b/bundles/specmate-objectif/.project @@ -0,0 +1,23 @@ + + + specmate-objectif + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/bundles/specmate-objectif/.settings/org.eclipse.core.resources.prefs b/bundles/specmate-objectif/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..1554c6f84 --- /dev/null +++ b/bundles/specmate-objectif/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/bnd.bnd=UTF-8 diff --git a/bundles/specmate-objectif/.settings/org.eclipse.jdt.core.prefs b/bundles/specmate-objectif/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/bundles/specmate-objectif/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bundles/specmate-objectif/bnd.bnd b/bundles/specmate-objectif/bnd.bnd new file mode 100644 index 000000000..4f8493d1a --- /dev/null +++ b/bundles/specmate-objectif/bnd.bnd @@ -0,0 +1,33 @@ +-buildpath: \ + org.eclipse.xtext,\ + com.google.inject,\ + org.eclipse.xtext.util,\ + org.eclipse.emf.ecore,\ + org.antlr.runtime,\ + org.eclipse.emf.common,\ + org.eclipse.xtext.xbase.lib,\ + com.google.guava,\ + specmate-nlp,\ + org.glassfish.hk2.external.javax.inject,\ + specmate-xtext;version=latest +-privatepackage: \ + com.specmate.objectif.internal,\ + com.specmate.objectif.internal.dSL,\ + com.specmate.objectif.internal.generator,\ + com.specmate.objectif.internal.parser.antlr,\ + com.specmate.objectif.internal.scoping,\ + com.specmate.objectif.internal.serializer,\ + com.specmate.objectif.internal.services,\ + com.specmate.objectif.internal.validation,\ + com.specmate.objectif.internal.dSL.impl,\ + com.specmate.objectif.internal.parser.antlr.internal,\ + com.specmate.objectif.internal.dSL.util +Export-Package: \ + com.specmate.objectif.resolve,\ + com.specmate.objectif.resolve.rule +Import-Package: \ + org.eclipse.xtext.smap;resolution:=optional,\ + * +-runfw: org.eclipse.osgi;version='[3.10.2.v20150203-1939,3.10.2.v20150203-1939]' +-runee: JavaSE-1.8 +Bundle-Version: 0.0.0.${tstamp} \ No newline at end of file diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/AbstractDSLRuntimeModule.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/AbstractDSLRuntimeModule.java new file mode 100644 index 000000000..866f5d621 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/AbstractDSLRuntimeModule.java @@ -0,0 +1,201 @@ +/* + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal; + +import com.google.inject.Binder; +import com.google.inject.Provider; +import com.google.inject.name.Names; +import com.specmate.objectif.internal.generator.DSLGenerator; +import com.specmate.objectif.internal.parser.antlr.DSLAntlrTokenFileProvider; +import com.specmate.objectif.internal.parser.antlr.DSLParser; +import com.specmate.objectif.internal.parser.antlr.internal.InternalDSLLexer; +import com.specmate.objectif.internal.scoping.DSLScopeProvider; +import com.specmate.objectif.internal.serializer.DSLSemanticSequencer; +import com.specmate.objectif.internal.serializer.DSLSyntacticSequencer; +import com.specmate.objectif.internal.services.DSLGrammarAccess; +import com.specmate.objectif.internal.validation.DSLConfigurableIssueCodesProvider; +import com.specmate.objectif.internal.validation.DSLValidator; +import java.util.Properties; +import org.eclipse.xtext.Constants; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.generator.IGenerator2; +import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider; +import org.eclipse.xtext.naming.IQualifiedNameProvider; +import org.eclipse.xtext.parser.IParser; +import org.eclipse.xtext.parser.ITokenToStringConverter; +import org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider; +import org.eclipse.xtext.parser.antlr.AntlrTokenToStringConverter; +import org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider; +import org.eclipse.xtext.parser.antlr.ITokenDefProvider; +import org.eclipse.xtext.parser.antlr.Lexer; +import org.eclipse.xtext.parser.antlr.LexerBindings; +import org.eclipse.xtext.parser.antlr.LexerProvider; +import org.eclipse.xtext.resource.IContainer; +import org.eclipse.xtext.resource.IResourceDescriptions; +import org.eclipse.xtext.resource.containers.IAllContainersState; +import org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider; +import org.eclipse.xtext.resource.containers.StateBasedContainerManager; +import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider; +import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions; +import org.eclipse.xtext.scoping.IGlobalScopeProvider; +import org.eclipse.xtext.scoping.IScopeProvider; +import org.eclipse.xtext.scoping.IgnoreCaseLinking; +import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider; +import org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider; +import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider; +import org.eclipse.xtext.serializer.ISerializer; +import org.eclipse.xtext.serializer.impl.Serializer; +import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer; +import org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer; +import org.eclipse.xtext.service.DefaultRuntimeModule; +import org.eclipse.xtext.service.SingletonBinding; +import org.eclipse.xtext.validation.ConfigurableIssueCodesProvider; + +/** + * Manual modifications go to {@link DSLRuntimeModule}. + */ +@SuppressWarnings("all") +public abstract class AbstractDSLRuntimeModule extends DefaultRuntimeModule { + + protected Properties properties = null; + + @Override + public void configure(Binder binder) { + properties = tryBindProperties(binder, "com/specmate/objectif/DSL.properties"); + super.configure(binder); + } + + public void configureLanguageName(Binder binder) { + binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("com.specmate.objectif.internal.DSL"); + } + + public void configureFileExtensions(Binder binder) { + if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null) + binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("objectif"); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public ClassLoader bindClassLoaderToInstance() { + return getClass().getClassLoader(); + } + + // contributed by org.eclipse.xtext.xtext.generator.grammarAccess.GrammarAccessFragment2 + public Class bindIGrammarAccess() { + return DSLGrammarAccess.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISemanticSequencer() { + return DSLSemanticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISyntacticSequencer() { + return DSLSyntacticSequencer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.serializer.SerializerFragment2 + public Class bindISerializer() { + return Serializer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIParser() { + return DSLParser.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenToStringConverter() { + return AntlrTokenToStringConverter.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindIAntlrTokenFileProvider() { + return DSLAntlrTokenFileProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindLexer() { + return InternalDSLLexer.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Class bindITokenDefProvider() { + return AntlrTokenDefProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public Provider provideInternalDSLLexer() { + return LexerProvider.create(InternalDSLLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2 + public void configureRuntimeLexer(Binder binder) { + binder.bind(Lexer.class) + .annotatedWith(Names.named(LexerBindings.RUNTIME)) + .to(InternalDSLLexer.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.validation.ValidatorFragment2 + @SingletonBinding(eager=true) + public Class bindDSLValidator() { + return DSLValidator.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.validation.ValidatorFragment2 + public Class bindConfigurableIssueCodesProvider() { + return DSLConfigurableIssueCodesProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2 + public Class bindIScopeProvider() { + return DSLScopeProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2 + public void configureIScopeProviderDelegate(Binder binder) { + binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ImportedNamespaceAwareLocalScopeProvider.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2 + public Class bindIGlobalScopeProvider() { + return DefaultGlobalScopeProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.scoping.ImportNamespacesScopingFragment2 + public void configureIgnoreCaseLinking(Binder binder) { + binder.bindConstant().annotatedWith(IgnoreCaseLinking.class).to(false); + } + + // contributed by org.eclipse.xtext.xtext.generator.exporting.QualifiedNamesFragment2 + public Class bindIQualifiedNameProvider() { + return DefaultDeclarativeQualifiedNameProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public Class bindIContainer$Manager() { + return StateBasedContainerManager.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public Class bindIAllContainersState$Provider() { + return ResourceSetBasedAllContainersStateProvider.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public void configureIResourceDescriptions(Binder binder) { + binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.builder.BuilderIntegrationFragment2 + public void configureIResourceDescriptionsPersisted(Binder binder) { + binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class); + } + + // contributed by org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2 + public Class bindIGenerator2() { + return DSLGenerator.class; + } + +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/DSL.xtextbin b/bundles/specmate-objectif/src/com/specmate/objectif/internal/DSL.xtextbin new file mode 100644 index 0000000000000000000000000000000000000000..63b718ec0ccfb69cffbd9d2b1e44468b9f68bd63 GIT binary patch literal 2365 zcma);`Ck)96u@~inaxF@Rcl*&Su7r)S!*w~A}=N>P$6g%idsv$CX=wT+2HO*#M=9` z_kG{T|JnC88w5Y?=Oe$o*_rpg^X6UQrfxS=nO&&?2{5u81gpnQb8T%ctLu)v>g#OB zYnew5A3kcH3-q<%4pf8*i7C%&w=GX7*J|rs^-eqMuj+c+3W#^r##d&^yxnoLRqeHH*K+*Wj)rd9uJ)(xMnk*R&Wd(@P?_aTpD_s{ z)3+#h9o=(9E>@%p)>m~5WTHy4teYa$)`8XTG_<22wu5%Gr`@`4%=NcLQlGKvD^^Pz zV(<9Z%n>nhD8bgdPyWl!oQlmTzcgfK1mN%lGZ3t-ZJqsbawjEOvT8 zq)f9|2|U|vK`diAf%aT0u&-)AL2<}!`WAzA%WH7h>|kAttE6^xTf2d;l3*lG>-Dvc z*HFe)%js&d8&Y5>k%Tmh3=FbJ0YC<2ioiITvNlu3O+s5Z(CShSab1S#FJNn#vAg*FNLy!sgLNZg*Eh?Ty zh}!z5v0LQ(Kq+~D&*@z(GIYlS5Z`JrspNxT+`dP;5A`g`#@M-05(Vl5%cJ0STwkcT z;ZZI5iHFH?Ia832^c~*K4nIm*F{#87jF2a>J&+pCFOzYdo?f=xmR8Eq&EPS<#{$Ff z?ACHH%3s$3_CiYS<8=;<{VXp49AH@k7y~85m{Q}UbCCDQ`VdR9%hI07YqC4clI$L5 zS%V{V^aL+y|4Ej|=xqQ`k@K+`O5@X^_s6VHUiv(Z7hXUD|K#xk>AVwIkf%9YO7 z=Bv}ivc!e{bMOUbQ9^MM2DeXXS5p!E=S;wJ0tV#hrn#^&>u7SB{ds57yc1?DoQSbT zg&dFLdB~*CSe{Siu`!~IIi5tlDTNov9bA<7qLA@oo~OZpOqgbqB7q>Q>nv)&LBacsb_LQUAje7RPl*GguKXnW%T%fI@3<%&^OZt5iPQ^3%C;E?+H{Yn8JL#ZtZ~agA8v zfW&KDspD!Ju2VDObuKR)_~7u3M`IxlK~Z}9P({6Rg8Z}Ebf z7~kf_1mHU?O~7|qjsm{Nau4A9EKdM_!15&EO_nzRKV+E&{D|cw;KwWv0)E1B1n^Uq z`vE^=d4TFa{KL;_hSFe@_yq+qX1NVRPErWIB(2y&sXz{WMF$DLdx_H-=IHBQjv~M} zeZaS*Cp%ux{yVZ)^MzuW0N>vZ_<;es@4=6(TF7xV{Y08^-E7i-5#dcghn@Zlt1kim z+Bd`B`gi_Lwnk;XRH*{~LB@ldelSDApCRF|i12rx0Qe7Cri!IP@laUEy + * A representation of the model object 'AND Node'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.AND_Node#getNode Node}
  • + *
  • {@link com.specmate.objectif.dSL.AND_Node#isAnd And}
  • + *
  • {@link com.specmate.objectif.dSL.AND_Node#getSubNode Sub Node}
  • + *
+ * + * @see com.specmate.objectif.dSL.DSLPackage#getAND_Node() + * @model + * @generated + */ +public interface AND_Node extends EObject +{ + /** + * Returns the value of the 'Node' containment reference. + * + *

+ * If the meaning of the 'Node' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Node' containment reference. + * @see #setNode(Literal) + * @see com.specmate.objectif.dSL.DSLPackage#getAND_Node_Node() + * @model containment="true" + * @generated + */ + Literal getNode(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.AND_Node#getNode Node}' containment reference. + * + * + * @param value the new value of the 'Node' containment reference. + * @see #getNode() + * @generated + */ + void setNode(Literal value); + + /** + * Returns the value of the 'And' attribute. + * + *

+ * If the meaning of the 'And' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'And' attribute. + * @see #setAnd(boolean) + * @see com.specmate.objectif.dSL.DSLPackage#getAND_Node_And() + * @model + * @generated + */ + boolean isAnd(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.AND_Node#isAnd And}' attribute. + * + * + * @param value the new value of the 'And' attribute. + * @see #isAnd() + * @generated + */ + void setAnd(boolean value); + + /** + * Returns the value of the 'Sub Node' containment reference. + * + *

+ * If the meaning of the 'Sub Node' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Sub Node' containment reference. + * @see #setSubNode(AND_Node) + * @see com.specmate.objectif.dSL.DSLPackage#getAND_Node_SubNode() + * @model containment="true" + * @generated + */ + AND_Node getSubNode(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.AND_Node#getSubNode Sub Node}' containment reference. + * + * + * @param value the new value of the 'Sub Node' containment reference. + * @see #getSubNode() + * @generated + */ + void setSubNode(AND_Node value); + +} // AND_Node diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/BusinessRule.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/BusinessRule.java new file mode 100644 index 000000000..de2a707a1 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/BusinessRule.java @@ -0,0 +1,106 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Business Rule'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.BusinessRule#getCause Cause}
  • + *
  • {@link com.specmate.objectif.dSL.BusinessRule#getEffect Effect}
  • + *
  • {@link com.specmate.objectif.dSL.BusinessRule#getAlternative Alternative}
  • + *
+ * + * @see com.specmate.objectif.dSL.DSLPackage#getBusinessRule() + * @model + * @generated + */ +public interface BusinessRule extends EObject +{ + /** + * Returns the value of the 'Cause' containment reference. + * + *

+ * If the meaning of the 'Cause' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Cause' containment reference. + * @see #setCause(OR_Node) + * @see com.specmate.objectif.dSL.DSLPackage#getBusinessRule_Cause() + * @model containment="true" + * @generated + */ + OR_Node getCause(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.BusinessRule#getCause Cause}' containment reference. + * + * + * @param value the new value of the 'Cause' containment reference. + * @see #getCause() + * @generated + */ + void setCause(OR_Node value); + + /** + * Returns the value of the 'Effect' containment reference. + * + *

+ * If the meaning of the 'Effect' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Effect' containment reference. + * @see #setEffect(EObject) + * @see com.specmate.objectif.dSL.DSLPackage#getBusinessRule_Effect() + * @model containment="true" + * @generated + */ + EObject getEffect(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.BusinessRule#getEffect Effect}' containment reference. + * + * + * @param value the new value of the 'Effect' containment reference. + * @see #getEffect() + * @generated + */ + void setEffect(EObject value); + + /** + * Returns the value of the 'Alternative' containment reference. + * + *

+ * If the meaning of the 'Alternative' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Alternative' containment reference. + * @see #setAlternative(EObject) + * @see com.specmate.objectif.dSL.DSLPackage#getBusinessRule_Alternative() + * @model containment="true" + * @generated + */ + EObject getAlternative(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.BusinessRule#getAlternative Alternative}' containment reference. + * + * + * @param value the new value of the 'Alternative' containment reference. + * @see #getAlternative() + * @generated + */ + void setAlternative(EObject value); + +} // BusinessRule diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/DSLFactory.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/DSLFactory.java new file mode 100644 index 000000000..da854c362 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/DSLFactory.java @@ -0,0 +1,80 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see com.specmate.objectif.dSL.DSLPackage + * @generated + */ +public interface DSLFactory extends EFactory +{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + DSLFactory eINSTANCE = com.specmate.objectif.internal.dSL.impl.DSLFactoryImpl.init(); + + /** + * Returns a new object of class 'Model'. + * + * + * @return a new object of class 'Model'. + * @generated + */ + Model createModel(); + + /** + * Returns a new object of class 'Business Rule'. + * + * + * @return a new object of class 'Business Rule'. + * @generated + */ + BusinessRule createBusinessRule(); + + /** + * Returns a new object of class 'OR Node'. + * + * + * @return a new object of class 'OR Node'. + * @generated + */ + OR_Node createOR_Node(); + + /** + * Returns a new object of class 'AND Node'. + * + * + * @return a new object of class 'AND Node'. + * @generated + */ + AND_Node createAND_Node(); + + /** + * Returns a new object of class 'Literal'. + * + * + * @return a new object of class 'Literal'. + * @generated + */ + Literal createLiteral(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + DSLPackage getDSLPackage(); + +} //DSLFactory diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/DSLPackage.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/DSLPackage.java new file mode 100644 index 000000000..212b146a5 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/DSLPackage.java @@ -0,0 +1,589 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see com.specmate.objectif.dSL.DSLFactory + * @model kind="package" + * @generated + */ +public interface DSLPackage extends EPackage +{ + /** + * The package name. + * + * + * @generated + */ + String eNAME = "dSL"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.specmate.com/objectif/DSL"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "dSL"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + DSLPackage eINSTANCE = com.specmate.objectif.internal.dSL.impl.DSLPackageImpl.init(); + + /** + * The meta object id for the '{@link com.specmate.objectif.dSL.impl.ModelImpl Model}' class. + * + * + * @see com.specmate.objectif.dSL.impl.ModelImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getModel() + * @generated + */ + int MODEL = 0; + + /** + * The feature id for the 'Rules' containment reference list. + * + * + * @generated + * @ordered + */ + int MODEL__RULES = 0; + + /** + * The number of structural features of the 'Model' class. + * + * + * @generated + * @ordered + */ + int MODEL_FEATURE_COUNT = 1; + + /** + * The meta object id for the '{@link com.specmate.objectif.dSL.impl.BusinessRuleImpl Business Rule}' class. + * + * + * @see com.specmate.objectif.dSL.impl.BusinessRuleImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getBusinessRule() + * @generated + */ + int BUSINESS_RULE = 1; + + /** + * The feature id for the 'Cause' containment reference. + * + * + * @generated + * @ordered + */ + int BUSINESS_RULE__CAUSE = 0; + + /** + * The feature id for the 'Effect' containment reference. + * + * + * @generated + * @ordered + */ + int BUSINESS_RULE__EFFECT = 1; + + /** + * The feature id for the 'Alternative' containment reference. + * + * + * @generated + * @ordered + */ + int BUSINESS_RULE__ALTERNATIVE = 2; + + /** + * The number of structural features of the 'Business Rule' class. + * + * + * @generated + * @ordered + */ + int BUSINESS_RULE_FEATURE_COUNT = 3; + + /** + * The meta object id for the '{@link com.specmate.objectif.dSL.impl.OR_NodeImpl OR Node}' class. + * + * + * @see com.specmate.objectif.dSL.impl.OR_NodeImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getOR_Node() + * @generated + */ + int OR_NODE = 2; + + /** + * The feature id for the 'Node' containment reference. + * + * + * @generated + * @ordered + */ + int OR_NODE__NODE = 0; + + /** + * The feature id for the 'Or' attribute. + * + * + * @generated + * @ordered + */ + int OR_NODE__OR = 1; + + /** + * The feature id for the 'Sub Node' containment reference. + * + * + * @generated + * @ordered + */ + int OR_NODE__SUB_NODE = 2; + + /** + * The number of structural features of the 'OR Node' class. + * + * + * @generated + * @ordered + */ + int OR_NODE_FEATURE_COUNT = 3; + + /** + * The meta object id for the '{@link com.specmate.objectif.dSL.impl.AND_NodeImpl AND Node}' class. + * + * + * @see com.specmate.objectif.dSL.impl.AND_NodeImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getAND_Node() + * @generated + */ + int AND_NODE = 3; + + /** + * The feature id for the 'Node' containment reference. + * + * + * @generated + * @ordered + */ + int AND_NODE__NODE = 0; + + /** + * The feature id for the 'And' attribute. + * + * + * @generated + * @ordered + */ + int AND_NODE__AND = 1; + + /** + * The feature id for the 'Sub Node' containment reference. + * + * + * @generated + * @ordered + */ + int AND_NODE__SUB_NODE = 2; + + /** + * The number of structural features of the 'AND Node' class. + * + * + * @generated + * @ordered + */ + int AND_NODE_FEATURE_COUNT = 3; + + /** + * The meta object id for the '{@link com.specmate.objectif.dSL.impl.LiteralImpl Literal}' class. + * + * + * @see com.specmate.objectif.dSL.impl.LiteralImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getLiteral() + * @generated + */ + int LITERAL = 4; + + /** + * The feature id for the 'Content' attribute list. + * + * + * @generated + * @ordered + */ + int LITERAL__CONTENT = 0; + + /** + * The number of structural features of the 'Literal' class. + * + * + * @generated + * @ordered + */ + int LITERAL_FEATURE_COUNT = 1; + + + /** + * Returns the meta object for class '{@link com.specmate.objectif.dSL.Model Model}'. + * + * + * @return the meta object for class 'Model'. + * @see com.specmate.objectif.dSL.Model + * @generated + */ + EClass getModel(); + + /** + * Returns the meta object for the containment reference list '{@link com.specmate.objectif.dSL.Model#getRules Rules}'. + * + * + * @return the meta object for the containment reference list 'Rules'. + * @see com.specmate.objectif.dSL.Model#getRules() + * @see #getModel() + * @generated + */ + EReference getModel_Rules(); + + /** + * Returns the meta object for class '{@link com.specmate.objectif.dSL.BusinessRule Business Rule}'. + * + * + * @return the meta object for class 'Business Rule'. + * @see com.specmate.objectif.dSL.BusinessRule + * @generated + */ + EClass getBusinessRule(); + + /** + * Returns the meta object for the containment reference '{@link com.specmate.objectif.dSL.BusinessRule#getCause Cause}'. + * + * + * @return the meta object for the containment reference 'Cause'. + * @see com.specmate.objectif.dSL.BusinessRule#getCause() + * @see #getBusinessRule() + * @generated + */ + EReference getBusinessRule_Cause(); + + /** + * Returns the meta object for the containment reference '{@link com.specmate.objectif.dSL.BusinessRule#getEffect Effect}'. + * + * + * @return the meta object for the containment reference 'Effect'. + * @see com.specmate.objectif.dSL.BusinessRule#getEffect() + * @see #getBusinessRule() + * @generated + */ + EReference getBusinessRule_Effect(); + + /** + * Returns the meta object for the containment reference '{@link com.specmate.objectif.dSL.BusinessRule#getAlternative Alternative}'. + * + * + * @return the meta object for the containment reference 'Alternative'. + * @see com.specmate.objectif.dSL.BusinessRule#getAlternative() + * @see #getBusinessRule() + * @generated + */ + EReference getBusinessRule_Alternative(); + + /** + * Returns the meta object for class '{@link com.specmate.objectif.dSL.OR_Node OR Node}'. + * + * + * @return the meta object for class 'OR Node'. + * @see com.specmate.objectif.dSL.OR_Node + * @generated + */ + EClass getOR_Node(); + + /** + * Returns the meta object for the containment reference '{@link com.specmate.objectif.dSL.OR_Node#getNode Node}'. + * + * + * @return the meta object for the containment reference 'Node'. + * @see com.specmate.objectif.dSL.OR_Node#getNode() + * @see #getOR_Node() + * @generated + */ + EReference getOR_Node_Node(); + + /** + * Returns the meta object for the attribute '{@link com.specmate.objectif.dSL.OR_Node#isOr Or}'. + * + * + * @return the meta object for the attribute 'Or'. + * @see com.specmate.objectif.dSL.OR_Node#isOr() + * @see #getOR_Node() + * @generated + */ + EAttribute getOR_Node_Or(); + + /** + * Returns the meta object for the containment reference '{@link com.specmate.objectif.dSL.OR_Node#getSubNode Sub Node}'. + * + * + * @return the meta object for the containment reference 'Sub Node'. + * @see com.specmate.objectif.dSL.OR_Node#getSubNode() + * @see #getOR_Node() + * @generated + */ + EReference getOR_Node_SubNode(); + + /** + * Returns the meta object for class '{@link com.specmate.objectif.dSL.AND_Node AND Node}'. + * + * + * @return the meta object for class 'AND Node'. + * @see com.specmate.objectif.dSL.AND_Node + * @generated + */ + EClass getAND_Node(); + + /** + * Returns the meta object for the containment reference '{@link com.specmate.objectif.dSL.AND_Node#getNode Node}'. + * + * + * @return the meta object for the containment reference 'Node'. + * @see com.specmate.objectif.dSL.AND_Node#getNode() + * @see #getAND_Node() + * @generated + */ + EReference getAND_Node_Node(); + + /** + * Returns the meta object for the attribute '{@link com.specmate.objectif.dSL.AND_Node#isAnd And}'. + * + * + * @return the meta object for the attribute 'And'. + * @see com.specmate.objectif.dSL.AND_Node#isAnd() + * @see #getAND_Node() + * @generated + */ + EAttribute getAND_Node_And(); + + /** + * Returns the meta object for the containment reference '{@link com.specmate.objectif.dSL.AND_Node#getSubNode Sub Node}'. + * + * + * @return the meta object for the containment reference 'Sub Node'. + * @see com.specmate.objectif.dSL.AND_Node#getSubNode() + * @see #getAND_Node() + * @generated + */ + EReference getAND_Node_SubNode(); + + /** + * Returns the meta object for class '{@link com.specmate.objectif.dSL.Literal Literal}'. + * + * + * @return the meta object for class 'Literal'. + * @see com.specmate.objectif.dSL.Literal + * @generated + */ + EClass getLiteral(); + + /** + * Returns the meta object for the attribute list '{@link com.specmate.objectif.dSL.Literal#getContent Content}'. + * + * + * @return the meta object for the attribute list 'Content'. + * @see com.specmate.objectif.dSL.Literal#getContent() + * @see #getLiteral() + * @generated + */ + EAttribute getLiteral_Content(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + DSLFactory getDSLFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals + { + /** + * The meta object literal for the '{@link com.specmate.objectif.dSL.impl.ModelImpl Model}' class. + * + * + * @see com.specmate.objectif.dSL.impl.ModelImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getModel() + * @generated + */ + EClass MODEL = eINSTANCE.getModel(); + + /** + * The meta object literal for the 'Rules' containment reference list feature. + * + * + * @generated + */ + EReference MODEL__RULES = eINSTANCE.getModel_Rules(); + + /** + * The meta object literal for the '{@link com.specmate.objectif.dSL.impl.BusinessRuleImpl Business Rule}' class. + * + * + * @see com.specmate.objectif.dSL.impl.BusinessRuleImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getBusinessRule() + * @generated + */ + EClass BUSINESS_RULE = eINSTANCE.getBusinessRule(); + + /** + * The meta object literal for the 'Cause' containment reference feature. + * + * + * @generated + */ + EReference BUSINESS_RULE__CAUSE = eINSTANCE.getBusinessRule_Cause(); + + /** + * The meta object literal for the 'Effect' containment reference feature. + * + * + * @generated + */ + EReference BUSINESS_RULE__EFFECT = eINSTANCE.getBusinessRule_Effect(); + + /** + * The meta object literal for the 'Alternative' containment reference feature. + * + * + * @generated + */ + EReference BUSINESS_RULE__ALTERNATIVE = eINSTANCE.getBusinessRule_Alternative(); + + /** + * The meta object literal for the '{@link com.specmate.objectif.dSL.impl.OR_NodeImpl OR Node}' class. + * + * + * @see com.specmate.objectif.dSL.impl.OR_NodeImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getOR_Node() + * @generated + */ + EClass OR_NODE = eINSTANCE.getOR_Node(); + + /** + * The meta object literal for the 'Node' containment reference feature. + * + * + * @generated + */ + EReference OR_NODE__NODE = eINSTANCE.getOR_Node_Node(); + + /** + * The meta object literal for the 'Or' attribute feature. + * + * + * @generated + */ + EAttribute OR_NODE__OR = eINSTANCE.getOR_Node_Or(); + + /** + * The meta object literal for the 'Sub Node' containment reference feature. + * + * + * @generated + */ + EReference OR_NODE__SUB_NODE = eINSTANCE.getOR_Node_SubNode(); + + /** + * The meta object literal for the '{@link com.specmate.objectif.dSL.impl.AND_NodeImpl AND Node}' class. + * + * + * @see com.specmate.objectif.dSL.impl.AND_NodeImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getAND_Node() + * @generated + */ + EClass AND_NODE = eINSTANCE.getAND_Node(); + + /** + * The meta object literal for the 'Node' containment reference feature. + * + * + * @generated + */ + EReference AND_NODE__NODE = eINSTANCE.getAND_Node_Node(); + + /** + * The meta object literal for the 'And' attribute feature. + * + * + * @generated + */ + EAttribute AND_NODE__AND = eINSTANCE.getAND_Node_And(); + + /** + * The meta object literal for the 'Sub Node' containment reference feature. + * + * + * @generated + */ + EReference AND_NODE__SUB_NODE = eINSTANCE.getAND_Node_SubNode(); + + /** + * The meta object literal for the '{@link com.specmate.objectif.dSL.impl.LiteralImpl Literal}' class. + * + * + * @see com.specmate.objectif.dSL.impl.LiteralImpl + * @see com.specmate.objectif.dSL.impl.DSLPackageImpl#getLiteral() + * @generated + */ + EClass LITERAL = eINSTANCE.getLiteral(); + + /** + * The meta object literal for the 'Content' attribute list feature. + * + * + * @generated + */ + EAttribute LITERAL__CONTENT = eINSTANCE.getLiteral_Content(); + + } + +} //DSLPackage diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/Literal.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/Literal.java new file mode 100644 index 000000000..d5203ac05 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/Literal.java @@ -0,0 +1,44 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Literal'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.Literal#getContent Content}
  • + *
+ * + * @see com.specmate.objectif.dSL.DSLPackage#getLiteral() + * @model + * @generated + */ +public interface Literal extends EObject +{ + /** + * Returns the value of the 'Content' attribute list. + * The list contents are of type {@link java.lang.String}. + * + *

+ * If the meaning of the 'Content' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Content' attribute list. + * @see com.specmate.objectif.dSL.DSLPackage#getLiteral_Content() + * @model unique="false" + * @generated + */ + EList getContent(); + +} // Literal diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/Model.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/Model.java new file mode 100644 index 000000000..55b54ac8e --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/Model.java @@ -0,0 +1,44 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Model'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.Model#getRules Rules}
  • + *
+ * + * @see com.specmate.objectif.dSL.DSLPackage#getModel() + * @model + * @generated + */ +public interface Model extends EObject +{ + /** + * Returns the value of the 'Rules' containment reference list. + * The list contents are of type {@link com.specmate.objectif.dSL.BusinessRule}. + * + *

+ * If the meaning of the 'Rules' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Rules' containment reference list. + * @see com.specmate.objectif.dSL.DSLPackage#getModel_Rules() + * @model containment="true" + * @generated + */ + EList getRules(); + +} // Model diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/OR_Node.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/OR_Node.java new file mode 100644 index 000000000..02ec2af9a --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/OR_Node.java @@ -0,0 +1,106 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'OR Node'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.OR_Node#getNode Node}
  • + *
  • {@link com.specmate.objectif.dSL.OR_Node#isOr Or}
  • + *
  • {@link com.specmate.objectif.dSL.OR_Node#getSubNode Sub Node}
  • + *
+ * + * @see com.specmate.objectif.dSL.DSLPackage#getOR_Node() + * @model + * @generated + */ +public interface OR_Node extends EObject +{ + /** + * Returns the value of the 'Node' containment reference. + * + *

+ * If the meaning of the 'Node' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Node' containment reference. + * @see #setNode(AND_Node) + * @see com.specmate.objectif.dSL.DSLPackage#getOR_Node_Node() + * @model containment="true" + * @generated + */ + AND_Node getNode(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.OR_Node#getNode Node}' containment reference. + * + * + * @param value the new value of the 'Node' containment reference. + * @see #getNode() + * @generated + */ + void setNode(AND_Node value); + + /** + * Returns the value of the 'Or' attribute. + * + *

+ * If the meaning of the 'Or' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Or' attribute. + * @see #setOr(boolean) + * @see com.specmate.objectif.dSL.DSLPackage#getOR_Node_Or() + * @model + * @generated + */ + boolean isOr(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.OR_Node#isOr Or}' attribute. + * + * + * @param value the new value of the 'Or' attribute. + * @see #isOr() + * @generated + */ + void setOr(boolean value); + + /** + * Returns the value of the 'Sub Node' containment reference. + * + *

+ * If the meaning of the 'Sub Node' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Sub Node' containment reference. + * @see #setSubNode(OR_Node) + * @see com.specmate.objectif.dSL.DSLPackage#getOR_Node_SubNode() + * @model containment="true" + * @generated + */ + OR_Node getSubNode(); + + /** + * Sets the value of the '{@link com.specmate.objectif.dSL.OR_Node#getSubNode Sub Node}' containment reference. + * + * + * @param value the new value of the 'Sub Node' containment reference. + * @see #getSubNode() + * @generated + */ + void setSubNode(OR_Node value); + +} // OR_Node diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/AND_NodeImpl.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/AND_NodeImpl.java new file mode 100644 index 000000000..0ce7ded53 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/AND_NodeImpl.java @@ -0,0 +1,337 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.impl; + +import com.specmate.objectif.internal.dSL.AND_Node; +import com.specmate.objectif.internal.dSL.DSLPackage; +import com.specmate.objectif.internal.dSL.Literal; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'AND Node'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.impl.AND_NodeImpl#getNode Node}
  • + *
  • {@link com.specmate.objectif.dSL.impl.AND_NodeImpl#isAnd And}
  • + *
  • {@link com.specmate.objectif.dSL.impl.AND_NodeImpl#getSubNode Sub Node}
  • + *
+ * + * @generated + */ +public class AND_NodeImpl extends MinimalEObjectImpl.Container implements AND_Node +{ + /** + * The cached value of the '{@link #getNode() Node}' containment reference. + * + * + * @see #getNode() + * @generated + * @ordered + */ + protected Literal node; + + /** + * The default value of the '{@link #isAnd() And}' attribute. + * + * + * @see #isAnd() + * @generated + * @ordered + */ + protected static final boolean AND_EDEFAULT = false; + + /** + * The cached value of the '{@link #isAnd() And}' attribute. + * + * + * @see #isAnd() + * @generated + * @ordered + */ + protected boolean and = AND_EDEFAULT; + + /** + * The cached value of the '{@link #getSubNode() Sub Node}' containment reference. + * + * + * @see #getSubNode() + * @generated + * @ordered + */ + protected AND_Node subNode; + + /** + * + * + * @generated + */ + protected AND_NodeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return DSLPackage.Literals.AND_NODE; + } + + /** + * + * + * @generated + */ + public Literal getNode() + { + return node; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetNode(Literal newNode, NotificationChain msgs) + { + Literal oldNode = node; + node = newNode; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DSLPackage.AND_NODE__NODE, oldNode, newNode); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setNode(Literal newNode) + { + if (newNode != node) + { + NotificationChain msgs = null; + if (node != null) + msgs = ((InternalEObject)node).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DSLPackage.AND_NODE__NODE, null, msgs); + if (newNode != null) + msgs = ((InternalEObject)newNode).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DSLPackage.AND_NODE__NODE, null, msgs); + msgs = basicSetNode(newNode, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.AND_NODE__NODE, newNode, newNode)); + } + + /** + * + * + * @generated + */ + public boolean isAnd() + { + return and; + } + + /** + * + * + * @generated + */ + public void setAnd(boolean newAnd) + { + boolean oldAnd = and; + and = newAnd; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.AND_NODE__AND, oldAnd, and)); + } + + /** + * + * + * @generated + */ + public AND_Node getSubNode() + { + return subNode; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetSubNode(AND_Node newSubNode, NotificationChain msgs) + { + AND_Node oldSubNode = subNode; + subNode = newSubNode; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DSLPackage.AND_NODE__SUB_NODE, oldSubNode, newSubNode); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setSubNode(AND_Node newSubNode) + { + if (newSubNode != subNode) + { + NotificationChain msgs = null; + if (subNode != null) + msgs = ((InternalEObject)subNode).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DSLPackage.AND_NODE__SUB_NODE, null, msgs); + if (newSubNode != null) + msgs = ((InternalEObject)newSubNode).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DSLPackage.AND_NODE__SUB_NODE, null, msgs); + msgs = basicSetSubNode(newSubNode, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.AND_NODE__SUB_NODE, newSubNode, newSubNode)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case DSLPackage.AND_NODE__NODE: + return basicSetNode(null, msgs); + case DSLPackage.AND_NODE__SUB_NODE: + return basicSetSubNode(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case DSLPackage.AND_NODE__NODE: + return getNode(); + case DSLPackage.AND_NODE__AND: + return isAnd(); + case DSLPackage.AND_NODE__SUB_NODE: + return getSubNode(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case DSLPackage.AND_NODE__NODE: + setNode((Literal)newValue); + return; + case DSLPackage.AND_NODE__AND: + setAnd((Boolean)newValue); + return; + case DSLPackage.AND_NODE__SUB_NODE: + setSubNode((AND_Node)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case DSLPackage.AND_NODE__NODE: + setNode((Literal)null); + return; + case DSLPackage.AND_NODE__AND: + setAnd(AND_EDEFAULT); + return; + case DSLPackage.AND_NODE__SUB_NODE: + setSubNode((AND_Node)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case DSLPackage.AND_NODE__NODE: + return node != null; + case DSLPackage.AND_NODE__AND: + return and != AND_EDEFAULT; + case DSLPackage.AND_NODE__SUB_NODE: + return subNode != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (and: "); + result.append(and); + result.append(')'); + return result.toString(); + } + +} //AND_NodeImpl diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/BusinessRuleImpl.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/BusinessRuleImpl.java new file mode 100644 index 000000000..7320d9098 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/BusinessRuleImpl.java @@ -0,0 +1,338 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.impl; + +import com.specmate.objectif.internal.dSL.BusinessRule; +import com.specmate.objectif.internal.dSL.DSLPackage; +import com.specmate.objectif.internal.dSL.OR_Node; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'Business Rule'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.impl.BusinessRuleImpl#getCause Cause}
  • + *
  • {@link com.specmate.objectif.dSL.impl.BusinessRuleImpl#getEffect Effect}
  • + *
  • {@link com.specmate.objectif.dSL.impl.BusinessRuleImpl#getAlternative Alternative}
  • + *
+ * + * @generated + */ +public class BusinessRuleImpl extends MinimalEObjectImpl.Container implements BusinessRule +{ + /** + * The cached value of the '{@link #getCause() Cause}' containment reference. + * + * + * @see #getCause() + * @generated + * @ordered + */ + protected OR_Node cause; + + /** + * The cached value of the '{@link #getEffect() Effect}' containment reference. + * + * + * @see #getEffect() + * @generated + * @ordered + */ + protected EObject effect; + + /** + * The cached value of the '{@link #getAlternative() Alternative}' containment reference. + * + * + * @see #getAlternative() + * @generated + * @ordered + */ + protected EObject alternative; + + /** + * + * + * @generated + */ + protected BusinessRuleImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return DSLPackage.Literals.BUSINESS_RULE; + } + + /** + * + * + * @generated + */ + public OR_Node getCause() + { + return cause; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetCause(OR_Node newCause, NotificationChain msgs) + { + OR_Node oldCause = cause; + cause = newCause; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DSLPackage.BUSINESS_RULE__CAUSE, oldCause, newCause); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setCause(OR_Node newCause) + { + if (newCause != cause) + { + NotificationChain msgs = null; + if (cause != null) + msgs = ((InternalEObject)cause).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DSLPackage.BUSINESS_RULE__CAUSE, null, msgs); + if (newCause != null) + msgs = ((InternalEObject)newCause).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DSLPackage.BUSINESS_RULE__CAUSE, null, msgs); + msgs = basicSetCause(newCause, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.BUSINESS_RULE__CAUSE, newCause, newCause)); + } + + /** + * + * + * @generated + */ + public EObject getEffect() + { + return effect; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetEffect(EObject newEffect, NotificationChain msgs) + { + EObject oldEffect = effect; + effect = newEffect; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DSLPackage.BUSINESS_RULE__EFFECT, oldEffect, newEffect); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setEffect(EObject newEffect) + { + if (newEffect != effect) + { + NotificationChain msgs = null; + if (effect != null) + msgs = ((InternalEObject)effect).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DSLPackage.BUSINESS_RULE__EFFECT, null, msgs); + if (newEffect != null) + msgs = ((InternalEObject)newEffect).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DSLPackage.BUSINESS_RULE__EFFECT, null, msgs); + msgs = basicSetEffect(newEffect, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.BUSINESS_RULE__EFFECT, newEffect, newEffect)); + } + + /** + * + * + * @generated + */ + public EObject getAlternative() + { + return alternative; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetAlternative(EObject newAlternative, NotificationChain msgs) + { + EObject oldAlternative = alternative; + alternative = newAlternative; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DSLPackage.BUSINESS_RULE__ALTERNATIVE, oldAlternative, newAlternative); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setAlternative(EObject newAlternative) + { + if (newAlternative != alternative) + { + NotificationChain msgs = null; + if (alternative != null) + msgs = ((InternalEObject)alternative).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DSLPackage.BUSINESS_RULE__ALTERNATIVE, null, msgs); + if (newAlternative != null) + msgs = ((InternalEObject)newAlternative).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DSLPackage.BUSINESS_RULE__ALTERNATIVE, null, msgs); + msgs = basicSetAlternative(newAlternative, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.BUSINESS_RULE__ALTERNATIVE, newAlternative, newAlternative)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case DSLPackage.BUSINESS_RULE__CAUSE: + return basicSetCause(null, msgs); + case DSLPackage.BUSINESS_RULE__EFFECT: + return basicSetEffect(null, msgs); + case DSLPackage.BUSINESS_RULE__ALTERNATIVE: + return basicSetAlternative(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case DSLPackage.BUSINESS_RULE__CAUSE: + return getCause(); + case DSLPackage.BUSINESS_RULE__EFFECT: + return getEffect(); + case DSLPackage.BUSINESS_RULE__ALTERNATIVE: + return getAlternative(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case DSLPackage.BUSINESS_RULE__CAUSE: + setCause((OR_Node)newValue); + return; + case DSLPackage.BUSINESS_RULE__EFFECT: + setEffect((EObject)newValue); + return; + case DSLPackage.BUSINESS_RULE__ALTERNATIVE: + setAlternative((EObject)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case DSLPackage.BUSINESS_RULE__CAUSE: + setCause((OR_Node)null); + return; + case DSLPackage.BUSINESS_RULE__EFFECT: + setEffect((EObject)null); + return; + case DSLPackage.BUSINESS_RULE__ALTERNATIVE: + setAlternative((EObject)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case DSLPackage.BUSINESS_RULE__CAUSE: + return cause != null; + case DSLPackage.BUSINESS_RULE__EFFECT: + return effect != null; + case DSLPackage.BUSINESS_RULE__ALTERNATIVE: + return alternative != null; + } + return super.eIsSet(featureID); + } + +} //BusinessRuleImpl diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/DSLFactoryImpl.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/DSLFactoryImpl.java new file mode 100644 index 000000000..8115bc2f7 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/DSLFactoryImpl.java @@ -0,0 +1,155 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.impl; + +import com.specmate.objectif.internal.dSL.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class DSLFactoryImpl extends EFactoryImpl implements DSLFactory +{ + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static DSLFactory init() + { + try + { + DSLFactory theDSLFactory = (DSLFactory)EPackage.Registry.INSTANCE.getEFactory(DSLPackage.eNS_URI); + if (theDSLFactory != null) + { + return theDSLFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new DSLFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public DSLFactoryImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case DSLPackage.MODEL: return createModel(); + case DSLPackage.BUSINESS_RULE: return createBusinessRule(); + case DSLPackage.OR_NODE: return createOR_Node(); + case DSLPackage.AND_NODE: return createAND_Node(); + case DSLPackage.LITERAL: return createLiteral(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public Model createModel() + { + ModelImpl model = new ModelImpl(); + return model; + } + + /** + * + * + * @generated + */ + public BusinessRule createBusinessRule() + { + BusinessRuleImpl businessRule = new BusinessRuleImpl(); + return businessRule; + } + + /** + * + * + * @generated + */ + public OR_Node createOR_Node() + { + OR_NodeImpl oR_Node = new OR_NodeImpl(); + return oR_Node; + } + + /** + * + * + * @generated + */ + public AND_Node createAND_Node() + { + AND_NodeImpl anD_Node = new AND_NodeImpl(); + return anD_Node; + } + + /** + * + * + * @generated + */ + public Literal createLiteral() + { + LiteralImpl literal = new LiteralImpl(); + return literal; + } + + /** + * + * + * @generated + */ + public DSLPackage getDSLPackage() + { + return (DSLPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static DSLPackage getPackage() + { + return DSLPackage.eINSTANCE; + } + +} //DSLFactoryImpl diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/DSLPackageImpl.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/DSLPackageImpl.java new file mode 100644 index 000000000..337c7d0e4 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/DSLPackageImpl.java @@ -0,0 +1,395 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.impl; + +import com.specmate.objectif.internal.dSL.AND_Node; +import com.specmate.objectif.internal.dSL.BusinessRule; +import com.specmate.objectif.internal.dSL.DSLFactory; +import com.specmate.objectif.internal.dSL.DSLPackage; +import com.specmate.objectif.internal.dSL.Literal; +import com.specmate.objectif.internal.dSL.Model; +import com.specmate.objectif.internal.dSL.OR_Node; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class DSLPackageImpl extends EPackageImpl implements DSLPackage +{ + /** + * + * + * @generated + */ + private EClass modelEClass = null; + + /** + * + * + * @generated + */ + private EClass businessRuleEClass = null; + + /** + * + * + * @generated + */ + private EClass oR_NodeEClass = null; + + /** + * + * + * @generated + */ + private EClass anD_NodeEClass = null; + + /** + * + * + * @generated + */ + private EClass literalEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see com.specmate.objectif.dSL.DSLPackage#eNS_URI + * @see #init() + * @generated + */ + private DSLPackageImpl() + { + super(eNS_URI, DSLFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link DSLPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static DSLPackage init() + { + if (isInited) return (DSLPackage)EPackage.Registry.INSTANCE.getEPackage(DSLPackage.eNS_URI); + + // Obtain or create and register package + DSLPackageImpl theDSLPackage = (DSLPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof DSLPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new DSLPackageImpl()); + + isInited = true; + + // Create package meta-data objects + theDSLPackage.createPackageContents(); + + // Initialize created meta-data + theDSLPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theDSLPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(DSLPackage.eNS_URI, theDSLPackage); + return theDSLPackage; + } + + /** + * + * + * @generated + */ + public EClass getModel() + { + return modelEClass; + } + + /** + * + * + * @generated + */ + public EReference getModel_Rules() + { + return (EReference)modelEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getBusinessRule() + { + return businessRuleEClass; + } + + /** + * + * + * @generated + */ + public EReference getBusinessRule_Cause() + { + return (EReference)businessRuleEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EReference getBusinessRule_Effect() + { + return (EReference)businessRuleEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getBusinessRule_Alternative() + { + return (EReference)businessRuleEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EClass getOR_Node() + { + return oR_NodeEClass; + } + + /** + * + * + * @generated + */ + public EReference getOR_Node_Node() + { + return (EReference)oR_NodeEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getOR_Node_Or() + { + return (EAttribute)oR_NodeEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getOR_Node_SubNode() + { + return (EReference)oR_NodeEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EClass getAND_Node() + { + return anD_NodeEClass; + } + + /** + * + * + * @generated + */ + public EReference getAND_Node_Node() + { + return (EReference)anD_NodeEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getAND_Node_And() + { + return (EAttribute)anD_NodeEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getAND_Node_SubNode() + { + return (EReference)anD_NodeEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EClass getLiteral() + { + return literalEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getLiteral_Content() + { + return (EAttribute)literalEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public DSLFactory getDSLFactory() + { + return (DSLFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + modelEClass = createEClass(MODEL); + createEReference(modelEClass, MODEL__RULES); + + businessRuleEClass = createEClass(BUSINESS_RULE); + createEReference(businessRuleEClass, BUSINESS_RULE__CAUSE); + createEReference(businessRuleEClass, BUSINESS_RULE__EFFECT); + createEReference(businessRuleEClass, BUSINESS_RULE__ALTERNATIVE); + + oR_NodeEClass = createEClass(OR_NODE); + createEReference(oR_NodeEClass, OR_NODE__NODE); + createEAttribute(oR_NodeEClass, OR_NODE__OR); + createEReference(oR_NodeEClass, OR_NODE__SUB_NODE); + + anD_NodeEClass = createEClass(AND_NODE); + createEReference(anD_NodeEClass, AND_NODE__NODE); + createEAttribute(anD_NodeEClass, AND_NODE__AND); + createEReference(anD_NodeEClass, AND_NODE__SUB_NODE); + + literalEClass = createEClass(LITERAL); + createEAttribute(literalEClass, LITERAL__CONTENT); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getModel_Rules(), this.getBusinessRule(), null, "rules", null, 0, -1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(businessRuleEClass, BusinessRule.class, "BusinessRule", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getBusinessRule_Cause(), this.getOR_Node(), null, "cause", null, 0, 1, BusinessRule.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getBusinessRule_Effect(), ecorePackage.getEObject(), null, "effect", null, 0, 1, BusinessRule.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getBusinessRule_Alternative(), ecorePackage.getEObject(), null, "alternative", null, 0, 1, BusinessRule.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(oR_NodeEClass, OR_Node.class, "OR_Node", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getOR_Node_Node(), this.getAND_Node(), null, "node", null, 0, 1, OR_Node.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getOR_Node_Or(), ecorePackage.getEBoolean(), "or", null, 0, 1, OR_Node.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getOR_Node_SubNode(), this.getOR_Node(), null, "subNode", null, 0, 1, OR_Node.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(anD_NodeEClass, AND_Node.class, "AND_Node", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getAND_Node_Node(), this.getLiteral(), null, "node", null, 0, 1, AND_Node.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getAND_Node_And(), ecorePackage.getEBoolean(), "and", null, 0, 1, AND_Node.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getAND_Node_SubNode(), this.getAND_Node(), null, "subNode", null, 0, 1, AND_Node.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(literalEClass, Literal.class, "Literal", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getLiteral_Content(), ecorePackage.getEString(), "content", null, 0, -1, Literal.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //DSLPackageImpl diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/LiteralImpl.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/LiteralImpl.java new file mode 100644 index 000000000..91e292cef --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/LiteralImpl.java @@ -0,0 +1,164 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.impl; + +import com.specmate.objectif.internal.dSL.DSLPackage; +import com.specmate.objectif.internal.dSL.Literal; + +import java.util.Collection; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EDataTypeEList; + +/** + * + * An implementation of the model object 'Literal'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.impl.LiteralImpl#getContent Content}
  • + *
+ * + * @generated + */ +public class LiteralImpl extends MinimalEObjectImpl.Container implements Literal +{ + /** + * The cached value of the '{@link #getContent() Content}' attribute list. + * + * + * @see #getContent() + * @generated + * @ordered + */ + protected EList content; + + /** + * + * + * @generated + */ + protected LiteralImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return DSLPackage.Literals.LITERAL; + } + + /** + * + * + * @generated + */ + public EList getContent() + { + if (content == null) + { + content = new EDataTypeEList(String.class, this, DSLPackage.LITERAL__CONTENT); + } + return content; + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case DSLPackage.LITERAL__CONTENT: + return getContent(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case DSLPackage.LITERAL__CONTENT: + getContent().clear(); + getContent().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case DSLPackage.LITERAL__CONTENT: + getContent().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case DSLPackage.LITERAL__CONTENT: + return content != null && !content.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (content: "); + result.append(content); + result.append(')'); + return result.toString(); + } + +} //LiteralImpl diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/ModelImpl.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/ModelImpl.java new file mode 100644 index 000000000..93b732f11 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/ModelImpl.java @@ -0,0 +1,168 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.impl; + +import com.specmate.objectif.internal.dSL.BusinessRule; +import com.specmate.objectif.internal.dSL.DSLPackage; +import com.specmate.objectif.internal.dSL.Model; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Model'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.impl.ModelImpl#getRules Rules}
  • + *
+ * + * @generated + */ +public class ModelImpl extends MinimalEObjectImpl.Container implements Model +{ + /** + * The cached value of the '{@link #getRules() Rules}' containment reference list. + * + * + * @see #getRules() + * @generated + * @ordered + */ + protected EList rules; + + /** + * + * + * @generated + */ + protected ModelImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return DSLPackage.Literals.MODEL; + } + + /** + * + * + * @generated + */ + public EList getRules() + { + if (rules == null) + { + rules = new EObjectContainmentEList(BusinessRule.class, this, DSLPackage.MODEL__RULES); + } + return rules; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case DSLPackage.MODEL__RULES: + return ((InternalEList)getRules()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case DSLPackage.MODEL__RULES: + return getRules(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case DSLPackage.MODEL__RULES: + getRules().clear(); + getRules().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case DSLPackage.MODEL__RULES: + getRules().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case DSLPackage.MODEL__RULES: + return rules != null && !rules.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //ModelImpl diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/OR_NodeImpl.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/OR_NodeImpl.java new file mode 100644 index 000000000..caf70e7d9 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/impl/OR_NodeImpl.java @@ -0,0 +1,337 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.impl; + +import com.specmate.objectif.internal.dSL.AND_Node; +import com.specmate.objectif.internal.dSL.DSLPackage; +import com.specmate.objectif.internal.dSL.OR_Node; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +/** + * + * An implementation of the model object 'OR Node'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link com.specmate.objectif.dSL.impl.OR_NodeImpl#getNode Node}
  • + *
  • {@link com.specmate.objectif.dSL.impl.OR_NodeImpl#isOr Or}
  • + *
  • {@link com.specmate.objectif.dSL.impl.OR_NodeImpl#getSubNode Sub Node}
  • + *
+ * + * @generated + */ +public class OR_NodeImpl extends MinimalEObjectImpl.Container implements OR_Node +{ + /** + * The cached value of the '{@link #getNode() Node}' containment reference. + * + * + * @see #getNode() + * @generated + * @ordered + */ + protected AND_Node node; + + /** + * The default value of the '{@link #isOr() Or}' attribute. + * + * + * @see #isOr() + * @generated + * @ordered + */ + protected static final boolean OR_EDEFAULT = false; + + /** + * The cached value of the '{@link #isOr() Or}' attribute. + * + * + * @see #isOr() + * @generated + * @ordered + */ + protected boolean or = OR_EDEFAULT; + + /** + * The cached value of the '{@link #getSubNode() Sub Node}' containment reference. + * + * + * @see #getSubNode() + * @generated + * @ordered + */ + protected OR_Node subNode; + + /** + * + * + * @generated + */ + protected OR_NodeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return DSLPackage.Literals.OR_NODE; + } + + /** + * + * + * @generated + */ + public AND_Node getNode() + { + return node; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetNode(AND_Node newNode, NotificationChain msgs) + { + AND_Node oldNode = node; + node = newNode; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DSLPackage.OR_NODE__NODE, oldNode, newNode); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setNode(AND_Node newNode) + { + if (newNode != node) + { + NotificationChain msgs = null; + if (node != null) + msgs = ((InternalEObject)node).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DSLPackage.OR_NODE__NODE, null, msgs); + if (newNode != null) + msgs = ((InternalEObject)newNode).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DSLPackage.OR_NODE__NODE, null, msgs); + msgs = basicSetNode(newNode, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.OR_NODE__NODE, newNode, newNode)); + } + + /** + * + * + * @generated + */ + public boolean isOr() + { + return or; + } + + /** + * + * + * @generated + */ + public void setOr(boolean newOr) + { + boolean oldOr = or; + or = newOr; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.OR_NODE__OR, oldOr, or)); + } + + /** + * + * + * @generated + */ + public OR_Node getSubNode() + { + return subNode; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetSubNode(OR_Node newSubNode, NotificationChain msgs) + { + OR_Node oldSubNode = subNode; + subNode = newSubNode; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DSLPackage.OR_NODE__SUB_NODE, oldSubNode, newSubNode); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setSubNode(OR_Node newSubNode) + { + if (newSubNode != subNode) + { + NotificationChain msgs = null; + if (subNode != null) + msgs = ((InternalEObject)subNode).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DSLPackage.OR_NODE__SUB_NODE, null, msgs); + if (newSubNode != null) + msgs = ((InternalEObject)newSubNode).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DSLPackage.OR_NODE__SUB_NODE, null, msgs); + msgs = basicSetSubNode(newSubNode, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, DSLPackage.OR_NODE__SUB_NODE, newSubNode, newSubNode)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case DSLPackage.OR_NODE__NODE: + return basicSetNode(null, msgs); + case DSLPackage.OR_NODE__SUB_NODE: + return basicSetSubNode(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case DSLPackage.OR_NODE__NODE: + return getNode(); + case DSLPackage.OR_NODE__OR: + return isOr(); + case DSLPackage.OR_NODE__SUB_NODE: + return getSubNode(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case DSLPackage.OR_NODE__NODE: + setNode((AND_Node)newValue); + return; + case DSLPackage.OR_NODE__OR: + setOr((Boolean)newValue); + return; + case DSLPackage.OR_NODE__SUB_NODE: + setSubNode((OR_Node)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case DSLPackage.OR_NODE__NODE: + setNode((AND_Node)null); + return; + case DSLPackage.OR_NODE__OR: + setOr(OR_EDEFAULT); + return; + case DSLPackage.OR_NODE__SUB_NODE: + setSubNode((OR_Node)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case DSLPackage.OR_NODE__NODE: + return node != null; + case DSLPackage.OR_NODE__OR: + return or != OR_EDEFAULT; + case DSLPackage.OR_NODE__SUB_NODE: + return subNode != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (or: "); + result.append(or); + result.append(')'); + return result.toString(); + } + +} //OR_NodeImpl diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/util/DSLAdapterFactory.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/util/DSLAdapterFactory.java new file mode 100644 index 000000000..8f67f56d4 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/util/DSLAdapterFactory.java @@ -0,0 +1,213 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.util; + +import com.specmate.objectif.internal.dSL.*; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see com.specmate.objectif.dSL.DSLPackage + * @generated + */ +public class DSLAdapterFactory extends AdapterFactoryImpl +{ + /** + * The cached model package. + * + * + * @generated + */ + protected static DSLPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public DSLAdapterFactory() + { + if (modelPackage == null) + { + modelPackage = DSLPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) + { + if (object == modelPackage) + { + return true; + } + if (object instanceof EObject) + { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected DSLSwitch modelSwitch = + new DSLSwitch() + { + @Override + public Adapter caseModel(Model object) + { + return createModelAdapter(); + } + @Override + public Adapter caseBusinessRule(BusinessRule object) + { + return createBusinessRuleAdapter(); + } + @Override + public Adapter caseOR_Node(OR_Node object) + { + return createOR_NodeAdapter(); + } + @Override + public Adapter caseAND_Node(AND_Node object) + { + return createAND_NodeAdapter(); + } + @Override + public Adapter caseLiteral(Literal object) + { + return createLiteralAdapter(); + } + @Override + public Adapter defaultCase(EObject object) + { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) + { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link com.specmate.objectif.dSL.Model Model}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.objectif.dSL.Model + * @generated + */ + public Adapter createModelAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.objectif.dSL.BusinessRule Business Rule}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.objectif.dSL.BusinessRule + * @generated + */ + public Adapter createBusinessRuleAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.objectif.dSL.OR_Node OR Node}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.objectif.dSL.OR_Node + * @generated + */ + public Adapter createOR_NodeAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.objectif.dSL.AND_Node AND Node}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.objectif.dSL.AND_Node + * @generated + */ + public Adapter createAND_NodeAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.objectif.dSL.Literal Literal}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.objectif.dSL.Literal + * @generated + */ + public Adapter createLiteralAdapter() + { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() + { + return null; + } + +} //DSLAdapterFactory diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/util/DSLSwitch.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/util/DSLSwitch.java new file mode 100644 index 000000000..e0cc0c195 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/dSL/util/DSLSwitch.java @@ -0,0 +1,212 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.dSL.util; + +import com.specmate.objectif.internal.dSL.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see com.specmate.objectif.dSL.DSLPackage + * @generated + */ +public class DSLSwitch extends Switch +{ + /** + * The cached model package + * + * + * @generated + */ + protected static DSLPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public DSLSwitch() + { + if (modelPackage == null) + { + modelPackage = DSLPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) + { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) + { + switch (classifierID) + { + case DSLPackage.MODEL: + { + Model model = (Model)theEObject; + T result = caseModel(model); + if (result == null) result = defaultCase(theEObject); + return result; + } + case DSLPackage.BUSINESS_RULE: + { + BusinessRule businessRule = (BusinessRule)theEObject; + T result = caseBusinessRule(businessRule); + if (result == null) result = defaultCase(theEObject); + return result; + } + case DSLPackage.OR_NODE: + { + OR_Node oR_Node = (OR_Node)theEObject; + T result = caseOR_Node(oR_Node); + if (result == null) result = defaultCase(theEObject); + return result; + } + case DSLPackage.AND_NODE: + { + AND_Node anD_Node = (AND_Node)theEObject; + T result = caseAND_Node(anD_Node); + if (result == null) result = defaultCase(theEObject); + return result; + } + case DSLPackage.LITERAL: + { + Literal literal = (Literal)theEObject; + T result = caseLiteral(literal); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Model'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Model'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseModel(Model object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Business Rule'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Business Rule'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseBusinessRule(BusinessRule object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'OR Node'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'OR Node'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseOR_Node(OR_Node object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'AND Node'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'AND Node'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseAND_Node(AND_Node object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Literal'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Literal'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseLiteral(Literal object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) + { + return null; + } + +} //DSLSwitch diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/generator/.DSLGenerator.xtendbin b/bundles/specmate-objectif/src/com/specmate/objectif/internal/generator/.DSLGenerator.xtendbin new file mode 100644 index 0000000000000000000000000000000000000000..ca482712a0b3ca9fb02bf8ae707a50ea046c054c GIT binary patch literal 2285 zcmaJ@X*d*W8y-YsLS~F*oNR~2KC%bM)OUHWkeX?1+$MvSMn@Vch^p?>n5BgiBv?uJn>IKx1-SrQHUr(8WKNI%5_?;%`p|@m_37+_i&z2 z;K!vu$&W32AcM$jEVhe=&tLTX0>a?OIv2#T3&TAG6DQ3X+hWl%bI9YrisYx`>SI1I zDN(6)t1qP^a^`4M-q960@$PjT5*f->oz%g zg(6r`&O=vKZH#WrO_0I)t7A*{whrHo*K#BoUnUZn-l&0}edJWS;E5x(YK5^IRKT{x zoYKj(G2N2Q;;R_=OwH_9lD3v(K(f+HwpyW)C#uR5Q47 zDkH4mlmI<0-iygJP6ezkh+0!l65C{}%*v|%ZZ-!GC>P(o=IO&&x{I!JZfgkTLIqo{ ztn8`$8EI{{c2Na!Y9NPdH!J7b>CE4NoDNU6?1GRIZ#d<3HN(ljb*ecqGohc;%tyOH zv;8WnKdBgX7p3aW3=VNvZmNDY$t7D+AJTmCdEbwIrJ&DD`-hedw9D{6A0*R1mO#DP8e z@3EpC14xUqKridZxS}g7+*Iy@R!sy(b9Niqf7VF<9Gk#=*6#+qOV`xU%Mj;Et!^A`1!_D2zlXDx4A>w~}wX(^;33>JL zBKv#X+FO5x)pNK#flgaPY=nR?a*|l$IWR#+pU?VX_Kjun0c}yUDmlYAm{M1eqOobs zV=qta+>n1#!UHV;vSMBxjcg`J>be>1Rmxs##Ba|m>FsIVI6$w;7JwFX$WK)b`c;H@ z-R_GKz%XTq;ujKeeV@@75$zNEc&SzDWI*a5R|4b?zDqO<0zI`1LhyqfMB+^NYO^4_{YR`uCf zupHtjS#t6m{F$j=WR10Z_&%r0*ik2{2&rvb~76P1&@fJ1jWI z^eGxy7vGiE5rxB_>*YNiNE8;>!AF>8H^u3XMO$|pf9I1?%v^j6l;yGLu0;i+^MMQ= zUyl2#hzaf(UY#O-%~sX5KSx_sWP|NpbXtufJQ(peohp4fXhHd{99-)VKR~F839PL# zLnep#tkD_U(etrJlQVZXeab46+SAZMG`Qkl1jgN`nEP<3d|g>jnc?VfOsyEV`SKSs z&8!o18QAwa##HOt4X-d-zg7F+ykNpY(@YSzzWs+cTCh=SO-)()E-0S_jVa z;>OY<8wsq@cxC3>%F+1lgW=4}qVd!)H!NX)3@rI<(9{xhb_u-PhWjSOonm5p>k?ai zL*grc3;N5*V53+`iEO*+yKSbt*-tdc@1zsZc6cW`fj2t^Zyn1oam``+tRh3?h~Gct zTjWVh0D#KB`DJ2;0{&?cjyum0!@uHq!+'|'|'|'.'|'?'|','|'"'|'('|')')+; + +RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; + +RULE_INT : ('0'..'9')+; + +RULE_STRING : ('"' ('\\' .|~(('\\'|'"')))* '"'|'\'' ('\\' .|~(('\\'|'\'')))* '\''); + +RULE_ML_COMMENT : '/*' ( options {greedy=false;} : . )*'*/'; + +RULE_SL_COMMENT : '//' ~(('\n'|'\r'))* ('\r'? '\n')?; + +RULE_WS : (' '|'\t'|'\r'|'\n')+; + +RULE_ANY_OTHER : .; diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSL.tokens b/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSL.tokens new file mode 100644 index 000000000..138572fb4 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSL.tokens @@ -0,0 +1,20 @@ +'DANN'=13 +'ENDE-WENN'=15 +'ODER'=16 +'SONST'=14 +'UND'=17 +'WENN'=12 +RULE_ANY_OTHER=11 +RULE_CHARACTER_SQUENCE=4 +RULE_ID=5 +RULE_INT=6 +RULE_ML_COMMENT=8 +RULE_SL_COMMENT=9 +RULE_STRING=7 +RULE_WS=10 +T__12=12 +T__13=13 +T__14=14 +T__15=15 +T__16=16 +T__17=17 diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSLLexer.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSLLexer.java new file mode 100644 index 000000000..a0a72d4b9 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSLLexer.java @@ -0,0 +1,1045 @@ +package com.specmate.objectif.internal.parser.antlr.internal; + +// Hack: Use our own Lexer superclass by means of import. +// Currently there is no other way to specify the superclass for the lexer. +import org.eclipse.xtext.parser.antlr.Lexer; + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalDSLLexer extends Lexer { + public static final int RULE_ID=5; + public static final int RULE_WS=10; + public static final int RULE_STRING=7; + public static final int RULE_ANY_OTHER=11; + public static final int RULE_SL_COMMENT=9; + public static final int T__15=15; + public static final int T__16=16; + public static final int T__17=17; + public static final int RULE_INT=6; + public static final int RULE_ML_COMMENT=8; + public static final int T__12=12; + public static final int T__13=13; + public static final int T__14=14; + public static final int EOF=-1; + public static final int RULE_CHARACTER_SQUENCE=4; + + // delegates + // delegators + + public InternalDSLLexer() {;} + public InternalDSLLexer(CharStream input) { + this(input, new RecognizerSharedState()); + } + public InternalDSLLexer(CharStream input, RecognizerSharedState state) { + super(input,state); + + } + public String getGrammarFileName() { return "InternalDSL.g"; } + + // $ANTLR start "T__12" + public final void mT__12() throws RecognitionException { + try { + int _type = T__12; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:11:7: ( 'WENN' ) + // InternalDSL.g:11:9: 'WENN' + { + match("WENN"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__12" + + // $ANTLR start "T__13" + public final void mT__13() throws RecognitionException { + try { + int _type = T__13; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:12:7: ( 'DANN' ) + // InternalDSL.g:12:9: 'DANN' + { + match("DANN"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__13" + + // $ANTLR start "T__14" + public final void mT__14() throws RecognitionException { + try { + int _type = T__14; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:13:7: ( 'SONST' ) + // InternalDSL.g:13:9: 'SONST' + { + match("SONST"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__14" + + // $ANTLR start "T__15" + public final void mT__15() throws RecognitionException { + try { + int _type = T__15; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:14:7: ( 'ENDE-WENN' ) + // InternalDSL.g:14:9: 'ENDE-WENN' + { + match("ENDE-WENN"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__15" + + // $ANTLR start "T__16" + public final void mT__16() throws RecognitionException { + try { + int _type = T__16; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:15:7: ( 'ODER' ) + // InternalDSL.g:15:9: 'ODER' + { + match("ODER"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__16" + + // $ANTLR start "T__17" + public final void mT__17() throws RecognitionException { + try { + int _type = T__17; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:16:7: ( 'UND' ) + // InternalDSL.g:16:9: 'UND' + { + match("UND"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "T__17" + + // $ANTLR start "RULE_CHARACTER_SQUENCE" + public final void mRULE_CHARACTER_SQUENCE() throws RecognitionException { + try { + int _type = RULE_CHARACTER_SQUENCE; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:410:24: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '=' | '/' | '%' | '#' | '<' | '>' | '|' | '.' | '?' | ',' | '\"' | '(' | ')' )+ ) + // InternalDSL.g:410:26: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '=' | '/' | '%' | '#' | '<' | '>' | '|' | '.' | '?' | ',' | '\"' | '(' | ')' )+ + { + // InternalDSL.g:410:26: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '=' | '/' | '%' | '#' | '<' | '>' | '|' | '.' | '?' | ',' | '\"' | '(' | ')' )+ + int cnt1=0; + loop1: + do { + int alt1=2; + int LA1_0 = input.LA(1); + + if ( ((LA1_0>='\"' && LA1_0<='#')||LA1_0=='%'||(LA1_0>='(' && LA1_0<=')')||LA1_0==','||(LA1_0>='.' && LA1_0<='9')||(LA1_0>='<' && LA1_0<='?')||(LA1_0>='A' && LA1_0<='Z')||LA1_0=='_'||(LA1_0>='a' && LA1_0<='z')||LA1_0=='|') ) { + alt1=1; + } + + + switch (alt1) { + case 1 : + // InternalDSL.g: + { + if ( (input.LA(1)>='\"' && input.LA(1)<='#')||input.LA(1)=='%'||(input.LA(1)>='(' && input.LA(1)<=')')||input.LA(1)==','||(input.LA(1)>='.' && input.LA(1)<='9')||(input.LA(1)>='<' && input.LA(1)<='?')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z')||input.LA(1)=='|' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + if ( cnt1 >= 1 ) break loop1; + EarlyExitException eee = + new EarlyExitException(1, input); + throw eee; + } + cnt1++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_CHARACTER_SQUENCE" + + // $ANTLR start "RULE_ID" + public final void mRULE_ID() throws RecognitionException { + try { + int _type = RULE_ID; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:412:9: ( ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* ) + // InternalDSL.g:412:11: ( '^' )? ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + { + // InternalDSL.g:412:11: ( '^' )? + int alt2=2; + int LA2_0 = input.LA(1); + + if ( (LA2_0=='^') ) { + alt2=1; + } + switch (alt2) { + case 1 : + // InternalDSL.g:412:11: '^' + { + match('^'); + + } + break; + + } + + if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + // InternalDSL.g:412:40: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + loop3: + do { + int alt3=2; + int LA3_0 = input.LA(1); + + if ( ((LA3_0>='0' && LA3_0<='9')||(LA3_0>='A' && LA3_0<='Z')||LA3_0=='_'||(LA3_0>='a' && LA3_0<='z')) ) { + alt3=1; + } + + + switch (alt3) { + case 1 : + // InternalDSL.g: + { + if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop3; + } + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ID" + + // $ANTLR start "RULE_INT" + public final void mRULE_INT() throws RecognitionException { + try { + int _type = RULE_INT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:414:10: ( ( '0' .. '9' )+ ) + // InternalDSL.g:414:12: ( '0' .. '9' )+ + { + // InternalDSL.g:414:12: ( '0' .. '9' )+ + int cnt4=0; + loop4: + do { + int alt4=2; + int LA4_0 = input.LA(1); + + if ( ((LA4_0>='0' && LA4_0<='9')) ) { + alt4=1; + } + + + switch (alt4) { + case 1 : + // InternalDSL.g:414:13: '0' .. '9' + { + matchRange('0','9'); + + } + break; + + default : + if ( cnt4 >= 1 ) break loop4; + EarlyExitException eee = + new EarlyExitException(4, input); + throw eee; + } + cnt4++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_INT" + + // $ANTLR start "RULE_STRING" + public final void mRULE_STRING() throws RecognitionException { + try { + int _type = RULE_STRING; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:416:13: ( ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) ) + // InternalDSL.g:416:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + { + // InternalDSL.g:416:15: ( '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' | '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' ) + int alt7=2; + int LA7_0 = input.LA(1); + + if ( (LA7_0=='\"') ) { + alt7=1; + } + else if ( (LA7_0=='\'') ) { + alt7=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 7, 0, input); + + throw nvae; + } + switch (alt7) { + case 1 : + // InternalDSL.g:416:16: '\"' ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* '\"' + { + match('\"'); + // InternalDSL.g:416:20: ( '\\\\' . | ~ ( ( '\\\\' | '\"' ) ) )* + loop5: + do { + int alt5=3; + int LA5_0 = input.LA(1); + + if ( (LA5_0=='\\') ) { + alt5=1; + } + else if ( ((LA5_0>='\u0000' && LA5_0<='!')||(LA5_0>='#' && LA5_0<='[')||(LA5_0>=']' && LA5_0<='\uFFFF')) ) { + alt5=2; + } + + + switch (alt5) { + case 1 : + // InternalDSL.g:416:21: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalDSL.g:416:28: ~ ( ( '\\\\' | '\"' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop5; + } + } while (true); + + match('\"'); + + } + break; + case 2 : + // InternalDSL.g:416:48: '\\'' ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* '\\'' + { + match('\''); + // InternalDSL.g:416:53: ( '\\\\' . | ~ ( ( '\\\\' | '\\'' ) ) )* + loop6: + do { + int alt6=3; + int LA6_0 = input.LA(1); + + if ( (LA6_0=='\\') ) { + alt6=1; + } + else if ( ((LA6_0>='\u0000' && LA6_0<='&')||(LA6_0>='(' && LA6_0<='[')||(LA6_0>=']' && LA6_0<='\uFFFF')) ) { + alt6=2; + } + + + switch (alt6) { + case 1 : + // InternalDSL.g:416:54: '\\\\' . + { + match('\\'); + matchAny(); + + } + break; + case 2 : + // InternalDSL.g:416:61: ~ ( ( '\\\\' | '\\'' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop6; + } + } while (true); + + match('\''); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_STRING" + + // $ANTLR start "RULE_ML_COMMENT" + public final void mRULE_ML_COMMENT() throws RecognitionException { + try { + int _type = RULE_ML_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:418:17: ( '/*' ( options {greedy=false; } : . )* '*/' ) + // InternalDSL.g:418:19: '/*' ( options {greedy=false; } : . )* '*/' + { + match("/*"); + + // InternalDSL.g:418:24: ( options {greedy=false; } : . )* + loop8: + do { + int alt8=2; + int LA8_0 = input.LA(1); + + if ( (LA8_0=='*') ) { + int LA8_1 = input.LA(2); + + if ( (LA8_1=='/') ) { + alt8=2; + } + else if ( ((LA8_1>='\u0000' && LA8_1<='.')||(LA8_1>='0' && LA8_1<='\uFFFF')) ) { + alt8=1; + } + + + } + else if ( ((LA8_0>='\u0000' && LA8_0<=')')||(LA8_0>='+' && LA8_0<='\uFFFF')) ) { + alt8=1; + } + + + switch (alt8) { + case 1 : + // InternalDSL.g:418:52: . + { + matchAny(); + + } + break; + + default : + break loop8; + } + } while (true); + + match("*/"); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ML_COMMENT" + + // $ANTLR start "RULE_SL_COMMENT" + public final void mRULE_SL_COMMENT() throws RecognitionException { + try { + int _type = RULE_SL_COMMENT; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:420:17: ( '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? ) + // InternalDSL.g:420:19: '//' (~ ( ( '\\n' | '\\r' ) ) )* ( ( '\\r' )? '\\n' )? + { + match("//"); + + // InternalDSL.g:420:24: (~ ( ( '\\n' | '\\r' ) ) )* + loop9: + do { + int alt9=2; + int LA9_0 = input.LA(1); + + if ( ((LA9_0>='\u0000' && LA9_0<='\t')||(LA9_0>='\u000B' && LA9_0<='\f')||(LA9_0>='\u000E' && LA9_0<='\uFFFF')) ) { + alt9=1; + } + + + switch (alt9) { + case 1 : + // InternalDSL.g:420:24: ~ ( ( '\\n' | '\\r' ) ) + { + if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + break loop9; + } + } while (true); + + // InternalDSL.g:420:40: ( ( '\\r' )? '\\n' )? + int alt11=2; + int LA11_0 = input.LA(1); + + if ( (LA11_0=='\n'||LA11_0=='\r') ) { + alt11=1; + } + switch (alt11) { + case 1 : + // InternalDSL.g:420:41: ( '\\r' )? '\\n' + { + // InternalDSL.g:420:41: ( '\\r' )? + int alt10=2; + int LA10_0 = input.LA(1); + + if ( (LA10_0=='\r') ) { + alt10=1; + } + switch (alt10) { + case 1 : + // InternalDSL.g:420:41: '\\r' + { + match('\r'); + + } + break; + + } + + match('\n'); + + } + break; + + } + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_SL_COMMENT" + + // $ANTLR start "RULE_WS" + public final void mRULE_WS() throws RecognitionException { + try { + int _type = RULE_WS; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:422:9: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) + // InternalDSL.g:422:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + { + // InternalDSL.g:422:11: ( ' ' | '\\t' | '\\r' | '\\n' )+ + int cnt12=0; + loop12: + do { + int alt12=2; + int LA12_0 = input.LA(1); + + if ( ((LA12_0>='\t' && LA12_0<='\n')||LA12_0=='\r'||LA12_0==' ') ) { + alt12=1; + } + + + switch (alt12) { + case 1 : + // InternalDSL.g: + { + if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { + input.consume(); + + } + else { + MismatchedSetException mse = new MismatchedSetException(null,input); + recover(mse); + throw mse;} + + + } + break; + + default : + if ( cnt12 >= 1 ) break loop12; + EarlyExitException eee = + new EarlyExitException(12, input); + throw eee; + } + cnt12++; + } while (true); + + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_WS" + + // $ANTLR start "RULE_ANY_OTHER" + public final void mRULE_ANY_OTHER() throws RecognitionException { + try { + int _type = RULE_ANY_OTHER; + int _channel = DEFAULT_TOKEN_CHANNEL; + // InternalDSL.g:424:16: ( . ) + // InternalDSL.g:424:18: . + { + matchAny(); + + } + + state.type = _type; + state.channel = _channel; + } + finally { + } + } + // $ANTLR end "RULE_ANY_OTHER" + + public void mTokens() throws RecognitionException { + // InternalDSL.g:1:8: ( T__12 | T__13 | T__14 | T__15 | T__16 | T__17 | RULE_CHARACTER_SQUENCE | RULE_ID | RULE_INT | RULE_STRING | RULE_ML_COMMENT | RULE_SL_COMMENT | RULE_WS | RULE_ANY_OTHER ) + int alt13=14; + alt13 = dfa13.predict(input); + switch (alt13) { + case 1 : + // InternalDSL.g:1:10: T__12 + { + mT__12(); + + } + break; + case 2 : + // InternalDSL.g:1:16: T__13 + { + mT__13(); + + } + break; + case 3 : + // InternalDSL.g:1:22: T__14 + { + mT__14(); + + } + break; + case 4 : + // InternalDSL.g:1:28: T__15 + { + mT__15(); + + } + break; + case 5 : + // InternalDSL.g:1:34: T__16 + { + mT__16(); + + } + break; + case 6 : + // InternalDSL.g:1:40: T__17 + { + mT__17(); + + } + break; + case 7 : + // InternalDSL.g:1:46: RULE_CHARACTER_SQUENCE + { + mRULE_CHARACTER_SQUENCE(); + + } + break; + case 8 : + // InternalDSL.g:1:69: RULE_ID + { + mRULE_ID(); + + } + break; + case 9 : + // InternalDSL.g:1:77: RULE_INT + { + mRULE_INT(); + + } + break; + case 10 : + // InternalDSL.g:1:86: RULE_STRING + { + mRULE_STRING(); + + } + break; + case 11 : + // InternalDSL.g:1:98: RULE_ML_COMMENT + { + mRULE_ML_COMMENT(); + + } + break; + case 12 : + // InternalDSL.g:1:114: RULE_SL_COMMENT + { + mRULE_SL_COMMENT(); + + } + break; + case 13 : + // InternalDSL.g:1:130: RULE_WS + { + mRULE_WS(); + + } + break; + case 14 : + // InternalDSL.g:1:138: RULE_ANY_OTHER + { + mRULE_ANY_OTHER(); + + } + break; + + } + + } + + + protected DFA13 dfa13 = new DFA13(this); + static final String DFA13_eotS = + "\1\uffff\7\22\1\17\3\22\1\17\3\uffff\2\22\1\uffff\5\22\1\uffff\2\22\3\uffff\1\22\1\uffff\5\22\1\55\1\22\1\uffff\1\56\1\57\2\22\1\62\3\uffff\1\63\3\uffff"; + static final String DFA13_eofS = + "\64\uffff"; + static final String DFA13_minS = + "\1\0\7\60\1\101\1\60\1\0\1\52\1\0\3\uffff\2\60\1\uffff\5\60\1\uffff\1\60\1\0\3\uffff\1\0\1\uffff\5\60\1\42\1\0\1\uffff\2\42\1\60\1\55\1\42\3\uffff\1\42\3\uffff"; + static final String DFA13_maxS = + "\1\uffff\10\172\1\71\1\uffff\1\57\1\uffff\3\uffff\2\172\1\uffff\5\172\1\uffff\1\71\1\uffff\3\uffff\1\uffff\1\uffff\5\172\1\174\1\uffff\1\uffff\2\174\2\172\1\174\3\uffff\1\174\3\uffff"; + static final String DFA13_acceptS = + "\15\uffff\1\7\1\15\1\16\2\uffff\1\7\5\uffff\1\10\2\uffff\1\12\1\7\1\13\1\uffff\1\15\7\uffff\1\14\5\uffff\1\6\1\1\1\2\1\uffff\1\4\1\5\1\3"; + static final String DFA13_specialS = + "\1\4\11\uffff\1\1\1\uffff\1\0\15\uffff\1\3\3\uffff\1\2\7\uffff\1\5\15\uffff}>"; + static final String[] DFA13_transitionS = { + "\11\17\2\16\2\17\1\16\22\17\1\16\1\17\1\12\1\15\1\17\1\15\1\17\1\14\2\15\2\17\1\15\1\17\1\15\1\13\12\11\2\17\4\15\1\17\3\7\1\2\1\4\11\7\1\5\3\7\1\3\1\7\1\6\1\7\1\1\3\7\3\17\1\10\1\7\1\17\32\7\1\17\1\15\uff83\17", + "\12\21\7\uffff\4\21\1\20\25\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\1\23\31\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\16\21\1\24\13\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\15\21\1\25\14\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\3\21\1\26\26\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\15\21\1\27\14\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\32\21\4\uffff\1\21\1\uffff\32\21", + "\32\30\4\uffff\1\30\1\uffff\32\30", + "\12\31", + "\42\33\1\34\1\32\1\33\1\32\2\33\2\32\2\33\1\32\1\33\14\32\2\33\4\32\1\33\32\32\4\33\1\32\1\33\32\32\1\33\1\32\uff83\33", + "\1\35\4\uffff\1\36", + "\0\33", + "", + "", + "", + "\12\21\7\uffff\15\21\1\40\14\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\32\21\4\uffff\1\21\1\uffff\32\21", + "", + "\12\21\7\uffff\15\21\1\41\14\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\15\21\1\42\14\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\3\21\1\43\26\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\4\21\1\44\25\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\3\21\1\45\26\21\4\uffff\1\21\1\uffff\32\21", + "", + "\12\31", + "\42\33\1\34\1\32\1\33\1\32\2\33\2\32\2\33\1\32\1\33\14\32\2\33\4\32\1\33\32\32\4\33\1\32\1\33\32\32\1\33\1\32\uff83\33", + "", + "", + "", + "\42\47\2\46\1\47\1\46\2\47\2\46\2\47\1\46\1\47\14\46\2\47\4\46\1\47\32\46\4\47\1\46\1\47\32\46\1\47\1\46\uff83\47", + "", + "\12\21\7\uffff\15\21\1\50\14\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\15\21\1\51\14\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\22\21\1\52\7\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\4\21\1\53\25\21\4\uffff\1\21\1\uffff\32\21", + "\12\21\7\uffff\21\21\1\54\10\21\4\uffff\1\21\1\uffff\32\21", + "\2\22\1\uffff\1\22\2\uffff\2\22\2\uffff\1\22\1\uffff\2\22\12\21\2\uffff\4\22\1\uffff\32\21\4\uffff\1\21\1\uffff\32\21\1\uffff\1\22", + "\42\47\2\46\1\47\1\46\2\47\2\46\2\47\1\46\1\47\14\46\2\47\4\46\1\47\32\46\4\47\1\46\1\47\32\46\1\47\1\46\uff83\47", + "", + "\2\22\1\uffff\1\22\2\uffff\2\22\2\uffff\1\22\1\uffff\2\22\12\21\2\uffff\4\22\1\uffff\32\21\4\uffff\1\21\1\uffff\32\21\1\uffff\1\22", + "\2\22\1\uffff\1\22\2\uffff\2\22\2\uffff\1\22\1\uffff\2\22\12\21\2\uffff\4\22\1\uffff\32\21\4\uffff\1\21\1\uffff\32\21\1\uffff\1\22", + "\12\21\7\uffff\23\21\1\60\6\21\4\uffff\1\21\1\uffff\32\21", + "\1\61\2\uffff\12\21\7\uffff\32\21\4\uffff\1\21\1\uffff\32\21", + "\2\22\1\uffff\1\22\2\uffff\2\22\2\uffff\1\22\1\uffff\2\22\12\21\2\uffff\4\22\1\uffff\32\21\4\uffff\1\21\1\uffff\32\21\1\uffff\1\22", + "", + "", + "", + "\2\22\1\uffff\1\22\2\uffff\2\22\2\uffff\1\22\1\uffff\2\22\12\21\2\uffff\4\22\1\uffff\32\21\4\uffff\1\21\1\uffff\32\21\1\uffff\1\22", + "", + "", + "" + }; + + static final short[] DFA13_eot = DFA.unpackEncodedString(DFA13_eotS); + static final short[] DFA13_eof = DFA.unpackEncodedString(DFA13_eofS); + static final char[] DFA13_min = DFA.unpackEncodedStringToUnsignedChars(DFA13_minS); + static final char[] DFA13_max = DFA.unpackEncodedStringToUnsignedChars(DFA13_maxS); + static final short[] DFA13_accept = DFA.unpackEncodedString(DFA13_acceptS); + static final short[] DFA13_special = DFA.unpackEncodedString(DFA13_specialS); + static final short[][] DFA13_transition; + + static { + int numStates = DFA13_transitionS.length; + DFA13_transition = new short[numStates][]; + for (int i=0; i='\u0000' && LA13_12<='\uFFFF')) ) {s = 27;} + + else s = 15; + + if ( s>=0 ) return s; + break; + case 1 : + int LA13_10 = input.LA(1); + + s = -1; + if ( (LA13_10=='#'||LA13_10=='%'||(LA13_10>='(' && LA13_10<=')')||LA13_10==','||(LA13_10>='.' && LA13_10<='9')||(LA13_10>='<' && LA13_10<='?')||(LA13_10>='A' && LA13_10<='Z')||LA13_10=='_'||(LA13_10>='a' && LA13_10<='z')||LA13_10=='|') ) {s = 26;} + + else if ( ((LA13_10>='\u0000' && LA13_10<='!')||LA13_10=='$'||(LA13_10>='&' && LA13_10<='\'')||(LA13_10>='*' && LA13_10<='+')||LA13_10=='-'||(LA13_10>=':' && LA13_10<=';')||LA13_10=='@'||(LA13_10>='[' && LA13_10<='^')||LA13_10=='`'||LA13_10=='{'||(LA13_10>='}' && LA13_10<='\uFFFF')) ) {s = 27;} + + else if ( (LA13_10=='\"') ) {s = 28;} + + else s = 18; + + if ( s>=0 ) return s; + break; + case 2 : + int LA13_30 = input.LA(1); + + s = -1; + if ( ((LA13_30>='\"' && LA13_30<='#')||LA13_30=='%'||(LA13_30>='(' && LA13_30<=')')||LA13_30==','||(LA13_30>='.' && LA13_30<='9')||(LA13_30>='<' && LA13_30<='?')||(LA13_30>='A' && LA13_30<='Z')||LA13_30=='_'||(LA13_30>='a' && LA13_30<='z')||LA13_30=='|') ) {s = 38;} + + else if ( ((LA13_30>='\u0000' && LA13_30<='!')||LA13_30=='$'||(LA13_30>='&' && LA13_30<='\'')||(LA13_30>='*' && LA13_30<='+')||LA13_30=='-'||(LA13_30>=':' && LA13_30<=';')||LA13_30=='@'||(LA13_30>='[' && LA13_30<='^')||LA13_30=='`'||LA13_30=='{'||(LA13_30>='}' && LA13_30<='\uFFFF')) ) {s = 39;} + + else s = 18; + + if ( s>=0 ) return s; + break; + case 3 : + int LA13_26 = input.LA(1); + + s = -1; + if ( (LA13_26=='\"') ) {s = 28;} + + else if ( ((LA13_26>='\u0000' && LA13_26<='!')||LA13_26=='$'||(LA13_26>='&' && LA13_26<='\'')||(LA13_26>='*' && LA13_26<='+')||LA13_26=='-'||(LA13_26>=':' && LA13_26<=';')||LA13_26=='@'||(LA13_26>='[' && LA13_26<='^')||LA13_26=='`'||LA13_26=='{'||(LA13_26>='}' && LA13_26<='\uFFFF')) ) {s = 27;} + + else if ( (LA13_26=='#'||LA13_26=='%'||(LA13_26>='(' && LA13_26<=')')||LA13_26==','||(LA13_26>='.' && LA13_26<='9')||(LA13_26>='<' && LA13_26<='?')||(LA13_26>='A' && LA13_26<='Z')||LA13_26=='_'||(LA13_26>='a' && LA13_26<='z')||LA13_26=='|') ) {s = 26;} + + else s = 18; + + if ( s>=0 ) return s; + break; + case 4 : + int LA13_0 = input.LA(1); + + s = -1; + if ( (LA13_0=='W') ) {s = 1;} + + else if ( (LA13_0=='D') ) {s = 2;} + + else if ( (LA13_0=='S') ) {s = 3;} + + else if ( (LA13_0=='E') ) {s = 4;} + + else if ( (LA13_0=='O') ) {s = 5;} + + else if ( (LA13_0=='U') ) {s = 6;} + + else if ( ((LA13_0>='A' && LA13_0<='C')||(LA13_0>='F' && LA13_0<='N')||(LA13_0>='P' && LA13_0<='R')||LA13_0=='T'||LA13_0=='V'||(LA13_0>='X' && LA13_0<='Z')||LA13_0=='_'||(LA13_0>='a' && LA13_0<='z')) ) {s = 7;} + + else if ( (LA13_0=='^') ) {s = 8;} + + else if ( ((LA13_0>='0' && LA13_0<='9')) ) {s = 9;} + + else if ( (LA13_0=='\"') ) {s = 10;} + + else if ( (LA13_0=='/') ) {s = 11;} + + else if ( (LA13_0=='\'') ) {s = 12;} + + else if ( (LA13_0=='#'||LA13_0=='%'||(LA13_0>='(' && LA13_0<=')')||LA13_0==','||LA13_0=='.'||(LA13_0>='<' && LA13_0<='?')||LA13_0=='|') ) {s = 13;} + + else if ( ((LA13_0>='\t' && LA13_0<='\n')||LA13_0=='\r'||LA13_0==' ') ) {s = 14;} + + else if ( ((LA13_0>='\u0000' && LA13_0<='\b')||(LA13_0>='\u000B' && LA13_0<='\f')||(LA13_0>='\u000E' && LA13_0<='\u001F')||LA13_0=='!'||LA13_0=='$'||LA13_0=='&'||(LA13_0>='*' && LA13_0<='+')||LA13_0=='-'||(LA13_0>=':' && LA13_0<=';')||LA13_0=='@'||(LA13_0>='[' && LA13_0<=']')||LA13_0=='`'||LA13_0=='{'||(LA13_0>='}' && LA13_0<='\uFFFF')) ) {s = 15;} + + if ( s>=0 ) return s; + break; + case 5 : + int LA13_38 = input.LA(1); + + s = -1; + if ( ((LA13_38>='\"' && LA13_38<='#')||LA13_38=='%'||(LA13_38>='(' && LA13_38<=')')||LA13_38==','||(LA13_38>='.' && LA13_38<='9')||(LA13_38>='<' && LA13_38<='?')||(LA13_38>='A' && LA13_38<='Z')||LA13_38=='_'||(LA13_38>='a' && LA13_38<='z')||LA13_38=='|') ) {s = 38;} + + else if ( ((LA13_38>='\u0000' && LA13_38<='!')||LA13_38=='$'||(LA13_38>='&' && LA13_38<='\'')||(LA13_38>='*' && LA13_38<='+')||LA13_38=='-'||(LA13_38>=':' && LA13_38<=';')||LA13_38=='@'||(LA13_38>='[' && LA13_38<='^')||LA13_38=='`'||LA13_38=='{'||(LA13_38>='}' && LA13_38<='\uFFFF')) ) {s = 39;} + + else s = 18; + + if ( s>=0 ) return s; + break; + } + NoViableAltException nvae = + new NoViableAltException(getDescription(), 13, _s, input); + error(nvae); + throw nvae; + } + } + + +} \ No newline at end of file diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSLParser.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSLParser.java new file mode 100644 index 000000000..d5842967c --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/parser/antlr/internal/InternalDSLParser.java @@ -0,0 +1,1011 @@ +package com.specmate.objectif.internal.parser.antlr.internal; + +import org.eclipse.xtext.*; +import org.eclipse.xtext.parser.*; +import org.eclipse.xtext.parser.impl.*; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser; +import org.eclipse.xtext.parser.antlr.XtextTokenStream; +import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens; +import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken; +import com.specmate.objectif.internal.services.DSLGrammarAccess; + + + +import org.antlr.runtime.*; +import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + +@SuppressWarnings("all") +public class InternalDSLParser extends AbstractInternalAntlrParser { + public static final String[] tokenNames = new String[] { + "", "", "", "", "RULE_CHARACTER_SQUENCE", "RULE_ID", "RULE_INT", "RULE_STRING", "RULE_ML_COMMENT", "RULE_SL_COMMENT", "RULE_WS", "RULE_ANY_OTHER", "'WENN'", "'DANN'", "'SONST'", "'ENDE-WENN'", "'ODER'", "'UND'" + }; + public static final int RULE_ID=5; + public static final int RULE_WS=10; + public static final int RULE_STRING=7; + public static final int RULE_ANY_OTHER=11; + public static final int RULE_SL_COMMENT=9; + public static final int T__15=15; + public static final int T__16=16; + public static final int T__17=17; + public static final int RULE_INT=6; + public static final int RULE_ML_COMMENT=8; + public static final int T__12=12; + public static final int T__13=13; + public static final int T__14=14; + public static final int EOF=-1; + public static final int RULE_CHARACTER_SQUENCE=4; + + // delegates + // delegators + + + public InternalDSLParser(TokenStream input) { + this(input, new RecognizerSharedState()); + } + public InternalDSLParser(TokenStream input, RecognizerSharedState state) { + super(input, state); + + } + + + public String[] getTokenNames() { return InternalDSLParser.tokenNames; } + public String getGrammarFileName() { return "InternalDSL.g"; } + + + + private DSLGrammarAccess grammarAccess; + + public InternalDSLParser(TokenStream input, DSLGrammarAccess grammarAccess) { + this(input); + this.grammarAccess = grammarAccess; + registerRules(grammarAccess.getGrammar()); + } + + @Override + protected String getFirstRuleName() { + return "Model"; + } + + @Override + protected DSLGrammarAccess getGrammarAccess() { + return grammarAccess; + } + + + + + // $ANTLR start "entryRuleModel" + // InternalDSL.g:64:1: entryRuleModel returns [EObject current=null] : iv_ruleModel= ruleModel EOF ; + public final EObject entryRuleModel() throws RecognitionException { + EObject current = null; + + EObject iv_ruleModel = null; + + + try { + // InternalDSL.g:64:46: (iv_ruleModel= ruleModel EOF ) + // InternalDSL.g:65:2: iv_ruleModel= ruleModel EOF + { + newCompositeNode(grammarAccess.getModelRule()); + pushFollow(FOLLOW_1); + iv_ruleModel=ruleModel(); + + state._fsp--; + + current =iv_ruleModel; + match(input,EOF,FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleModel" + + + // $ANTLR start "ruleModel" + // InternalDSL.g:71:1: ruleModel returns [EObject current=null] : ( (lv_rules_0_0= ruleBusinessRule ) )* ; + public final EObject ruleModel() throws RecognitionException { + EObject current = null; + + EObject lv_rules_0_0 = null; + + + + enterRule(); + + try { + // InternalDSL.g:77:2: ( ( (lv_rules_0_0= ruleBusinessRule ) )* ) + // InternalDSL.g:78:2: ( (lv_rules_0_0= ruleBusinessRule ) )* + { + // InternalDSL.g:78:2: ( (lv_rules_0_0= ruleBusinessRule ) )* + loop1: + do { + int alt1=2; + int LA1_0 = input.LA(1); + + if ( (LA1_0==12) ) { + alt1=1; + } + + + switch (alt1) { + case 1 : + // InternalDSL.g:79:3: (lv_rules_0_0= ruleBusinessRule ) + { + // InternalDSL.g:79:3: (lv_rules_0_0= ruleBusinessRule ) + // InternalDSL.g:80:4: lv_rules_0_0= ruleBusinessRule + { + + newCompositeNode(grammarAccess.getModelAccess().getRulesBusinessRuleParserRuleCall_0()); + + pushFollow(FOLLOW_3); + lv_rules_0_0=ruleBusinessRule(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getModelRule()); + } + add( + current, + "rules", + lv_rules_0_0, + "com.specmate.objectif.DSL.BusinessRule"); + afterParserOrEnumRuleCall(); + + + } + + + } + break; + + default : + break loop1; + } + } while (true); + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleModel" + + + // $ANTLR start "entryRuleBusinessRule" + // InternalDSL.g:100:1: entryRuleBusinessRule returns [EObject current=null] : iv_ruleBusinessRule= ruleBusinessRule EOF ; + public final EObject entryRuleBusinessRule() throws RecognitionException { + EObject current = null; + + EObject iv_ruleBusinessRule = null; + + + try { + // InternalDSL.g:100:53: (iv_ruleBusinessRule= ruleBusinessRule EOF ) + // InternalDSL.g:101:2: iv_ruleBusinessRule= ruleBusinessRule EOF + { + newCompositeNode(grammarAccess.getBusinessRuleRule()); + pushFollow(FOLLOW_1); + iv_ruleBusinessRule=ruleBusinessRule(); + + state._fsp--; + + current =iv_ruleBusinessRule; + match(input,EOF,FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleBusinessRule" + + + // $ANTLR start "ruleBusinessRule" + // InternalDSL.g:107:1: ruleBusinessRule returns [EObject current=null] : (otherlv_0= 'WENN' ( (lv_cause_1_0= ruleOR_Node ) ) otherlv_2= 'DANN' ( ( (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) ) ) (otherlv_4= 'SONST' ( ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) ) )? otherlv_6= 'ENDE-WENN' ) ; + public final EObject ruleBusinessRule() throws RecognitionException { + EObject current = null; + + Token otherlv_0=null; + Token otherlv_2=null; + Token otherlv_4=null; + Token otherlv_6=null; + EObject lv_cause_1_0 = null; + + EObject lv_effect_3_1 = null; + + EObject lv_effect_3_2 = null; + + EObject lv_alternative_5_1 = null; + + EObject lv_alternative_5_2 = null; + + + + enterRule(); + + try { + // InternalDSL.g:113:2: ( (otherlv_0= 'WENN' ( (lv_cause_1_0= ruleOR_Node ) ) otherlv_2= 'DANN' ( ( (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) ) ) (otherlv_4= 'SONST' ( ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) ) )? otherlv_6= 'ENDE-WENN' ) ) + // InternalDSL.g:114:2: (otherlv_0= 'WENN' ( (lv_cause_1_0= ruleOR_Node ) ) otherlv_2= 'DANN' ( ( (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) ) ) (otherlv_4= 'SONST' ( ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) ) )? otherlv_6= 'ENDE-WENN' ) + { + // InternalDSL.g:114:2: (otherlv_0= 'WENN' ( (lv_cause_1_0= ruleOR_Node ) ) otherlv_2= 'DANN' ( ( (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) ) ) (otherlv_4= 'SONST' ( ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) ) )? otherlv_6= 'ENDE-WENN' ) + // InternalDSL.g:115:3: otherlv_0= 'WENN' ( (lv_cause_1_0= ruleOR_Node ) ) otherlv_2= 'DANN' ( ( (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) ) ) (otherlv_4= 'SONST' ( ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) ) )? otherlv_6= 'ENDE-WENN' + { + otherlv_0=(Token)match(input,12,FOLLOW_4); + + newLeafNode(otherlv_0, grammarAccess.getBusinessRuleAccess().getWENNKeyword_0()); + + // InternalDSL.g:119:3: ( (lv_cause_1_0= ruleOR_Node ) ) + // InternalDSL.g:120:4: (lv_cause_1_0= ruleOR_Node ) + { + // InternalDSL.g:120:4: (lv_cause_1_0= ruleOR_Node ) + // InternalDSL.g:121:5: lv_cause_1_0= ruleOR_Node + { + + newCompositeNode(grammarAccess.getBusinessRuleAccess().getCauseOR_NodeParserRuleCall_1_0()); + + pushFollow(FOLLOW_5); + lv_cause_1_0=ruleOR_Node(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getBusinessRuleRule()); + } + set( + current, + "cause", + lv_cause_1_0, + "com.specmate.objectif.DSL.OR_Node"); + afterParserOrEnumRuleCall(); + + + } + + + } + + otherlv_2=(Token)match(input,13,FOLLOW_6); + + newLeafNode(otherlv_2, grammarAccess.getBusinessRuleAccess().getDANNKeyword_2()); + + // InternalDSL.g:142:3: ( ( (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) ) ) + // InternalDSL.g:143:4: ( (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) ) + { + // InternalDSL.g:143:4: ( (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) ) + // InternalDSL.g:144:5: (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) + { + // InternalDSL.g:144:5: (lv_effect_3_1= ruleBusinessRule | lv_effect_3_2= ruleOR_Node ) + int alt2=2; + int LA2_0 = input.LA(1); + + if ( (LA2_0==12) ) { + alt2=1; + } + else if ( (LA2_0==RULE_CHARACTER_SQUENCE) ) { + alt2=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 2, 0, input); + + throw nvae; + } + switch (alt2) { + case 1 : + // InternalDSL.g:145:6: lv_effect_3_1= ruleBusinessRule + { + + newCompositeNode(grammarAccess.getBusinessRuleAccess().getEffectBusinessRuleParserRuleCall_3_0_0()); + + pushFollow(FOLLOW_7); + lv_effect_3_1=ruleBusinessRule(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getBusinessRuleRule()); + } + set( + current, + "effect", + lv_effect_3_1, + "com.specmate.objectif.DSL.BusinessRule"); + afterParserOrEnumRuleCall(); + + + } + break; + case 2 : + // InternalDSL.g:161:6: lv_effect_3_2= ruleOR_Node + { + + newCompositeNode(grammarAccess.getBusinessRuleAccess().getEffectOR_NodeParserRuleCall_3_0_1()); + + pushFollow(FOLLOW_7); + lv_effect_3_2=ruleOR_Node(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getBusinessRuleRule()); + } + set( + current, + "effect", + lv_effect_3_2, + "com.specmate.objectif.DSL.OR_Node"); + afterParserOrEnumRuleCall(); + + + } + break; + + } + + + } + + + } + + // InternalDSL.g:179:3: (otherlv_4= 'SONST' ( ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) ) )? + int alt4=2; + int LA4_0 = input.LA(1); + + if ( (LA4_0==14) ) { + alt4=1; + } + switch (alt4) { + case 1 : + // InternalDSL.g:180:4: otherlv_4= 'SONST' ( ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) ) + { + otherlv_4=(Token)match(input,14,FOLLOW_8); + + newLeafNode(otherlv_4, grammarAccess.getBusinessRuleAccess().getSONSTKeyword_4_0()); + + // InternalDSL.g:184:4: ( ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) ) + // InternalDSL.g:185:5: ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) + { + // InternalDSL.g:185:5: ( (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) ) + // InternalDSL.g:186:6: (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) + { + // InternalDSL.g:186:6: (lv_alternative_5_1= ruleBusinessRule | lv_alternative_5_2= ruleOR_Node ) + int alt3=2; + int LA3_0 = input.LA(1); + + if ( (LA3_0==12) ) { + alt3=1; + } + else if ( (LA3_0==RULE_CHARACTER_SQUENCE) ) { + alt3=2; + } + else { + NoViableAltException nvae = + new NoViableAltException("", 3, 0, input); + + throw nvae; + } + switch (alt3) { + case 1 : + // InternalDSL.g:187:7: lv_alternative_5_1= ruleBusinessRule + { + + newCompositeNode(grammarAccess.getBusinessRuleAccess().getAlternativeBusinessRuleParserRuleCall_4_1_0_0()); + + pushFollow(FOLLOW_9); + lv_alternative_5_1=ruleBusinessRule(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getBusinessRuleRule()); + } + set( + current, + "alternative", + lv_alternative_5_1, + "com.specmate.objectif.DSL.BusinessRule"); + afterParserOrEnumRuleCall(); + + + } + break; + case 2 : + // InternalDSL.g:203:7: lv_alternative_5_2= ruleOR_Node + { + + newCompositeNode(grammarAccess.getBusinessRuleAccess().getAlternativeOR_NodeParserRuleCall_4_1_0_1()); + + pushFollow(FOLLOW_9); + lv_alternative_5_2=ruleOR_Node(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getBusinessRuleRule()); + } + set( + current, + "alternative", + lv_alternative_5_2, + "com.specmate.objectif.DSL.OR_Node"); + afterParserOrEnumRuleCall(); + + + } + break; + + } + + + } + + + } + + + } + break; + + } + + otherlv_6=(Token)match(input,15,FOLLOW_2); + + newLeafNode(otherlv_6, grammarAccess.getBusinessRuleAccess().getENDEWENNKeyword_5()); + + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleBusinessRule" + + + // $ANTLR start "entryRuleOR_Node" + // InternalDSL.g:230:1: entryRuleOR_Node returns [EObject current=null] : iv_ruleOR_Node= ruleOR_Node EOF ; + public final EObject entryRuleOR_Node() throws RecognitionException { + EObject current = null; + + EObject iv_ruleOR_Node = null; + + + try { + // InternalDSL.g:230:48: (iv_ruleOR_Node= ruleOR_Node EOF ) + // InternalDSL.g:231:2: iv_ruleOR_Node= ruleOR_Node EOF + { + newCompositeNode(grammarAccess.getOR_NodeRule()); + pushFollow(FOLLOW_1); + iv_ruleOR_Node=ruleOR_Node(); + + state._fsp--; + + current =iv_ruleOR_Node; + match(input,EOF,FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleOR_Node" + + + // $ANTLR start "ruleOR_Node" + // InternalDSL.g:237:1: ruleOR_Node returns [EObject current=null] : ( ( (lv_node_0_0= ruleAND_Node ) ) ( ( (lv_or_1_0= 'ODER' ) ) ( (lv_subNode_2_0= ruleOR_Node ) ) )? ) ; + public final EObject ruleOR_Node() throws RecognitionException { + EObject current = null; + + Token lv_or_1_0=null; + EObject lv_node_0_0 = null; + + EObject lv_subNode_2_0 = null; + + + + enterRule(); + + try { + // InternalDSL.g:243:2: ( ( ( (lv_node_0_0= ruleAND_Node ) ) ( ( (lv_or_1_0= 'ODER' ) ) ( (lv_subNode_2_0= ruleOR_Node ) ) )? ) ) + // InternalDSL.g:244:2: ( ( (lv_node_0_0= ruleAND_Node ) ) ( ( (lv_or_1_0= 'ODER' ) ) ( (lv_subNode_2_0= ruleOR_Node ) ) )? ) + { + // InternalDSL.g:244:2: ( ( (lv_node_0_0= ruleAND_Node ) ) ( ( (lv_or_1_0= 'ODER' ) ) ( (lv_subNode_2_0= ruleOR_Node ) ) )? ) + // InternalDSL.g:245:3: ( (lv_node_0_0= ruleAND_Node ) ) ( ( (lv_or_1_0= 'ODER' ) ) ( (lv_subNode_2_0= ruleOR_Node ) ) )? + { + // InternalDSL.g:245:3: ( (lv_node_0_0= ruleAND_Node ) ) + // InternalDSL.g:246:4: (lv_node_0_0= ruleAND_Node ) + { + // InternalDSL.g:246:4: (lv_node_0_0= ruleAND_Node ) + // InternalDSL.g:247:5: lv_node_0_0= ruleAND_Node + { + + newCompositeNode(grammarAccess.getOR_NodeAccess().getNodeAND_NodeParserRuleCall_0_0()); + + pushFollow(FOLLOW_10); + lv_node_0_0=ruleAND_Node(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getOR_NodeRule()); + } + set( + current, + "node", + lv_node_0_0, + "com.specmate.objectif.DSL.AND_Node"); + afterParserOrEnumRuleCall(); + + + } + + + } + + // InternalDSL.g:264:3: ( ( (lv_or_1_0= 'ODER' ) ) ( (lv_subNode_2_0= ruleOR_Node ) ) )? + int alt5=2; + int LA5_0 = input.LA(1); + + if ( (LA5_0==16) ) { + alt5=1; + } + switch (alt5) { + case 1 : + // InternalDSL.g:265:4: ( (lv_or_1_0= 'ODER' ) ) ( (lv_subNode_2_0= ruleOR_Node ) ) + { + // InternalDSL.g:265:4: ( (lv_or_1_0= 'ODER' ) ) + // InternalDSL.g:266:5: (lv_or_1_0= 'ODER' ) + { + // InternalDSL.g:266:5: (lv_or_1_0= 'ODER' ) + // InternalDSL.g:267:6: lv_or_1_0= 'ODER' + { + lv_or_1_0=(Token)match(input,16,FOLLOW_4); + + newLeafNode(lv_or_1_0, grammarAccess.getOR_NodeAccess().getOrODERKeyword_1_0_0()); + + + if (current==null) { + current = createModelElement(grammarAccess.getOR_NodeRule()); + } + setWithLastConsumed(current, "or", true, "ODER"); + + + } + + + } + + // InternalDSL.g:279:4: ( (lv_subNode_2_0= ruleOR_Node ) ) + // InternalDSL.g:280:5: (lv_subNode_2_0= ruleOR_Node ) + { + // InternalDSL.g:280:5: (lv_subNode_2_0= ruleOR_Node ) + // InternalDSL.g:281:6: lv_subNode_2_0= ruleOR_Node + { + + newCompositeNode(grammarAccess.getOR_NodeAccess().getSubNodeOR_NodeParserRuleCall_1_1_0()); + + pushFollow(FOLLOW_2); + lv_subNode_2_0=ruleOR_Node(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getOR_NodeRule()); + } + set( + current, + "subNode", + lv_subNode_2_0, + "com.specmate.objectif.DSL.OR_Node"); + afterParserOrEnumRuleCall(); + + + } + + + } + + + } + break; + + } + + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleOR_Node" + + + // $ANTLR start "entryRuleAND_Node" + // InternalDSL.g:303:1: entryRuleAND_Node returns [EObject current=null] : iv_ruleAND_Node= ruleAND_Node EOF ; + public final EObject entryRuleAND_Node() throws RecognitionException { + EObject current = null; + + EObject iv_ruleAND_Node = null; + + + try { + // InternalDSL.g:303:49: (iv_ruleAND_Node= ruleAND_Node EOF ) + // InternalDSL.g:304:2: iv_ruleAND_Node= ruleAND_Node EOF + { + newCompositeNode(grammarAccess.getAND_NodeRule()); + pushFollow(FOLLOW_1); + iv_ruleAND_Node=ruleAND_Node(); + + state._fsp--; + + current =iv_ruleAND_Node; + match(input,EOF,FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleAND_Node" + + + // $ANTLR start "ruleAND_Node" + // InternalDSL.g:310:1: ruleAND_Node returns [EObject current=null] : ( ( (lv_node_0_0= ruleLiteral ) ) ( ( (lv_and_1_0= 'UND' ) ) ( (lv_subNode_2_0= ruleAND_Node ) ) )? ) ; + public final EObject ruleAND_Node() throws RecognitionException { + EObject current = null; + + Token lv_and_1_0=null; + EObject lv_node_0_0 = null; + + EObject lv_subNode_2_0 = null; + + + + enterRule(); + + try { + // InternalDSL.g:316:2: ( ( ( (lv_node_0_0= ruleLiteral ) ) ( ( (lv_and_1_0= 'UND' ) ) ( (lv_subNode_2_0= ruleAND_Node ) ) )? ) ) + // InternalDSL.g:317:2: ( ( (lv_node_0_0= ruleLiteral ) ) ( ( (lv_and_1_0= 'UND' ) ) ( (lv_subNode_2_0= ruleAND_Node ) ) )? ) + { + // InternalDSL.g:317:2: ( ( (lv_node_0_0= ruleLiteral ) ) ( ( (lv_and_1_0= 'UND' ) ) ( (lv_subNode_2_0= ruleAND_Node ) ) )? ) + // InternalDSL.g:318:3: ( (lv_node_0_0= ruleLiteral ) ) ( ( (lv_and_1_0= 'UND' ) ) ( (lv_subNode_2_0= ruleAND_Node ) ) )? + { + // InternalDSL.g:318:3: ( (lv_node_0_0= ruleLiteral ) ) + // InternalDSL.g:319:4: (lv_node_0_0= ruleLiteral ) + { + // InternalDSL.g:319:4: (lv_node_0_0= ruleLiteral ) + // InternalDSL.g:320:5: lv_node_0_0= ruleLiteral + { + + newCompositeNode(grammarAccess.getAND_NodeAccess().getNodeLiteralParserRuleCall_0_0()); + + pushFollow(FOLLOW_11); + lv_node_0_0=ruleLiteral(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getAND_NodeRule()); + } + set( + current, + "node", + lv_node_0_0, + "com.specmate.objectif.DSL.Literal"); + afterParserOrEnumRuleCall(); + + + } + + + } + + // InternalDSL.g:337:3: ( ( (lv_and_1_0= 'UND' ) ) ( (lv_subNode_2_0= ruleAND_Node ) ) )? + int alt6=2; + int LA6_0 = input.LA(1); + + if ( (LA6_0==17) ) { + alt6=1; + } + switch (alt6) { + case 1 : + // InternalDSL.g:338:4: ( (lv_and_1_0= 'UND' ) ) ( (lv_subNode_2_0= ruleAND_Node ) ) + { + // InternalDSL.g:338:4: ( (lv_and_1_0= 'UND' ) ) + // InternalDSL.g:339:5: (lv_and_1_0= 'UND' ) + { + // InternalDSL.g:339:5: (lv_and_1_0= 'UND' ) + // InternalDSL.g:340:6: lv_and_1_0= 'UND' + { + lv_and_1_0=(Token)match(input,17,FOLLOW_4); + + newLeafNode(lv_and_1_0, grammarAccess.getAND_NodeAccess().getAndUNDKeyword_1_0_0()); + + + if (current==null) { + current = createModelElement(grammarAccess.getAND_NodeRule()); + } + setWithLastConsumed(current, "and", true, "UND"); + + + } + + + } + + // InternalDSL.g:352:4: ( (lv_subNode_2_0= ruleAND_Node ) ) + // InternalDSL.g:353:5: (lv_subNode_2_0= ruleAND_Node ) + { + // InternalDSL.g:353:5: (lv_subNode_2_0= ruleAND_Node ) + // InternalDSL.g:354:6: lv_subNode_2_0= ruleAND_Node + { + + newCompositeNode(grammarAccess.getAND_NodeAccess().getSubNodeAND_NodeParserRuleCall_1_1_0()); + + pushFollow(FOLLOW_2); + lv_subNode_2_0=ruleAND_Node(); + + state._fsp--; + + + if (current==null) { + current = createModelElementForParent(grammarAccess.getAND_NodeRule()); + } + set( + current, + "subNode", + lv_subNode_2_0, + "com.specmate.objectif.DSL.AND_Node"); + afterParserOrEnumRuleCall(); + + + } + + + } + + + } + break; + + } + + + } + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleAND_Node" + + + // $ANTLR start "entryRuleLiteral" + // InternalDSL.g:376:1: entryRuleLiteral returns [EObject current=null] : iv_ruleLiteral= ruleLiteral EOF ; + public final EObject entryRuleLiteral() throws RecognitionException { + EObject current = null; + + EObject iv_ruleLiteral = null; + + + try { + // InternalDSL.g:376:48: (iv_ruleLiteral= ruleLiteral EOF ) + // InternalDSL.g:377:2: iv_ruleLiteral= ruleLiteral EOF + { + newCompositeNode(grammarAccess.getLiteralRule()); + pushFollow(FOLLOW_1); + iv_ruleLiteral=ruleLiteral(); + + state._fsp--; + + current =iv_ruleLiteral; + match(input,EOF,FOLLOW_2); + + } + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "entryRuleLiteral" + + + // $ANTLR start "ruleLiteral" + // InternalDSL.g:383:1: ruleLiteral returns [EObject current=null] : ( (lv_content_0_0= RULE_CHARACTER_SQUENCE ) )+ ; + public final EObject ruleLiteral() throws RecognitionException { + EObject current = null; + + Token lv_content_0_0=null; + + + enterRule(); + + try { + // InternalDSL.g:389:2: ( ( (lv_content_0_0= RULE_CHARACTER_SQUENCE ) )+ ) + // InternalDSL.g:390:2: ( (lv_content_0_0= RULE_CHARACTER_SQUENCE ) )+ + { + // InternalDSL.g:390:2: ( (lv_content_0_0= RULE_CHARACTER_SQUENCE ) )+ + int cnt7=0; + loop7: + do { + int alt7=2; + int LA7_0 = input.LA(1); + + if ( (LA7_0==RULE_CHARACTER_SQUENCE) ) { + alt7=1; + } + + + switch (alt7) { + case 1 : + // InternalDSL.g:391:3: (lv_content_0_0= RULE_CHARACTER_SQUENCE ) + { + // InternalDSL.g:391:3: (lv_content_0_0= RULE_CHARACTER_SQUENCE ) + // InternalDSL.g:392:4: lv_content_0_0= RULE_CHARACTER_SQUENCE + { + lv_content_0_0=(Token)match(input,RULE_CHARACTER_SQUENCE,FOLLOW_12); + + newLeafNode(lv_content_0_0, grammarAccess.getLiteralAccess().getContentCHARACTER_SQUENCETerminalRuleCall_0()); + + + if (current==null) { + current = createModelElement(grammarAccess.getLiteralRule()); + } + addWithLastConsumed( + current, + "content", + lv_content_0_0, + "com.specmate.objectif.DSL.CHARACTER_SQUENCE"); + + + } + + + } + break; + + default : + if ( cnt7 >= 1 ) break loop7; + EarlyExitException eee = + new EarlyExitException(7, input); + throw eee; + } + cnt7++; + } while (true); + + + } + + + leaveRule(); + + } + + catch (RecognitionException re) { + recover(input,re); + appendSkippedTokens(); + } + finally { + } + return current; + } + // $ANTLR end "ruleLiteral" + + // Delegated rules + + + + + public static final BitSet FOLLOW_1 = new BitSet(new long[]{0x0000000000000000L}); + public static final BitSet FOLLOW_2 = new BitSet(new long[]{0x0000000000000002L}); + public static final BitSet FOLLOW_3 = new BitSet(new long[]{0x0000000000001002L}); + public static final BitSet FOLLOW_4 = new BitSet(new long[]{0x0000000000000010L}); + public static final BitSet FOLLOW_5 = new BitSet(new long[]{0x0000000000002000L}); + public static final BitSet FOLLOW_6 = new BitSet(new long[]{0x000000000000D010L}); + public static final BitSet FOLLOW_7 = new BitSet(new long[]{0x000000000000C000L}); + public static final BitSet FOLLOW_8 = new BitSet(new long[]{0x0000000000009010L}); + public static final BitSet FOLLOW_9 = new BitSet(new long[]{0x0000000000008000L}); + public static final BitSet FOLLOW_10 = new BitSet(new long[]{0x0000000000010002L}); + public static final BitSet FOLLOW_11 = new BitSet(new long[]{0x0000000000020002L}); + public static final BitSet FOLLOW_12 = new BitSet(new long[]{0x0000000000000012L}); + +} \ No newline at end of file diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/scoping/AbstractDSLScopeProvider.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/scoping/AbstractDSLScopeProvider.java new file mode 100644 index 000000000..9ab5f2c90 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/scoping/AbstractDSLScopeProvider.java @@ -0,0 +1,9 @@ +/* + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.scoping; + +import org.eclipse.xtext.scoping.impl.DelegatingScopeProvider; + +public abstract class AbstractDSLScopeProvider extends DelegatingScopeProvider { +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/scoping/DSLScopeProvider.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/scoping/DSLScopeProvider.java new file mode 100644 index 000000000..4ec2ccd0f --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/scoping/DSLScopeProvider.java @@ -0,0 +1,16 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.scoping; + +import com.specmate.objectif.internal.scoping.AbstractDSLScopeProvider; + +/** + * This class contains custom scoping description. + * + * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping + * on how and when to use it. + */ +@SuppressWarnings("all") +public class DSLScopeProvider extends AbstractDSLScopeProvider { +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/serializer/DSLSemanticSequencer.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/serializer/DSLSemanticSequencer.java new file mode 100644 index 000000000..e23458878 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/serializer/DSLSemanticSequencer.java @@ -0,0 +1,117 @@ +/* + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.serializer; + +import com.google.inject.Inject; +import com.specmate.objectif.internal.dSL.AND_Node; +import com.specmate.objectif.internal.dSL.BusinessRule; +import com.specmate.objectif.internal.dSL.DSLPackage; +import com.specmate.objectif.internal.dSL.Literal; +import com.specmate.objectif.internal.dSL.Model; +import com.specmate.objectif.internal.dSL.OR_Node; +import com.specmate.objectif.internal.services.DSLGrammarAccess; +import java.util.Set; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.xtext.Action; +import org.eclipse.xtext.Parameter; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.serializer.ISerializationContext; +import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer; + +@SuppressWarnings("all") +public class DSLSemanticSequencer extends AbstractDelegatingSemanticSequencer { + + @Inject + private DSLGrammarAccess grammarAccess; + + @Override + public void sequence(ISerializationContext context, EObject semanticObject) { + EPackage epackage = semanticObject.eClass().getEPackage(); + ParserRule rule = context.getParserRule(); + Action action = context.getAssignedAction(); + Set parameters = context.getEnabledBooleanParameters(); + if (epackage == DSLPackage.eINSTANCE) + switch (semanticObject.eClass().getClassifierID()) { + case DSLPackage.AND_NODE: + sequence_AND_Node(context, (AND_Node) semanticObject); + return; + case DSLPackage.BUSINESS_RULE: + sequence_BusinessRule(context, (BusinessRule) semanticObject); + return; + case DSLPackage.LITERAL: + sequence_Literal(context, (Literal) semanticObject); + return; + case DSLPackage.MODEL: + sequence_Model(context, (Model) semanticObject); + return; + case DSLPackage.OR_NODE: + sequence_OR_Node(context, (OR_Node) semanticObject); + return; + } + if (errorAcceptor != null) + errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); + } + + /** + * Contexts: + * AND_Node returns AND_Node + * + * Constraint: + * (node=Literal (and?='UND' subNode=AND_Node)?) + */ + protected void sequence_AND_Node(ISerializationContext context, AND_Node semanticObject) { + genericSequencer.createSequence(context, semanticObject); + } + + + /** + * Contexts: + * BusinessRule returns BusinessRule + * + * Constraint: + * (cause=OR_Node (effect=BusinessRule | effect=OR_Node) (alternative=BusinessRule | alternative=OR_Node)?) + */ + protected void sequence_BusinessRule(ISerializationContext context, BusinessRule semanticObject) { + genericSequencer.createSequence(context, semanticObject); + } + + + /** + * Contexts: + * Literal returns Literal + * + * Constraint: + * content+=CHARACTER_SQUENCE+ + */ + protected void sequence_Literal(ISerializationContext context, Literal semanticObject) { + genericSequencer.createSequence(context, semanticObject); + } + + + /** + * Contexts: + * Model returns Model + * + * Constraint: + * rules+=BusinessRule+ + */ + protected void sequence_Model(ISerializationContext context, Model semanticObject) { + genericSequencer.createSequence(context, semanticObject); + } + + + /** + * Contexts: + * OR_Node returns OR_Node + * + * Constraint: + * (node=AND_Node (or?='ODER' subNode=OR_Node)?) + */ + protected void sequence_OR_Node(ISerializationContext context, OR_Node semanticObject) { + genericSequencer.createSequence(context, semanticObject); + } + + +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/serializer/DSLSyntacticSequencer.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/serializer/DSLSyntacticSequencer.java new file mode 100644 index 000000000..955411101 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/serializer/DSLSyntacticSequencer.java @@ -0,0 +1,43 @@ +/* + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.serializer; + +import com.google.inject.Inject; +import com.specmate.objectif.internal.services.DSLGrammarAccess; +import java.util.List; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.nodemodel.INode; +import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias; +import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition; +import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer; + +@SuppressWarnings("all") +public class DSLSyntacticSequencer extends AbstractSyntacticSequencer { + + protected DSLGrammarAccess grammarAccess; + + @Inject + protected void init(IGrammarAccess access) { + grammarAccess = (DSLGrammarAccess) access; + } + + @Override + protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { + return ""; + } + + + @Override + protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) { + if (transition.getAmbiguousSyntaxes().isEmpty()) return; + List transitionNodes = collectNodes(fromNode, toNode); + for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) { + List syntaxNodes = getNodesFor(transitionNodes, syntax); + acceptNodes(getLastNavigableState(), syntaxNodes); + } + } + +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/services/DSLGrammarAccess.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/services/DSLGrammarAccess.java new file mode 100644 index 000000000..afcc9b399 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/services/DSLGrammarAccess.java @@ -0,0 +1,357 @@ +/* + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.services; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.util.List; +import org.eclipse.xtext.Alternatives; +import org.eclipse.xtext.Assignment; +import org.eclipse.xtext.Grammar; +import org.eclipse.xtext.GrammarUtil; +import org.eclipse.xtext.Group; +import org.eclipse.xtext.Keyword; +import org.eclipse.xtext.ParserRule; +import org.eclipse.xtext.RuleCall; +import org.eclipse.xtext.TerminalRule; +import org.eclipse.xtext.common.services.TerminalsGrammarAccess; +import org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder; +import org.eclipse.xtext.service.GrammarProvider; + +@Singleton +public class DSLGrammarAccess extends AbstractGrammarElementFinder { + + public class ModelElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "com.specmate.objectif.DSL.Model"); + private final Assignment cRulesAssignment = (Assignment)rule.eContents().get(1); + private final RuleCall cRulesBusinessRuleParserRuleCall_0 = (RuleCall)cRulesAssignment.eContents().get(0); + + //Model: + // rules+=BusinessRule*; + @Override public ParserRule getRule() { return rule; } + + //rules+=BusinessRule* + public Assignment getRulesAssignment() { return cRulesAssignment; } + + //BusinessRule + public RuleCall getRulesBusinessRuleParserRuleCall_0() { return cRulesBusinessRuleParserRuleCall_0; } + } + public class BusinessRuleElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "com.specmate.objectif.DSL.BusinessRule"); + private final Group cGroup = (Group)rule.eContents().get(1); + private final Keyword cWENNKeyword_0 = (Keyword)cGroup.eContents().get(0); + private final Assignment cCauseAssignment_1 = (Assignment)cGroup.eContents().get(1); + private final RuleCall cCauseOR_NodeParserRuleCall_1_0 = (RuleCall)cCauseAssignment_1.eContents().get(0); + private final Keyword cDANNKeyword_2 = (Keyword)cGroup.eContents().get(2); + private final Assignment cEffectAssignment_3 = (Assignment)cGroup.eContents().get(3); + private final Alternatives cEffectAlternatives_3_0 = (Alternatives)cEffectAssignment_3.eContents().get(0); + private final RuleCall cEffectBusinessRuleParserRuleCall_3_0_0 = (RuleCall)cEffectAlternatives_3_0.eContents().get(0); + private final RuleCall cEffectOR_NodeParserRuleCall_3_0_1 = (RuleCall)cEffectAlternatives_3_0.eContents().get(1); + private final Group cGroup_4 = (Group)cGroup.eContents().get(4); + private final Keyword cSONSTKeyword_4_0 = (Keyword)cGroup_4.eContents().get(0); + private final Assignment cAlternativeAssignment_4_1 = (Assignment)cGroup_4.eContents().get(1); + private final Alternatives cAlternativeAlternatives_4_1_0 = (Alternatives)cAlternativeAssignment_4_1.eContents().get(0); + private final RuleCall cAlternativeBusinessRuleParserRuleCall_4_1_0_0 = (RuleCall)cAlternativeAlternatives_4_1_0.eContents().get(0); + private final RuleCall cAlternativeOR_NodeParserRuleCall_4_1_0_1 = (RuleCall)cAlternativeAlternatives_4_1_0.eContents().get(1); + private final Keyword cENDEWENNKeyword_5 = (Keyword)cGroup.eContents().get(5); + + //BusinessRule: + // 'WENN' cause=OR_Node "DANN" effect=(BusinessRule | OR_Node) ("SONST" alternative=(BusinessRule | OR_Node))? + // "ENDE-WENN"; + @Override public ParserRule getRule() { return rule; } + + //'WENN' cause=OR_Node "DANN" effect=(BusinessRule | OR_Node) ("SONST" alternative=(BusinessRule | OR_Node))? "ENDE-WENN" + public Group getGroup() { return cGroup; } + + //'WENN' + public Keyword getWENNKeyword_0() { return cWENNKeyword_0; } + + //cause=OR_Node + public Assignment getCauseAssignment_1() { return cCauseAssignment_1; } + + //OR_Node + public RuleCall getCauseOR_NodeParserRuleCall_1_0() { return cCauseOR_NodeParserRuleCall_1_0; } + + //"DANN" + public Keyword getDANNKeyword_2() { return cDANNKeyword_2; } + + //effect=(BusinessRule | OR_Node) + public Assignment getEffectAssignment_3() { return cEffectAssignment_3; } + + //(BusinessRule | OR_Node) + public Alternatives getEffectAlternatives_3_0() { return cEffectAlternatives_3_0; } + + //BusinessRule + public RuleCall getEffectBusinessRuleParserRuleCall_3_0_0() { return cEffectBusinessRuleParserRuleCall_3_0_0; } + + //OR_Node + public RuleCall getEffectOR_NodeParserRuleCall_3_0_1() { return cEffectOR_NodeParserRuleCall_3_0_1; } + + //("SONST" alternative=(BusinessRule | OR_Node))? + public Group getGroup_4() { return cGroup_4; } + + //"SONST" + public Keyword getSONSTKeyword_4_0() { return cSONSTKeyword_4_0; } + + //alternative=(BusinessRule | OR_Node) + public Assignment getAlternativeAssignment_4_1() { return cAlternativeAssignment_4_1; } + + //(BusinessRule | OR_Node) + public Alternatives getAlternativeAlternatives_4_1_0() { return cAlternativeAlternatives_4_1_0; } + + //BusinessRule + public RuleCall getAlternativeBusinessRuleParserRuleCall_4_1_0_0() { return cAlternativeBusinessRuleParserRuleCall_4_1_0_0; } + + //OR_Node + public RuleCall getAlternativeOR_NodeParserRuleCall_4_1_0_1() { return cAlternativeOR_NodeParserRuleCall_4_1_0_1; } + + //"ENDE-WENN" + public Keyword getENDEWENNKeyword_5() { return cENDEWENNKeyword_5; } + } + public class OR_NodeElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "com.specmate.objectif.DSL.OR_Node"); + private final Group cGroup = (Group)rule.eContents().get(1); + private final Assignment cNodeAssignment_0 = (Assignment)cGroup.eContents().get(0); + private final RuleCall cNodeAND_NodeParserRuleCall_0_0 = (RuleCall)cNodeAssignment_0.eContents().get(0); + private final Group cGroup_1 = (Group)cGroup.eContents().get(1); + private final Assignment cOrAssignment_1_0 = (Assignment)cGroup_1.eContents().get(0); + private final Keyword cOrODERKeyword_1_0_0 = (Keyword)cOrAssignment_1_0.eContents().get(0); + private final Assignment cSubNodeAssignment_1_1 = (Assignment)cGroup_1.eContents().get(1); + private final RuleCall cSubNodeOR_NodeParserRuleCall_1_1_0 = (RuleCall)cSubNodeAssignment_1_1.eContents().get(0); + + //OR_Node: + // node=AND_Node (or?="ODER" subNode=OR_Node)?; + @Override public ParserRule getRule() { return rule; } + + //node=AND_Node (or?="ODER" subNode=OR_Node)? + public Group getGroup() { return cGroup; } + + //node=AND_Node + public Assignment getNodeAssignment_0() { return cNodeAssignment_0; } + + //AND_Node + public RuleCall getNodeAND_NodeParserRuleCall_0_0() { return cNodeAND_NodeParserRuleCall_0_0; } + + //(or?="ODER" subNode=OR_Node)? + public Group getGroup_1() { return cGroup_1; } + + //or?="ODER" + public Assignment getOrAssignment_1_0() { return cOrAssignment_1_0; } + + //"ODER" + public Keyword getOrODERKeyword_1_0_0() { return cOrODERKeyword_1_0_0; } + + //subNode=OR_Node + public Assignment getSubNodeAssignment_1_1() { return cSubNodeAssignment_1_1; } + + //OR_Node + public RuleCall getSubNodeOR_NodeParserRuleCall_1_1_0() { return cSubNodeOR_NodeParserRuleCall_1_1_0; } + } + public class AND_NodeElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "com.specmate.objectif.DSL.AND_Node"); + private final Group cGroup = (Group)rule.eContents().get(1); + private final Assignment cNodeAssignment_0 = (Assignment)cGroup.eContents().get(0); + private final RuleCall cNodeLiteralParserRuleCall_0_0 = (RuleCall)cNodeAssignment_0.eContents().get(0); + private final Group cGroup_1 = (Group)cGroup.eContents().get(1); + private final Assignment cAndAssignment_1_0 = (Assignment)cGroup_1.eContents().get(0); + private final Keyword cAndUNDKeyword_1_0_0 = (Keyword)cAndAssignment_1_0.eContents().get(0); + private final Assignment cSubNodeAssignment_1_1 = (Assignment)cGroup_1.eContents().get(1); + private final RuleCall cSubNodeAND_NodeParserRuleCall_1_1_0 = (RuleCall)cSubNodeAssignment_1_1.eContents().get(0); + + //AND_Node: + // node=Literal (and?="UND" subNode=AND_Node)?; + @Override public ParserRule getRule() { return rule; } + + //node=Literal (and?="UND" subNode=AND_Node)? + public Group getGroup() { return cGroup; } + + //node=Literal + public Assignment getNodeAssignment_0() { return cNodeAssignment_0; } + + //Literal + public RuleCall getNodeLiteralParserRuleCall_0_0() { return cNodeLiteralParserRuleCall_0_0; } + + //(and?="UND" subNode=AND_Node)? + public Group getGroup_1() { return cGroup_1; } + + //and?="UND" + public Assignment getAndAssignment_1_0() { return cAndAssignment_1_0; } + + //"UND" + public Keyword getAndUNDKeyword_1_0_0() { return cAndUNDKeyword_1_0_0; } + + //subNode=AND_Node + public Assignment getSubNodeAssignment_1_1() { return cSubNodeAssignment_1_1; } + + //AND_Node + public RuleCall getSubNodeAND_NodeParserRuleCall_1_1_0() { return cSubNodeAND_NodeParserRuleCall_1_1_0; } + } + public class LiteralElements extends AbstractParserRuleElementFinder { + private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "com.specmate.objectif.DSL.Literal"); + private final Assignment cContentAssignment = (Assignment)rule.eContents().get(1); + private final RuleCall cContentCHARACTER_SQUENCETerminalRuleCall_0 = (RuleCall)cContentAssignment.eContents().get(0); + + //Literal: + // content+=CHARACTER_SQUENCE+; + @Override public ParserRule getRule() { return rule; } + + //content+=CHARACTER_SQUENCE+ + public Assignment getContentAssignment() { return cContentAssignment; } + + //CHARACTER_SQUENCE + public RuleCall getContentCHARACTER_SQUENCETerminalRuleCall_0() { return cContentCHARACTER_SQUENCETerminalRuleCall_0; } + } + + + private final ModelElements pModel; + private final BusinessRuleElements pBusinessRule; + private final OR_NodeElements pOR_Node; + private final AND_NodeElements pAND_Node; + private final LiteralElements pLiteral; + private final TerminalRule tCHARACTER_SQUENCE; + + private final Grammar grammar; + + private final TerminalsGrammarAccess gaTerminals; + + @Inject + public DSLGrammarAccess(GrammarProvider grammarProvider, + TerminalsGrammarAccess gaTerminals) { + this.grammar = internalFindGrammar(grammarProvider); + this.gaTerminals = gaTerminals; + this.pModel = new ModelElements(); + this.pBusinessRule = new BusinessRuleElements(); + this.pOR_Node = new OR_NodeElements(); + this.pAND_Node = new AND_NodeElements(); + this.pLiteral = new LiteralElements(); + this.tCHARACTER_SQUENCE = (TerminalRule) GrammarUtil.findRuleForName(getGrammar(), "com.specmate.objectif.DSL.CHARACTER_SQUENCE"); + } + + protected Grammar internalFindGrammar(GrammarProvider grammarProvider) { + Grammar grammar = grammarProvider.getGrammar(this); + while (grammar != null) { + if ("com.specmate.objectif.DSL".equals(grammar.getName())) { + return grammar; + } + List grammars = grammar.getUsedGrammars(); + if (!grammars.isEmpty()) { + grammar = grammars.iterator().next(); + } else { + return null; + } + } + return grammar; + } + + @Override + public Grammar getGrammar() { + return grammar; + } + + + public TerminalsGrammarAccess getTerminalsGrammarAccess() { + return gaTerminals; + } + + + //Model: + // rules+=BusinessRule*; + public ModelElements getModelAccess() { + return pModel; + } + + public ParserRule getModelRule() { + return getModelAccess().getRule(); + } + + //BusinessRule: + // 'WENN' cause=OR_Node "DANN" effect=(BusinessRule | OR_Node) ("SONST" alternative=(BusinessRule | OR_Node))? + // "ENDE-WENN"; + public BusinessRuleElements getBusinessRuleAccess() { + return pBusinessRule; + } + + public ParserRule getBusinessRuleRule() { + return getBusinessRuleAccess().getRule(); + } + + //OR_Node: + // node=AND_Node (or?="ODER" subNode=OR_Node)?; + public OR_NodeElements getOR_NodeAccess() { + return pOR_Node; + } + + public ParserRule getOR_NodeRule() { + return getOR_NodeAccess().getRule(); + } + + //AND_Node: + // node=Literal (and?="UND" subNode=AND_Node)?; + public AND_NodeElements getAND_NodeAccess() { + return pAND_Node; + } + + public ParserRule getAND_NodeRule() { + return getAND_NodeAccess().getRule(); + } + + //Literal: + // content+=CHARACTER_SQUENCE+; + public LiteralElements getLiteralAccess() { + return pLiteral; + } + + public ParserRule getLiteralRule() { + return getLiteralAccess().getRule(); + } + + //terminal CHARACTER_SQUENCE: + // 'a'..'z' | 'A'..'Z' | '_' | '0'..'9' | "=" | "/" | "%" | "#" | "<" | ">" | "|" | "." | "?" | "," | "\"" | "(" | ")"+; + public TerminalRule getCHARACTER_SQUENCERule() { + return tCHARACTER_SQUENCE; + } + + //terminal ID: + // '^'? ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*; + public TerminalRule getIDRule() { + return gaTerminals.getIDRule(); + } + + //terminal INT returns ecore::EInt: + // '0'..'9'+; + public TerminalRule getINTRule() { + return gaTerminals.getINTRule(); + } + + //terminal STRING: + // '"' ('\\' . | !('\\' | '"'))* '"' | + // "'" ('\\' . | !('\\' | "'"))* "'"; + public TerminalRule getSTRINGRule() { + return gaTerminals.getSTRINGRule(); + } + + //terminal ML_COMMENT: + // '/*'->'*/'; + public TerminalRule getML_COMMENTRule() { + return gaTerminals.getML_COMMENTRule(); + } + + //terminal SL_COMMENT: + // '//' !('\n' | '\r')* ('\r'? '\n')?; + public TerminalRule getSL_COMMENTRule() { + return gaTerminals.getSL_COMMENTRule(); + } + + //terminal WS: + // ' ' | '\t' | '\r' | '\n'+; + public TerminalRule getWSRule() { + return gaTerminals.getWSRule(); + } + + //terminal ANY_OTHER: + // .; + public TerminalRule getANY_OTHERRule() { + return gaTerminals.getANY_OTHERRule(); + } +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/AbstractDSLValidator.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/AbstractDSLValidator.java new file mode 100644 index 000000000..e5feb3b8a --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/AbstractDSLValidator.java @@ -0,0 +1,19 @@ +/* + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.validation; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.xtext.validation.AbstractDeclarativeValidator; + +public abstract class AbstractDSLValidator extends AbstractDeclarativeValidator { + + @Override + protected List getEPackages() { + List result = new ArrayList(); + result.add(com.specmate.objectif.internal.dSL.DSLPackage.eINSTANCE); + return result; + } +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/DSLConfigurableIssueCodesProvider.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/DSLConfigurableIssueCodesProvider.java new file mode 100644 index 000000000..56bf6b2ea --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/DSLConfigurableIssueCodesProvider.java @@ -0,0 +1,12 @@ +/* + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.validation; + +import org.eclipse.xtext.validation.ConfigurableIssueCodesProvider; + +public class DSLConfigurableIssueCodesProvider extends ConfigurableIssueCodesProvider { + protected static final String ISSUE_CODE_PREFIX = "com.specmate.objectif."; + + public static final String DEPRECATED_MODEL_PART = ISSUE_CODE_PREFIX + "deprecatedModelPart"; +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/DSLValidator.java b/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/DSLValidator.java new file mode 100644 index 000000000..201ca714c --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/internal/validation/DSLValidator.java @@ -0,0 +1,15 @@ +/** + * generated by Xtext 2.17.1 + */ +package com.specmate.objectif.internal.validation; + +import com.specmate.objectif.internal.validation.AbstractDSLValidator; + +/** + * This class contains custom validation rules. + * + * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation + */ +@SuppressWarnings("all") +public class DSLValidator extends AbstractDSLValidator { +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/BusinessRuleUtil.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/BusinessRuleUtil.java new file mode 100644 index 000000000..b551c8238 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/BusinessRuleUtil.java @@ -0,0 +1,80 @@ +package com.specmate.objectif.resolve; + +import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.ISetup; + +import com.specmate.objectif.internal.DSLStandaloneSetup; +import com.specmate.objectif.internal.dSL.AND_Node; +import com.specmate.objectif.internal.dSL.BusinessRule; +import com.specmate.objectif.internal.dSL.Literal; +import com.specmate.objectif.internal.dSL.Model; +import com.specmate.objectif.internal.dSL.OR_Node; +import com.specmate.objectif.resolve.rule.AndNode; +import com.specmate.objectif.resolve.rule.BusinessRuleNode; +import com.specmate.objectif.resolve.rule.LiteralNode; +import com.specmate.objectif.resolve.rule.ObjectifNode; +import com.specmate.objectif.resolve.rule.OrNode; +import com.specmate.xtext.XTextResourceProcessor; + +public class BusinessRuleUtil extends XTextResourceProcessor{ + + @Override + public ISetup getGrammar() { + return new DSLStandaloneSetup(); + } + + @Override + public List process(EList eList) { + return eList.stream() + .filter(e -> e instanceof Model) + .flatMap(m -> ((Model)m).getRules().stream()) + .map(BusinessRuleUtil::resolveRule) + .collect(Collectors.toList()); + } + + private static BusinessRuleNode resolveRule(BusinessRule businessRule) { + ObjectifNode cause = resolveOrNode(businessRule.getCause()); + ObjectifNode effect = resolveEffect(businessRule.getEffect()); + if(businessRule.getAlternative() != null) { + ObjectifNode alternative = resolveEffect(businessRule.getAlternative()); + return new BusinessRuleNode(cause, effect, alternative); + } + return new BusinessRuleNode(cause, effect); + } + + private static ObjectifNode resolveEffect(EObject eObject) { + if(eObject instanceof BusinessRule) { + return resolveRule((BusinessRule)eObject); + } + return resolveOrNode((OR_Node) eObject); + } + + private static ObjectifNode resolveOrNode(OR_Node orNode) { + ObjectifNode node = resolveAndNode(orNode.getNode()); + if(orNode.isOr()) { + ObjectifNode sub = resolveOrNode(orNode.getSubNode()); + return new OrNode(node, sub); + } + return node; + + } + + private static ObjectifNode resolveAndNode(AND_Node andNode) { + ObjectifNode node = resolveLiteralNode(andNode.getNode()); + if(andNode.isAnd()) { + ObjectifNode sub = resolveAndNode(andNode.getSubNode()); + return new AndNode(node, sub); + } + return node; + } + + private static ObjectifNode resolveLiteralNode(Literal literal) { + EList contentList = literal.getContent(); + String[] content = contentList.toArray(new String[contentList.size()]); + return new LiteralNode(content); + } +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/packageinfo b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/packageinfo new file mode 100644 index 000000000..9ad81f6fa --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/packageinfo @@ -0,0 +1 @@ +version 1.0.0 diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/AndNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/AndNode.java new file mode 100644 index 000000000..7524a8380 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/AndNode.java @@ -0,0 +1,23 @@ +package com.specmate.objectif.resolve.rule; + +public class AndNode extends ObjectifNode { + ObjectifNode leftNode; + ObjectifNode rightNode; + + public AndNode(ObjectifNode left, ObjectifNode right) { + this.leftNode = left; + this.rightNode = right; + } + + @Override + void generateCEG() { + // TODO Auto-generated method stub + + } + + @Override + public String toString() { + return "("+this.leftNode+" && "+this.rightNode+")"; + } + +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/BusinessRuleNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/BusinessRuleNode.java new file mode 100644 index 000000000..ff792b9f9 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/BusinessRuleNode.java @@ -0,0 +1,43 @@ +package com.specmate.objectif.resolve.rule; + +import java.util.Optional; + +public class BusinessRuleNode extends ObjectifNode { + private ObjectifNode cause; + private ObjectifNode effect; + private Optional alternative; + + public BusinessRuleNode(ObjectifNode cause, ObjectifNode effect, ObjectifNode alternative) { + this(cause, effect); + this.alternative = Optional.of(alternative); + } + + public BusinessRuleNode(ObjectifNode cause, ObjectifNode effect) { + this.cause = cause; + this.effect = effect; + } + + @Override + void generateCEG() { + this.cause.generateCEG(); + this.effect.generateCEG(); + if(this.alternative.isPresent()) { + this.alternative.get().generateCEG(); + } + } + + @Override + public String toString() { + String result = "if "; + if(this.cause instanceof LiteralNode) { + result += "("+this.cause+")"; + } else { + result += this.cause; + } + result += " { "+this.effect+" }"; + if(this.alternative.isPresent()) { + result += " else { "+this.alternative.get()+" }"; + } + return result; + } +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/LiteralNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/LiteralNode.java new file mode 100644 index 000000000..3680d7855 --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/LiteralNode.java @@ -0,0 +1,21 @@ +package com.specmate.objectif.resolve.rule; + +public class LiteralNode extends ObjectifNode { + String[] literal; + + public LiteralNode(String[] content) { + this.literal = content; + } + + + @Override + void generateCEG() { + // TODO Auto-generated method stub + + } + + @Override + public String toString() { + return String.join(" ", this.literal); + } +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/ObjectifNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/ObjectifNode.java new file mode 100644 index 000000000..dbe8ae26a --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/ObjectifNode.java @@ -0,0 +1,5 @@ +package com.specmate.objectif.resolve.rule; + +public abstract class ObjectifNode { + abstract void generateCEG(); +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/OrNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/OrNode.java new file mode 100644 index 000000000..7fed2106d --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/OrNode.java @@ -0,0 +1,22 @@ +package com.specmate.objectif.resolve.rule; + +public class OrNode extends ObjectifNode { + ObjectifNode leftNode; + ObjectifNode rightNode; + + public OrNode(ObjectifNode left, ObjectifNode right) { + this.leftNode = left; + this.rightNode = right; + } + + @Override + void generateCEG() { + // TODO Auto-generated method stub + + } + + @Override + public String toString() { + return "("+this.leftNode+" || "+this.rightNode+")"; + } +} diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/packageinfo b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/packageinfo new file mode 100644 index 000000000..9ad81f6fa --- /dev/null +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/packageinfo @@ -0,0 +1 @@ +version 1.0.0 diff --git a/bundles/specmate-xtext/.classpath b/bundles/specmate-xtext/.classpath new file mode 100644 index 000000000..6483fc14f --- /dev/null +++ b/bundles/specmate-xtext/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/specmate-xtext/.gitignore b/bundles/specmate-xtext/.gitignore new file mode 100644 index 000000000..57b341172 --- /dev/null +++ b/bundles/specmate-xtext/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/generated/ diff --git a/bundles/specmate-xtext/.project b/bundles/specmate-xtext/.project new file mode 100644 index 000000000..36e25ec3f --- /dev/null +++ b/bundles/specmate-xtext/.project @@ -0,0 +1,23 @@ + + + specmate-xtext + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/bundles/specmate-xtext/.settings/org.eclipse.core.resources.prefs b/bundles/specmate-xtext/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..1554c6f84 --- /dev/null +++ b/bundles/specmate-xtext/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/bnd.bnd=UTF-8 diff --git a/bundles/specmate-xtext/.settings/org.eclipse.jdt.core.prefs b/bundles/specmate-xtext/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..3a2153707 --- /dev/null +++ b/bundles/specmate-xtext/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bundles/specmate-xtext/bnd.bnd b/bundles/specmate-xtext/bnd.bnd new file mode 100644 index 000000000..569a915ed --- /dev/null +++ b/bundles/specmate-xtext/bnd.bnd @@ -0,0 +1,12 @@ +-buildpath: \ + org.eclipse.xtext,\ + com.google.inject,\ + org.eclipse.xtext.util,\ + org.eclipse.emf.ecore,\ + org.antlr.runtime,\ + org.eclipse.emf.common,\ + org.eclipse.xtext.xbase.lib,\ + com.google.guava,\ + specmate-nlp,\ + org.glassfish.hk2.external.javax.inject +Export-Package: com.specmate.xtext \ No newline at end of file diff --git a/bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/XTextException.java b/bundles/specmate-xtext/src/com/specmate/xtext/XTextException.java similarity index 77% rename from bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/XTextException.java rename to bundles/specmate-xtext/src/com/specmate/xtext/XTextException.java index 19e8fdd4c..6c0d65541 100644 --- a/bundles/specmate-cause-effect-patterns/src/com/specmate/cause_effect_patterns/resolve/XTextException.java +++ b/bundles/specmate-xtext/src/com/specmate/xtext/XTextException.java @@ -1,4 +1,4 @@ -package com.specmate.cause_effect_patterns.resolve; +package com.specmate.xtext; public class XTextException extends Exception { diff --git a/bundles/specmate-xtext/src/com/specmate/xtext/XTextResourceProcessor.java b/bundles/specmate-xtext/src/com/specmate/xtext/XTextResourceProcessor.java new file mode 100644 index 000000000..751ab694a --- /dev/null +++ b/bundles/specmate-xtext/src/com/specmate/xtext/XTextResourceProcessor.java @@ -0,0 +1,21 @@ +package com.specmate.xtext; + +import java.util.List; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.ISetup; + +public abstract class XTextResourceProcessor { + public abstract ISetup getGrammar(); + public abstract List process(EList data) throws XTextException; + + public List loadXTextResources(URI mainFile, URI... paths) throws XTextException{ + return this.process(XTextUtil.loadXTextResources(this.getGrammar(), mainFile, paths)); + } + + public List parseXTextResource(String data) throws XTextException{ + return this.process(XTextUtil.parseXTextResource(this.getGrammar(), data)); + } +} diff --git a/bundles/specmate-xtext/src/com/specmate/xtext/XTextUtil.java b/bundles/specmate-xtext/src/com/specmate/xtext/XTextUtil.java new file mode 100644 index 000000000..276609559 --- /dev/null +++ b/bundles/specmate-xtext/src/com/specmate/xtext/XTextUtil.java @@ -0,0 +1,69 @@ +package com.specmate.xtext; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.xtext.ISetup; +import org.eclipse.xtext.resource.XtextResource; +import org.eclipse.xtext.resource.XtextResourceSet; +import org.eclipse.xtext.util.CancelIndicator; +import org.eclipse.xtext.validation.CheckMode; +import org.eclipse.xtext.validation.IResourceValidator; +import org.eclipse.xtext.validation.Issue; + +import com.google.inject.Injector; + +public class XTextUtil { + public static EList loadXTextResources(ISetup grammar ,URI mainFile, URI... paths) throws XTextException{ + // do this only once per application + Injector injector = grammar.createInjectorAndDoEMFRegistration(); + + // obtain a resourceset from the injector + XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class); + + // load a resource by URI, in this case from the file system + Resource resource = resourceSet.getResource(mainFile, true); + for(URI res: paths) { + resourceSet.getResource(res, true); + } + + // Validation + IResourceValidator validator = ((XtextResource)resource).getResourceServiceProvider().getResourceValidator(); + List issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl); + if(issues.size() > 0) { + String issueText = issues.stream().map(Issue::getMessage).collect(Collectors.joining("\n")); + throw new XTextException("Validation encountered issues:\n"+issueText); + } + + return resource.getContents(); + } + + public static EList parseXTextResource(ISetup grammar, String data) throws XTextException { + Injector injector = grammar.createInjectorAndDoEMFRegistration(); + XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class); + + Resource resource = resourceSet.createResource(URI.createURI("dummy:/string.objectif")); + InputStream in = new ByteArrayInputStream(data.getBytes()); + try { + resource.load(in, resourceSet.getLoadOptions()); + } catch (IOException e) { + throw new XTextException("Validation encountered issues:\n"+e.getMessage()); + } + + // Validation + IResourceValidator validator = ((XtextResource)resource).getResourceServiceProvider().getResourceValidator(); + List issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl); + if(issues.size() > 0) { + String issueText = issues.stream().map(Issue::getMessage).collect(Collectors.joining("\n")); + throw new XTextException("Validation encountered issues:\n"+issueText); + } + return resource.getContents(); + } +} diff --git a/bundles/specmate-xtext/src/com/specmate/xtext/packageinfo b/bundles/specmate-xtext/src/com/specmate/xtext/packageinfo new file mode 100644 index 000000000..9ad81f6fa --- /dev/null +++ b/bundles/specmate-xtext/src/com/specmate/xtext/packageinfo @@ -0,0 +1 @@ +version 1.0.0 From 15cfa404e5cb899c546ec98c5c3c0e8ebd886706 Mon Sep 17 00:00:00 2001 From: Dominik Date: Mon, 27 May 2019 13:20:40 +0200 Subject: [PATCH 02/10] Added Objectif Grammar & Test --- bundles/specmate-integration-test/.classpath | 2 + .../resources/test_rules.objectif | 5 +- .../test/integration/ObjectifTest.java | 93 ++++++++++- bundles/specmate-objectif/.classpath | 141 ++++++++++++++++ bundles/specmate-objectif/bnd.bnd | 4 +- .../objectif/resolve/rule/AndNode.java | 11 +- .../resolve/rule/BusinessRuleNode.java | 17 ++ .../objectif/resolve/rule/LiteralNode.java | 4 + .../objectif/resolve/rule/OrNode.java | 12 +- bundles/specmate-xtext/.classpath | 154 ++++++++++++++++++ .../src/com/specmate/xtext/XTextUtil.java | 2 +- 11 files changed, 432 insertions(+), 13 deletions(-) diff --git a/bundles/specmate-integration-test/.classpath b/bundles/specmate-integration-test/.classpath index 2458f8c0c..f5275bd21 100644 --- a/bundles/specmate-integration-test/.classpath +++ b/bundles/specmate-integration-test/.classpath @@ -4,5 +4,7 @@ + + diff --git a/bundles/specmate-integration-test/resources/test_rules.objectif b/bundles/specmate-integration-test/resources/test_rules.objectif index 8a78cf82c..6b969e482 100644 --- a/bundles/specmate-integration-test/resources/test_rules.objectif +++ b/bundles/specmate-integration-test/resources/test_rules.objectif @@ -1 +1,4 @@ -WENN A=5 UND B=3 DANN C=7 SONST D=5 ENDE-WENN \ No newline at end of file +WENN A=5 UND B=3 DANN C=7 ENDE-WENN +WENN X = Z ODER Y>4 DANN F="Test" ENDE-WENN +WENN A=1 DANN WENN B=1 DANN C=1 ENDE-WENN ENDE-WENN +WENN A=1 DANN B=1 SONST C=2 ENDE-WENN \ No newline at end of file diff --git a/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java b/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java index 5f64e8d74..597ba4e44 100644 --- a/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java +++ b/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java @@ -1,27 +1,110 @@ package com.specmate.test.integration; +import org.junit.Assert; +import org.junit.Test; + import java.net.URISyntaxException; import java.util.List; import org.eclipse.emf.common.util.URI; -import org.junit.Test; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; import com.specmate.objectif.resolve.BusinessRuleUtil; +import com.specmate.objectif.resolve.rule.AndNode; import com.specmate.objectif.resolve.rule.BusinessRuleNode; +import com.specmate.objectif.resolve.rule.LiteralNode; +import com.specmate.objectif.resolve.rule.ObjectifNode; +import com.specmate.objectif.resolve.rule.OrNode; import com.specmate.xtext.XTextException; public class ObjectifTest { @Test public void testLoadRules() throws URISyntaxException, XTextException { - loadRules("/resources/test_rules.objectif"); + List rules = loadRules("/resources/test_rules.objectif"); + Assert.assertTrue(rules.size() == 4); + } + + @Test + public void testAND() throws URISyntaxException, XTextException { + List rules = loadRules("/resources/test_rules.objectif"); + BusinessRuleNode rule = rules.get(0); + ObjectifNode cause = rule.getCause(); + Assert.assertTrue(cause instanceof AndNode); + + ObjectifNode causeA = ((AndNode)cause).getLeft(); + ObjectifNode causeB = ((AndNode)cause).getRight(); + Assert.assertTrue(causeA instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)causeA).getContent().equals("A=5")); + Assert.assertTrue(causeB instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)causeB).getContent().equals("B=3")); + + ObjectifNode effect = rule.getEffect(); + Assert.assertTrue(effect instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)effect).getContent().equals("C=7")); + } + + @Test + public void testOR() throws URISyntaxException, XTextException { + List rules = loadRules("/resources/test_rules.objectif"); + BusinessRuleNode rule = rules.get(1); + ObjectifNode cause = rule.getCause(); + Assert.assertTrue(cause instanceof OrNode); + + ObjectifNode causeA = ((OrNode)cause).getLeft(); + ObjectifNode causeB = ((OrNode)cause).getRight(); + Assert.assertTrue(causeA instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)causeA).getContent().equals("X = Z")); + Assert.assertTrue(causeB instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)causeB).getContent().equals("Y>4")); + + ObjectifNode effect = rule.getEffect(); + Assert.assertTrue(effect instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)effect).getContent().equals("F=\"Test\"")); + } + + @Test + public void testNesting() throws URISyntaxException, XTextException { + List rules = loadRules("/resources/test_rules.objectif"); + BusinessRuleNode rule = rules.get(2); + ObjectifNode cause = rule.getCause(); + Assert.assertTrue(cause instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)cause).getContent().equals("A=1")); + + ObjectifNode effect = rule.getEffect(); + Assert.assertTrue(effect instanceof BusinessRuleNode); + + BusinessRuleNode ruleB = (BusinessRuleNode) effect; + + ObjectifNode causeB = ruleB.getCause(); + Assert.assertTrue(causeB instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)causeB).getContent().equals("B=1")); + + ObjectifNode effectB = ruleB.getEffect(); + Assert.assertTrue(effectB instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)effectB).getContent().equals("C=1")); + } + + @Test + public void testAlternative() throws URISyntaxException, XTextException { + List rules = loadRules("/resources/test_rules.objectif"); + BusinessRuleNode rule = rules.get(3); + ObjectifNode cause = rule.getCause(); + Assert.assertTrue(cause instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)cause).getContent().equals("A=1")); + ObjectifNode effect = rule.getEffect(); + Assert.assertTrue(effect instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)effect).getContent().equals("B=1")); + + Assert.assertTrue(rule.hasAlternative()); + ObjectifNode alternative = rule.getAlternative(); + Assert.assertTrue(alternative instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)alternative).getContent().equals("C=2")); } - private void loadRules(String mainFile) throws URISyntaxException, XTextException { + private List loadRules(String mainFile) throws URISyntaxException, XTextException { URI main = getLocalFile(mainFile); - List rules = new BusinessRuleUtil().loadXTextResources(main); - rules.forEach(System.out::println); + return new BusinessRuleUtil().loadXTextResources(main); } private URI getLocalFile(String fileName) throws URISyntaxException { diff --git a/bundles/specmate-objectif/.classpath b/bundles/specmate-objectif/.classpath index 6483fc14f..8cf0bdacb 100644 --- a/bundles/specmate-objectif/.classpath +++ b/bundles/specmate-objectif/.classpath @@ -3,5 +3,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/specmate-objectif/bnd.bnd b/bundles/specmate-objectif/bnd.bnd index 4f8493d1a..0e997d290 100644 --- a/bundles/specmate-objectif/bnd.bnd +++ b/bundles/specmate-objectif/bnd.bnd @@ -1,7 +1,7 @@ -buildpath: \ org.eclipse.xtext,\ - com.google.inject,\ org.eclipse.xtext.util,\ + com.google.inject,\ org.eclipse.emf.ecore,\ org.antlr.runtime,\ org.eclipse.emf.common,\ @@ -9,7 +9,7 @@ com.google.guava,\ specmate-nlp,\ org.glassfish.hk2.external.javax.inject,\ - specmate-xtext;version=latest + specmate-xtext -privatepackage: \ com.specmate.objectif.internal,\ com.specmate.objectif.internal.dSL,\ diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/AndNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/AndNode.java index 7524a8380..5991224f2 100644 --- a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/AndNode.java +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/AndNode.java @@ -1,8 +1,8 @@ package com.specmate.objectif.resolve.rule; public class AndNode extends ObjectifNode { - ObjectifNode leftNode; - ObjectifNode rightNode; + private ObjectifNode leftNode; + private ObjectifNode rightNode; public AndNode(ObjectifNode left, ObjectifNode right) { this.leftNode = left; @@ -20,4 +20,11 @@ public String toString() { return "("+this.leftNode+" && "+this.rightNode+")"; } + public ObjectifNode getLeft() { + return this.leftNode; + } + + public ObjectifNode getRight() { + return this.rightNode; + } } diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/BusinessRuleNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/BusinessRuleNode.java index ff792b9f9..48168f4f6 100644 --- a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/BusinessRuleNode.java +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/BusinessRuleNode.java @@ -15,6 +15,7 @@ public BusinessRuleNode(ObjectifNode cause, ObjectifNode effect, ObjectifNode al public BusinessRuleNode(ObjectifNode cause, ObjectifNode effect) { this.cause = cause; this.effect = effect; + this.alternative = Optional.empty(); } @Override @@ -40,4 +41,20 @@ public String toString() { } return result; } + + public ObjectifNode getCause() { + return this.cause; + } + + public ObjectifNode getEffect() { + return this.effect; + } + + public boolean hasAlternative() { + return this.alternative.isPresent(); + } + + public ObjectifNode getAlternative() { + return this.alternative.get(); + } } diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/LiteralNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/LiteralNode.java index 3680d7855..e48eabd61 100644 --- a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/LiteralNode.java +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/LiteralNode.java @@ -16,6 +16,10 @@ void generateCEG() { @Override public String toString() { + return getContent(); + } + + public String getContent() { return String.join(" ", this.literal); } } diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/OrNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/OrNode.java index 7fed2106d..356baf9e1 100644 --- a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/OrNode.java +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/OrNode.java @@ -1,8 +1,8 @@ package com.specmate.objectif.resolve.rule; public class OrNode extends ObjectifNode { - ObjectifNode leftNode; - ObjectifNode rightNode; + private ObjectifNode leftNode; + private ObjectifNode rightNode; public OrNode(ObjectifNode left, ObjectifNode right) { this.leftNode = left; @@ -19,4 +19,12 @@ void generateCEG() { public String toString() { return "("+this.leftNode+" || "+this.rightNode+")"; } + + public ObjectifNode getLeft() { + return this.leftNode; + } + + public ObjectifNode getRight() { + return this.rightNode; + } } diff --git a/bundles/specmate-xtext/.classpath b/bundles/specmate-xtext/.classpath index 6483fc14f..5be7ac0d0 100644 --- a/bundles/specmate-xtext/.classpath +++ b/bundles/specmate-xtext/.classpath @@ -3,5 +3,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/specmate-xtext/src/com/specmate/xtext/XTextUtil.java b/bundles/specmate-xtext/src/com/specmate/xtext/XTextUtil.java index 276609559..39a2c54e9 100644 --- a/bundles/specmate-xtext/src/com/specmate/xtext/XTextUtil.java +++ b/bundles/specmate-xtext/src/com/specmate/xtext/XTextUtil.java @@ -21,7 +21,7 @@ import com.google.inject.Injector; public class XTextUtil { - public static EList loadXTextResources(ISetup grammar ,URI mainFile, URI... paths) throws XTextException{ + public static EList loadXTextResources(ISetup grammar, URI mainFile, URI... paths) throws XTextException{ // do this only once per application Injector injector = grammar.createInjectorAndDoEMFRegistration(); From cd2ef14b152b11e20ecb91bf66936d4223e5516f Mon Sep 17 00:00:00 2001 From: Dominik Date: Mon, 27 May 2019 13:52:56 +0200 Subject: [PATCH 03/10] Fixed Import error --- bundles/specmate-model-generation/bnd.bnd | 3 ++- .../GenerateModelFromRequirementService.java | 1 - .../specmate/modelgeneration/PatternbasedCEGGenerator.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bundles/specmate-model-generation/bnd.bnd b/bundles/specmate-model-generation/bnd.bnd index e99836d9f..a0cbc4d0d 100644 --- a/bundles/specmate-model-generation/bnd.bnd +++ b/bundles/specmate-model-generation/bnd.bnd @@ -18,7 +18,8 @@ specmate-model-support;version=latest,\ org.apache.commons.lang3,\ specmate-cause-effect-patterns,\ - specmate-config-api;version=latest + specmate-config-api;version=latest,\ + specmate-xtext;version=latest Private-Package: \ com.specmate.modelgeneration,\ com.specmate.modelgeneration.legacy \ No newline at end of file diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java index 75f32603e..ec88db256 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java @@ -9,7 +9,6 @@ import org.osgi.service.component.annotations.Reference; import org.osgi.service.log.LogService; -import com.specmate.cause_effect_patterns.resolve.XTextException; import com.specmate.common.exception.SpecmateException; import com.specmate.emfrest.api.IRestService; import com.specmate.emfrest.api.RestServiceBase; diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/PatternbasedCEGGenerator.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/PatternbasedCEGGenerator.java index 7462a2c79..4f6534f29 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/PatternbasedCEGGenerator.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/PatternbasedCEGGenerator.java @@ -17,8 +17,7 @@ import com.specmate.cause_effect_patterns.parse.matcher.MatchUtil; import com.specmate.cause_effect_patterns.parse.wrapper.MatchResultWrapper; import com.specmate.cause_effect_patterns.parse.wrapper.MatchResultWrapper.RuleType; -import com.specmate.cause_effect_patterns.resolve.XTextException; -import com.specmate.cause_effect_patterns.resolve.XTextUtil; +import com.specmate.cause_effect_patterns.resolve.GenerateMatcherUtil; import com.specmate.common.exception.SpecmateException; import com.specmate.common.exception.SpecmateInternalException; import com.specmate.model.administration.ErrorCode; @@ -30,6 +29,7 @@ import com.specmate.nlp.util.EnglishSentenceUnfolder; import com.specmate.nlp.util.GermanSentenceUnfolder; import com.specmate.nlp.util.SentenceUnfolderBase; +import com.specmate.xtext.XTextException; public class PatternbasedCEGGenerator implements ICEGFromRequirementGenerator { private INLPService tagger; @@ -62,7 +62,7 @@ public PatternbasedCEGGenerator(String folder, ELanguage lang, INLPService tagge } try { - this.rules = XTextUtil.generateMatchers(rule, dep, pos); + this.rules = new GenerateMatcherUtil().loadXTextResources(rule, dep, pos); } catch (XTextException e) { throw new SpecmateInternalException(ErrorCode.NLP, e); } From 17bcb9e645e5074f8503c9c65b5cccf7b4c2b726 Mon Sep 17 00:00:00 2001 From: Jannik Fischbach Date: Thu, 4 Jul 2019 12:42:51 +0200 Subject: [PATCH 04/10] Add: Non nested pseudo code --- .../resources/test_rules.objectif | 2 +- bundles/specmate-model-generation/bnd.bnd | 3 +- .../generated/buildfiles | 2 +- .../resources/test_rules.objectif | 1 + .../GenerateModelFromPseudoCode.java | 284 ++++++++++++++++++ .../GenerateModelFromRequirementService.java | 4 +- .../bin/.gitignore | 1 - .../generators/typescript/generateAngular.mtl | 144 +++++++++ .../objectif/resolve/rule/ObjectifNode.java | 7 + .../specmate-std-env/dev-specmate-all.bndrun | 4 +- 10 files changed, 446 insertions(+), 6 deletions(-) create mode 100644 bundles/specmate-model-generation/resources/test_rules.objectif create mode 100644 bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java delete mode 100644 bundles/specmate-model-generators-typescript/bin/.gitignore create mode 100644 bundles/specmate-model-generators-typescript/bin/com/specmate/model/generators/typescript/generateAngular.mtl diff --git a/bundles/specmate-integration-test/resources/test_rules.objectif b/bundles/specmate-integration-test/resources/test_rules.objectif index 6b969e482..0fa46fc67 100644 --- a/bundles/specmate-integration-test/resources/test_rules.objectif +++ b/bundles/specmate-integration-test/resources/test_rules.objectif @@ -1,4 +1,4 @@ -WENN A=5 UND B=3 DANN C=7 ENDE-WENN +WENN A=5 UND X=9 DANN C=7 ENDE-WENN WENN X = Z ODER Y>4 DANN F="Test" ENDE-WENN WENN A=1 DANN WENN B=1 DANN C=1 ENDE-WENN ENDE-WENN WENN A=1 DANN B=1 SONST C=2 ENDE-WENN \ No newline at end of file diff --git a/bundles/specmate-model-generation/bnd.bnd b/bundles/specmate-model-generation/bnd.bnd index a0cbc4d0d..ef8764fd7 100644 --- a/bundles/specmate-model-generation/bnd.bnd +++ b/bundles/specmate-model-generation/bnd.bnd @@ -19,7 +19,8 @@ org.apache.commons.lang3,\ specmate-cause-effect-patterns,\ specmate-config-api;version=latest,\ - specmate-xtext;version=latest + specmate-xtext;version=latest,\ + specmate-objectif Private-Package: \ com.specmate.modelgeneration,\ com.specmate.modelgeneration.legacy \ No newline at end of file diff --git a/bundles/specmate-model-generation/generated/buildfiles b/bundles/specmate-model-generation/generated/buildfiles index 47666f55f..d354c9596 100644 --- a/bundles/specmate-model-generation/generated/buildfiles +++ b/bundles/specmate-model-generation/generated/buildfiles @@ -1 +1 @@ -/Users/Dominik/Documents/Arbeit/Qualicen/Specmate/bundles/specmate-model-generation/generated/specmate-model-generation.jar +A:/specmate/bundles/specmate-model-generation/generated/specmate-model-generation.jar diff --git a/bundles/specmate-model-generation/resources/test_rules.objectif b/bundles/specmate-model-generation/resources/test_rules.objectif new file mode 100644 index 000000000..c184eb802 --- /dev/null +++ b/bundles/specmate-model-generation/resources/test_rules.objectif @@ -0,0 +1 @@ +WENN Die Sonne scheint ODER es nicht regnet DANN gehe an den See UND spiele Ball ENDE-WENN \ No newline at end of file diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java new file mode 100644 index 000000000..fe0e06378 --- /dev/null +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java @@ -0,0 +1,284 @@ +package com.specmate.modelgeneration; + +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.util.URI; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +import com.specmate.common.exception.SpecmateException; +import com.specmate.common.exception.SpecmateInternalException; +import com.specmate.model.administration.ErrorCode; +import com.specmate.model.requirements.CEGModel; +import com.specmate.model.requirements.CEGNode; +import com.specmate.model.requirements.NodeType; +import com.specmate.model.requirements.RequirementsFactory; +import com.specmate.model.support.util.SpecmateEcoreUtil; +import com.specmate.objectif.resolve.BusinessRuleUtil; +import com.specmate.objectif.resolve.rule.AndNode; +import com.specmate.objectif.resolve.rule.BusinessRuleNode; +import com.specmate.objectif.resolve.rule.LiteralNode; +import com.specmate.objectif.resolve.rule.ObjectifNode; +import com.specmate.objectif.resolve.rule.OrNode; +import com.specmate.xtext.XTextException; + +public class GenerateModelFromPseudoCode implements ICEGFromRequirementGenerator { + + CEGCreation creation = new CEGCreation(); + + @Override + public CEGModel createModel(CEGModel model, String text) throws SpecmateException { + return translateObjectIf(model); + } + + public CEGModel translateObjectIf(CEGModel model) throws SpecmateException { + List rules; + try { + rules = loadRules("/resources/test_rules.objectif"); + } catch (URISyntaxException | XTextException e) { + throw new SpecmateInternalException(ErrorCode.INTERNAL_PROBLEM, "..."); + } + + // Iterate through each rule and create corresponding CEG Graph + int brnum = 1; + for (BusinessRuleNode rule : rules) { + // create node for each rule and nested rules + String id = "BR" + (brnum++); + + // Eigneltich ist ein BR node immer ein Oder node. es gibt nur eine ausnahme. es + // gibt nur und causes und kein oder cause + CEGNode cegNodeBR = creation.createNode(model, id, "is present", 0, 0, NodeType.OR); + + // check for nesting + // WurzelEffect (enthält alle effekte einer rule oder die entsprechenden + // verschachtelten rules) + ObjectifNode rootEffect = rule.getEffect(); + if (rootEffect instanceof BusinessRuleNode) { + // nested + + } else { + // not nested + + // Ursachenseite + // WurzelCause (enthält alle Causes einer rule) + ObjectifNode rootCause = rule.getCause(); + + // 1. Variante = Business Rule enthält nur einen Cause --> dann literal node + if (rootCause instanceof LiteralNode) { + // erstelle einen node mit dem inhalt von root Cause und verbinde den node + // mittels identitiy mit dem node der BR + // Dann verlasse die Ursachen seite. +// CEGNode cegNode = RequirementsFactory.eINSTANCE.createCEGNode(); +// cegNode.setId(SpecmateEcoreUtil.getIdForChild(model, cegNode.eClass())); +// cegNode.setName(rootCause.toString()); +// cegNode.setVariable(((LiteralNode) rootCause).getContent()); +// cegNode.setCondition("is present"); +// model.getContents().add(cegNode); + + CEGNode cegNode = creation.createNode(model, ((LiteralNode) rootCause).getContent(), "is present", + 0, 0, null); + + creation.createConnection(model, cegNode, cegNodeBR, false); + break; + } + + // 2. Variante = Besteht nur aus "und" verknüpfern + // dazu müssen wir durch den baum iterieren + List> andCausesGroups = new ArrayList>(); + List effects = new ArrayList(); + List singleOrCauses = new ArrayList(); + + causes(rootCause, singleOrCauses, andCausesGroups); + + effects(rootEffect, effects); + + for (List andCauses : andCausesGroups) { + + CEGNode intermediateNode = null; + + if (andCausesGroups.size() >= 1) { +// intermediateNode = RequirementsFactory.eINSTANCE.createCEGNode(); +// intermediateNode.setId(SpecmateEcoreUtil.getIdForChild(model, intermediateNode.eClass())); +// intermediateNode.setName("Intermediate Node"); +// intermediateNode.setVariable("Intermediate Node"); +// intermediateNode.setCondition("is present"); +// model.getContents().add(intermediateNode); + + intermediateNode = creation.createNode(model, "Intermediate Node", "is present", 0, 0, null); + + creation.createConnection(model, intermediateNode, cegNodeBR, false); + } + + for (ObjectifNode cause : andCauses) { + // jetzt werden alle UndCauses mit der jweiligen Business Rule verbunden mittels + // Konjunktion +// CEGNode cegNode = RequirementsFactory.eINSTANCE.createCEGNode(); +// cegNode.setId(SpecmateEcoreUtil.getIdForChild(model, cegNode.eClass())); +// cegNode.setName(cause.toString()); +// cegNode.setVariable(((LiteralNode) cause).getContent()); +// cegNode.setCondition("is present"); +// model.getContents().add(cegNode); + + CEGNode cegNode = creation.createNode(model, ((LiteralNode) cause).getContent(), "is present", + 0, 0, null); + + // zwei Fälle: + // a) es gibt nur ein Päckchen an Unds und die liste an veroderten Causes ist + // leer --> kein zwischenknoten pro päckchen; alle knoten direkt mit der BR + // verbinden + + if (andCausesGroups.size() == 1 && singleOrCauses.size() == 0) { + creation.createConnection(model, cegNode, cegNodeBR, false); + cegNodeBR.setType(NodeType.AND); + } else if (andCausesGroups.size() >= 1) { + creation.createConnection(model, cegNode, intermediateNode, false); + } + } + } + // Jetzt laufen wir noch durch alle single causes durch und verbinden dieser per + // Oder mit der BR node + for (ObjectifNode cause : singleOrCauses) { + // CEGNode cegNode = RequirementsFactory.eINSTANCE.createCEGNode(); + // cegNode.setId(SpecmateEcoreUtil.getIdForChild(model, cegNode.eClass())); + // cegNode.setName(cause.toString()); + // cegNode.setVariable(((LiteralNode) cause).getContent()); + // cegNode.setCondition("is present"); + // model.getContents().add(cegNode); + + CEGNode cegNode = creation.createNode(model, ((LiteralNode) cause).getContent(), "is present", 0, 0, + null); + creation.createConnection(model, cegNode, cegNodeBR, false); + } + + // Durch alle effekte laufen und die BR damit verbunden. + for (ObjectifNode effect : effects) { + /* + * CEGNode cegNode = RequirementsFactory.eINSTANCE.createCEGNode(); + * cegNode.setId(SpecmateEcoreUtil.getIdForChild(model, cegNode.eClass())); + * cegNode.setName(effect.toString()); cegNode.setVariable(((LiteralNode) + * effect).getContent()); cegNode.setCondition("is present"); + * model.getContents().add(cegNode); + */ + + CEGNode cegNode = creation.createNode(model, ((LiteralNode) effect).getContent(), "is present", 0, 0, + null); + + + creation.createConnection(model, cegNodeBR, cegNode, false); + } + } + } + return model; + } + + private void effects(ObjectifNode rootEffect, List effects) { + // 1. Fall: es gibt nur einen effect + if (rootEffect instanceof LiteralNode) { + effects.add(rootEffect); + } + + // 2. Fall: die effekte sind miteinander verschachtelt + if (rootEffect instanceof AndNode) { + + if (rootEffect.getLeft() instanceof LiteralNode) { + effects.add(rootEffect.getLeft()); + } + + if (rootEffect.getRight() instanceof LiteralNode) { + effects.add(rootEffect.getRight()); + } + + if (rootEffect.getLeft() instanceof AndNode) { + // wiederholt aufrufen aber mit geupdateter root cause + connectAndCauses(rootEffect.getLeft(), effects); + } + + if (rootEffect.getRight() instanceof AndNode) { + // wiederholt aufrufen aber mit geupdateter root cause + connectAndCauses(rootEffect.getRight(), effects); + } + } + } + + private void connectAndCauses(ObjectifNode rootCause, List andCauses) { + if (rootCause instanceof AndNode) { + + if (rootCause.getLeft() instanceof LiteralNode) { + andCauses.add(rootCause.getLeft()); + } + + if (rootCause.getRight() instanceof LiteralNode) { + andCauses.add(rootCause.getRight()); + } + + if (rootCause.getLeft() instanceof AndNode) { + // wiederholt aufrufen aber mit geupdateter root cause + connectAndCauses(rootCause.getLeft(), andCauses); + } + + if (rootCause.getRight() instanceof AndNode) { + // wiederholt aufrufen aber mit geupdateter root cause + connectAndCauses(rootCause.getRight(), andCauses); + } + } + } + + private void causes(ObjectifNode rootCause, List orCauses, List> causesGroups) { + if (rootCause instanceof OrNode) { + // jetzt brauchen wir für die Und Konnektoren jeweils Zwischenknoten + // für jedes Päckchen erstellen wir eine neue Liste an Causes + + // Die beiden einfachsten Fälle: ein einzelnes Oder mit nur zwei Literalen + if (rootCause.getLeft() instanceof LiteralNode) { + orCauses.add(rootCause.getLeft()); + } + + if (rootCause.getRight() instanceof LiteralNode) { + orCauses.add(rootCause.getRight()); + } + + if (rootCause.getLeft() instanceof AndNode) { + // offensichtlich entsteht hier ein neues Und Päckchen + // Wir sollten eine entsprechende Liste erstellen und das Päckchen befüllen + List andCauses = new ArrayList(); + connectAndCauses(rootCause.getLeft(), andCauses); + causesGroups.add(andCauses); + } + + if (rootCause.getRight() instanceof AndNode) { + // offensichtlich entsteht hier ein neues Und Päckchen + // Wir sollten eine entsprechende Liste erstellen und das Päckchen befüllen + List andCauses = new ArrayList(); + connectAndCauses(rootCause.getRight(), andCauses); + causesGroups.add(andCauses); + } + + if (rootCause.getRight() instanceof OrNode) { + causes(rootCause.getRight(), orCauses, causesGroups); + } + + if (rootCause.getLeft() instanceof OrNode) { + causes(rootCause.getLeft(), orCauses, causesGroups); + } + + } else if (rootCause instanceof AndNode) { + List andCauses = new ArrayList(); + connectAndCauses(rootCause, andCauses); + causesGroups.add(andCauses); + + } + } + + private List loadRules(String mainFile) throws URISyntaxException, XTextException { + URI main = getLocalFile(mainFile); + return new BusinessRuleUtil().loadXTextResources(main); + } + + private URI getLocalFile(String fileName) throws URISyntaxException { + Bundle bundle = FrameworkUtil.getBundle(GenerateModelFromRequirementService.class); + return URI.createURI(bundle.getResource(fileName).toURI().toString()); + } + +} diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java index ec88db256..7ec9ddc54 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java @@ -76,7 +76,9 @@ private CEGModel generateModelFromDescription(CEGModel model) throws SpecmateExc ELanguage lang = NLPUtil.detectLanguage(text); ICEGFromRequirementGenerator generator; - generator = new PatternbasedCEGGenerator(lang, tagger); + generator = new GenerateModelFromPseudoCode(); + + //generator = new PatternbasedCEGGenerator(lang, tagger); try { generator.createModel(model, text); diff --git a/bundles/specmate-model-generators-typescript/bin/.gitignore b/bundles/specmate-model-generators-typescript/bin/.gitignore deleted file mode 100644 index c2d9872a1..000000000 --- a/bundles/specmate-model-generators-typescript/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/com/ diff --git a/bundles/specmate-model-generators-typescript/bin/com/specmate/model/generators/typescript/generateAngular.mtl b/bundles/specmate-model-generators-typescript/bin/com/specmate/model/generators/typescript/generateAngular.mtl new file mode 100644 index 000000000..7a6cbc508 --- /dev/null +++ b/bundles/specmate-model-generators-typescript/bin/com/specmate/model/generators/typescript/generateAngular.mtl @@ -0,0 +1,144 @@ +[comment encoding = UTF-8 /] +[module generateAngular('http://www.eclipse.org/emf/2002/Ecore')] + +[template public generateElement(aClass : EClass)] +[comment @main/] + +[file (aClass.name.concat('.ts'), false)] + import './support/gentypes'; + import { Proxy } from './support/proxy'; + + [comment imports for referenced classes /] + [if ((aClass.ePackage.name='history') or (aClass.ePackage.name='batch'))] + [for (r: EString | aClass.eAllReferences.eType.name->asSet())] + import { [r /] } from './[r/]'; + [/for] + [/if] + + [if (aClass.interface)] + export interface [aClass.name.toUpperFirst()/] { + [else] + export class [aClass.name.toUpperFirst()/] { + [/if] + + ___nsuri: string[if not (aClass.interface)] = "[aClass.ePackage.nsURI /]"[/if]; + [if not (aClass.interface)]public[/if] url: string; + [if not (aClass.interface)]public[/if] className: string[if not (aClass.interface)] = "[aClass.name.toUpperFirst()/]"[/if]; + [if not (aClass.interface)]public static className: string = "[aClass.name.toUpperFirst()/]";[/if] + + // Attributes + [for (a: EAttribute | aClass.eAllAttributes)] + [if not (aClass.interface)]public[/if] [a.name/]: [a.eType.name/][if (a.many)]['['/][']'/][/if]; + [/for] + + // References + [for (r: EReference | aClass.eAllReferences)] + [if not (r.containment)][if (not (aClass.interface))]public[/if] [r.name/]: Proxy[if (r.many)]['['/][']'/][/if];[/if] + [/for] + + // Containment + [comment Containment for history package /] + [if ((aClass.ePackage.name='history') or (aClass.ePackage.name='batch'))] + [for (r: EReference | aClass.eAllReferences)] + [if (r.containment)][if (not (aClass.interface))]public[/if] [r.name/]: [r.eType.name/][if (r.many)]['['/][']'/][/if];[/if] + [/for] + [/if] + + [comment Fetch icon string from model annotation /] + [if (aClass.eAnnotations.details->exists(entry|entry.key='icon'))] + // Icon + public iconClass:string = "[aClass.getEAnnotation('http://specmate.com/gen').details + ->select(entry|entry.key='icon')->first().value/]"; + [/if] + + } + + [/file] +[/template] + +[template public generateEnum(aEnum: EEnum)] +[comment @main/] +[file (aEnum.name.concat('.ts'), false)] +export enum [aEnum.name/] { + [for (el: EEnumLiteral | aEnum.eLiterals) separator(',\n')][el.literal.toUpperCase()/] = [el.value/][/for] +} +[/file] +[/template] + +[template public generateMeta(aPackage: EPackage)] +[comment @main/] +[if (aPackage.name.equalsIgnoreCase('model'))] + [file ('meta/field-meta.ts', false)] + +export class FieldMetaItem { + public name: string; + public shortDesc: string; + public longDesc: string; + public type: string; + public required?: boolean; + public values?: string; + public rows?: string; + public position?: string; + public allowedPattern?: string; +} + +export class MetaInfo { + [for (aClass: EClass | aPackage.eSubpackages.eClassifiers->filter(EClass))] + public static [aClass.name/]: FieldMetaItem['['/][']'/] = ['['/] + [for (attribute: EAttribute | + aClass.eAllAttributes->select(attr: EAttribute | not attr.eAnnotations.getEAnnotation('http://specmate.com/form_meta')->isEmpty() and + aClass.eAnnotations.details->select(detail: EStringToStringMapEntry | detail.key.startsWith('disabled') and detail.value.equalsIgnoreCase(attr.name))->isEmpty()) + ) separator(',')] + { + name: "[attribute.name/]", + [for (detail: EStringToStringMapEntry | attribute.eAnnotations.details) separator(',\n')] + [detail.key/]: [if (not (detail.value.equalsIgnoreCase('true') or detail.value.equalsIgnoreCase('false')))]'[/if][detail.value.replaceAll('\'', '\\\\' + '\'')/][if (not (detail.value.equalsIgnoreCase('true') or detail.value.equalsIgnoreCase('false')))]'[/if][/for] + + }[/for] + [']'/]; + [/for] +} + + [/file] +[/if] +[/template] + +[template public generateGentypes(aPackage: EPackage)] +[comment @main/] + + [if (aPackage.eContainer() = null)] + [file ('support/gentypes.ts', false)] +type EInt = number; +type EDouble = number; +type EString = string; +type EBoolean = boolean; +type NodeType = string; +type OperationType = string; +type EDate = Date; +type ParameterType = string; +type AccessRights = string; +type ErrorCode = string; +type ELong = number; + [/file] + + [file ('support/proxy.ts',false)] + export class Proxy { + public ___proxy = true; + public url:string; + } + [/file] + [/if] + +[/template] + + +[query public default(type: String) : String = + if type='EString' then '""' + else if type='EInt' then 'Number(0)' + else if type='EBoolean' then 'false' + else 'undefined' + endif + endif + endif +/] + diff --git a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/ObjectifNode.java b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/ObjectifNode.java index dbe8ae26a..75ebe3004 100644 --- a/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/ObjectifNode.java +++ b/bundles/specmate-objectif/src/com/specmate/objectif/resolve/rule/ObjectifNode.java @@ -2,4 +2,11 @@ public abstract class ObjectifNode { abstract void generateCEG(); + public ObjectifNode getLeft() { + return null; + } + + public ObjectifNode getRight() { + return null; + } } diff --git a/bundles/specmate-std-env/dev-specmate-all.bndrun b/bundles/specmate-std-env/dev-specmate-all.bndrun index 70e29885f..6b525bf03 100644 --- a/bundles/specmate-std-env/dev-specmate-all.bndrun +++ b/bundles/specmate-std-env/dev-specmate-all.bndrun @@ -220,7 +220,9 @@ org.eclipse.xtext.smap;version='[2.10.0,2.10.1)',\ org.eclipse.xtext.util;version='[2.10.0,2.10.1)',\ org.eclipse.xtext.xbase.lib;version='[2.10.0,2.10.1)',\ - specmate-cause-effect-patterns;version=snapshot + specmate-cause-effect-patterns;version=snapshot,\ + specmate-objectif;version=snapshot,\ + specmate-xtext;version=snapshot -runproperties: \ jetty.http.port=8080,\ From 79c1e07e12ab02d14f20eea6f4d9d19f16fe3086 Mon Sep 17 00:00:00 2001 From: Jannik Fischbach Date: Tue, 9 Jul 2019 09:11:43 +0200 Subject: [PATCH 05/10] add "nested" pseudo code translation --- .../resources/test_rules.objectif | 2 +- .../GenerateModelFromPseudoCode.java | 340 +++++++++++------- .../GenerateModelFromRequirementService.java | 2 +- 3 files changed, 217 insertions(+), 127 deletions(-) diff --git a/bundles/specmate-model-generation/resources/test_rules.objectif b/bundles/specmate-model-generation/resources/test_rules.objectif index c184eb802..27c6b2f98 100644 --- a/bundles/specmate-model-generation/resources/test_rules.objectif +++ b/bundles/specmate-model-generation/resources/test_rules.objectif @@ -1 +1 @@ -WENN Die Sonne scheint ODER es nicht regnet DANN gehe an den See UND spiele Ball ENDE-WENN \ No newline at end of file +WENN die sonne scheint UND meine freunde Zeit haben ODER ich bock hab DANN WENN der see frei ist DANN WENN csxc ODER 34234 DANN fahre ich an den See ENDE-WENN ENDE-WENN ENDE-WENN \ No newline at end of file diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java index fe0e06378..1350c492b 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java @@ -14,8 +14,6 @@ import com.specmate.model.requirements.CEGModel; import com.specmate.model.requirements.CEGNode; import com.specmate.model.requirements.NodeType; -import com.specmate.model.requirements.RequirementsFactory; -import com.specmate.model.support.util.SpecmateEcoreUtil; import com.specmate.objectif.resolve.BusinessRuleUtil; import com.specmate.objectif.resolve.rule.AndNode; import com.specmate.objectif.resolve.rule.BusinessRuleNode; @@ -24,162 +22,240 @@ import com.specmate.objectif.resolve.rule.OrNode; import com.specmate.xtext.XTextException; +// This class transforms pseudo code into a CEG. +// The pseudo code must conform with the implemented XText grammar. public class GenerateModelFromPseudoCode implements ICEGFromRequirementGenerator { + // Our factory to create the elements of the CEG (nodes and connections). CEGCreation creation = new CEGCreation(); + // Counter for numbering of intermediate nodes as well as business rule nodes. + int intermediatenum = 1; + int brnum = 1; + @Override public CEGModel createModel(CEGModel model, String text) throws SpecmateException { return translateObjectIf(model); } + // public CEGModel translateObjectIf(CEGModel model) throws SpecmateException { List rules; + // First, we need to load all pseudo code lines from a document / input. try { rules = loadRules("/resources/test_rules.objectif"); } catch (URISyntaxException | XTextException e) { throw new SpecmateInternalException(ErrorCode.INTERNAL_PROBLEM, "..."); } - // Iterate through each rule and create corresponding CEG Graph - int brnum = 1; - for (BusinessRuleNode rule : rules) { - // create node for each rule and nested rules - String id = "BR" + (brnum++); - - // Eigneltich ist ein BR node immer ein Oder node. es gibt nur eine ausnahme. es - // gibt nur und causes und kein oder cause - CEGNode cegNodeBR = creation.createNode(model, id, "is present", 0, 0, NodeType.OR); + BusinessRuleNode rule = rules.get(0); + return createCEGModelForEachSection(rule, model, null, false); + } - // check for nesting - // WurzelEffect (enthält alle effekte einer rule oder die entsprechenden - // verschachtelten rules) - ObjectifNode rootEffect = rule.getEffect(); - if (rootEffect instanceof BusinessRuleNode) { - // nested + // This method creates a CEG model for each "WENN" --> "DANN" --> "ENDE-WENN" + // clause. + private CEGModel createCEGModelForEachSection(BusinessRuleNode rule, CEGModel model, CEGNode brNode, + boolean nesting) { + + // The type of a BR node should be always "OR". Exception: The model consists + // only of conjunctive causes. + CEGNode cegNodeBR; + + // If the brNode is null, we start with a new model. + if (brNode == null) { + cegNodeBR = creation.createNode(model, "BR" + (brnum++), "is present", 0, 0, NodeType.OR); + } else { + // Otherwise, we are within a recursive loop (i.e. the clause is nested) and the + // brNode is our superior + // business rule. + cegNodeBR = brNode; + } + // Check for nesting: + // The rootEffect contains all effects of a rule. If the rootEffect is a + // "BusinessRuleNode", the rule is nested and consists of multiple rules. + // Here we check if we need to do a recursion again or if we reached the + // business rule at the lowest depth (i.e. the business rule which does not + // contains another one). + ObjectifNode rootEffect = rule.getEffect(); + if (rootEffect instanceof BusinessRuleNode) { + // Case: nested + // Basic idea: Split the whole tree in subtrees (i.e. split the tree into + // individual business rules) and connect first the causes to these business + // rules and then simply connect superior rules to inferior rules. + CEGNode cegNodeBRNested = creation.createNode(model, "BR" + (brnum++), "is present", 0, 0, NodeType.AND); + List> andCausesGroups = new ArrayList>(); + List singleOrCauses = new ArrayList(); + + ObjectifNode rootCause = rule.getCause(); + identifyCauses(rootCause, singleOrCauses, andCausesGroups); + + if (nesting == false) { + connectCausesToBR(cegNodeBR, singleOrCauses, andCausesGroups, model); } else { - // not nested - - // Ursachenseite - // WurzelCause (enthält alle Causes einer rule) - ObjectifNode rootCause = rule.getCause(); - - // 1. Variante = Business Rule enthält nur einen Cause --> dann literal node - if (rootCause instanceof LiteralNode) { - // erstelle einen node mit dem inhalt von root Cause und verbinde den node - // mittels identitiy mit dem node der BR - // Dann verlasse die Ursachen seite. -// CEGNode cegNode = RequirementsFactory.eINSTANCE.createCEGNode(); -// cegNode.setId(SpecmateEcoreUtil.getIdForChild(model, cegNode.eClass())); -// cegNode.setName(rootCause.toString()); -// cegNode.setVariable(((LiteralNode) rootCause).getContent()); -// cegNode.setCondition("is present"); -// model.getContents().add(cegNode); - - CEGNode cegNode = creation.createNode(model, ((LiteralNode) rootCause).getContent(), "is present", - 0, 0, null); + connectCausesToNestedBR(cegNodeBR, singleOrCauses, andCausesGroups, model); + } - creation.createConnection(model, cegNode, cegNodeBR, false); - break; + // We do not need to identify the effects of the business rule since we know + // that the rule contains another one and is therefore a condition for the + // nested rule. We simply connect the rule with the inferior rule. + creation.createConnection(model, cegNodeBR, cegNodeBRNested, false); + + // Start with the recursion. We update the root and do the whole procedure for + // the inferior rule again. Until we reach a rule which is not nested anymore. + createCEGModelForEachSection((BusinessRuleNode) rootEffect, model, cegNodeBRNested, true); + + } else { + // Case: not nested + // RootCause contains all causes of a rule. + ObjectifNode rootCause = rule.getCause(); + List effects = new ArrayList(); + + // 1. Case = The rule contains only one cause. This is the case if the rootCause + // is a "LiteralNode". + if (rootCause instanceof LiteralNode) { + // Create a node with the content of the rootCause and connect the node with the + // rule node by means of identity connection. + CEGNode cegNode = creation.createNode(model, ((LiteralNode) rootCause).getContent(), "is present", 0, 0, + null); + + creation.createConnection(model, cegNode, cegNodeBR, false); + // Search for effects of the rule. + identifyEffects(rootEffect, effects); + + // Connect the rule node with all identified effects. + for (ObjectifNode effect : effects) { + CEGNode cegNodeEffect = creation.createNode(model, ((LiteralNode) effect).getContent(), + "is present", 0, 0, null); + creation.createConnection(model, cegNodeBR, cegNodeEffect, false); } + } else { - // 2. Variante = Besteht nur aus "und" verknüpfern - // dazu müssen wir durch den baum iterieren + // 2. Case = The rule contains multiple causes which are interconnected + // (conjunctions or disjunctions). List> andCausesGroups = new ArrayList>(); - List effects = new ArrayList(); List singleOrCauses = new ArrayList(); - causes(rootCause, singleOrCauses, andCausesGroups); + identifyCauses(rootCause, singleOrCauses, andCausesGroups); + identifyEffects(rootEffect, effects); - effects(rootEffect, effects); - - for (List andCauses : andCausesGroups) { + if (nesting == false) { + connectCausesToBR(cegNodeBR, singleOrCauses, andCausesGroups, model); + } else { + connectCausesToNestedBR(cegNodeBR, singleOrCauses, andCausesGroups, model); + } + connectBRToEffects(cegNodeBR, effects, model); + } + } + return model; + } - CEGNode intermediateNode = null; + private void connectBRToEffects(CEGNode cegNodeBR, List effects, CEGModel model) { + // Iterate over all effects and connect the business rule node with these + // effects. + for (ObjectifNode effect : effects) { + CEGNode cegNode = creation.createNode(model, ((LiteralNode) effect).getContent(), "is present", 0, 0, null); + creation.createConnection(model, cegNodeBR, cegNode, false); + } + } - if (andCausesGroups.size() >= 1) { -// intermediateNode = RequirementsFactory.eINSTANCE.createCEGNode(); -// intermediateNode.setId(SpecmateEcoreUtil.getIdForChild(model, intermediateNode.eClass())); -// intermediateNode.setName("Intermediate Node"); -// intermediateNode.setVariable("Intermediate Node"); -// intermediateNode.setCondition("is present"); -// model.getContents().add(intermediateNode); + // Implementation for non nested BRs + private void connectCausesToBR(CEGNode cegNodeBR, List singleOrCauses, + List> andCausesGroups, CEGModel model) { - intermediateNode = creation.createNode(model, "Intermediate Node", "is present", 0, 0, null); + for (List andCauses : andCausesGroups) { - creation.createConnection(model, intermediateNode, cegNodeBR, false); - } + CEGNode intermediateNode = null; - for (ObjectifNode cause : andCauses) { - // jetzt werden alle UndCauses mit der jweiligen Business Rule verbunden mittels - // Konjunktion -// CEGNode cegNode = RequirementsFactory.eINSTANCE.createCEGNode(); -// cegNode.setId(SpecmateEcoreUtil.getIdForChild(model, cegNode.eClass())); -// cegNode.setName(cause.toString()); -// cegNode.setVariable(((LiteralNode) cause).getContent()); -// cegNode.setCondition("is present"); -// model.getContents().add(cegNode); + if (andCausesGroups.size() > 0 && singleOrCauses.size() != 0) { + intermediateNode = creation.createNode(model, "Intermediate Node" + (intermediatenum++), "is present", + 0, 0, NodeType.AND); - CEGNode cegNode = creation.createNode(model, ((LiteralNode) cause).getContent(), "is present", - 0, 0, null); + creation.createConnection(model, intermediateNode, cegNodeBR, false); + } - // zwei Fälle: - // a) es gibt nur ein Päckchen an Unds und die liste an veroderten Causes ist - // leer --> kein zwischenknoten pro päckchen; alle knoten direkt mit der BR - // verbinden + for (ObjectifNode cause : andCauses) { + CEGNode cegNode = creation.createNode(model, ((LiteralNode) cause).getContent(), "is present", 0, 0, + null); - if (andCausesGroups.size() == 1 && singleOrCauses.size() == 0) { - creation.createConnection(model, cegNode, cegNodeBR, false); - cegNodeBR.setType(NodeType.AND); - } else if (andCausesGroups.size() >= 1) { - creation.createConnection(model, cegNode, intermediateNode, false); - } - } - } - // Jetzt laufen wir noch durch alle single causes durch und verbinden dieser per - // Oder mit der BR node - for (ObjectifNode cause : singleOrCauses) { - // CEGNode cegNode = RequirementsFactory.eINSTANCE.createCEGNode(); - // cegNode.setId(SpecmateEcoreUtil.getIdForChild(model, cegNode.eClass())); - // cegNode.setName(cause.toString()); - // cegNode.setVariable(((LiteralNode) cause).getContent()); - // cegNode.setCondition("is present"); - // model.getContents().add(cegNode); - - CEGNode cegNode = creation.createNode(model, ((LiteralNode) cause).getContent(), "is present", 0, 0, - null); + // There are two cases: + // a) there is only one set of conjunctive causes and no single / disjunctive + // causes --> just connect the causes with the rule without intermediate node. + if (andCausesGroups.size() == 1 && singleOrCauses.size() == 0) { creation.createConnection(model, cegNode, cegNodeBR, false); + cegNodeBR.setType(NodeType.AND); + } else { + // b) otherwise we need an intermediate node and connect conjunctive causes to + // these nodes. All related causes share the same intermediate node! + creation.createConnection(model, cegNode, intermediateNode, false); } + } + } + // We iterate over all single causes and connect them with the BR by means of a + // disjunction. + for (ObjectifNode cause : singleOrCauses) { + CEGNode cegNode = creation.createNode(model, ((LiteralNode) cause).getContent(), "is present", 0, 0, null); + creation.createConnection(model, cegNode, cegNodeBR, false); + } + } - // Durch alle effekte laufen und die BR damit verbunden. - for (ObjectifNode effect : effects) { - /* - * CEGNode cegNode = RequirementsFactory.eINSTANCE.createCEGNode(); - * cegNode.setId(SpecmateEcoreUtil.getIdForChild(model, cegNode.eClass())); - * cegNode.setName(effect.toString()); cegNode.setVariable(((LiteralNode) - * effect).getContent()); cegNode.setCondition("is present"); - * model.getContents().add(cegNode); - */ - - CEGNode cegNode = creation.createNode(model, ((LiteralNode) effect).getContent(), "is present", 0, 0, - null); - - - creation.createConnection(model, cegNodeBR, cegNode, false); + // Implementation for nested BRs: + // It is important to differentiate between non nested and nested BR since + // nested BRs have always the NodeType "AND" (because superior BRs are always a + // condition for the nested ones). As a result, here we need intermediate nodes + // for the disjunctive causes and no intermediate nodes for the conjunction + // since they can be directly connected to the BR. + private void connectCausesToNestedBR(CEGNode cegNodeBR, List singleOrCauses, + List> andCausesGroups, CEGModel model) { + + CEGNode intermediateNodeNested = null; + + if (singleOrCauses.size() > 1) { + System.out.println("hallo" + brnum); + intermediateNodeNested = creation.createNode(model, "Intermediate Node" + (intermediatenum++), "is present", + 0, 0, NodeType.OR); + creation.createConnection(model, intermediateNodeNested, cegNodeBR, false); + } + + for (List andCauses : andCausesGroups) { + + CEGNode intermediateNode = null; + + if (andCausesGroups.size() > 0 && singleOrCauses.size() != 0) { + intermediateNode = creation.createNode(model, "Intermediate Node" + (intermediatenum++), "is present", + 0, 0, NodeType.AND); + creation.createConnection(model, intermediateNode, intermediateNodeNested, false); + } + + for (ObjectifNode cause : andCauses) { + CEGNode cegNode = creation.createNode(model, ((LiteralNode) cause).getContent(), "is present", 0, 0, + null); + + if (singleOrCauses.size() == 1 || andCausesGroups.size() == 1 && singleOrCauses.size() == 0) { + creation.createConnection(model, cegNode, cegNodeBR, false); + } else { + creation.createConnection(model, cegNode, intermediateNode, false); } } } - return model; + + for (ObjectifNode cause : singleOrCauses) { + CEGNode cegNode = creation.createNode(model, ((LiteralNode) cause).getContent(), "is present", 0, 0, null); + if (singleOrCauses.size() == 1) { + creation.createConnection(model, cegNode, cegNodeBR, false); + } else { + creation.createConnection(model, cegNode, intermediateNodeNested, false); + } + } } - private void effects(ObjectifNode rootEffect, List effects) { - // 1. Fall: es gibt nur einen effect + private void identifyEffects(ObjectifNode rootEffect, List effects) { + // 1. Case: There is only a single effect if (rootEffect instanceof LiteralNode) { effects.add(rootEffect); } - // 2. Fall: die effekte sind miteinander verschachtelt + // 2. Case: The effects are interconnected. if (rootEffect instanceof AndNode) { if (rootEffect.getLeft() instanceof LiteralNode) { @@ -202,75 +278,90 @@ private void effects(ObjectifNode rootEffect, List effects) { } } + // Here we connect causes which are interconnected using conjunctions. + // Related causes are saved within individual lists. private void connectAndCauses(ObjectifNode rootCause, List andCauses) { if (rootCause instanceof AndNode) { if (rootCause.getLeft() instanceof LiteralNode) { + // add cause to the list. andCauses.add(rootCause.getLeft()); } if (rootCause.getRight() instanceof LiteralNode) { + // add cause to the list. andCauses.add(rootCause.getRight()); } if (rootCause.getLeft() instanceof AndNode) { - // wiederholt aufrufen aber mit geupdateter root cause + // recursive call of the method but with updated rootcause. + // Here we do not (!) create a new list because this is connection of multiple + // conjunctions. So we build a large list of multiple interconnected causes. connectAndCauses(rootCause.getLeft(), andCauses); } if (rootCause.getRight() instanceof AndNode) { - // wiederholt aufrufen aber mit geupdateter root cause + // recursive call of the method but with updated rootcause. + // See explanation above. connectAndCauses(rootCause.getRight(), andCauses); } } } - private void causes(ObjectifNode rootCause, List orCauses, List> causesGroups) { + // Here we separate between isolated causes (disjunctive causes) and related + // causes (conjunctive causes). + private void identifyCauses(ObjectifNode rootCause, List orCauses, + List> causesGroups) { if (rootCause instanceof OrNode) { - // jetzt brauchen wir für die Und Konnektoren jeweils Zwischenknoten - // für jedes Päckchen erstellen wir eine neue Liste an Causes - - // Die beiden einfachsten Fälle: ein einzelnes Oder mit nur zwei Literalen + // 1. Case: A single "or" connection if (rootCause.getLeft() instanceof LiteralNode) { orCauses.add(rootCause.getLeft()); } + // belongs to case 1 if (rootCause.getRight() instanceof LiteralNode) { orCauses.add(rootCause.getRight()); } if (rootCause.getLeft() instanceof AndNode) { - // offensichtlich entsteht hier ein neues Und Päckchen - // Wir sollten eine entsprechende Liste erstellen und das Päckchen befüllen + // Here we identify a conjunction. We create a list of Objectif nodes for each + // identified conjunction. List andCauses = new ArrayList(); connectAndCauses(rootCause.getLeft(), andCauses); causesGroups.add(andCauses); } if (rootCause.getRight() instanceof AndNode) { - // offensichtlich entsteht hier ein neues Und Päckchen - // Wir sollten eine entsprechende Liste erstellen und das Päckchen befüllen + // Here we identify also a conjunction. Same procedure as described above. List andCauses = new ArrayList(); connectAndCauses(rootCause.getRight(), andCauses); causesGroups.add(andCauses); } if (rootCause.getRight() instanceof OrNode) { - causes(rootCause.getRight(), orCauses, causesGroups); + // recursive call of the method with updated rootCause + identifyCauses(rootCause.getRight(), orCauses, causesGroups); } if (rootCause.getLeft() instanceof OrNode) { - causes(rootCause.getLeft(), orCauses, causesGroups); + // same here + identifyCauses(rootCause.getLeft(), orCauses, causesGroups); } } else if (rootCause instanceof AndNode) { + // Exceptional case if rootCause is a "AndNode". + // Here we also need to create a new list of conjunctive nodes. List andCauses = new ArrayList(); connectAndCauses(rootCause, andCauses); causesGroups.add(andCauses); + } else if (rootCause instanceof LiteralNode) { + // This is the case if the rule consists of only one cause. + orCauses.add(rootCause); } } + // Method that loads all rules from a local file. private List loadRules(String mainFile) throws URISyntaxException, XTextException { URI main = getLocalFile(mainFile); return new BusinessRuleUtil().loadXTextResources(main); @@ -280,5 +371,4 @@ private URI getLocalFile(String fileName) throws URISyntaxException { Bundle bundle = FrameworkUtil.getBundle(GenerateModelFromRequirementService.class); return URI.createURI(bundle.getResource(fileName).toURI().toString()); } - } diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java index 7ec9ddc54..038d78c63 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java @@ -72,7 +72,7 @@ private CEGModel generateModelFromDescription(CEGModel model) throws SpecmateExc if (text == null || StringUtils.isEmpty(text)) { return model; } - text = new PersonalPronounsReplacer(tagger).replacePronouns(text); + //text = new PersonalPronounsReplacer(tagger).replacePronouns(text); ELanguage lang = NLPUtil.detectLanguage(text); ICEGFromRequirementGenerator generator; From d689167f127934b75422e17b24f72116bd744aef Mon Sep 17 00:00:00 2001 From: Jannik Fischbach Date: Tue, 9 Jul 2019 10:01:48 +0200 Subject: [PATCH 06/10] add explanations --- .../specmate/modelgeneration/GenerateModelFromPseudoCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java index 1350c492b..0337d9bb9 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java @@ -90,9 +90,11 @@ private CEGModel createCEGModelForEachSection(BusinessRuleNode rule, CEGModel mo ObjectifNode rootCause = rule.getCause(); identifyCauses(rootCause, singleOrCauses, andCausesGroups); + // superior rule if (nesting == false) { connectCausesToBR(cegNodeBR, singleOrCauses, andCausesGroups, model); } else { + // inferior rule connectCausesToNestedBR(cegNodeBR, singleOrCauses, andCausesGroups, model); } @@ -211,7 +213,6 @@ private void connectCausesToNestedBR(CEGNode cegNodeBR, List singl CEGNode intermediateNodeNested = null; if (singleOrCauses.size() > 1) { - System.out.println("hallo" + brnum); intermediateNodeNested = creation.createNode(model, "Intermediate Node" + (intermediatenum++), "is present", 0, 0, NodeType.OR); creation.createConnection(model, intermediateNodeNested, cegNodeBR, false); From 48e7e4ed6bcb1e815b9afc8c9abca85abd0140f2 Mon Sep 17 00:00:00 2001 From: Jannik Fischbach Date: Tue, 9 Jul 2019 13:57:11 +0200 Subject: [PATCH 07/10] integrate translation algorithm with GUI (input of pseudo code within the model description) --- .../modelgeneration/GenerateModelFromPseudoCode.java | 9 ++------- .../GenerateModelFromRequirementService.java | 10 ++++++---- .../src/com/specmate/nlp/api/ELanguage.java | 2 +- .../src/com/specmate/nlp/util/NLPUtil.java | 5 ++++- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java index 0337d9bb9..0bd7affd8 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java @@ -35,16 +35,11 @@ public class GenerateModelFromPseudoCode implements ICEGFromRequirementGenerator @Override public CEGModel createModel(CEGModel model, String text) throws SpecmateException { - return translateObjectIf(model); - } - - // - public CEGModel translateObjectIf(CEGModel model) throws SpecmateException { List rules; // First, we need to load all pseudo code lines from a document / input. try { - rules = loadRules("/resources/test_rules.objectif"); - } catch (URISyntaxException | XTextException e) { + rules = new BusinessRuleUtil().parseXTextResource(text); + } catch (XTextException e) { throw new SpecmateInternalException(ErrorCode.INTERNAL_PROBLEM, "..."); } diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java index 038d78c63..be7fa5e51 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java @@ -72,13 +72,15 @@ private CEGModel generateModelFromDescription(CEGModel model) throws SpecmateExc if (text == null || StringUtils.isEmpty(text)) { return model; } - //text = new PersonalPronounsReplacer(tagger).replacePronouns(text); + text = new PersonalPronounsReplacer(tagger).replacePronouns(text); ELanguage lang = NLPUtil.detectLanguage(text); ICEGFromRequirementGenerator generator; - generator = new GenerateModelFromPseudoCode(); - - //generator = new PatternbasedCEGGenerator(lang, tagger); + if(lang == ELanguage.PSEUDO) { + generator = new GenerateModelFromPseudoCode(); + } else { + generator = new PatternbasedCEGGenerator(lang, tagger); + } try { generator.createModel(model, text); diff --git a/bundles/specmate-nlp/src/com/specmate/nlp/api/ELanguage.java b/bundles/specmate-nlp/src/com/specmate/nlp/api/ELanguage.java index 54ee5761c..35f5be429 100644 --- a/bundles/specmate-nlp/src/com/specmate/nlp/api/ELanguage.java +++ b/bundles/specmate-nlp/src/com/specmate/nlp/api/ELanguage.java @@ -1,7 +1,7 @@ package com.specmate.nlp.api; public enum ELanguage { - DE("de", "SUBJ"), EN("en", "subj"); + DE("de", "SUBJ"), EN("en", "subj"), PSEUDO("pseudo", "subj"); private String language; private String subjectDependencyType; diff --git a/bundles/specmate-nlp/src/com/specmate/nlp/util/NLPUtil.java b/bundles/specmate-nlp/src/com/specmate/nlp/util/NLPUtil.java index 6e97be35c..91eb2924e 100644 --- a/bundles/specmate-nlp/src/com/specmate/nlp/util/NLPUtil.java +++ b/bundles/specmate-nlp/src/com/specmate/nlp/util/NLPUtil.java @@ -242,9 +242,12 @@ public static List findDependencies(Collection dependenc private static String DE_Pattern = "\\b(der|die|das|ein|eine|einen)\\b"; public static ELanguage detectLanguage(String text) { + if (text.matches(".*WENN.*ENDE-WENN.*")) { + return ELanguage.PSEUDO; + } if (text.matches("(?i)(.*)"+DE_Pattern+"(.*)")) { return ELanguage.DE; - } + } return ELanguage.EN; } From 7b341eb83d432031d2d070689eefa55bb5b9bf3a Mon Sep 17 00:00:00 2001 From: Jannik Fischbach Date: Wed, 10 Jul 2019 17:45:22 +0200 Subject: [PATCH 08/10] fix build error --- .../GenerateModelFromRequirementService.java | 2 +- .../specmate-std-env/dev-specmate-all.bndrun | 453 +++++++++--------- 2 files changed, 229 insertions(+), 226 deletions(-) diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java index 54e7d33cb..0b5fb75be 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromRequirementService.java @@ -93,7 +93,7 @@ private CEGModel generateModelFromDescription(CEGModel model) throws SpecmateExc if(lang == ELanguage.PSEUDO) { generator = new GenerateModelFromPseudoCode(); } else { - generator = new PatternbasedCEGGenerator(lang, tagger); + generator = new PatternbasedCEGGenerator(lang, tagger, this.configService); } diff --git a/bundles/specmate-std-env/dev-specmate-all.bndrun b/bundles/specmate-std-env/dev-specmate-all.bndrun index 52d1c490c..75688de9e 100644 --- a/bundles/specmate-std-env/dev-specmate-all.bndrun +++ b/bundles/specmate-std-env/dev-specmate-all.bndrun @@ -1,228 +1,230 @@ -runfw: org.eclipse.osgi;version='[3.13.300.v20190218-1622,3.13.300.v20190218-1622]' --runrequires: \ - osgi.identity;filter:='(osgi.identity=specmate-cdo-server)',\ - osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\ - osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\ - osgi.identity;filter:='(osgi.identity=org.glassfish.hk2.locator)',\ - osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.log)',\ - osgi.identity;filter:='(osgi.identity=jul.to.slf4j)',\ - osgi.identity;filter:='(osgi.identity=specmate-common)',\ - osgi.identity;filter:='(osgi.identity=specmate-emfjson)',\ - osgi.identity;filter:='(osgi.identity=specmate-logging)',\ - osgi.identity;filter:='(osgi.identity=specmate-logging-slf4j)',\ - osgi.identity;filter:='(osgi.identity=specmate-logging-slf4j-julbridge)',\ - osgi.identity;filter:='(osgi.identity=specmate-persistency-api)',\ - osgi.identity;filter:='(osgi.identity=org.glassfish.jersey.containers.jersey-container-servlet)',\ - osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.event)',\ - osgi.identity;filter:='(osgi.identity=specmate-emfrest)',\ - osgi.identity;filter:='(osgi.identity=specmate-model-gen)',\ - osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.cm)',\ - osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.metatype)',\ - osgi.identity;filter:='(osgi.identity=specmate-model-support)',\ - osgi.identity;filter:='(osgi.identity=specmate-ui-core)',\ - osgi.identity;filter:='(osgi.identity=specmate-dummy-data)',\ - osgi.identity;filter:='(osgi.identity=specmate-config)',\ - osgi.identity;filter:='(osgi.identity=specmate-connectors)',\ - osgi.identity;filter:='(osgi.identity=specmate-testspecification)',\ - osgi.identity;filter:='(osgi.identity=specmate-hp-connector)',\ - osgi.identity;filter:='(osgi.identity=org.apache.felix.scr)',\ - osgi.identity;filter:='(&(osgi.identity=org.apache.felix.webconsole)(version>=4.3.0))',\ - osgi.identity;filter:='(&(osgi.identity=org.eclipse.jetty.osgi.boot)(version>=9.4.6))',\ - osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.osgi.httpservice)',\ - osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.rewrite)',\ - osgi.identity;filter:='(osgi.identity=specmate-jettystarter)',\ - osgi.identity;filter:='(osgi.identity=org.eclipse.emf.cdo.server.ocl)',\ - osgi.identity;filter:='(osgi.identity=org.json)',\ - osgi.identity;filter:='(osgi.identity=specmate-file-connector)',\ - osgi.identity;filter:='(osgi.identity=specmate-search)',\ - osgi.identity;filter:='(osgi.identity=specmate-migration)',\ - osgi.identity;filter:='(osgi.identity=specmate-persistency-cdo)',\ - osgi.identity;filter:='(osgi.identity=specmate-administration)',\ - osgi.identity;filter:='(osgi.identity=org.apache.commons.fileupload)',\ - osgi.identity;filter:='(osgi.identity=specmate-trello-connector)',\ - osgi.identity;filter:='(osgi.identity=specmate-auth-api)',\ - osgi.identity;filter:='(osgi.identity=specmate-auth)',\ - osgi.identity;filter:='(osgi.identity=specmate-dbprovider-api)',\ - osgi.identity;filter:='(osgi.identity=specmate-dbprovider-h2)',\ - osgi.identity;filter:='(osgi.identity=specmate-jira-connector)',\ - osgi.identity;filter:='(osgi.identity=specmate-nlp)',\ - osgi.identity;filter:='(osgi.identity=specmate-model-generation)',\ - bnd.identity;id='log4j' --runbundles: \ - javassist;version='[3.18.1,3.18.2)',\ - javax.annotation-api;version='[1.2.0,1.2.1)',\ - javax.validation.api;version='[1.1.0,1.1.1)',\ - javax.ws.rs-api;version='[2.0.1,2.0.2)',\ - jul.to.slf4j;version='[1.7.12,1.7.13)',\ - org.apache.felix.gogo.command;version='[0.10.0,0.10.1)',\ - org.apache.felix.gogo.runtime;version='[0.10.0,0.10.1)',\ - org.apache.felix.gogo.shell;version='[0.10.0,0.10.1)',\ - org.eclipse.core.contenttype;version='[3.4.200,3.4.201)',\ - org.eclipse.core.jobs;version='[3.6.1,3.6.2)',\ - org.eclipse.core.runtime;version='[3.10.0,3.10.1)',\ - org.eclipse.emf.ecore.change;version='[2.11.0,2.11.1)',\ - org.eclipse.equinox.app;version='[1.3.200,1.3.201)',\ - org.eclipse.equinox.cm;version='[1.1.0,1.1.1)',\ - org.eclipse.equinox.common;version='[3.6.200,3.6.201)',\ - org.eclipse.equinox.event;version='[1.3.100,1.3.101)',\ - org.eclipse.equinox.log;version='[1.2.300,1.2.301)',\ - org.eclipse.equinox.metatype;version='[1.4.0,1.4.1)',\ - org.eclipse.equinox.preferences;version='[3.5.200,3.5.201)',\ - org.eclipse.equinox.registry;version='[3.5.400,3.5.401)',\ - org.eclipse.osgi.services;version='[3.4.0,3.4.1)',\ - org.glassfish.hk2.api;version='[2.4.0,2.4.1)',\ - org.glassfish.hk2.external.aopalliance-repackaged;version='[2.4.0,2.4.1)',\ - org.glassfish.hk2.external.javax.inject;version='[2.4.0,2.4.1)',\ - org.glassfish.hk2.locator;version='[2.4.0,2.4.1)',\ - org.glassfish.hk2.osgi-resource-locator;version='[1.0.1,1.0.2)',\ - org.glassfish.hk2.utils;version='[2.4.0,2.4.1)',\ - org.glassfish.jersey.bundles.repackaged.jersey-guava;version='[2.17.0,2.17.1)',\ - org.glassfish.jersey.containers.jersey-container-servlet;version='[2.17.0,2.17.1)',\ - org.glassfish.jersey.containers.jersey-container-servlet-core;version='[2.17.0,2.17.1)',\ - org.glassfish.jersey.core.jersey-client;version='[2.17.0,2.17.1)',\ - org.glassfish.jersey.core.jersey-common;version='[2.17.0,2.17.1)',\ - org.glassfish.jersey.core.jersey-server;version='[2.17.0,2.17.1)',\ - org.glassfish.jersey.media.jersey-media-sse;version='[2.17.0,2.17.1)',\ - org.json;version=snapshot,\ - org.slf4j.api;version='[1.7.2,1.7.3)',\ - specmate-common;version=snapshot,\ - specmate-emfjson;version=snapshot,\ - specmate-emfrest;version=snapshot,\ - specmate-logging;version=snapshot,\ - specmate-logging-slf4j;version=snapshot,\ - specmate-logging-slf4j-julbridge;version=snapshot,\ - specmate-model-gen;version=snapshot,\ - specmate-persistency-api;version=snapshot,\ - specmate-persistency-cdo;version=snapshot,\ - specmate-model-support;version=snapshot,\ - specmate-ui-core;version=snapshot,\ - specmate-dummy-data;version=snapshot,\ - specmate-config;version=snapshot,\ - specmate-connectors;version=snapshot,\ - org.eclipse.emf.cdo;version='[4.5.0,4.5.1)',\ - org.eclipse.emf.cdo.common;version='[4.5.0,4.5.1)',\ - org.eclipse.emf.cdo.ecore.retrofit;version='[4.2.300,4.2.301)',\ - org.eclipse.emf.cdo.net4j;version='[4.1.400,4.1.401)',\ - org.eclipse.emf.cdo.server;version='[4.5.0,4.5.1)',\ - org.eclipse.emf.cdo.server.net4j;version='[4.1.300,4.1.301)',\ - org.eclipse.emf.common;version='[2.12.0,2.12.1)',\ - org.eclipse.emf.ecore;version='[2.12.0,2.12.1)',\ - org.eclipse.emf.ecore.xmi;version='[2.12.0,2.12.1)',\ - org.eclipse.net4j;version='[4.5.0,4.5.1)',\ - org.eclipse.net4j.tcp;version='[4.1.400,4.1.401)',\ - org.eclipse.net4j.util;version='[3.6.0,3.6.1)',\ - com.google.guava;version='[21.0.0,21.0.1)',\ - specmate-hp-connector;version=snapshot,\ - specmate-testspecification;version=snapshot,\ - org.apache.felix.scr;version='[2.0.8,2.0.9)',\ - org.apache.commons.fileupload;version='[1.3.1,1.3.2)',\ - org.apache.commons.io;version='[2.4.0,2.4.1)',\ - org.apache.felix.webconsole;version='[4.3.0,4.3.1)',\ - org.eclipse.equinox.http.servlet;version='[1.1.500,1.1.501)',\ - org.eclipse.jetty.deploy;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.http;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.io;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.osgi-servlet-api;version='[3.1.0,3.1.1)',\ - org.eclipse.jetty.osgi.boot;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.osgi.httpservice;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.rewrite;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.security;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.server;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.servlet;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.util;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.webapp;version='[9.4.6,9.4.7)',\ - org.eclipse.jetty.xml;version='[9.4.6,9.4.7)',\ - org.eclipse.equinox.http.jetty;version='[3.0.200,3.0.201)',\ - org.eclipse.jetty.continuation;version='[8.1.16,8.1.17)',\ - org.eclipse.jetty.http;version='[8.1.16,8.1.17)',\ - org.eclipse.jetty.io;version='[8.1.16,8.1.17)',\ - org.eclipse.jetty.security;version='[8.1.16,8.1.17)',\ - org.eclipse.jetty.server;version='[8.1.16,8.1.17)',\ - org.eclipse.jetty.servlet;version='[8.1.16,8.1.17)',\ - org.eclipse.jetty.util;version='[8.1.16,8.1.17)',\ - specmate-jettystarter;version=snapshot,\ - lpg.runtime.java;version='[2.0.17,2.0.18)',\ - org.eclipse.emf.cdo.server.ocl;version='[4.2.100,4.2.101)',\ - org.eclipse.ocl;version='[3.6.200,3.6.201)',\ - org.eclipse.ocl.common;version='[1.4.200,1.4.201)',\ - org.eclipse.ocl.ecore;version='[3.6.200,3.6.201)',\ - org.sat4j.core;version='[2.3.5,2.3.6)',\ - org.jgrapht.core;version='[1.0.1,1.0.2)',\ - org.apache.commons.cli;version='[1.4.0,1.4.1)',\ - org.sat4j.maxsat;version='[2.3.5,2.3.6)',\ - org.sat4j.pb;version='[2.3.5,2.3.6)',\ - specmate-file-connector;version=snapshot,\ - org.apache.servicemix.bundles.jakarta-regexp;version='[1.4.0,1.4.1)',\ - org.apache.servicemix.bundles.lucene;version='[7.2.0,7.2.1)',\ - org.apache.servicemix.bundles.lucene-queries;version='[7.2.0,7.2.1)',\ - org.apache.servicemix.bundles.lucene-queryparser;version='[7.2.0,7.2.1)',\ - org.apache.servicemix.bundles.lucene-sandbox;version='[7.2.0,7.2.1)',\ - specmate-search;version=snapshot,\ - specmate-migration;version=snapshot,\ - specmate-administration;version=snapshot,\ - specmate-emfrest-api;version=snapshot,\ - specmate-trello-connector;version=snapshot,\ - specmate-auth-api;version=snapshot,\ - specmate-auth;version=snapshot,\ - specmate-dbprovider-api;version=snapshot,\ - org.eclipse.net4j.db;version='[4.5.0,4.5.1)',\ - org.eclipse.net4j.db.jdbc;version='[4.3.100,4.3.101)',\ - org.eclipse.net4j.db.h2;version='[4.2.300,4.2.301)',\ - specmate-dbprovider-h2;version=snapshot,\ - specmate-config-api;version=snapshot,\ - com.diffplug.osgi.extension.sun.misc;version='[0.0.0,0.0.1)',\ - io.prometheus.simpleclient;version='[0.4.0,0.4.1)',\ - io.prometheus.simpleclient_common;version='[0.4.0,0.4.1)',\ - io.prometheus.simpleclient_servlet;version='[0.4.0,0.4.1)',\ - specmate-metrics;version=snapshot,\ - io.prometheus.simpleclient_hotspot;version='[0.4.0,0.4.1)',\ - org.h2;version='[1.3.168,1.3.169)',\ - specmate-cdo-server;version=snapshot,\ - org.eclipse.emf.cdo.server.db;version='[4.4.0,4.4.1)',\ - specmate-jira-connector;version=snapshot,\ - specmate-rest;version=snapshot,\ - specmate-scheduler;version=snapshot,\ - com.ibm.icu;version='[63.1.0,63.1.1)',\ - io.reactivex.rxjava2.rxjava;version='[2.2.3,2.2.4)',\ - it.unimi.dsi.fastutil;version='[8.2.2,8.2.3)',\ - javax.money.api;version='[1.0.1,1.0.2)',\ - joda-time;version='[2.10.1,2.10.2)',\ - org.apache.commons.commons-compress;version='[1.18.0,1.18.1)',\ - org.apache.commons.commons-pool2;version='[2.6.0,2.6.1)',\ - org.apache.commons.lang;version='[2.6.0,2.6.1)',\ - org.apache.ivy;version='[2.4.0,2.4.1)',\ - org.apache.opennlp.tools;version='[1.9.1,1.9.2)',\ - org.reactivestreams.reactive-streams;version='[1.0.2,1.0.3)',\ - specmate-model-generation;version=snapshot,\ - specmate-nlp;version=snapshot,\ - com.google.guava;version='[18.0.0,18.0.1)',\ - org.apache.commons.lang3;version='[3.5.0,3.5.1)',\ - slf4j.api;version='[1.7.25,1.7.26)',\ - com.atlassian.fugue;version='[2.7.0,2.7.1)',\ - com.atlassian.sal.api;version='[3.0.7,3.0.8)',\ - com.atlassian.util.concurrent.atlassian-util-concurrent;version='[3.0.0,3.0.1)',\ - org.apache.commons.codec;version='[1.10.0,1.10.1)',\ - org.apache.commons.logging;version='[1.1.1,1.1.2)',\ - org.apache.httpcomponents.httpasyncclient;version='[4.1.3,4.1.4)',\ - org.apache.httpcomponents.httpclient;version='[4.5.3,4.5.4)',\ - org.apache.httpcomponents.httpcore;version='[4.4.6,4.4.7)',\ - org.apache.servicemix.bundles.jcip-annotations;version='[1.0.0,1.0.1)',\ - org.apache.servicemix.bundles.spring-beans;version='[4.1.7,4.1.8)',\ - org.apache.servicemix.bundles.spring-core;version='[4.1.7,4.1.8)',\ - org.codehaus.jettison.jettison;version='[1.1.0,1.1.1)',\ - log4j;version='[1.2.17,1.2.18)',\ - com.sun.activation.javax.activation;version='[1.2.0,1.2.1)',\ - com.google.inject;version='[3.0.0,3.0.1)',\ - org.antlr.runtime;version='[3.2.0,3.2.1)',\ - org.eclipse.xtend.lib;version='[2.10.0,2.10.1)',\ - org.eclipse.xtend.lib.macro;version='[2.10.0,2.10.1)',\ - org.eclipse.xtext;version='[2.10.0,2.10.1)',\ - org.eclipse.xtext.smap;version='[2.10.0,2.10.1)',\ - org.eclipse.xtext.util;version='[2.10.0,2.10.1)',\ - org.eclipse.xtext.xbase.lib;version='[2.10.0,2.10.1)',\ - specmate-cause-effect-patterns;version=snapshot,\ - specmate-xtext;version=snapshot,\ - jaxb-api;version='[2.3.1,2.3.2)' +-runrequires: \ + osgi.identity;filter:='(osgi.identity=specmate-cdo-server)',\ + osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\ + osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\ + osgi.identity;filter:='(osgi.identity=org.glassfish.hk2.locator)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.log)',\ + osgi.identity;filter:='(osgi.identity=jul.to.slf4j)',\ + osgi.identity;filter:='(osgi.identity=specmate-common)',\ + osgi.identity;filter:='(osgi.identity=specmate-emfjson)',\ + osgi.identity;filter:='(osgi.identity=specmate-logging)',\ + osgi.identity;filter:='(osgi.identity=specmate-logging-slf4j)',\ + osgi.identity;filter:='(osgi.identity=specmate-logging-slf4j-julbridge)',\ + osgi.identity;filter:='(osgi.identity=specmate-persistency-api)',\ + osgi.identity;filter:='(osgi.identity=org.glassfish.jersey.containers.jersey-container-servlet)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.event)',\ + osgi.identity;filter:='(osgi.identity=specmate-emfrest)',\ + osgi.identity;filter:='(osgi.identity=specmate-model-gen)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.cm)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.equinox.metatype)',\ + osgi.identity;filter:='(osgi.identity=specmate-model-support)',\ + osgi.identity;filter:='(osgi.identity=specmate-ui-core)',\ + osgi.identity;filter:='(osgi.identity=specmate-dummy-data)',\ + osgi.identity;filter:='(osgi.identity=specmate-config)',\ + osgi.identity;filter:='(osgi.identity=specmate-connectors)',\ + osgi.identity;filter:='(osgi.identity=specmate-testspecification)',\ + osgi.identity;filter:='(osgi.identity=specmate-hp-connector)',\ + osgi.identity;filter:='(osgi.identity=org.apache.felix.scr)',\ + osgi.identity;filter:='(&(osgi.identity=org.apache.felix.webconsole)(version>=4.3.0))',\ + osgi.identity;filter:='(&(osgi.identity=org.eclipse.jetty.osgi.boot)(version>=9.4.6))',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.osgi.httpservice)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.rewrite)',\ + osgi.identity;filter:='(osgi.identity=specmate-jettystarter)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.emf.cdo.server.ocl)',\ + osgi.identity;filter:='(osgi.identity=org.json)',\ + osgi.identity;filter:='(osgi.identity=specmate-file-connector)',\ + osgi.identity;filter:='(osgi.identity=specmate-search)',\ + osgi.identity;filter:='(osgi.identity=specmate-migration)',\ + osgi.identity;filter:='(osgi.identity=specmate-persistency-cdo)',\ + osgi.identity;filter:='(osgi.identity=specmate-administration)',\ + osgi.identity;filter:='(osgi.identity=org.apache.commons.fileupload)',\ + osgi.identity;filter:='(osgi.identity=specmate-trello-connector)',\ + osgi.identity;filter:='(osgi.identity=specmate-auth-api)',\ + osgi.identity;filter:='(osgi.identity=specmate-auth)',\ + osgi.identity;filter:='(osgi.identity=specmate-dbprovider-api)',\ + osgi.identity;filter:='(osgi.identity=specmate-dbprovider-h2)',\ + osgi.identity;filter:='(osgi.identity=specmate-jira-connector)',\ + osgi.identity;filter:='(osgi.identity=specmate-nlp)',\ + osgi.identity;filter:='(osgi.identity=specmate-model-generation)',\ + bnd.identity;id='log4j',\ + bnd.identity;id='specmate-objectif' +-runbundles: \ + javassist;version='[3.18.1,3.18.2)',\ + javax.annotation-api;version='[1.2.0,1.2.1)',\ + javax.validation.api;version='[1.1.0,1.1.1)',\ + javax.ws.rs-api;version='[2.0.1,2.0.2)',\ + jul.to.slf4j;version='[1.7.12,1.7.13)',\ + org.apache.felix.gogo.command;version='[0.10.0,0.10.1)',\ + org.apache.felix.gogo.runtime;version='[0.10.0,0.10.1)',\ + org.apache.felix.gogo.shell;version='[0.10.0,0.10.1)',\ + org.eclipse.core.contenttype;version='[3.4.200,3.4.201)',\ + org.eclipse.core.jobs;version='[3.6.1,3.6.2)',\ + org.eclipse.core.runtime;version='[3.10.0,3.10.1)',\ + org.eclipse.emf.ecore.change;version='[2.11.0,2.11.1)',\ + org.eclipse.equinox.app;version='[1.3.200,1.3.201)',\ + org.eclipse.equinox.cm;version='[1.1.0,1.1.1)',\ + org.eclipse.equinox.common;version='[3.6.200,3.6.201)',\ + org.eclipse.equinox.event;version='[1.3.100,1.3.101)',\ + org.eclipse.equinox.log;version='[1.2.300,1.2.301)',\ + org.eclipse.equinox.metatype;version='[1.4.0,1.4.1)',\ + org.eclipse.equinox.preferences;version='[3.5.200,3.5.201)',\ + org.eclipse.equinox.registry;version='[3.5.400,3.5.401)',\ + org.eclipse.osgi.services;version='[3.4.0,3.4.1)',\ + org.glassfish.hk2.api;version='[2.4.0,2.4.1)',\ + org.glassfish.hk2.external.aopalliance-repackaged;version='[2.4.0,2.4.1)',\ + org.glassfish.hk2.external.javax.inject;version='[2.4.0,2.4.1)',\ + org.glassfish.hk2.locator;version='[2.4.0,2.4.1)',\ + org.glassfish.hk2.osgi-resource-locator;version='[1.0.1,1.0.2)',\ + org.glassfish.hk2.utils;version='[2.4.0,2.4.1)',\ + org.glassfish.jersey.bundles.repackaged.jersey-guava;version='[2.17.0,2.17.1)',\ + org.glassfish.jersey.containers.jersey-container-servlet;version='[2.17.0,2.17.1)',\ + org.glassfish.jersey.containers.jersey-container-servlet-core;version='[2.17.0,2.17.1)',\ + org.glassfish.jersey.core.jersey-client;version='[2.17.0,2.17.1)',\ + org.glassfish.jersey.core.jersey-common;version='[2.17.0,2.17.1)',\ + org.glassfish.jersey.core.jersey-server;version='[2.17.0,2.17.1)',\ + org.glassfish.jersey.media.jersey-media-sse;version='[2.17.0,2.17.1)',\ + org.json;version=snapshot,\ + org.slf4j.api;version='[1.7.2,1.7.3)',\ + specmate-common;version=snapshot,\ + specmate-emfjson;version=snapshot,\ + specmate-emfrest;version=snapshot,\ + specmate-logging;version=snapshot,\ + specmate-logging-slf4j;version=snapshot,\ + specmate-logging-slf4j-julbridge;version=snapshot,\ + specmate-model-gen;version=snapshot,\ + specmate-persistency-api;version=snapshot,\ + specmate-persistency-cdo;version=snapshot,\ + specmate-model-support;version=snapshot,\ + specmate-ui-core;version=snapshot,\ + specmate-dummy-data;version=snapshot,\ + specmate-config;version=snapshot,\ + specmate-connectors;version=snapshot,\ + org.eclipse.emf.cdo;version='[4.5.0,4.5.1)',\ + org.eclipse.emf.cdo.common;version='[4.5.0,4.5.1)',\ + org.eclipse.emf.cdo.ecore.retrofit;version='[4.2.300,4.2.301)',\ + org.eclipse.emf.cdo.net4j;version='[4.1.400,4.1.401)',\ + org.eclipse.emf.cdo.server;version='[4.5.0,4.5.1)',\ + org.eclipse.emf.cdo.server.net4j;version='[4.1.300,4.1.301)',\ + org.eclipse.emf.common;version='[2.12.0,2.12.1)',\ + org.eclipse.emf.ecore;version='[2.12.0,2.12.1)',\ + org.eclipse.emf.ecore.xmi;version='[2.12.0,2.12.1)',\ + org.eclipse.net4j;version='[4.5.0,4.5.1)',\ + org.eclipse.net4j.tcp;version='[4.1.400,4.1.401)',\ + org.eclipse.net4j.util;version='[3.6.0,3.6.1)',\ + com.google.guava;version='[21.0.0,21.0.1)',\ + specmate-hp-connector;version=snapshot,\ + specmate-testspecification;version=snapshot,\ + org.apache.felix.scr;version='[2.0.8,2.0.9)',\ + org.apache.commons.fileupload;version='[1.3.1,1.3.2)',\ + org.apache.commons.io;version='[2.4.0,2.4.1)',\ + org.apache.felix.webconsole;version='[4.3.0,4.3.1)',\ + org.eclipse.equinox.http.servlet;version='[1.1.500,1.1.501)',\ + org.eclipse.jetty.deploy;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.http;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.io;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.osgi-servlet-api;version='[3.1.0,3.1.1)',\ + org.eclipse.jetty.osgi.boot;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.osgi.httpservice;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.rewrite;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.security;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.server;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.servlet;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.util;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.webapp;version='[9.4.6,9.4.7)',\ + org.eclipse.jetty.xml;version='[9.4.6,9.4.7)',\ + org.eclipse.equinox.http.jetty;version='[3.0.200,3.0.201)',\ + org.eclipse.jetty.continuation;version='[8.1.16,8.1.17)',\ + org.eclipse.jetty.http;version='[8.1.16,8.1.17)',\ + org.eclipse.jetty.io;version='[8.1.16,8.1.17)',\ + org.eclipse.jetty.security;version='[8.1.16,8.1.17)',\ + org.eclipse.jetty.server;version='[8.1.16,8.1.17)',\ + org.eclipse.jetty.servlet;version='[8.1.16,8.1.17)',\ + org.eclipse.jetty.util;version='[8.1.16,8.1.17)',\ + specmate-jettystarter;version=snapshot,\ + lpg.runtime.java;version='[2.0.17,2.0.18)',\ + org.eclipse.emf.cdo.server.ocl;version='[4.2.100,4.2.101)',\ + org.eclipse.ocl;version='[3.6.200,3.6.201)',\ + org.eclipse.ocl.common;version='[1.4.200,1.4.201)',\ + org.eclipse.ocl.ecore;version='[3.6.200,3.6.201)',\ + org.sat4j.core;version='[2.3.5,2.3.6)',\ + org.jgrapht.core;version='[1.0.1,1.0.2)',\ + org.apache.commons.cli;version='[1.4.0,1.4.1)',\ + org.sat4j.maxsat;version='[2.3.5,2.3.6)',\ + org.sat4j.pb;version='[2.3.5,2.3.6)',\ + specmate-file-connector;version=snapshot,\ + org.apache.servicemix.bundles.jakarta-regexp;version='[1.4.0,1.4.1)',\ + org.apache.servicemix.bundles.lucene;version='[7.2.0,7.2.1)',\ + org.apache.servicemix.bundles.lucene-queries;version='[7.2.0,7.2.1)',\ + org.apache.servicemix.bundles.lucene-queryparser;version='[7.2.0,7.2.1)',\ + org.apache.servicemix.bundles.lucene-sandbox;version='[7.2.0,7.2.1)',\ + specmate-search;version=snapshot,\ + specmate-migration;version=snapshot,\ + specmate-administration;version=snapshot,\ + specmate-emfrest-api;version=snapshot,\ + specmate-trello-connector;version=snapshot,\ + specmate-auth-api;version=snapshot,\ + specmate-auth;version=snapshot,\ + specmate-dbprovider-api;version=snapshot,\ + org.eclipse.net4j.db;version='[4.5.0,4.5.1)',\ + org.eclipse.net4j.db.jdbc;version='[4.3.100,4.3.101)',\ + org.eclipse.net4j.db.h2;version='[4.2.300,4.2.301)',\ + specmate-dbprovider-h2;version=snapshot,\ + specmate-config-api;version=snapshot,\ + com.diffplug.osgi.extension.sun.misc;version='[0.0.0,0.0.1)',\ + io.prometheus.simpleclient;version='[0.4.0,0.4.1)',\ + io.prometheus.simpleclient_common;version='[0.4.0,0.4.1)',\ + io.prometheus.simpleclient_servlet;version='[0.4.0,0.4.1)',\ + specmate-metrics;version=snapshot,\ + io.prometheus.simpleclient_hotspot;version='[0.4.0,0.4.1)',\ + org.h2;version='[1.3.168,1.3.169)',\ + specmate-cdo-server;version=snapshot,\ + org.eclipse.emf.cdo.server.db;version='[4.4.0,4.4.1)',\ + specmate-jira-connector;version=snapshot,\ + specmate-rest;version=snapshot,\ + specmate-scheduler;version=snapshot,\ + com.ibm.icu;version='[63.1.0,63.1.1)',\ + io.reactivex.rxjava2.rxjava;version='[2.2.3,2.2.4)',\ + it.unimi.dsi.fastutil;version='[8.2.2,8.2.3)',\ + javax.money.api;version='[1.0.1,1.0.2)',\ + joda-time;version='[2.10.1,2.10.2)',\ + org.apache.commons.commons-compress;version='[1.18.0,1.18.1)',\ + org.apache.commons.commons-pool2;version='[2.6.0,2.6.1)',\ + org.apache.commons.lang;version='[2.6.0,2.6.1)',\ + org.apache.ivy;version='[2.4.0,2.4.1)',\ + org.apache.opennlp.tools;version='[1.9.1,1.9.2)',\ + org.reactivestreams.reactive-streams;version='[1.0.2,1.0.3)',\ + specmate-model-generation;version=snapshot,\ + specmate-nlp;version=snapshot,\ + com.google.guava;version='[18.0.0,18.0.1)',\ + org.apache.commons.lang3;version='[3.5.0,3.5.1)',\ + slf4j.api;version='[1.7.25,1.7.26)',\ + com.atlassian.fugue;version='[2.7.0,2.7.1)',\ + com.atlassian.sal.api;version='[3.0.7,3.0.8)',\ + com.atlassian.util.concurrent.atlassian-util-concurrent;version='[3.0.0,3.0.1)',\ + org.apache.commons.codec;version='[1.10.0,1.10.1)',\ + org.apache.commons.logging;version='[1.1.1,1.1.2)',\ + org.apache.httpcomponents.httpasyncclient;version='[4.1.3,4.1.4)',\ + org.apache.httpcomponents.httpclient;version='[4.5.3,4.5.4)',\ + org.apache.httpcomponents.httpcore;version='[4.4.6,4.4.7)',\ + org.apache.servicemix.bundles.jcip-annotations;version='[1.0.0,1.0.1)',\ + org.apache.servicemix.bundles.spring-beans;version='[4.1.7,4.1.8)',\ + org.apache.servicemix.bundles.spring-core;version='[4.1.7,4.1.8)',\ + org.codehaus.jettison.jettison;version='[1.1.0,1.1.1)',\ + log4j;version='[1.2.17,1.2.18)',\ + com.sun.activation.javax.activation;version='[1.2.0,1.2.1)',\ + com.google.inject;version='[3.0.0,3.0.1)',\ + org.antlr.runtime;version='[3.2.0,3.2.1)',\ + org.eclipse.xtend.lib;version='[2.10.0,2.10.1)',\ + org.eclipse.xtend.lib.macro;version='[2.10.0,2.10.1)',\ + org.eclipse.xtext;version='[2.10.0,2.10.1)',\ + org.eclipse.xtext.smap;version='[2.10.0,2.10.1)',\ + org.eclipse.xtext.util;version='[2.10.0,2.10.1)',\ + org.eclipse.xtext.xbase.lib;version='[2.10.0,2.10.1)',\ + specmate-cause-effect-patterns;version=snapshot,\ + specmate-xtext;version=snapshot,\ + jaxb-api;version='[2.3.0,2.3.1)',\ + specmate-objectif;version=snapshot -runproperties: \ jetty.http.port=8080,\ @@ -237,4 +239,5 @@ Local -runvm: -Xmx6000m\n\ -Djdk.crypto.KeyAgreement.legacyKDF=true --resolve: auto \ No newline at end of file +-resolve: auto +-runee: JavaSE-11 \ No newline at end of file From 8aea9e7ce863da7b0db3336a727951a5e88216b9 Mon Sep 17 00:00:00 2001 From: Jannik Fischbach Date: Tue, 16 Jul 2019 13:45:36 +0200 Subject: [PATCH 09/10] update regex, add "SONST" effects, add proper exception message, add unit test for xtext parsing --- .../resources/test_rules.objectif | 3 +- .../test/integration/ObjectifTest.java | 30 ++++++++++- .../resources/test_rules.objectif | 1 - .../GenerateModelFromPseudoCode.java | 54 +++++++++++-------- .../src/com/specmate/nlp/util/NLPUtil.java | 5 +- 5 files changed, 65 insertions(+), 28 deletions(-) delete mode 100644 bundles/specmate-model-generation/resources/test_rules.objectif diff --git a/bundles/specmate-integration-test/resources/test_rules.objectif b/bundles/specmate-integration-test/resources/test_rules.objectif index 0fa46fc67..9e51fa68c 100644 --- a/bundles/specmate-integration-test/resources/test_rules.objectif +++ b/bundles/specmate-integration-test/resources/test_rules.objectif @@ -1,4 +1,5 @@ WENN A=5 UND X=9 DANN C=7 ENDE-WENN WENN X = Z ODER Y>4 DANN F="Test" ENDE-WENN WENN A=1 DANN WENN B=1 DANN C=1 ENDE-WENN ENDE-WENN -WENN A=1 DANN B=1 SONST C=2 ENDE-WENN \ No newline at end of file +WENN A=1 DANN B=1 SONST C=2 ENDE-WENN +WENN A=1 DANN WENN B=1 DANN C=1 SONST C=2 ENDE-WENN ENDE-WENN \ No newline at end of file diff --git a/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java b/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java index 597ba4e44..47dba92d2 100644 --- a/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java +++ b/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java @@ -22,7 +22,7 @@ public class ObjectifTest { @Test public void testLoadRules() throws URISyntaxException, XTextException { List rules = loadRules("/resources/test_rules.objectif"); - Assert.assertTrue(rules.size() == 4); + Assert.assertTrue(rules.size() == 5); } @Test @@ -37,7 +37,7 @@ public void testAND() throws URISyntaxException, XTextException { Assert.assertTrue(causeA instanceof LiteralNode); Assert.assertTrue(((LiteralNode)causeA).getContent().equals("A=5")); Assert.assertTrue(causeB instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)causeB).getContent().equals("B=3")); + Assert.assertTrue(((LiteralNode)causeB).getContent().equals("X=9")); ObjectifNode effect = rule.getEffect(); Assert.assertTrue(effect instanceof LiteralNode); @@ -102,6 +102,32 @@ public void testAlternative() throws URISyntaxException, XTextException { Assert.assertTrue(((LiteralNode)alternative).getContent().equals("C=2")); } + @Test + public void testAlternativeCombinedWithNesting() throws URISyntaxException, XTextException { + List rules = loadRules("/resources/test_rules.objectif"); + BusinessRuleNode rule = rules.get(4); + ObjectifNode cause = rule.getCause(); + Assert.assertTrue(cause instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)cause).getContent().equals("A=1")); + ObjectifNode effect = rule.getEffect(); + Assert.assertTrue(effect instanceof BusinessRuleNode); + BusinessRuleNode ruleB = (BusinessRuleNode) effect; + + ObjectifNode causeB = ruleB.getCause(); + Assert.assertTrue(causeB instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)causeB).getContent().equals("B=1")); + + ObjectifNode effectB = ruleB.getEffect(); + Assert.assertTrue(effectB instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)effectB).getContent().equals("C=1")); + + Assert.assertTrue(ruleB.hasAlternative()); + ObjectifNode alternative = ruleB.getAlternative(); + Assert.assertTrue(alternative instanceof LiteralNode); + Assert.assertTrue(((LiteralNode)alternative).getContent().equals("C=2")); + + } + private List loadRules(String mainFile) throws URISyntaxException, XTextException { URI main = getLocalFile(mainFile); return new BusinessRuleUtil().loadXTextResources(main); diff --git a/bundles/specmate-model-generation/resources/test_rules.objectif b/bundles/specmate-model-generation/resources/test_rules.objectif deleted file mode 100644 index 27c6b2f98..000000000 --- a/bundles/specmate-model-generation/resources/test_rules.objectif +++ /dev/null @@ -1 +0,0 @@ -WENN die sonne scheint UND meine freunde Zeit haben ODER ich bock hab DANN WENN der see frei ist DANN WENN csxc ODER 34234 DANN fahre ich an den See ENDE-WENN ENDE-WENN ENDE-WENN \ No newline at end of file diff --git a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java index 0bd7affd8..cf0108888 100644 --- a/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java +++ b/bundles/specmate-model-generation/src/com/specmate/modelgeneration/GenerateModelFromPseudoCode.java @@ -1,13 +1,8 @@ package com.specmate.modelgeneration; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; -import org.eclipse.emf.common.util.URI; -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; - import com.specmate.common.exception.SpecmateException; import com.specmate.common.exception.SpecmateInternalException; import com.specmate.model.administration.ErrorCode; @@ -40,7 +35,8 @@ public CEGModel createModel(CEGModel model, String text) throws SpecmateExceptio try { rules = new BusinessRuleUtil().parseXTextResource(text); } catch (XTextException e) { - throw new SpecmateInternalException(ErrorCode.INTERNAL_PROBLEM, "..."); + throw new SpecmateInternalException(ErrorCode.INTERNAL_PROBLEM, + "Unfortunately, the XText parsing of your inserted pseudo code went wrong." + e.getMessage()); } BusinessRuleNode rule = rules.get(0); @@ -107,6 +103,14 @@ private CEGModel createCEGModelForEachSection(BusinessRuleNode rule, CEGModel mo // RootCause contains all causes of a rule. ObjectifNode rootCause = rule.getCause(); List effects = new ArrayList(); + List alternativeEffects = new ArrayList(); + + identifyEffects(rootEffect, effects); + + if (rule.hasAlternative()) { + rootEffect = rule.getAlternative(); + identifyEffects(rootEffect, alternativeEffects); + } // 1. Case = The rule contains only one cause. This is the case if the rootCause // is a "LiteralNode". @@ -118,7 +122,12 @@ private CEGModel createCEGModelForEachSection(BusinessRuleNode rule, CEGModel mo creation.createConnection(model, cegNode, cegNodeBR, false); // Search for effects of the rule. - identifyEffects(rootEffect, effects); + //identifyEffects(rootEffect, effects); + +// if (rule.hasAlternative()) { +// rootEffect = rule.getAlternative(); +// identifyEffects(rootEffect, alternativeEffects); +// } // Connect the rule node with all identified effects. for (ObjectifNode effect : effects) { @@ -126,6 +135,13 @@ private CEGModel createCEGModelForEachSection(BusinessRuleNode rule, CEGModel mo "is present", 0, 0, null); creation.createConnection(model, cegNodeBR, cegNodeEffect, false); } + + // Connect the rule node with its alternative effects + for (ObjectifNode effect : alternativeEffects) { + CEGNode cegNodeEffect = creation.createNode(model, ((LiteralNode) effect).getContent(), + "is present", 0, 0, null); + creation.createConnection(model, cegNodeBR, cegNodeEffect, true); + } } else { // 2. Case = The rule contains multiple causes which are interconnected @@ -134,26 +150,31 @@ private CEGModel createCEGModelForEachSection(BusinessRuleNode rule, CEGModel mo List singleOrCauses = new ArrayList(); identifyCauses(rootCause, singleOrCauses, andCausesGroups); - identifyEffects(rootEffect, effects); + //identifyEffects(rootEffect, effects); if (nesting == false) { connectCausesToBR(cegNodeBR, singleOrCauses, andCausesGroups, model); } else { connectCausesToNestedBR(cegNodeBR, singleOrCauses, andCausesGroups, model); } - connectBRToEffects(cegNodeBR, effects, model); + connectBRToEffects(cegNodeBR, effects, alternativeEffects, model); } } return model; } - private void connectBRToEffects(CEGNode cegNodeBR, List effects, CEGModel model) { + private void connectBRToEffects(CEGNode cegNodeBR, List effects, + List alternativeEffects, CEGModel model) { // Iterate over all effects and connect the business rule node with these // effects. for (ObjectifNode effect : effects) { CEGNode cegNode = creation.createNode(model, ((LiteralNode) effect).getContent(), "is present", 0, 0, null); creation.createConnection(model, cegNodeBR, cegNode, false); } + for (ObjectifNode effect : alternativeEffects) { + CEGNode cegNode = creation.createNode(model, ((LiteralNode) effect).getContent(), "is present", 0, 0, null); + creation.createConnection(model, cegNodeBR, cegNode, true); + } } // Implementation for non nested BRs @@ -263,12 +284,10 @@ private void identifyEffects(ObjectifNode rootEffect, List effects } if (rootEffect.getLeft() instanceof AndNode) { - // wiederholt aufrufen aber mit geupdateter root cause connectAndCauses(rootEffect.getLeft(), effects); } if (rootEffect.getRight() instanceof AndNode) { - // wiederholt aufrufen aber mit geupdateter root cause connectAndCauses(rootEffect.getRight(), effects); } } @@ -356,15 +375,4 @@ private void identifyCauses(ObjectifNode rootCause, List orCauses, orCauses.add(rootCause); } } - - // Method that loads all rules from a local file. - private List loadRules(String mainFile) throws URISyntaxException, XTextException { - URI main = getLocalFile(mainFile); - return new BusinessRuleUtil().loadXTextResources(main); - } - - private URI getLocalFile(String fileName) throws URISyntaxException { - Bundle bundle = FrameworkUtil.getBundle(GenerateModelFromRequirementService.class); - return URI.createURI(bundle.getResource(fileName).toURI().toString()); - } } diff --git a/bundles/specmate-nlp/src/com/specmate/nlp/util/NLPUtil.java b/bundles/specmate-nlp/src/com/specmate/nlp/util/NLPUtil.java index 91eb2924e..d2b444a45 100644 --- a/bundles/specmate-nlp/src/com/specmate/nlp/util/NLPUtil.java +++ b/bundles/specmate-nlp/src/com/specmate/nlp/util/NLPUtil.java @@ -7,6 +7,7 @@ import java.util.Optional; import java.util.Set; import java.util.StringJoiner; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -242,7 +243,9 @@ public static List findDependencies(Collection dependenc private static String DE_Pattern = "\\b(der|die|das|ein|eine|einen)\\b"; public static ELanguage detectLanguage(String text) { - if (text.matches(".*WENN.*ENDE-WENN.*")) { + Pattern pattern= Pattern.compile(".*WENN.*ENDE-WENN.*", Pattern.DOTALL); + + if (pattern.matcher(text).matches()) { return ELanguage.PSEUDO; } if (text.matches("(?i)(.*)"+DE_Pattern+"(.*)")) { From 2324847c9c585bebd45f2c39bb7005e0483496b5 Mon Sep 17 00:00:00 2001 From: Jannik Fischbach Date: Tue, 16 Jul 2019 14:23:34 +0200 Subject: [PATCH 10/10] add unit tests for pseudo code translation --- .../test/integration/ObjectifTest.java | 233 +++++++++++++++--- 1 file changed, 192 insertions(+), 41 deletions(-) diff --git a/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java b/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java index 47dba92d2..96c17052e 100644 --- a/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java +++ b/bundles/specmate-integration-test/src/com/specmate/test/integration/ObjectifTest.java @@ -7,9 +7,14 @@ import java.util.List; import org.eclipse.emf.common.util.URI; +import org.json.JSONArray; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; +import com.specmate.model.requirements.CEGModel; +import com.specmate.model.requirements.CEGNode; +import com.specmate.model.requirements.NodeType; +import com.specmate.model.requirements.RequirementsFactory; import com.specmate.objectif.resolve.BusinessRuleUtil; import com.specmate.objectif.resolve.rule.AndNode; import com.specmate.objectif.resolve.rule.BusinessRuleNode; @@ -18,121 +23,267 @@ import com.specmate.objectif.resolve.rule.OrNode; import com.specmate.xtext.XTextException; -public class ObjectifTest { +// Two types of tests: +// 1) tests for checking the functionality of the xtext parsing +// 2) tests for checking the functionality of the pseudo code translator +public class ObjectifTest extends ModelGenerationTestBase { + + public ObjectifTest() throws Exception { + super(); + } + + // Unit tests for the Xtext Parsing @Test public void testLoadRules() throws URISyntaxException, XTextException { List rules = loadRules("/resources/test_rules.objectif"); Assert.assertTrue(rules.size() == 5); } - + @Test public void testAND() throws URISyntaxException, XTextException { List rules = loadRules("/resources/test_rules.objectif"); BusinessRuleNode rule = rules.get(0); ObjectifNode cause = rule.getCause(); Assert.assertTrue(cause instanceof AndNode); - - ObjectifNode causeA = ((AndNode)cause).getLeft(); - ObjectifNode causeB = ((AndNode)cause).getRight(); + + ObjectifNode causeA = ((AndNode) cause).getLeft(); + ObjectifNode causeB = ((AndNode) cause).getRight(); Assert.assertTrue(causeA instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)causeA).getContent().equals("A=5")); + Assert.assertTrue(((LiteralNode) causeA).getContent().equals("A=5")); Assert.assertTrue(causeB instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)causeB).getContent().equals("X=9")); - + Assert.assertTrue(((LiteralNode) causeB).getContent().equals("X=9")); + ObjectifNode effect = rule.getEffect(); Assert.assertTrue(effect instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)effect).getContent().equals("C=7")); + Assert.assertTrue(((LiteralNode) effect).getContent().equals("C=7")); } - + @Test public void testOR() throws URISyntaxException, XTextException { List rules = loadRules("/resources/test_rules.objectif"); BusinessRuleNode rule = rules.get(1); ObjectifNode cause = rule.getCause(); Assert.assertTrue(cause instanceof OrNode); - - ObjectifNode causeA = ((OrNode)cause).getLeft(); - ObjectifNode causeB = ((OrNode)cause).getRight(); + + ObjectifNode causeA = ((OrNode) cause).getLeft(); + ObjectifNode causeB = ((OrNode) cause).getRight(); Assert.assertTrue(causeA instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)causeA).getContent().equals("X = Z")); + Assert.assertTrue(((LiteralNode) causeA).getContent().equals("X = Z")); Assert.assertTrue(causeB instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)causeB).getContent().equals("Y>4")); - + Assert.assertTrue(((LiteralNode) causeB).getContent().equals("Y>4")); + ObjectifNode effect = rule.getEffect(); Assert.assertTrue(effect instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)effect).getContent().equals("F=\"Test\"")); + Assert.assertTrue(((LiteralNode) effect).getContent().equals("F=\"Test\"")); } - + @Test public void testNesting() throws URISyntaxException, XTextException { List rules = loadRules("/resources/test_rules.objectif"); BusinessRuleNode rule = rules.get(2); ObjectifNode cause = rule.getCause(); Assert.assertTrue(cause instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)cause).getContent().equals("A=1")); - + Assert.assertTrue(((LiteralNode) cause).getContent().equals("A=1")); + ObjectifNode effect = rule.getEffect(); Assert.assertTrue(effect instanceof BusinessRuleNode); - - BusinessRuleNode ruleB = (BusinessRuleNode) effect; - + + BusinessRuleNode ruleB = (BusinessRuleNode) effect; + ObjectifNode causeB = ruleB.getCause(); Assert.assertTrue(causeB instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)causeB).getContent().equals("B=1")); - + Assert.assertTrue(((LiteralNode) causeB).getContent().equals("B=1")); + ObjectifNode effectB = ruleB.getEffect(); Assert.assertTrue(effectB instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)effectB).getContent().equals("C=1")); + Assert.assertTrue(((LiteralNode) effectB).getContent().equals("C=1")); } - + @Test public void testAlternative() throws URISyntaxException, XTextException { List rules = loadRules("/resources/test_rules.objectif"); BusinessRuleNode rule = rules.get(3); ObjectifNode cause = rule.getCause(); Assert.assertTrue(cause instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)cause).getContent().equals("A=1")); + Assert.assertTrue(((LiteralNode) cause).getContent().equals("A=1")); ObjectifNode effect = rule.getEffect(); Assert.assertTrue(effect instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)effect).getContent().equals("B=1")); - + Assert.assertTrue(((LiteralNode) effect).getContent().equals("B=1")); + Assert.assertTrue(rule.hasAlternative()); ObjectifNode alternative = rule.getAlternative(); Assert.assertTrue(alternative instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)alternative).getContent().equals("C=2")); + Assert.assertTrue(((LiteralNode) alternative).getContent().equals("C=2")); } - + @Test public void testAlternativeCombinedWithNesting() throws URISyntaxException, XTextException { List rules = loadRules("/resources/test_rules.objectif"); BusinessRuleNode rule = rules.get(4); ObjectifNode cause = rule.getCause(); Assert.assertTrue(cause instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)cause).getContent().equals("A=1")); + Assert.assertTrue(((LiteralNode) cause).getContent().equals("A=1")); ObjectifNode effect = rule.getEffect(); Assert.assertTrue(effect instanceof BusinessRuleNode); - BusinessRuleNode ruleB = (BusinessRuleNode) effect; - + BusinessRuleNode ruleB = (BusinessRuleNode) effect; + ObjectifNode causeB = ruleB.getCause(); Assert.assertTrue(causeB instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)causeB).getContent().equals("B=1")); - + Assert.assertTrue(((LiteralNode) causeB).getContent().equals("B=1")); + ObjectifNode effectB = ruleB.getEffect(); Assert.assertTrue(effectB instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)effectB).getContent().equals("C=1")); - + Assert.assertTrue(((LiteralNode) effectB).getContent().equals("C=1")); + Assert.assertTrue(ruleB.hasAlternative()); ObjectifNode alternative = ruleB.getAlternative(); Assert.assertTrue(alternative instanceof LiteralNode); - Assert.assertTrue(((LiteralNode)alternative).getContent().equals("C=2")); + Assert.assertTrue(((LiteralNode) alternative).getContent().equals("C=2")); + + } + + // Unit tests for the pseudo code translation + @Test + public void testModelGenerationSimplePseudoCode() { + String text = "WENN x DANN y ENDE-WENN"; + RequirementsFactory f = RequirementsFactory.eINSTANCE; + CEGModel model = f.createCEGModel(); + CEGNode node1 = createNode(model, "BR1", "is present", NodeType.OR); + CEGNode node2 = createNode(model, "x", "is present", null); + CEGNode node3 = createNode(model, "y", "is present", null); + createConnection(model, node1, node3, false); + createConnection(model, node2, node1, false); + JSONArray generated = generateCEGWithModelRequirementsText(text); + checkResultingModel(generated, model); + } + + @Test + public void testModelGenerationPseudoCodeWithInterconnectedCauses() { + String text = "WENN x UND y UND z ODER w DANN effekt ENDE-WENN"; + RequirementsFactory f = RequirementsFactory.eINSTANCE; + CEGModel model = f.createCEGModel(); + CEGNode node1 = createNode(model, "BR1", "is present", NodeType.OR); + CEGNode node2 = createNode(model, "x", "is present", null); + CEGNode node3 = createNode(model, "y", "is present", null); + CEGNode node4 = createNode(model, "z", "is present", null); + CEGNode node5 = createNode(model, "w", "is present", null); + CEGNode node6 = createNode(model, "effekt", "is present", null); + CEGNode node7 = createNode(model, "Intermediate Node1", "is present", NodeType.AND); + createConnection(model, node2, node7, false); + createConnection(model, node3, node7, false); + createConnection(model, node4, node7, false); + createConnection(model, node5, node1, false); + createConnection(model, node7, node1, false); + createConnection(model, node1, node6, false); + JSONArray generated = generateCEGWithModelRequirementsText(text); + checkResultingModel(generated, model); + } + + @Test + public void testModelGenerationPseudoCodeWithInterconnectedCausesAndSingleNesting() { + String text = "WENN x UND y UND z ODER w DANN WENN xB ODER yB DANN effekt ENDE-WENN ENDE-WENN"; + RequirementsFactory f = RequirementsFactory.eINSTANCE; + CEGModel model = f.createCEGModel(); + CEGNode node1 = createNode(model, "BR1", "is present", NodeType.OR); + CEGNode node2 = createNode(model, "x", "is present", null); + CEGNode node3 = createNode(model, "y", "is present", null); + CEGNode node4 = createNode(model, "z", "is present", null); + CEGNode node5 = createNode(model, "w", "is present", null); + CEGNode node7 = createNode(model, "Intermediate Node1", "is present", NodeType.AND); + + CEGNode node8 = createNode(model, "BR2", "is present", NodeType.AND); + CEGNode node9 = createNode(model, "xB", "is present", null); + CEGNode node10 = createNode(model, "yB", "is present", null); + CEGNode node6 = createNode(model, "effekt", "is present", null); + CEGNode node11 = createNode(model, "Intermediate Node2", "is present", NodeType.OR); + + createConnection(model, node2, node7, false); + createConnection(model, node3, node7, false); + createConnection(model, node4, node7, false); + createConnection(model, node5, node1, false); + createConnection(model, node7, node1, false); + createConnection(model, node1, node8, false); + createConnection(model, node9, node11, false); + createConnection(model, node10, node11, false); + createConnection(model, node11, node8, false); + createConnection(model, node8, node6, false); + JSONArray generated = generateCEGWithModelRequirementsText(text); + checkResultingModel(generated, model); + } + + @Test + public void testModelGenerationPseudoCodeWithMultipleNesting() { + String text = "WENN x UND y DANN WENN xB ODER yB DANN WENN xC UND yC DANN effekt ENDE-WENN ENDE-WENN ENDE-WENN"; + RequirementsFactory f = RequirementsFactory.eINSTANCE; + CEGModel model = f.createCEGModel(); + CEGNode node1 = createNode(model, "BR1", "is present", NodeType.AND); + CEGNode node2 = createNode(model, "x", "is present", null); + CEGNode node3 = createNode(model, "y", "is present", null); + + CEGNode node4 = createNode(model, "BR2", "is present", NodeType.AND); + CEGNode node5 = createNode(model, "xB", "is present", null); + CEGNode node6 = createNode(model, "yB", "is present", null); + CEGNode node7 = createNode(model, "Intermediate Node1", "is present", NodeType.OR); + CEGNode node8 = createNode(model, "BR3", "is present", NodeType.AND); + CEGNode node9 = createNode(model, "xC", "is present", null); + CEGNode node10 = createNode(model, "yC", "is present", null); + CEGNode node11 = createNode(model, "effekt", "is present", null); + + createConnection(model, node2, node1, false); + createConnection(model, node3, node1, false); + createConnection(model, node1, node4, false); + createConnection(model, node5, node7, false); + createConnection(model, node6, node7, false); + createConnection(model, node7, node4, false); + createConnection(model, node4, node8, false); + createConnection(model, node9, node8, false); + createConnection(model, node10, node8, false); + createConnection(model, node8, node11, false); + JSONArray generated = generateCEGWithModelRequirementsText(text); + checkResultingModel(generated, model); } + @Test + public void testModelGenerationPseudoCodeWithMultipleNestingAndAlternativeEffect() { + String text = "WENN x UND y DANN WENN xB ODER yB DANN WENN xC UND yC DANN effekt SONST aEffekt ENDE-WENN ENDE-WENN ENDE-WENN"; + RequirementsFactory f = RequirementsFactory.eINSTANCE; + CEGModel model = f.createCEGModel(); + CEGNode node1 = createNode(model, "BR1", "is present", NodeType.AND); + CEGNode node2 = createNode(model, "x", "is present", null); + CEGNode node3 = createNode(model, "y", "is present", null); + + CEGNode node4 = createNode(model, "BR2", "is present", NodeType.AND); + CEGNode node5 = createNode(model, "xB", "is present", null); + CEGNode node6 = createNode(model, "yB", "is present", null); + CEGNode node7 = createNode(model, "Intermediate Node1", "is present", NodeType.OR); + + CEGNode node8 = createNode(model, "BR3", "is present", NodeType.AND); + CEGNode node9 = createNode(model, "xC", "is present", null); + CEGNode node10 = createNode(model, "yC", "is present", null); + CEGNode node11 = createNode(model, "effekt", "is present", null); + CEGNode node12 = createNode(model, "aEffekt", "is present", null); + + createConnection(model, node2, node1, false); + createConnection(model, node3, node1, false); + createConnection(model, node1, node4, false); + createConnection(model, node5, node7, false); + createConnection(model, node6, node7, false); + createConnection(model, node7, node4, false); + createConnection(model, node4, node8, false); + createConnection(model, node9, node8, false); + createConnection(model, node10, node8, false); + createConnection(model, node8, node11, false); + createConnection(model, node8, node12, true); + JSONArray generated = generateCEGWithModelRequirementsText(text); + checkResultingModel(generated, model); + } + private List loadRules(String mainFile) throws URISyntaxException, XTextException { URI main = getLocalFile(mainFile); return new BusinessRuleUtil().loadXTextResources(main); } - + private URI getLocalFile(String fileName) throws URISyntaxException { Bundle bundle = FrameworkUtil.getBundle(NLPServiceTest.class); return URI.createURI(bundle.getResource(fileName).toURI().toString());