Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 51641d290e713098f7e6222be97d61014143751f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*******************************************************************************
 * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * CONTRIBUTORS:
 * 		Eyrak Paen (initial contribution)
 * 
 *******************************************************************************/
module org.eclipse.etrice.core.common.GenerateBase

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*
import org.eclipse.xtext.resource.XtextResourceSet

var grammarURI = "classpath:/org/eclipse/etrice/core/common/Base.xtext"
var fileExtensions = "__etbase"

var projectName = "org.eclipse.etrice.core.common"
var runtimeProject = "../${projectName}"
var generateXtendStub = true

var testgrammarURI = "classpath:/org/eclipse/etrice/core/common/BaseTest.xtext"
var testgrammarFileExtensions = "etbase"

Workflow {
    bean = StandaloneSetup {
    	scanClassPath = true
    	platformUri = "${runtimeProject}/.."
    	// The following two lines can be removed, if Xbase is not used.
    	// registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
    	// registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
    }
    
    
	/*bean = StandaloneSetup {
		resourceSet = XtextResourceSet : baseTestGrammarResourceSet {}
		registerEcoreFile = "platform:/resource/${projectName}/model/Base.ecore"
	}*/
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}/src-gen"
    }
    
    component = DirectoryCleaner {
    	directory = "${runtimeProject}.ui/src-gen"
    }
    
    component = DirectoryCleaner {
    	directory = "../../tests/${projectName}.tests/src-gen"
    }
    
    component = Generator {
    	pathRtProject = runtimeProject
    	pathUiProject = "${runtimeProject}.ui"
    	pathTestProject = "../../tests/${projectName}.tests"
    	projectNameRt = projectName
    	projectNameUi = "${projectName}.ui"
    	language = auto-inject {
    		uri = grammarURI
    
    		// Java API to access grammar elements (required by several other fragments)
    		fragment = grammarAccess.GrammarAccessFragment auto-inject {}
    
    		// generates Java API for the generated EPackages
    		fragment = ecore.EcoreGeneratorFragment auto-inject {
    		// referencedGenModels = "
    		//  platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,
    		//  platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel
    		// "
    		}
    
    		// the old serialization component
    		// fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}    
    
    		// serializer 2.0
    		fragment = serializer.SerializerFragment auto-inject {
    			generateStub = false
    		}
    
    		// a custom ResourceFactory for use with EMF
    		fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
    
    		// The antlr parser generator fragment.
    		fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
    		//  options = {
    		//      backtrack = true
    		//  }
    		}
    
//			JavaValidatorFragment is used by the eTrice subgrammars instead of xtend-based Validation 
//    		// Xtend-based API for validation
//    		fragment = validation.ValidatorFragment auto-inject {
//    		//    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
//    		//    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
//    		}
    		
    		// Added for compatibility with existing eTrice subgrammars
    		fragment = validation.JavaValidatorFragment {}
    
    		// old scoping and exporting API
    		// fragment = scoping.ImportURIScopingFragment auto-inject {}
    		// fragment = exporting.SimpleNamesFragment auto-inject {}
    
    		// scoping and exporting API
    		fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
    		fragment = exporting.QualifiedNamesFragment auto-inject {}
    		fragment = builder.BuilderIntegrationFragment auto-inject {}
    
    		// generator API
    		fragment = generator.GeneratorFragment auto-inject {}
    
    		// formatter API
    		fragment = formatting2.Formatter2Fragment auto-inject {}
    
    		// labeling API
    		fragment = labeling.LabelProviderFragment auto-inject {}
    
    		// outline API
    		fragment = outline.OutlineTreeProviderFragment auto-inject {}
    		fragment = outline.QuickOutlineFragment auto-inject {}
    
    		// quickfix API
    		fragment = quickfix.QuickfixProviderFragment auto-inject {}

//			JavaBasedContentAssistFragment used by eTrice sub-grammars instead of ContentAssistFragment
//    		// content assist API
//    		fragment = contentAssist.ContentAssistFragment auto-inject {}
    
    		// content assist API
            fragment = contentAssist.JavaBasedContentAssistFragment {}
            
    		// generates a more lightweight Antlr parser and lexer tailored for content assist
    		fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {}
    		
    		// rename refactoring
    		fragment = refactoring.RefactorElementNameFragment auto-inject {}
    	}
    	
    	language = auto-inject {
    		uri = testgrammarURI
    		fileExtensions = testgrammarFileExtensions
    
    		// Java API to access grammar elements (required by several other fragments)
    		fragment = grammarAccess.GrammarAccessFragment auto-inject {}
    
    		// generates Java API for the generated EPackages
    		fragment = ecore.EcoreGeneratorFragment auto-inject {}
    		
    		// serializer 2.0
    		fragment = serializer.SerializerFragment auto-inject {
    			generateStub = false
    		}
    		
    		// scoping and exporting API
    		fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
    		fragment = exporting.QualifiedNamesFragment auto-inject {}
    		fragment = builder.BuilderIntegrationFragment auto-inject {}
    
    		// a custom ResourceFactory for use with EMF
    		fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
    
    		// The antlr parser generator fragment.
    		fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {}
    		
    		// generates junit test support classes into Generator#pathTestProject
    		fragment = junit.Junit4Fragment auto-inject {}
    	}
    }
}

Back to the top