mirror of
http://172.16.200.102/MOISE/Pattern-Instanciation-On-System-Engineering-Model.git
synced 2025-11-27 10:37:58 +01:00
Initial commit.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
module com.irtsaintexupery.xtext.pseim.GeneratePattern
|
||||
|
||||
import org.eclipse.xtext.xtext.generator.*
|
||||
import org.eclipse.xtext.xtext.generator.model.project.*
|
||||
|
||||
var rootPath = ".."
|
||||
|
||||
Workflow {
|
||||
|
||||
component = XtextGenerator {
|
||||
configuration = {
|
||||
project = StandardProjectConfig {
|
||||
baseName = "com.irtsaintexupery.xtext.pseim.pattern"
|
||||
rootPath = rootPath
|
||||
eclipsePlugin = {
|
||||
enabled = true
|
||||
}
|
||||
createEclipseMetaData = true
|
||||
}
|
||||
code = {
|
||||
encoding = "UTF-8"
|
||||
lineDelimiter = "\r\n"
|
||||
fileHeader = "/*\n * generated by Xtext \${version}\n */"
|
||||
}
|
||||
}
|
||||
language = StandardLanguage {
|
||||
name = "com.irtsaintexupery.xtext.pseim.Pattern"
|
||||
fileExtensions = "pseimx"
|
||||
referencedResource = "platform:/resource/com.irtsaintexupery.modelpattern/model/pseim.genmodel"
|
||||
referencedResource = "platform:/resource/com.irtsaintexupery.modelpattern/model/seim.genmodel"
|
||||
|
||||
fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}
|
||||
|
||||
formatter = {
|
||||
generateStub = true
|
||||
}
|
||||
|
||||
serializer = {
|
||||
generateStub = false
|
||||
}
|
||||
validator = {
|
||||
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
grammar com.irtsaintexupery.xtext.pseim.Pattern with org.eclipse.xtext.common.Terminals
|
||||
|
||||
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
|
||||
import "http://www.irt-saintexupery.com/seim/0.1" as seim
|
||||
import "http://www.irt-saintexupery.com/pseim/0.1"
|
||||
|
||||
Pattern returns Pattern:
|
||||
'pattern' name=ID '(' (cardinalityElements+=CardinalityElement (',' cardinalityElements+=CardinalityElement)*)? ')'
|
||||
('{'
|
||||
(
|
||||
modelElements+=PatternComponent |
|
||||
modelElements+=PatternLink
|
||||
)*
|
||||
'}')?;
|
||||
|
||||
PatternComponent returns PatternComponent:
|
||||
'component' name=ID ('[' (multiplicityValue=INT | cardinalityElement=[CardinalityElement]) ']')? '(' (content+=PatternPort (',' content+=PatternPort)*)? ')'
|
||||
('{'
|
||||
(
|
||||
content+=PatternComponent |
|
||||
content+=PatternLink
|
||||
)*
|
||||
'}')?;
|
||||
|
||||
PatternPort returns PatternPort:
|
||||
dir=PatternPortDirection name=ID ('[' (multiplicityValue=INT | cardinalityElement=[CardinalityElement]) ']')?
|
||||
;
|
||||
|
||||
enum PatternPortDirection returns PatternPortDirection:
|
||||
UNSPECIFIED = 'unspec' | IN = 'in' | OUT = 'out' | INOUT = 'inout';
|
||||
|
||||
CardinalityElement returns CardinalityElement:
|
||||
name=ID
|
||||
;
|
||||
|
||||
PatternLink returns PatternLink:
|
||||
src=[PatternPort|QualifiedID] linkType=LinkType dst=[PatternPort|QualifiedID]
|
||||
;
|
||||
|
||||
enum LinkType returns LinkType:
|
||||
TRANSPOSE = '-{Transpose}->' | IDENTITY = '-{Identity}->' | FIRST = '-{First}->' | ROTATE = '-{Rotate}->' | SHIFT = '-{Shift}->'
|
||||
;
|
||||
|
||||
enum PortDirection returns seim::PortDirection:
|
||||
UNSPECIFIED = 'unspec' | IN = 'in' | OUT = 'out' | INOUT = 'inout'
|
||||
;
|
||||
|
||||
QualifiedID:
|
||||
ID('.'ID)*
|
||||
;
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.irtsaintexupery.xtext.pseim
|
||||
|
||||
|
||||
/**
|
||||
* Use this class to register components to be used at runtime / without the Equinox extension registry.
|
||||
*/
|
||||
class PatternRuntimeModule extends AbstractPatternRuntimeModule {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.irtsaintexupery.xtext.pseim
|
||||
|
||||
|
||||
/**
|
||||
* Initialization support for running Xtext languages without Equinox extension registry.
|
||||
*/
|
||||
class PatternStandaloneSetup extends PatternStandaloneSetupGenerated {
|
||||
|
||||
def static void doSetup() {
|
||||
new PatternStandaloneSetup().createInjectorAndDoEMFRegistration()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.irtsaintexupery.xtext.pseim.formatting2
|
||||
|
||||
import com.google.inject.Inject
|
||||
import com.irtsaintexupery.pseim.pseim.CardinalityElement
|
||||
import com.irtsaintexupery.pseim.pseim.Pattern
|
||||
import com.irtsaintexupery.pseim.pseim.PatternComponent
|
||||
import com.irtsaintexupery.pseim.seim.Element
|
||||
import com.irtsaintexupery.pseim.seim.GraphElement
|
||||
import com.irtsaintexupery.xtext.pseim.services.PatternGrammarAccess
|
||||
import org.eclipse.xtext.formatting2.AbstractFormatter2
|
||||
import org.eclipse.xtext.formatting2.IFormattableDocument
|
||||
|
||||
class PatternFormatter extends AbstractFormatter2 {
|
||||
|
||||
@Inject extension PatternGrammarAccess
|
||||
|
||||
def dispatch void format(Pattern pattern, extension IFormattableDocument document) {
|
||||
// TODO: format HiddenRegions around keywords, attributes, cross references, etc.
|
||||
for (CardinalityElement cardinalityElement : pattern.getCardinalityElements()) {
|
||||
cardinalityElement.format;
|
||||
}
|
||||
for (GraphElement graphElement : pattern.getModelElements()) {
|
||||
graphElement.format;
|
||||
}
|
||||
}
|
||||
|
||||
def dispatch void format(PatternComponent patternComponent, extension IFormattableDocument document) {
|
||||
// TODO: format HiddenRegions around keywords, attributes, cross references, etc.
|
||||
for (Element element : patternComponent.getContent()) {
|
||||
element.format;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement for
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.irtsaintexupery.xtext.pseim.generator
|
||||
|
||||
import org.eclipse.emf.ecore.resource.Resource
|
||||
import org.eclipse.xtext.generator.AbstractGenerator
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2
|
||||
import org.eclipse.xtext.generator.IGeneratorContext
|
||||
|
||||
/**
|
||||
* Generates code from your model files on save.
|
||||
*
|
||||
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
|
||||
*/
|
||||
class PatternGenerator extends AbstractGenerator {
|
||||
|
||||
override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
|
||||
// fsa.generateFile('greetings.txt', 'People to greet: ' +
|
||||
// resource.allContents
|
||||
// .filter(Greeting)
|
||||
// .map[name]
|
||||
// .join(', '))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.irtsaintexupery.xtext.pseim.scoping
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
class PatternScopeProvider extends AbstractPatternScopeProvider {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.irtsaintexupery.xtext.pseim.validation
|
||||
|
||||
|
||||
/**
|
||||
* This class contains custom validation rules.
|
||||
*
|
||||
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
|
||||
*/
|
||||
class PatternValidator extends AbstractPatternValidator {
|
||||
|
||||
// public static val INVALID_NAME = 'invalidName'
|
||||
//
|
||||
// @Check
|
||||
// def checkGreetingStartsWithCapital(Greeting greeting) {
|
||||
// if (!Character.isUpperCase(greeting.name.charAt(0))) {
|
||||
// warning('Name should start with a capital',
|
||||
// PatternPackage.Literals.GREETING__NAME,
|
||||
// INVALID_NAME)
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user