Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CheckTestUtil {
/*
* Gets the first instance of given type in given context object.
*/
def <T extends EObject> T getFirstInstanceOf(EObject context, Class<T> type) {
def <T extends EObject> T getFirstInstanceOf(EObject context, Class<T> type) {
return getInstanceOf(context, type, null, null, 1)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ grammar com.avaloq.tools.ddk.check.TestLanguage with org.eclipse.xtext.common.Te
generate testLanguage "http://www.avaloq.com/tools/ddk/check/TestLanguage"

Model:
greetings+=Greeting*;
greetings+=Greeting*;
Greeting:
'Hello' name=ID '!';
'Hello' name=ID '!';
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess

class TestLanguageGenerator implements IGenerator {

override void doGenerate(Resource resource, IFileSystemAccess fsa) {
//TODO implment me
}
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
//TODO implment me
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ var modelPath

Workflow {

component = org.eclipse.xtext.mwe.Reader {
// lookup all resources on the classpath
// useJavaClassPath = true

// or define search scope explicitly
path = modelPath

// this class will be generated by the xtext generator
register = com.avaloq.tools.ddk.check.TestLanguageStandaloneSetup {}
loadResource = {
slot = "model"
}
}

component = org.eclipse.xtext.generator.GeneratorComponent {
register = com.avaloq.tools.ddk.check.TestLanguageStandaloneSetup {}
slot = 'model'
outlet = {
path = targetDir
}
}
component = org.eclipse.xtext.mwe.Reader {
// lookup all resources on the classpath
// useJavaClassPath = true

// or define search scope explicitly
path = modelPath

// this class will be generated by the xtext generator
register = com.avaloq.tools.ddk.check.TestLanguageStandaloneSetup {}
loadResource = {
slot = "model"
}
}

component = org.eclipse.xtext.generator.GeneratorComponent {
register = com.avaloq.tools.ddk.check.TestLanguageStandaloneSetup {}
slot = 'model'
outlet = {
path = targetDir
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class CheckCfgJvmModelInferrer extends AbstractModelInferrer {

// Here you explain how your model is mapped to Java elements, by writing the actual translation code.
// An example based on the initial hellow world example could look like this:
// acceptor.accept(element.toClass("my.company.greeting.MyGreetings") [
// for (greeting : element.greetings) {
// members += greeting.toMethod(greeting.name, greeting.newTypeRef(typeof(String))) [
// it.body ['''
// return "Hello «greeting.name»";
// ''']
// ]
// }
// ])
// acceptor.accept(element.toClass("my.company.greeting.MyGreetings") [
// for (greeting : element.greetings) {
// members += greeting.toMethod(greeting.name, greeting.newTypeRef(typeof(String))) [
// it.body ['''
// return "Hello «greeting.name»";
// ''']
// ]
// }
// ])
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "http://www.avaloq.com/tools/ddk/xtext/expression/Expression"
// to Xtext

//expression returns [Expression e]:
// x=letExpression {$e=x;};
// x=letExpression {$e=x;};

Expression:
LetExpression | => CastedExpression | ChainExpression;
Expand All @@ -34,15 +34,15 @@ LetExpression:

//castedExpression returns [Expression e] :
// ('(' type ')' castedExpression)=>
// '(' t=type ')' x=chainExpression {$e = factory.createCast(t,x);}
// | x=chainExpression {$e=x;};
// '(' t=type ')' x=chainExpression {$e = factory.createCast(t,x);}
// | x=chainExpression {$e=x;};

CastedExpression:
'(' type=Type ')' target=Expression;


//chainExpression returns [Expression e] :
// x=ifExpression {$e=x;} ( '->' right=ifExpression {$e=factory.createChainExpression($e,right);})*;
// x=ifExpression {$e=x;} ( '->' right=ifExpression {$e=factory.createChainExpression($e,right);})*;

ChainExpression returns Expression:
ChainedExpression ({ChainExpression.first=current} '->' next=ChainedExpression)*;
Expand All @@ -52,8 +52,8 @@ ChainedExpression returns Expression:
IfExpressionKw | IfExpressionTri | SwitchExpression;

//ifExpression returns [Expression e] :
// x=switchExpression {$e=x;}('?' thenPart=switchExpression ':' elsePart=switchExpression {$e=factory.createIf($e,thenPart,elsePart);})?
//| 'if' condition=switchExpression 'then' thenPart=switchExpression ('else' elsePart=expression)? {$e=factory.createIf(condition,thenPart,elsePart);};
// x=switchExpression {$e=x;}('?' thenPart=switchExpression ':' elsePart=switchExpression {$e=factory.createIf($e,thenPart,elsePart);})?
//| 'if' condition=switchExpression 'then' thenPart=switchExpression ('else' elsePart=expression)? {$e=factory.createIf(condition,thenPart,elsePart);};

IfExpressionTri returns Expression:
OrExpression ({IfExpression.condition=current} '?' thenPart=ChainedExpression ':' elsePart=ChainedExpression)?;
Expand Down Expand Up @@ -83,54 +83,54 @@ Case:


//orExpression returns [Expression e] :
// x=andExpression {$e=x;} (name='||' r=andExpression {$e = factory.createBooleanOperation(id(name),$e,r);})*;
// x=andExpression {$e=x;} (name='||' r=andExpression {$e = factory.createBooleanOperation(id(name),$e,r);})*;

OrExpression returns Expression:
AndExpression ({BooleanOperation.left=current} operator='||' right=AndExpression)*;


//andExpression returns [Expression e] :
// x=impliesExpression {$e=x;} (name='&&' r=impliesExpression {$e = factory.createBooleanOperation(id(name),$e,r);})*;
//andExpression returns [Expression e] :
// x=impliesExpression {$e=x;} (name='&&' r=impliesExpression {$e = factory.createBooleanOperation(id(name),$e,r);})*;

AndExpression returns Expression:
ImpliesExpression ({BooleanOperation.left=current} operator='&&' right=ImpliesExpression)*;


//impliesExpression returns [Expression e] :
// x=relationalExpression {$e=x;} (name='implies' r=relationalExpression {$e = factory.createBooleanOperation(id(name),$e,r);})*;
// x=relationalExpression {$e=x;} (name='implies' r=relationalExpression {$e = factory.createBooleanOperation(id(name),$e,r);})*;

ImpliesExpression returns Expression:
RelationalExpression ({BooleanOperation.left=current} operator='implies' right=RelationalExpression)*;


//relationalExpression returns [Expression e] :
// x=additiveExpression {$e=x;}
// (name=('==' | '!=' | '>=' | '<=' | '>' | '<') r=additiveExpression {$e = factory.createBinaryOperation(id(name),$e,r);})*;
// x=additiveExpression {$e=x;}
// (name=('==' | '!=' | '>=' | '<=' | '>' | '<') r=additiveExpression {$e = factory.createBinaryOperation(id(name),$e,r);})*;

RelationalExpression returns Expression:
AdditiveExpression ({BooleanOperation.left=current} operator=('==' | '!=' | '>=' | '<=' | '>' | '<') right=AdditiveExpression)*;


//additiveExpression returns [Expression e] :
// x=multiplicativeExpression {$e=x;}
// x=multiplicativeExpression {$e=x;}
// (name=('+'| '-') r=multiplicativeExpression {$e = factory.createBinaryOperation(id(name),$e,r);})*;

AdditiveExpression returns Expression:
MultiplicativeExpression ({OperationCall.params+=current} name=('+' | '-') params+=MultiplicativeExpression)*;


//multiplicativeExpression returns [Expression e]:
// x=unaryExpression {$e=x;}
// (name=('*' | '/') r=unaryExpression {$e = factory.createBinaryOperation(id(name),$e,r);})*;
// x=unaryExpression {$e=x;}
// (name=('*' | '/') r=unaryExpression {$e = factory.createBinaryOperation(id(name),$e,r);})*;

MultiplicativeExpression returns Expression:
UnaryOrInfixExpression ({OperationCall.params+=current} name=('*' | '/') params+=UnaryOrInfixExpression)*;


//unaryExpression returns [Expression e] :
// x=infixExpression {$e=x;}
//| name='!' x=infixExpression {$e = factory.createOperationCall(id(name),x);}
//| name='-' x=infixExpression {$e = factory.createOperationCall(id(name),x);};
// x=infixExpression {$e=x;}
//| name='!' x=infixExpression {$e = factory.createOperationCall(id(name),x);}
//| name='-' x=infixExpression {$e = factory.createOperationCall(id(name),x);};

UnaryOrInfixExpression returns Expression:
UnaryExpression | InfixExpression;
Expand All @@ -140,7 +140,7 @@ UnaryExpression returns OperationCall:


//infixExpression returns [Expression e] :
// x=primaryExpression {$e=x;} ( '.' op=featureCall { if (op!=null) { op.setTarget($e);$e=op;}} )*;
// x=primaryExpression {$e=x;} ( '.' op=featureCall { if (op!=null) { op.setTarget($e);$e=op;}} )*;

// having support for fragments could avoid the redundancy at this point
InfixExpression returns Expression:
Expand All @@ -152,7 +152,7 @@ InfixExpression returns Expression:
)*;


//primaryExpression returns [Expression e] :
//primaryExpression returns [Expression e] :
// c=StringLiteral { $e = factory.createStringLiteral(id(c));}
//| x=featureCall {$e=x;}
//| x=booleanLiteral {$e=x;}
Expand Down Expand Up @@ -198,7 +198,7 @@ GlobalVarExpression:


//featureCall returns [FeatureCall e] :
// id1=identifier '(' (l=parameterList)? ')' {$e = factory.createOperationCall(id1,l);}
// id1=identifier '(' (l=parameterList)? ')' {$e = factory.createOperationCall(id1,l);}
//| t=type {$e=factory.createFeatureCall(t,null);}
//| x=collectionExpression {$e=x;};

Expand All @@ -212,15 +212,15 @@ OperationCall:
name=Identifier '(' (params+=Expression (',' params+=Expression)*)? ')';

//listLiteral returns [Expression e] :
// '{' (l=parameterList)? '}' {$e=factory.createListLiteral(l);};
// '{' (l=parameterList)? '}' {$e=factory.createListLiteral(l);};

ListLiteral:
{ListLiteral} '{' (elements+=Expression (',' elements+=Expression)*)? '}';


//constructorCall returns [Expression e] :
// 'new' t=simpleType
// {$e= factory.createConstructorCallExpression(t);};
// 'new' t=simpleType
// {$e= factory.createConstructorCallExpression(t);};

ConstructorCallExpression:
'new' type=SimpleType;
Expand Down Expand Up @@ -248,8 +248,8 @@ CollectionExpression:


//type returns [Identifier id] :
// a = collectionType {$id=a;}|
// b = simpleType {$id=b;};
// a = collectionType {$id=a;}|
// b = simpleType {$id=b;};

Type returns Identifier:
CollectionType | SimpleType;
Expand All @@ -264,8 +264,8 @@ CollectionType returns Identifier:


//simpleType returns [Identifier id] :
// x=identifier {$id=x;}
// (d='::' end=identifier {$id.append(id(d)); $id.append(end);})*;
// x=identifier {$id=x;}
// (d='::' end=identifier {$id.append(id(d)); $id.append(end);})*;

SimpleType returns Identifier:
id+=Identifier ('::' id+=Identifier)*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ const String SOME_STRING = "";
const int SOME_INT = 2;

Greeting {
rule : column 10 before, column 0 after;
"Hello" : linewrap 1 2 3 before;
["hello", "HELLO", "you"] : increment before, decrement after;
("Hello" "!") : right.no_space before, left.no_linewrap around;
"Hello" : right_padding 5 after;
rule : column 10 before, column 0 after;
"Hello" : linewrap 1 2 3 before;
["hello", "HELLO", "you"] : increment before, decrement after;
("Hello" "!") : right.no_space before, left.no_linewrap around;
"Hello" : right_padding 5 after;
}

Person {
}

Person {
"," : no_space before;
group 1 => group 1 : linewrap before;
=firstName(2,2) : linewrap before;
=^left : linewrap before;
group 1 => group 1 {
@ID(1,2) : linewrap before;
=firstName : increment 3 before;
=lastName : decrement 2 before;
"," : no_space before;
}
=age : space " " before;
@ID(3,3) : increment before;
"," : no_space before;
group 1 => group 1 : linewrap before;
=firstName(2,2) : linewrap before;
=^left : linewrap before;
group 1 => group 1 {
@ID(1,2) : linewrap before;
=firstName : increment 3 before;
=lastName : decrement 2 before;
"," : no_space before;
}
=age : space " " before;
@ID(3,3) : increment before;
}

Days {
rule : linewrap before;
"Monday" : space " " after, offset 2 after;
rule : linewrap before;
"Monday" : space " " after, offset 2 after;
}

STRING {
rule : no_space around;
rule : no_space around;
}

* {
["Keywords"] : no_linewrap before;
[ID, INT] : space " " around;
["Keywords"] : no_linewrap before;
[ID, INT] : space " " around;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ generate a "http://www.example.org/A"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

RuleA:
a=INT ('-' b=STRING | ('-'c=ID ('-'d=INT | '-'e=STRING)))? ';';
a=INT ('-' b=STRING | ('-'c=ID ('-'d=INT | '-'e=STRING)))? ';';

RuleAA:
a=RuleA ';';
a=RuleA ';';
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ generate b "http://www.example.org/B"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

RuleB:
a=INT | b=STRING | (c=ID (d=INT | e=STRING)) ';';
a=INT | b=STRING | (c=ID (d=INT | e=STRING)) ';';
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ generate c "http://www.example.org/C"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

RuleC:
a=INT | b=STRING | (c=ID (d=INT | e=STRING)) ';';
a=INT | b=STRING | (c=ID (d=INT | e=STRING)) ';';
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BundleVersionStripperFragment extends AbstractXtextGeneratorFragment {
}

override generate() {
projectConfig.enabledProjects.filter(typeof(IBundleProjectConfig)).map[manifest].filterNull.forEach[stripBundleVersions]
projectConfig.enabledProjects.filter(typeof(IBundleProjectConfig)).map[manifest].filterNull.forEach[stripBundleVersions]
}

def stripBundleVersions(ManifestAccess manifest) {
Expand Down
Loading
Loading