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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<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.PROGRAM_ARGUMENTS" value="${project_loc}/target/meta-models ${project_loc}/target/adoc-gen/xtext-grammars.plantuml nl.esi."/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="nl.esi.xplus.doc.design"/>
</launchConfiguration>
2 changes: 1 addition & 1 deletion bundles/nl.esi.xplus.doc.design/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<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>
Expand Down Expand Up @@ -104,6 +103,7 @@
<arguments>
<argument>${project.build.directory}/meta-models</argument>
<argument>${project.build.directory}/adoc-gen/xtext-grammars.plantuml</argument>
<argument>nl.esi.</argument>
</arguments>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,37 @@ import java.util.stream.Stream
import org.eclipse.xtend.lib.annotations.Accessors

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

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('''^.*fileExtensions\s*=\s*"([^"]+)".*''')

def static void main(String[] args) {
if (args.size != 2) {
System.err.println('Expected two arguments: [bundles_directory] [output-file]')
if (args.size < 2 || args.size > 3) {
System.err.println('Usage: <bundles_directory> <output-file> [<includes>]')
System.err.println()
System.err.println('includes\tA comma separated list of bundle prefixes to include')
System.exit(1)
}
val bundlesDir = Path.of(args.get(0)).toRealPath()
val outputFile = Path.of(args.get(1))
println('''Generate diagram: «bundlesDir» => «outputFile»''')

val xtextFiles = Files.find(bundlesDir, Integer.MAX_VALUE, [$1.regularFile && $0.toString.endsWith('.xtext')]).toIterable
val includes = args.length > 2 ? args.get(2).split(',').map[trim]
println('''Generate diagram: «bundlesDir» «includes» => «outputFile»''')

val xtextFiles = Files.find(bundlesDir, Integer.MAX_VALUE, [ path, attrs |
val relativePath = bundlesDir.relativize(path).toString
val included = includes.isNullOrEmpty || includes.exists[include | relativePath.startsWith(include)]
return included && attrs.regularFile && relativePath.endsWith('.xtext')
]).toIterable
val grammars = xtextFiles.map[createGrammar(bundlesDir)].filterNull.toList
if (!grammars.exists[name == 'org.eclipse.xtext.common.Terminals']) {
grammars += TERMINALS_GRAMMAR
if (grammars.exists[parent == TERMINALS_GRAMMAR__NAME] && !grammars.exists[name == TERMINALS_GRAMMAR__NAME]) {
grammars += new Grammar => [
bundle = TERMINALS_GRAMMAR__BUNDLE
name = TERMINALS_GRAMMAR__NAME
]
}
// Reduce grammar dependencies
grammars.forEach[
Expand Down
2 changes: 1 addition & 1 deletion bundles/nl.esi.xtext.launch/Maven Build.launch
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<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"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="true"/>
<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"/>
Expand Down
2 changes: 1 addition & 1 deletion bundles/nl.esi.xtext.launch/Maven Doc-Build.launch
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<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"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="true"/>
<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"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<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"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="true"/>
<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"/>
Expand Down
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 @@ -12,7 +12,7 @@
<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"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="true"/>
<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"/>
Expand Down
2 changes: 1 addition & 1 deletion bundles/nl.esi.xtext.launch/Maven Validate.launch
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<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"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="true"/>
<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"/>
Expand Down
Loading