diff options
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components')
12 files changed, 0 insertions, 550 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext deleted file mode 100644 index ab053f67..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext +++ /dev/null | |||
@@ -1,101 +0,0 @@ | |||
1 | grammar hu.bme.mit.inf.dslreasoner.faulttree.components.CftLanguage with org.eclipse.xtext.common.Terminals | ||
2 | |||
3 | import "http://www.eclipse.org/emf/2002/Ecore" as ecore | ||
4 | import "http://www.eclipse.org/viatra/query/patternlanguage/emf/PatternLanguage" as vql | ||
5 | import "http://www.bme.hu/mit/inf/dslreasoner/faulttree/model/ft" as ft | ||
6 | import "http://www.bme.hu/mit/inf/dslreasoner/faulttree/model/cft" as cft | ||
7 | generate cftLanguage "http://www.bme.hu/mit/inf/dslreasoner/faulttree/components/CftLanguage" | ||
8 | |||
9 | CftModel: | ||
10 | "package" packageName=QualifiedName ";"? | ||
11 | imports+=ImportDeclaration* | ||
12 | (componentDefinitions+=ComponentDefinition | transformationDefinitions+=TransformationDefinition)*; | ||
13 | |||
14 | ImportDeclaration: | ||
15 | "import" importedNamespace=QualifiedNameWithWildcard ";"?; | ||
16 | |||
17 | ComponentDefinition returns cft::ComponentDefinition: | ||
18 | "cft" name=ValidId "{" | ||
19 | (("in" inputEvents+=InputEvent* ";")? & ("out" outputEvents+=[cft::EventDeclaration|ValidId]* ";")?) | ||
20 | (eventDefinitions+=EventDefinition ";")* | ||
21 | "}"; | ||
22 | |||
23 | InputEvent returns cft::InputEvent: | ||
24 | name=ValidId multiple?="[]"?; | ||
25 | |||
26 | EventDefinition returns cft::EventDefinition: | ||
27 | BasicEventDefinition | GateDefinition; | ||
28 | |||
29 | BasicEventDefinition returns cft::BasicEventDefinition: | ||
30 | name=ValidId distribution=Distribution; | ||
31 | |||
32 | Distribution returns ft::Distribution: | ||
33 | ConstantDistribution | ExponentialDistribution; | ||
34 | |||
35 | ConstantDistribution returns ft::ConstantDistribution: | ||
36 | "prob" "=" p=Double; | ||
37 | |||
38 | ExponentialDistribution returns ft::ExponentialDistribution: | ||
39 | "lambda" "=" lambda=Double; | ||
40 | |||
41 | GateDefinition returns cft::GateDefinition: | ||
42 | AndGateDefinition | OrGateDefinition | KOfMGateDefinition; | ||
43 | |||
44 | AndGateDefinition returns cft::AndGateDefinition: | ||
45 | name=ValidId "and" inputEvents+=[cft::EventDeclaration|ValidId]*; | ||
46 | |||
47 | OrGateDefinition returns cft::OrGateDefinition: | ||
48 | name=ValidId "or" inputEvents+=[cft::EventDeclaration|ValidId]*; | ||
49 | |||
50 | KOfMGateDefinition returns cft::KOfMGateDefinition: | ||
51 | name=ValidId k=INT ("of" m=INT | m=OF_INT) inputEvents+=[cft::EventDeclaration|ValidId]*; | ||
52 | |||
53 | TransformationDefinition: | ||
54 | "transformation" name=ValidId "{" | ||
55 | mappingDefinitions+=MappingDefinition* | ||
56 | "}"; | ||
57 | |||
58 | MappingDefinition: | ||
59 | topLevel?="toplevel"? "mapping" pattern=[vql::Pattern|QualifiedName] | ||
60 | "(" parameters+=MappingParameter ("," parameters+=MappingParameter)* ")" | ||
61 | (componentInstance=ComponentInstance)? ("{" | ||
62 | ((lookupDefinitions+=LookupDefinition | assignments+=Assignment) ";")* | ||
63 | "}")?; | ||
64 | |||
65 | MappingParameter: | ||
66 | name=ValidId; | ||
67 | |||
68 | LookupDefinition: | ||
69 | "lookup" mapping=[MappingDefinition|QualifiedName] | ||
70 | "(" arguments+=[MappingParameter|ValidId] ("," arguments+=[MappingParameter|ValidId])* ")" | ||
71 | "as" name=ValidId; | ||
72 | |||
73 | Variable: | ||
74 | ComponentInstance | LookupDefinition; | ||
75 | |||
76 | Assignment: | ||
77 | input=EventReference (multiple?="+=" | ":=") output=EventReference; | ||
78 | |||
79 | EventReference: | ||
80 | component=[Variable|ValidId] "." event=[cft::EventDeclaration|ValidId]; | ||
81 | |||
82 | ComponentInstance: | ||
83 | "=>" componentType=[cft::ComponentDefinition|QualifiedName] name=ValidId?; | ||
84 | |||
85 | QualifiedName returns ecore::EString: | ||
86 | ValidId ("." ValidId)*; | ||
87 | |||
88 | QualifiedNameWithWildcard returns ecore::EString: | ||
89 | QualifiedName ("." "*")?; | ||
90 | |||
91 | ValidId: | ||
92 | ID | OF_INT; | ||
93 | |||
94 | Double returns ecore::EDouble: | ||
95 | INT | T_DOUBLE; | ||
96 | |||
97 | terminal OF_INT returns ecore::EInt: | ||
98 | "o" "f" ('0'..'9')+; | ||
99 | |||
100 | terminal T_DOUBLE: | ||
101 | ('0'..'9')+ ("." ('0'..'9')+ | ("." ('0'..'9')+)? ("e" | "E") ("+" | "-")? ('0'..'9')+); | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguageRuntimeModule.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguageRuntimeModule.xtend deleted file mode 100644 index fe5965fa..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguageRuntimeModule.xtend +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | /* | ||
2 | * generated by Xtext 2.16.0 | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.faulttree.components | ||
5 | |||
6 | import com.google.inject.Binder | ||
7 | import com.google.inject.name.Names | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.components.conversion.CftLanguageValueConverterService | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.components.naming.CftLanguageQualifiedNameProvider | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.components.scoping.CftLanguageImportedNamespaceAwareLocalScopeProvider | ||
11 | import org.eclipse.xtext.scoping.IScopeProvider | ||
12 | import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider | ||
13 | import org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider | ||
14 | |||
15 | /** | ||
16 | * Use this class to register components to be used at runtime / without the Equinox extension registry. | ||
17 | */ | ||
18 | class CftLanguageRuntimeModule extends AbstractCftLanguageRuntimeModule { | ||
19 | |||
20 | override bindIGlobalScopeProvider() { | ||
21 | DefaultGlobalScopeProvider | ||
22 | } | ||
23 | |||
24 | override configureIScopeProviderDelegate(Binder binder) { | ||
25 | binder.bind(IScopeProvider).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to( | ||
26 | CftLanguageImportedNamespaceAwareLocalScopeProvider) | ||
27 | } | ||
28 | |||
29 | |||
30 | override bindIQualifiedNameProvider() { | ||
31 | CftLanguageQualifiedNameProvider | ||
32 | } | ||
33 | |||
34 | override bindIValueConverterService() { | ||
35 | CftLanguageValueConverterService | ||
36 | } | ||
37 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguageStandaloneSetup.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguageStandaloneSetup.xtend deleted file mode 100644 index 7ec57980..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguageStandaloneSetup.xtend +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | /* | ||
2 | * generated by Xtext 2.16.0 | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.faulttree.components | ||
5 | |||
6 | |||
7 | /** | ||
8 | * Initialization support for running Xtext languages without Equinox extension registry. | ||
9 | */ | ||
10 | class CftLanguageStandaloneSetup extends CftLanguageStandaloneSetupGenerated { | ||
11 | |||
12 | def static void doSetup() { | ||
13 | new CftLanguageStandaloneSetup().createInjectorAndDoEMFRegistration() | ||
14 | } | ||
15 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/GenerateCftLanguage.mwe2 b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/GenerateCftLanguage.mwe2 deleted file mode 100644 index 89efbb05..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/GenerateCftLanguage.mwe2 +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | module hu.bme.mit.inf.dslreasoner.faulttree.components.GenerateCftLanguage | ||
2 | |||
3 | import org.eclipse.xtext.xtext.generator.* | ||
4 | import org.eclipse.xtext.xtext.generator.model.project.* | ||
5 | |||
6 | var rootPath = ".." | ||
7 | |||
8 | Workflow { | ||
9 | |||
10 | component = XtextGenerator { | ||
11 | configuration = { | ||
12 | project = StandardProjectConfig { | ||
13 | baseName = "hu.bme.mit.inf.dslreasoner.faulttree.components" | ||
14 | rootPath = rootPath | ||
15 | eclipsePlugin = { | ||
16 | enabled = true | ||
17 | } | ||
18 | createEclipseMetaData = true | ||
19 | } | ||
20 | code = { | ||
21 | encoding = "UTF-8" | ||
22 | lineDelimiter = "\n" | ||
23 | fileHeader = "/*\n * generated by Xtext \${version}\n */" | ||
24 | } | ||
25 | } | ||
26 | language = StandardLanguage { | ||
27 | name = "hu.bme.mit.inf.dslreasoner.faulttree.components.CftLanguage" | ||
28 | fileExtensions = "cft" | ||
29 | |||
30 | referencedResource = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel" | ||
31 | referencedResource = "platform:/resource/org.eclipse.viatra.query.patternlanguage.emf/model/PatternLanguage.genmodel" | ||
32 | referencedResource = "platform:/resource/hu.bme.mit.inf.dslreasoner.faulttree.model/model/ft.genmodel" | ||
33 | referencedResource = "platform:/resource/hu.bme.mit.inf.dslreasoner.faulttree.model/model/cft.genmodel" | ||
34 | |||
35 | serializer = { | ||
36 | generateStub = false | ||
37 | } | ||
38 | validator = { | ||
39 | // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator" | ||
40 | // Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage | ||
41 | generateDeprecationValidation = true | ||
42 | } | ||
43 | junitSupport = { | ||
44 | junitVersion = "5" | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/CftLanguageValueConverterService.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/CftLanguageValueConverterService.xtend deleted file mode 100644 index 974e0df4..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/CftLanguageValueConverterService.xtend +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.components.conversion | ||
2 | |||
3 | import com.google.inject.Inject | ||
4 | import org.eclipse.xtext.common.services.DefaultTerminalConverters | ||
5 | import org.eclipse.xtext.conversion.IValueConverter | ||
6 | import org.eclipse.xtext.conversion.ValueConverter | ||
7 | |||
8 | class CftLanguageValueConverterService extends DefaultTerminalConverters { | ||
9 | @Inject OF_INTValueConverter ofIntValueConverter | ||
10 | |||
11 | @ValueConverter(rule="OF_INT") | ||
12 | def IValueConverter<Integer> OF_INT() { | ||
13 | ofIntValueConverter | ||
14 | } | ||
15 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend deleted file mode 100644 index ba3d39e6..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/conversion/OF_INTValueConverter.xtend +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.components.conversion | ||
2 | |||
3 | import org.eclipse.xtext.conversion.ValueConverterException | ||
4 | import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter | ||
5 | import org.eclipse.xtext.nodemodel.INode | ||
6 | |||
7 | class OF_INTValueConverter extends AbstractLexerBasedConverter<Integer> { | ||
8 | static val PREFIX = "of" | ||
9 | |||
10 | override toValue(String string, INode node) throws ValueConverterException { | ||
11 | if (string === null) { | ||
12 | return null | ||
13 | } | ||
14 | if (string.length < PREFIX.length || string.substring(0, PREFIX.length) != PREFIX) { | ||
15 | throw new ValueConverterException("'" + string + "' must start with the characters 'of'.", node, null); | ||
16 | } | ||
17 | try { | ||
18 | val intValue = Integer.parseInt(string.substring(PREFIX.length), 10) | ||
19 | Integer.valueOf(intValue) | ||
20 | } catch (NumberFormatException e) { | ||
21 | throw new ValueConverterException("Couldn't convert '" + string + "' to an int value.", node, e); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | override protected toEscapedString(Integer value) { | ||
26 | PREFIX + value | ||
27 | } | ||
28 | |||
29 | override protected assertValidValue(Integer value) { | ||
30 | super.assertValidValue(value) | ||
31 | if (value < 0) { | ||
32 | throw new ValueConverterException(getRuleName() + " may not be negative.", null, null); | ||
33 | } | ||
34 | } | ||
35 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/generator/CftLanguageGenerator.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/generator/CftLanguageGenerator.xtend deleted file mode 100644 index d7ebace4..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/generator/CftLanguageGenerator.xtend +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | /* | ||
2 | * generated by Xtext 2.16.0 | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.faulttree.components.generator | ||
5 | |||
6 | import org.eclipse.emf.ecore.resource.Resource | ||
7 | import org.eclipse.xtext.generator.AbstractGenerator | ||
8 | import org.eclipse.xtext.generator.IFileSystemAccess2 | ||
9 | import org.eclipse.xtext.generator.IGeneratorContext | ||
10 | |||
11 | /** | ||
12 | * Generates code from your model files on save. | ||
13 | * | ||
14 | * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation | ||
15 | */ | ||
16 | class CftLanguageGenerator extends AbstractGenerator { | ||
17 | |||
18 | override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) { | ||
19 | // fsa.generateFile('greetings.txt', 'People to greet: ' + | ||
20 | // resource.allContents | ||
21 | // .filter(Greeting) | ||
22 | // .map[name] | ||
23 | // .join(', ')) | ||
24 | } | ||
25 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/naming/CftLanguageQualifiedNameProvider.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/naming/CftLanguageQualifiedNameProvider.xtend deleted file mode 100644 index db89ebf9..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/naming/CftLanguageQualifiedNameProvider.xtend +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.components.naming | ||
2 | |||
3 | import com.google.inject.Inject | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition | ||
6 | import org.eclipse.emf.ecore.EObject | ||
7 | import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider | ||
8 | |||
9 | class CftLanguageQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider { | ||
10 | @Inject PackageNameProvider packageNameProvider | ||
11 | |||
12 | def qualifiedName(ComponentDefinition componentDefinition) { | ||
13 | computePackageQualifiedName(componentDefinition, componentDefinition.name) | ||
14 | } | ||
15 | |||
16 | def qualifiedName(TransformationDefinition transformationDefinition) { | ||
17 | computePackageQualifiedName(transformationDefinition, transformationDefinition.name) | ||
18 | } | ||
19 | |||
20 | private def computePackageQualifiedName(EObject eObj, String name) { | ||
21 | if (name === null) { | ||
22 | return null | ||
23 | } | ||
24 | val packageQualifier = packageNameProvider.getPackageName(eObj) | ||
25 | packageQualifier.append(name) | ||
26 | } | ||
27 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/naming/PackageNameProvider.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/naming/PackageNameProvider.xtend deleted file mode 100644 index a05c8138..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/naming/PackageNameProvider.xtend +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.components.naming | ||
2 | |||
3 | import com.google.inject.Inject | ||
4 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.CftModel | ||
5 | import org.eclipse.emf.ecore.EObject | ||
6 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
7 | import org.eclipse.xtext.EcoreUtil2 | ||
8 | import org.eclipse.xtext.naming.IQualifiedNameConverter | ||
9 | import org.eclipse.xtext.naming.QualifiedName | ||
10 | |||
11 | class PackageNameProvider { | ||
12 | val IQualifiedNameConverter qualifiedNameConverter | ||
13 | |||
14 | @FinalFieldsConstructor | ||
15 | @Inject | ||
16 | new() { | ||
17 | } | ||
18 | |||
19 | def getPackageName(EObject eObj) { | ||
20 | if (eObj === null) { | ||
21 | return QualifiedName.EMPTY | ||
22 | } | ||
23 | val pacakgeName = EcoreUtil2.getContainerOfType(eObj, CftModel)?.packageName | ||
24 | if (pacakgeName.isNullOrEmpty) { | ||
25 | QualifiedName.EMPTY | ||
26 | } else { | ||
27 | qualifiedNameConverter.toQualifiedName(pacakgeName) | ||
28 | } | ||
29 | } | ||
30 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageImportedNamespaceAwareLocalScopeProvider.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageImportedNamespaceAwareLocalScopeProvider.xtend deleted file mode 100644 index 39a6e5a5..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageImportedNamespaceAwareLocalScopeProvider.xtend +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.faulttree.components.scoping | ||
2 | |||
3 | import com.google.inject.Inject | ||
4 | import com.google.inject.Singleton | ||
5 | import hu.bme.mit.inf.dslreasoner.faulttree.components.naming.PackageNameProvider | ||
6 | import org.eclipse.emf.ecore.EObject | ||
7 | import org.eclipse.emf.ecore.EReference | ||
8 | import org.eclipse.xtext.naming.IQualifiedNameConverter | ||
9 | import org.eclipse.xtext.naming.IQualifiedNameProvider | ||
10 | import org.eclipse.xtext.scoping.ICaseInsensitivityHelper | ||
11 | import org.eclipse.xtext.scoping.IGlobalScopeProvider | ||
12 | import org.eclipse.xtext.scoping.IScope | ||
13 | import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider | ||
14 | |||
15 | @Singleton | ||
16 | class CftLanguageImportedNamespaceAwareLocalScopeProvider extends ImportedNamespaceAwareLocalScopeProvider { | ||
17 | @Inject PackageNameProvider packageNameProvider | ||
18 | |||
19 | @Inject | ||
20 | new() { | ||
21 | } | ||
22 | |||
23 | new(IGlobalScopeProvider globalScopeProvider, IQualifiedNameProvider qualifiedNameProvider, | ||
24 | IQualifiedNameConverter qualifiedNameConverter, ICaseInsensitivityHelper caseInsensitivityHelper) { | ||
25 | super(globalScopeProvider, qualifiedNameProvider, qualifiedNameConverter, caseInsensitivityHelper) | ||
26 | packageNameProvider = new PackageNameProvider(qualifiedNameConverter) | ||
27 | } | ||
28 | |||
29 | override protected internalGetImportedNamespaceResolvers(EObject context, boolean ignoreCase) { | ||
30 | val resolvers = super.internalGetImportedNamespaceResolvers(context, ignoreCase) | ||
31 | val packageName = packageNameProvider.getPackageName(context) | ||
32 | if (!packageName.empty) { | ||
33 | val packageNormalizer = doCreateImportNormalizer(packageName, true, ignoreCase) | ||
34 | resolvers.add(0, packageNormalizer) | ||
35 | } | ||
36 | resolvers | ||
37 | } | ||
38 | |||
39 | def createImportNormalizedScope(IScope elements, EObject context, EReference reference) { | ||
40 | val ignoreCase = isIgnoreCase(reference) | ||
41 | val type = reference.EReferenceType | ||
42 | val namespaceResolvers = getImportedNamespaceResolvers(context, ignoreCase) | ||
43 | createImportScope(elements, namespaceResolvers, null, type, ignoreCase) | ||
44 | } | ||
45 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageScopeProvider.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageScopeProvider.xtend deleted file mode 100644 index f295f116..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageScopeProvider.xtend +++ /dev/null | |||
@@ -1,147 +0,0 @@ | |||
1 | /* | ||
2 | * generated by Xtext 2.16.0 | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.faulttree.components.scoping | ||
5 | |||
6 | import com.google.common.collect.Lists | ||
7 | import com.google.inject.Inject | ||
8 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.ComponentInstance | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.EventReference | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Variable | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.impl.MappingDefinitionImpl | ||
15 | import hu.bme.mit.inf.dslreasoner.faulttree.model.cft.ComponentDefinition | ||
16 | import org.eclipse.emf.common.notify.Notifier | ||
17 | import org.eclipse.emf.ecore.EObject | ||
18 | import org.eclipse.emf.ecore.EReference | ||
19 | import org.eclipse.xtext.EcoreUtil2 | ||
20 | import org.eclipse.xtext.resource.EObjectDescription | ||
21 | import org.eclipse.xtext.resource.IResourceDescriptions | ||
22 | import org.eclipse.xtext.resource.IResourceDescriptionsProvider | ||
23 | import org.eclipse.xtext.scoping.IScope | ||
24 | import org.eclipse.xtext.scoping.Scopes | ||
25 | import org.eclipse.xtext.scoping.impl.SimpleScope | ||
26 | |||
27 | import static hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.CftLanguagePackage.Literals.* | ||
28 | |||
29 | /** | ||
30 | * This class contains custom scoping description. | ||
31 | * | ||
32 | * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping | ||
33 | * on how and when to use it. | ||
34 | */ | ||
35 | class CftLanguageScopeProvider extends AbstractCftLanguageScopeProvider { | ||
36 | public static val SINGLETON_VARIABLE_PREFIX = "_" | ||
37 | |||
38 | @Inject IResourceDescriptionsProvider resourceDescriptionsProvider | ||
39 | @Inject CftLanguageImportedNamespaceAwareLocalScopeProvider importedNamespaceProvider | ||
40 | |||
41 | override getScope(EObject context, EReference reference) { | ||
42 | switch (reference) { | ||
43 | case LOOKUP_DEFINITION__MAPPING: | ||
44 | getRuleDefinitionsScope(context, reference) | ||
45 | case LOOKUP_DEFINITION__ARGUMENTS: | ||
46 | getMappingParametersScope(context) | ||
47 | case EVENT_REFERENCE__COMPONENT: | ||
48 | getComponentInstancesScope(context) | ||
49 | case EVENT_REFERENCE__EVENT: | ||
50 | getEventDeclarationsScope(context) | ||
51 | default: | ||
52 | super.getScope(context, reference) | ||
53 | } | ||
54 | } | ||
55 | |||
56 | protected def getRuleDefinitionsScope(EObject context, EReference referece) { | ||
57 | val transformationDefinition = EcoreUtil2.getContainerOfType(context, TransformationDefinition) | ||
58 | if (transformationDefinition === null) { | ||
59 | return IScope.NULLSCOPE | ||
60 | } | ||
61 | val resourceDescriptions = getResourceDescriptions(transformationDefinition) | ||
62 | val mappingDefinitionDescriptions = toMappingDefinitionDescriptions(resourceDescriptions, | ||
63 | transformationDefinition.mappingDefinitions) | ||
64 | val ruleDefinitionsScope = new SimpleScope(IScope.NULLSCOPE, mappingDefinitionDescriptions) | ||
65 | importedNamespaceProvider.createImportNormalizedScope(ruleDefinitionsScope, context, referece) | ||
66 | } | ||
67 | |||
68 | protected def toMappingDefinitionDescriptions(IResourceDescriptions resourceDescriptions, | ||
69 | Iterable<? extends MappingDefinition> ruleDefinitions) { | ||
70 | val mappingDefinitionDescriptions = Lists.newArrayListWithExpectedSize(ruleDefinitions.size) | ||
71 | for (ruleDefinition : ruleDefinitions) { | ||
72 | val pattern = ruleDefinition.safelyGetPattern | ||
73 | if (pattern !== null) { | ||
74 | val patternName = resourceDescriptions.getExportedObjectsByObject(pattern).head?.qualifiedName | ||
75 | if (patternName !== null) { | ||
76 | mappingDefinitionDescriptions += EObjectDescription.create(patternName, ruleDefinition) | ||
77 | } | ||
78 | } | ||
79 | |||
80 | } | ||
81 | mappingDefinitionDescriptions | ||
82 | } | ||
83 | |||
84 | private def safelyGetPattern(MappingDefinition mappingDefinition) { | ||
85 | switch (mappingDefinition) { | ||
86 | MappingDefinitionImpl: mappingDefinition.basicGetPattern | ||
87 | case null: null | ||
88 | default: mappingDefinition.pattern | ||
89 | } | ||
90 | } | ||
91 | |||
92 | private def getResourceDescriptions(Notifier notifier) { | ||
93 | val resourceSet = EcoreUtil2.getResourceSet(notifier) | ||
94 | if (resourceSet === null) { | ||
95 | new IResourceDescriptions.NullImpl | ||
96 | } else { | ||
97 | resourceDescriptionsProvider.getResourceDescriptions(resourceSet) | ||
98 | } | ||
99 | } | ||
100 | |||
101 | protected def getMappingParametersScope(EObject context) { | ||
102 | val mappingDefinition = EcoreUtil2.getContainerOfType(context, MappingDefinition) | ||
103 | if (mappingDefinition === null) { | ||
104 | return IScope.NULLSCOPE | ||
105 | } | ||
106 | val variables = mappingDefinition.parameters.filter [ | ||
107 | !name.startsWith(SINGLETON_VARIABLE_PREFIX) | ||
108 | ] | ||
109 | Scopes.scopeFor(variables) | ||
110 | } | ||
111 | |||
112 | protected def getComponentInstancesScope(EObject context) { | ||
113 | val mappingDefinition = EcoreUtil2.getContainerOfType(context, MappingDefinition) | ||
114 | if (mappingDefinition === null) { | ||
115 | return IScope.NULLSCOPE | ||
116 | } | ||
117 | val componentInstances = <Variable>newArrayList | ||
118 | componentInstances.addAll(mappingDefinition.lookupDefinitions) | ||
119 | if (mappingDefinition.componentInstance !== null) { | ||
120 | componentInstances += mappingDefinition.componentInstance | ||
121 | } | ||
122 | Scopes.scopeFor(componentInstances) | ||
123 | } | ||
124 | |||
125 | protected def getEventDeclarationsScope(EObject context) { | ||
126 | val variable = EcoreUtil2.getContainerOfType(context, EventReference)?.component | ||
127 | val events = switch (variable) { | ||
128 | ComponentInstance: | ||
129 | variable.componentType?.allEventDeclarations | ||
130 | LookupDefinition: | ||
131 | variable.mapping?.componentInstance?.componentType?.allEventDeclarations | ||
132 | default: | ||
133 | null | ||
134 | } | ||
135 | if (events === null) { | ||
136 | return IScope.NULLSCOPE | ||
137 | } | ||
138 | Scopes.scopeFor(events) | ||
139 | } | ||
140 | |||
141 | private def getAllEventDeclarations(ComponentDefinition componentDefinition) { | ||
142 | val eventDeclarations = newArrayList | ||
143 | eventDeclarations.addAll(componentDefinition.inputEvents) | ||
144 | eventDeclarations.addAll(componentDefinition.eventDefinitions) | ||
145 | eventDeclarations | ||
146 | } | ||
147 | } | ||
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/validation/CftLanguageValidator.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/validation/CftLanguageValidator.xtend deleted file mode 100644 index f1da10bb..00000000 --- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/validation/CftLanguageValidator.xtend +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | /* | ||
2 | * generated by Xtext 2.16.0 | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.faulttree.components.validation | ||
5 | |||
6 | |||
7 | /** | ||
8 | * This class contains custom validation rules. | ||
9 | * | ||
10 | * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation | ||
11 | */ | ||
12 | class CftLanguageValidator extends AbstractCftLanguageValidator { | ||
13 | |||
14 | // public static val INVALID_NAME = 'invalidName' | ||
15 | // | ||
16 | // @Check | ||
17 | // def checkGreetingStartsWithCapital(Greeting greeting) { | ||
18 | // if (!Character.isUpperCase(greeting.name.charAt(0))) { | ||
19 | // warning('Name should start with a capital', | ||
20 | // CftLanguagePackage.Literals.GREETING__NAME, | ||
21 | // INVALID_NAME) | ||
22 | // } | ||
23 | // } | ||
24 | |||
25 | } | ||