Skip to content

Commit f5898b3

Browse files
committed
Migrate the Scope generator from Xtend onto Xbase + JvmModelInferrer
The com.avaloq.tools.ddk.xtext.scope plugin compiled the embedded Expression DSL to Java through expression.generator.CodeGenerationX / CompilationContext, whose type system is the legacy classic Xtend runtime (org.eclipse.xtend.expression.*, org.eclipse.xtend.typesystem.emf.*). That was the only reason the plugin required those bundles. This PR replaces the IGenerator2-based ScopeGenerator with an Xbase JvmModelInferrer, introduces a self-contained (Xtend-free) expression-translation layer, deletes the classic-Xtend execution context, and removes org.eclipse.xtend and org.eclipse.xtend.typesystem.emf from the scope plugin. Key decisions Scope generation moves to a JvmModelInferrer + Xbase JvmModelGenerator Same pattern as Format/Check; lets the standard XbaseCompiler emit the provider classes. The *ScopeProvider/*ScopeNameProvider are now inferred JVM types rather than hand-templated .java. Hybrid expression backend: an Xbase translator + a string compiler fallback String + concatenation (very common in .scope) has no operator_plus in xbase.lib — Xbase special-cases it in its compiler — so it can't be pre-linked as an XExpression tree. We translate to Xbase what maps cleanly and fall back to a faithful port of the legacy string output for +, arithmetic and relational operators. Model-type names resolve via imported EPackages, not the classpath In real sources, (Cast)x / typeSelect(T) / T.isInstance(x) name EMF model types (FormDef, ILogicalTable, intfdef::AlternatingGroup), not Java FQNs. javaType resolves them through the model's imported EPackages → GenModelUtilX.instanceClassName, exactly as the legacy EmfRegistryMetaModel did. findDeclaredType would fail on these. .ext (JAVA extension) support dropped Scope sources no longer reference Xtend extension files; removed the .ext-reading validation and the isJavaExtensionCall/isExtension generator branches. factory becomes a direct Xbase static call Must be written Type.method(args); the generator resolves the type to a JvmDeclaredType.qualifiedName and emits the static call. Bare factory foo() is no longer supported. Downstream projects need to adapt their .scope/.ext sources.
1 parent 839bfdd commit f5898b3

126 files changed

Lines changed: 384335 additions & 54382 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

com.avaloq.tools.ddk.checkcfg.core/src/com/avaloq/tools/ddk/checkcfg/jvmmodel/CheckCfgJvmModelInferrer.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717

1818
import com.google.inject.Inject;
1919

20+
2021
/**
21-
* <p>Infers a JVM model from the source model.</p>
22-
*
23-
* <p>The JVM model should contain all elements that would appear in the Java code
24-
* which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
22+
* <p>
23+
* Infers a JVM model from the source model.
24+
* </p>
25+
* <p>
26+
* The JVM model should contain all elements that would appear in the Java code
27+
* which is generated from the source model. Other models link against the JVM model rather than the source model.
28+
* </p>
2529
*/
2630
@SuppressWarnings("nls")
2731
public class CheckCfgJvmModelInferrer extends AbstractModelInferrer {
@@ -32,18 +36,8 @@ public class CheckCfgJvmModelInferrer extends AbstractModelInferrer {
3236
@Override
3337
public void _infer(final EObject element, final IJvmDeclaredTypeAcceptor acceptor, final boolean preIndexingPhase) {
3438
// Infer dummy class as type resolver expects at least one root Java type
35-
acceptor.accept(jvmTypesBuilder.toClass(element, "xxxyyyzzz.dummy.class.name", it -> {}));
39+
acceptor.accept(jvmTypesBuilder.toClass(element, "xxxyyyzzz.dummy.class.name", it -> {
40+
}));
3641
}
3742

38-
// Here you explain how your model is mapped to Java elements, by writing the actual translation code.
39-
// An example based on the initial hellow world example could look like this:
40-
// acceptor.accept(element.toClass("my.company.greeting.MyGreetings") [
41-
// for (greeting : element.greetings) {
42-
// members += greeting.toMethod(greeting.name, greeting.newTypeRef(typeof(String))) [
43-
// it.body ['''
44-
// return "Hello «greeting.name»";
45-
// ''']
46-
// ]
47-
// }
48-
// ])
4943
}
Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
3-
<booleanAttribute key="append.args" value="true"/>
4-
<booleanAttribute key="askclear" value="true"/>
5-
<booleanAttribute key="automaticAdd" value="true"/>
6-
<booleanAttribute key="automaticValidate" value="false"/>
7-
<stringAttribute key="bad_container_name" value="/com.avaloq.tools.ddk.sample.helloworld/.launch/"/>
8-
<stringAttribute key="bootstrap" value=""/>
9-
<stringAttribute key="checked" value="[NONE]"/>
10-
<booleanAttribute key="clearConfig" value="false"/>
11-
<booleanAttribute key="clearws" value="false"/>
12-
<booleanAttribute key="clearwslog" value="false"/>
13-
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Launch Runtime Eclipse"/>
14-
<booleanAttribute key="default" value="true"/>
15-
<booleanAttribute key="includeOptional" value="true"/>
16-
<stringAttribute key="location" value="${workspace_loc}/../runtime-EclipseXtext"/>
17-
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
18-
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
19-
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
20-
</listAttribute>
21-
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
22-
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
23-
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
24-
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m"/>
25-
<stringAttribute key="pde.version" value="3.3"/>
26-
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
27-
<booleanAttribute key="show_selected_only" value="false"/>
28-
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
29-
<booleanAttribute key="tracing" value="false"/>
30-
<booleanAttribute key="useCustomFeatures" value="false"/>
31-
<booleanAttribute key="useDefaultConfig" value="true"/>
32-
<booleanAttribute key="useDefaultConfigArea" value="true"/>
33-
<booleanAttribute key="useProduct" value="true"/>
34-
<booleanAttribute key="usefeatures" value="false"/>
3+
<booleanAttribute key="append.args" value="true"/>
4+
<booleanAttribute key="askclear" value="true"/>
5+
<booleanAttribute key="automaticAdd" value="true"/>
6+
<booleanAttribute key="automaticValidate" value="false"/>
7+
<stringAttribute key="bad_container_name" value="/com.avaloq.tools.ddk.sample.helloworld/.launch/"/>
8+
<stringAttribute key="bootstrap" value=""/>
9+
<stringAttribute key="checked" value="[NONE]"/>
10+
<booleanAttribute key="clearConfig" value="false"/>
11+
<booleanAttribute key="clearws" value="false"/>
12+
<booleanAttribute key="clearwslog" value="false"/>
13+
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Launch Runtime Eclipse"/>
14+
<booleanAttribute key="default" value="true"/>
15+
<booleanAttribute key="includeOptional" value="true"/>
16+
<stringAttribute key="location" value="${workspace_loc}/../runtime-EclipseXtext"/>
17+
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
18+
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
19+
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
20+
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
21+
</listAttribute>
22+
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
23+
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
24+
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
25+
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
26+
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
27+
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx4g"/>
28+
<stringAttribute key="pde.version" value="3.3"/>
29+
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
30+
<booleanAttribute key="show_selected_only" value="false"/>
31+
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
32+
<booleanAttribute key="tracing" value="false"/>
33+
<booleanAttribute key="useCustomFeatures" value="false"/>
34+
<booleanAttribute key="useDefaultConfig" value="true"/>
35+
<booleanAttribute key="useDefaultConfigArea" value="true"/>
36+
<booleanAttribute key="useProduct" value="true"/>
37+
<booleanAttribute key="usefeatures" value="false"/>
3538
</launchConfiguration>

com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/GenerateExport.mwe2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Workflow {
5353
uriMap = {from = "platform:/plugin/" to = "platform:/resource/"}
5454
registerGenModelFile = "platform:/resource/org.eclipse.xtext/org/eclipse/xtext/Xtext.genmodel"
5555
registerGenModelFile = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
56+
registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
57+
registerGenModelFile = "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
5658
registerGenModelFile = "platform:/resource/com.avaloq.tools.ddk.xtext.expression/metamodel/com/avaloq/tools/ddk/xtext/expression/Expression.genmodel"
5759
registerEcoreFile = "${metamodelBase}/${modelDirectory}/${baseName}.ecore"
5860
registerGenModelFile = "${metamodelBase}/${modelDirectory}/${baseName}.genmodel"
@@ -153,6 +155,11 @@ Workflow {
153155
// rename refactoring
154156
// fragment = refactoring.RefactorElementNameFragment {}
155157

158+
// Xbase support
159+
fragment = org.eclipse.xtext.xtext.generator.types.TypesGeneratorFragment2 {}
160+
fragment = org.eclipse.xtext.xtext.generator.xbase.XtypeGeneratorFragment2 {}
161+
fragment = org.eclipse.xtext.xtext.generator.xbase.XbaseGeneratorFragment2 {}
162+
156163
// Code generator
157164
fragment = org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2 {
158165
generateJavaMain = false

com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/GenerateExpression.mwe2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Workflow {
4242
uriMap = {from = "platform:/plugin/" to = "platform:/resource/"}
4343
registerGenModelFile = "platform:/resource/org.eclipse.xtext/org/eclipse/xtext/Xtext.genmodel"
4444
registerGenModelFile = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
45+
registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
46+
registerGenModelFile = "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
4547
registerEcoreFile = "${metamodelBase}/${modelDirectory}/${baseName}.ecore"
4648
registerGenModelFile = "${metamodelBase}/${modelDirectory}/${baseName}.genmodel"
4749
}
@@ -126,6 +128,11 @@ Workflow {
126128
// content assist API
127129
fragment = org.eclipse.xtext.xtext.generator.ui.contentAssist.ContentAssistFragment2 {}
128130

131+
// Xbase support
132+
fragment = org.eclipse.xtext.xtext.generator.types.TypesGeneratorFragment2 {}
133+
fragment = org.eclipse.xtext.xtext.generator.xbase.XtypeGeneratorFragment2 {}
134+
fragment = org.eclipse.xtext.xtext.generator.xbase.XbaseGeneratorFragment2 {}
135+
129136
fragment = BundleVersionStripperFragment {
130137
bundle = "org.antlr.runtime"
131138
bundle = "org.eclipse.xtext.xbase.lib"

com.avaloq.tools.ddk.workflow/src/com/avaloq/tools/ddk/workflow/GenerateScope.mwe2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Workflow {
5353
uriMap = {from = "platform:/plugin/" to = "platform:/resource/"}
5454
registerGenModelFile = "platform:/resource/org.eclipse.xtext/org/eclipse/xtext/Xtext.genmodel"
5555
registerGenModelFile = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
56+
registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
57+
registerGenModelFile = "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
5658
registerGenModelFile = "platform:/resource/com.avaloq.tools.ddk.xtext.expression/metamodel/com/avaloq/tools/ddk/xtext/expression/Expression.genmodel"
5759
registerEcoreFile = "${metamodelBase}/${modelDirectory}/${baseName}.ecore"
5860
registerGenModelFile = "${metamodelBase}/${modelDirectory}/${baseName}.genmodel"
@@ -152,6 +154,11 @@ Workflow {
152154
// rename refactoring
153155
// fragment = refactoring.RefactorElementNameFragment {}
154156

157+
// Xbase support
158+
fragment = org.eclipse.xtext.xtext.generator.types.TypesGeneratorFragment2 {}
159+
fragment = org.eclipse.xtext.xtext.generator.xbase.XtypeGeneratorFragment2 {}
160+
fragment = org.eclipse.xtext.xtext.generator.xbase.XbaseGeneratorFragment2 {}
161+
155162
// Code generator
156163
fragment = org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2 {
157164
generateJavaMain = false

com.avaloq.tools.ddk.xtext.export.ide/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ Export-Package: com.avaloq.tools.ddk.xtext.export.ide.contentassist.antlr,
1010
com.avaloq.tools.ddk.xtext.export.ide.contentassist.antlr.internal
1111
Require-Bundle: org.antlr.runtime,
1212
org.eclipse.xtext.ide,
13-
com.avaloq.tools.ddk.xtext.export
13+
com.avaloq.tools.ddk.xtext.export,
14+
org.eclipse.xtext.xbase.ide
1415
Automatic-Module-Name: com.avaloq.tools.ddk.xtext.export.ide

com.avaloq.tools.ddk.xtext.export.ide/src-gen/com/avaloq/tools/ddk/xtext/export/ide/AbstractExportIdeModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
import com.avaloq.tools.ddk.xtext.export.ide.contentassist.antlr.internal.InternalExportLexer;
88
import com.google.inject.Binder;
99
import com.google.inject.name.Names;
10-
import org.eclipse.xtext.ide.DefaultIdeModule;
1110
import org.eclipse.xtext.ide.LexerIdeBindings;
1211
import org.eclipse.xtext.ide.editor.contentassist.IProposalConflictHelper;
1312
import org.eclipse.xtext.ide.editor.contentassist.antlr.AntlrProposalConflictHelper;
1413
import org.eclipse.xtext.ide.editor.contentassist.antlr.IContentAssistParser;
1514
import org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer;
15+
import org.eclipse.xtext.xbase.ide.DefaultXbaseIdeModule;
1616

1717
/**
1818
* Manual modifications go to {@link ExportIdeModule}.
1919
*/
2020
@SuppressWarnings("all")
21-
public abstract class AbstractExportIdeModule extends DefaultIdeModule {
21+
public abstract class AbstractExportIdeModule extends DefaultXbaseIdeModule {
2222

2323
// contributed by org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2
2424
public void configureContentAssistLexer(Binder binder) {

0 commit comments

Comments
 (0)