Skip to content
Merged
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
16 changes: 8 additions & 8 deletions XPlus.setup
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<setupTask
xsi:type="setup:EclipseIniTask"
option="-Doomph.redirection.XPlus"
value="=https://raw.githubusercontent.com/TNO/XPlus/main/XPlus.setup->${git.clone.XPlus.location|uri}/XPlus.setup"
value="=https://raw.githubusercontent.com/TNO/XPlus/develop/XPlus.setup->${git.clone.XPlus.location|uri}/XPlus.setup"
vm="true">
<description>Set an Oomph redirection system property to redirect the logical location of this setup to its physical location in the Git clone.</description>
</setupTask>
Expand Down Expand Up @@ -116,13 +116,13 @@
value="false"/>
</setupTask>
<setupTask
xsi:type="setup:CompoundTask"
name="Java Development">
<setupTask
xsi:type="setup:PreferenceTask"
key="org.eclipse.jdt.core.compiler.codegen.methodParameters"
value="generate"/>
</setupTask>
xsi:type="setup:CompoundTask"
name="Java Development">
<setupTask
xsi:type="setup:PreferenceTask"
key="org.eclipse.jdt.core.compiler.codegen.methodParameters"
value="generate"/>
</setupTask>
<setupTask
xsi:type="setup:CompoundTask"
name="org.eclipse.debug.ui">
Expand Down
18 changes: 18 additions & 0 deletions bundles/nl.esi.xplus.doc.design/GenerateGrammarsDiagram.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/nl.esi.xplus.doc.design/xtend-gen/nl/esi/xplus/doc/design/GenerateGrammarsDiagram.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="nl.esi.xplus.doc.design.GenerateGrammarsDiagram"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="nl.esi.xplus.doc.design"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${project_loc}/target/meta-models ${project_loc}/target/adoc-gen/xtext-grammars.plantuml"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="nl.esi.xplus.doc.design"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ For more information about the reuse of existing grammars, please read the (i.e.

include::{gendocdir}/xtext-grammars.plantuml[]

artifact nl.esi.xtext.types.Types #white/aqua

@enduml
....

Expand Down
119 changes: 70 additions & 49 deletions bundles/nl.esi.xplus.doc.design/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,64 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-ecore-models</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<useSubDirectoryPerArtifact>true</useSubDirectoryPerArtifact>
<stripVersion>true</stripVersion>
<stripClassifier>true</stripClassifier>
<stripType>true</stripType>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<includeGroupIds>nl.esi.xplus</includeGroupIds>
<includes>META-INF/MANIFEST.MF,model/generated/*.*,**/*.xtext</includes>
<outputDirectory>${project.build.directory}/meta-models/</outputDirectory>
</configuration>
</execution>
<execution>
<id>unpack-adoc-resources</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<includes>adoc/**</includes>
<outputDirectory>${project.build.directory}/adoc-ext</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<!-- Start: Preparing EcoreDoc and GenerateGrammarsDiagram -->
<!-- Both cannot handle ecore references based on platform:/resource/ uris yet -->
<!-- Workaround: Process all generated ecore models and change uris to relative uris -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<configuration>
<target>
<replace token="platform:/resource/" value="../../../"
dir="${project.build.directory}/meta-models">
<include name="*/model/generated/*.*" />
</replace>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- End: Preparing EcoreDoc and GenerateGrammarsDiagram -->

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
Expand All @@ -57,7 +102,7 @@
<mainClass>nl.esi.xplus.doc.design.GenerateGrammarsDiagram</mainClass>
<includePluginDependencies>true</includePluginDependencies>
<arguments>
<argument>${project.basedir}/..</argument>
<argument>${project.build.directory}/meta-models</argument>
<argument>${project.build.directory}/adoc-gen/xtext-grammars.plantuml</argument>
</arguments>
</configuration>
Expand All @@ -73,54 +118,6 @@
</dependencies>
</plugin>

<!-- Start: Preparing EcoreDoc -->
<!-- EcoreDoc cannot handle ecore references based on platform:/resource/ uris yet -->
<!-- Workaround: Copy all generated ecore models and change uris to relative uris -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.basedir}/..</directory>
<includes>
<include>*/model/generated/*.ecore</include>
</includes>
</resource>
</resources>
<outputDirectory>${project.build.directory}/meta-models</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<configuration>
<target>
<replace token="platform:/resource/" value="../../../"
dir="${project.build.directory}/meta-models">
<include name="**/*.ecore" />
</replace>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- End: Preparing EcoreDoc -->

<plugin>
<groupId>com.altran.general.emf.ecoredoc</groupId>
<artifactId>ecoredoc-maven-plugin</artifactId>
Expand Down Expand Up @@ -291,6 +288,30 @@
</additionalFileSets>
</configuration>
</plugin>

<plugin>
<!--The Xtext builder reports errors on the copied xtext files,
so we'll clean them up immediately after the build-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>remove-meta-models</id>
<phase>package</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${project.build.directory}/meta-models/</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import org.eclipse.xtend.lib.annotations.Accessors

class GenerateGrammarsDiagram {
static val TERMINALS_GRAMMAR = new Grammar => [
bundle = 'org.eclipse.xtext.common'
bundle = 'org.eclipse.xtext'
name = 'org.eclipse.xtext.common.Terminals'
]

static val GRAMMAR_PATTERN = Pattern.compile('''^grammar\s+((\w+\.)*\w+)\s+with\s+((\w+\.)*\w+)''')
static val GRAMMAR_PATTERN = Pattern.compile('''^grammar\s+((\w+\.)*\w+)(\s+with\s+((\w+\.)*\w+))?(\s+hidden\s*\((\w+(,\s*\w+)*)\))?\s*''')
static val GENERATE_PATTERN = Pattern.compile('''^generate\s+(\w+)\s+"([^"]+)"''')
static val IMPORT_PATTERN = Pattern.compile('''^import\s+"([^"]+)"\s+as\s+(\w+)''')
static val FILE_EXTENSIONS_PATTERN = Pattern.compile('''^\s*fileExtensions\s+=\s+"([^"]+)"''')
static val FILE_EXTENSIONS_PATTERN = Pattern.compile('''^.*fileExtensions\s*=\s*"([^"]+)".*''')

def static void main(String[] args) {
if (args.size != 2) {
Expand All @@ -39,12 +39,14 @@ class GenerateGrammarsDiagram {
val outputFile = Path.of(args.get(1))
println('''Generate diagram: «bundlesDir» => «outputFile»''')

val xtextFiles = Files.find(bundlesDir, Integer.MAX_VALUE, [$0.toString.endsWith('.xtext')]).toIterable
val xtextFiles = Files.find(bundlesDir, Integer.MAX_VALUE, [$1.regularFile && $0.toString.endsWith('.xtext')]).toIterable
val grammars = xtextFiles.map[createGrammar(bundlesDir)].filterNull.toList
grammars += TERMINALS_GRAMMAR
if (!grammars.exists[name == 'org.eclipse.xtext.common.Terminals']) {
grammars += TERMINALS_GRAMMAR
}
// Reduce grammar dependencies
grammars.forEach[
bundleUses.removeAll(getParentGrammar(grammars)?.bundle)
bundleUses.removeAll(getParentGrammars(grammars).map[bundle])
grammarUses.removeAll(getParentGrammars(grammars).map[uri])
]
grammars.sortInplace[a, b |
Expand Down Expand Up @@ -97,24 +99,26 @@ class GenerateGrammarsDiagram {
'''

def static Grammar createGrammar(Path xtextFile, Path bundlesDir) {
if (xtextFile.contains(Path.of('target')) || xtextFile.contains(Path.of('bin'))) {
return null
}
val fileName = com.google.common.io.Files.getNameWithoutExtension(xtextFile.fileName.toString)
val xtextLines = Files.lines(xtextFile).toIterable
val mwe2Lines = Files.lines(xtextFile.resolveSibling('''Generate«fileName».mwe2''')).toIterable
val bundlePath = xtextFile.getName(bundlesDir.nameCount)

val xtextLines = Files.lines(xtextFile).toIterable
val genmodel = bundlesDir.resolve(bundlePath).resolve('''model/generated/«fileName».genmodel''')
val fileExtensions = if (Files.isRegularFile(genmodel)) {
val genmodelLines = Files.lines(genmodel).toIterable
genmodelLines.matchAndReturn(FILE_EXTENSIONS_PATTERN, '$1').head
}
val manifest = new Manifest(bundlesDir.resolve(bundlePath).resolve('META-INF/MANIFEST.MF').read)
val requiredBundles = manifest.mainAttributes.getValue('Require-Bundle')

return new Grammar => [
bundle = bundlePath.toString
name = xtextLines.matchAndReturn(GRAMMAR_PATTERN, '$1').head
parent = xtextLines.matchAndReturn(GRAMMAR_PATTERN, '$3').head
uri = xtextLines.matchAndReturn(GENERATE_PATTERN, '$2').head
grammarUses += xtextLines.matchAndReturn(IMPORT_PATTERN, '$1')
bundleUses += requiredBundles.split(',').map[split(';').head]
fileExtensions = mwe2Lines.matchAndReturn(FILE_EXTENSIONS_PATTERN, '$1').head
return new Grammar => [ g |
g.bundle = bundlePath.toString
g.name = xtextLines.matchAndReturn(GRAMMAR_PATTERN, '$1').head
g.parent = xtextLines.matchAndReturn(GRAMMAR_PATTERN, '$4').head
g.uri = xtextLines.matchAndReturn(GENERATE_PATTERN, '$2').head
g.grammarUses += xtextLines.matchAndReturn(IMPORT_PATTERN, '$1')
g.bundleUses += requiredBundles.split(',').map[split(';').head]
g.fileExtensions = fileExtensions
]
}

Expand All @@ -137,14 +141,13 @@ class GenerateGrammarsDiagram {
def Set<Grammar> getParentGrammars(Iterable<Grammar> grammars) {
val parents = newLinkedHashSet
var parent = this.getParentGrammar(grammars)
while (parent !== null) {
parents += parent
while (parent !== null && parents.add(parent)) {
parent = parent.getParentGrammar(grammars)
}
return parents
}

def Grammar getParentGrammar(Iterable<Grammar> grammars) {
def private Grammar getParentGrammar(Iterable<Grammar> grammars) {
return grammars.findFirst[g | g.name == this.parent]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,4 @@ Operators are evaluated in the following order (highest to lowest):
* Operator associativity: most operators are left-associative; the power operator `^` is right-associative.
* Variables can be declared with optional initialization: `Type name = expression` or just `Type name`.

NOTE: When invoking functions with custom Java types, `IExpressionConverter` instances are evaluated in order until one successfully converts the argument. The first successful conversion is used. This allows custom converters to handle specific types while falling back to default converters for built-in types. See <<how-to-add-a-function-library>> for details on implementing custom converters.
NOTE: When invoking functions with custom Java types, `IExpressionConverter` instances are evaluated in order until one successfully converts the argument. The first successful conversion is used. This allows custom converters to handle specific types while falling back to default converters for built-in types. See <<how-to-add-an-expression-function-library>> for details on implementing custom converters.
2 changes: 1 addition & 1 deletion bundles/nl.esi.xtext.launch/Maven Re-build.launch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<intAttribute key="M2_COLORS" value="0"/>
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="verify -fae"/>
<stringAttribute key="M2_GOALS" value="verify"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
Expand Down
25 changes: 25 additions & 0 deletions bundles/nl.esi.xtext.launch/Maven Validate.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<intAttribute key="M2_COLORS" value="0"/>
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="validate"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
<listAttribute key="M2_PROPERTIES"/>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
<intAttribute key="M2_THREADS" value="1"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<stringAttribute key="M2_USER_SETTINGS" value=""/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="${workspace_loc:/nl.esi.xplus.root}/mvn.log"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<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/"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="--add-opens java.base/java.lang=ALL-UNNAMED"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc:nl.esi.xplus.root}"/>
</launchConfiguration>
Loading
Loading