extends configurability of generator

This commit is contained in:
Eyck Jentzsch 2022-10-24 20:18:49 +02:00
parent 1c9c0ee340
commit 1d2384257e
19 changed files with 826 additions and 684 deletions

View File

@ -1,466 +1,510 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?> <?eclipse version="3.0"?>
<plugin> <plugin>
<extension <extension
point="org.eclipse.ui.editors"> point="org.eclipse.ui.editors">
<editor <editor
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor" contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
default="true" default="true"
extensions="rdl" extensions="rdl"
id="com.minres.rdl.RDL" id="com.minres.rdl.RDL"
name="RDL Editor"> name="RDL Editor">
</editor> </editor>
</extension> </extension>
<extension <extension
point="org.eclipse.ui.handlers"> point="org.eclipse.ui.handlers">
<handler <handler
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration"> commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
<activeWhen> <activeWhen>
<reference <reference
definitionId="com.minres.rdl.RDL.Editor.opened"> definitionId="com.minres.rdl.RDL.Editor.opened">
</reference> </reference>
</activeWhen> </activeWhen>
</handler> </handler>
<handler <handler
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
commandId="com.minres.rdl.RDL.validate"> commandId="com.minres.rdl.RDL.validate">
<activeWhen> <activeWhen>
<reference <reference
definitionId="com.minres.rdl.RDL.Editor.opened"> definitionId="com.minres.rdl.RDL.Editor.opened">
</reference> </reference>
</activeWhen> </activeWhen>
</handler> </handler>
<!-- copy qualified name --> <!-- copy qualified name -->
<handler <handler
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler"
commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"> commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName">
<activeWhen> <activeWhen>
<reference definitionId="com.minres.rdl.RDL.Editor.opened" /> <reference definitionId="com.minres.rdl.RDL.Editor.opened" />
</activeWhen> </activeWhen>
</handler> </handler>
<handler <handler
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler"
commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"> commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName">
<activeWhen> <activeWhen>
<and> <and>
<reference definitionId="com.minres.rdl.RDL.XtextEditor.opened" /> <reference definitionId="com.minres.rdl.RDL.XtextEditor.opened" />
<iterate> <iterate>
<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" /> <adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
</iterate> </iterate>
</and> </and>
</activeWhen> </activeWhen>
</handler> </handler>
</extension> </extension>
<extension point="org.eclipse.core.expressions.definitions"> <extension point="org.eclipse.core.expressions.definitions">
<definition id="com.minres.rdl.RDL.Editor.opened"> <definition id="com.minres.rdl.RDL.Editor.opened">
<and> <and>
<reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/> <reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
<with variable="activeEditor"> <with variable="activeEditor">
<test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName" <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
value="com.minres.rdl.RDL" value="com.minres.rdl.RDL"
forcePluginActivation="true"/> forcePluginActivation="true"/>
</with> </with>
</and> </and>
</definition> </definition>
<definition id="com.minres.rdl.RDL.XtextEditor.opened"> <definition id="com.minres.rdl.RDL.XtextEditor.opened">
<and> <and>
<reference definitionId="isXtextEditorActive"/> <reference definitionId="isXtextEditorActive"/>
<with variable="activeEditor"> <with variable="activeEditor">
<test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName" <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
value="com.minres.rdl.RDL" value="com.minres.rdl.RDL"
forcePluginActivation="true"/> forcePluginActivation="true"/>
</with> </with>
</and> </and>
</definition> </definition>
</extension> </extension>
<extension <extension
point="org.eclipse.ui.preferencePages"> point="org.eclipse.ui.preferencePages">
<page <page
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
id="com.minres.rdl.RDL" id="com.minres.rdl.RDL"
name="RDL"> name="RDL">
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
</page> </page>
<page <page
category="com.minres.rdl.RDL" category="com.minres.rdl.RDL"
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
id="com.minres.rdl.RDL.coloring" id="com.minres.rdl.RDL.coloring"
name="Syntax Coloring"> name="Syntax Coloring">
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
</page> </page>
<page <page
category="com.minres.rdl.RDL" category="com.minres.rdl.RDL"
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
id="com.minres.rdl.RDL.templates" id="com.minres.rdl.RDL.templates"
name="Templates"> name="Templates">
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
</page> </page>
<page category="com.minres.rdl.RDL" <page category="com.minres.rdl.RDL"
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:com.minres.rdl.ui.preferences.RdlPreferencePage" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:com.minres.rdl.ui.preferences.RdlPreferencePage"
id="com.minres.rdl.RDL.preferences" id="com.minres.rdl.RDL.preferences"
name="Generator"> name="Output Configuration">
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
</page> </page>
</extension> </extension>
<extension <extension
point="org.eclipse.ui.propertyPages"> point="org.eclipse.ui.propertyPages">
<page <page
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
id="com.minres.rdl.RDL" id="com.minres.rdl.RDL"
name="RDL"> name="RDL">
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
<enabledWhen> <enabledWhen>
<adapt type="org.eclipse.core.resources.IProject"/> <adapt type="org.eclipse.core.resources.IProject"/>
</enabledWhen> </enabledWhen>
<filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
</page> </page>
</extension> </extension>
<extension <extension
point="org.eclipse.ui.keywords"> point="org.eclipse.ui.keywords">
<keyword <keyword
id="com.minres.rdl.ui.keyword_RDL" id="com.minres.rdl.ui.keyword_RDL"
label="RDL"/> label="RDL"/>
</extension> </extension>
<extension <extension
point="org.eclipse.ui.commands"> point="org.eclipse.ui.commands">
<command <command
description="Trigger expensive validation" description="Trigger expensive validation"
id="com.minres.rdl.RDL.validate" id="com.minres.rdl.RDL.validate"
name="Validate"> name="Validate">
</command> </command>
<!-- copy qualified name --> <!-- copy qualified name -->
<command <command
id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName" id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
categoryId="org.eclipse.ui.category.edit" categoryId="org.eclipse.ui.category.edit"
description="Copy the qualified name for the selected element" description="Copy the qualified name for the selected element"
name="Copy Qualified Name"> name="Copy Qualified Name">
</command> </command>
<command <command
id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName" id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
categoryId="org.eclipse.ui.category.edit" categoryId="org.eclipse.ui.category.edit"
description="Copy the qualified name for the selected element" description="Copy the qualified name for the selected element"
name="Copy Qualified Name"> name="Copy Qualified Name">
</command> </command>
</extension> </extension>
<extension point="org.eclipse.ui.menus"> <extension point="org.eclipse.ui.menus">
<menuContribution <menuContribution
locationURI="popup:#TextEditorContext?after=group.edit"> locationURI="popup:#TextEditorContext?after=group.edit">
<command <command
commandId="com.minres.rdl.RDL.validate" commandId="com.minres.rdl.RDL.validate"
style="push" style="push"
tooltip="Trigger expensive validation"> tooltip="Trigger expensive validation">
<visibleWhen checkEnabled="false"> <visibleWhen checkEnabled="false">
<reference <reference
definitionId="com.minres.rdl.RDL.Editor.opened"> definitionId="com.minres.rdl.RDL.Editor.opened">
</reference> </reference>
</visibleWhen> </visibleWhen>
</command> </command>
</menuContribution> </menuContribution>
<!-- copy qualified name --> <!-- copy qualified name -->
<menuContribution locationURI="popup:#TextEditorContext?after=copy"> <menuContribution locationURI="popup:#TextEditorContext?after=copy">
<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName" <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
style="push" tooltip="Copy Qualified Name"> style="push" tooltip="Copy Qualified Name">
<visibleWhen checkEnabled="false"> <visibleWhen checkEnabled="false">
<reference definitionId="com.minres.rdl.RDL.Editor.opened" /> <reference definitionId="com.minres.rdl.RDL.Editor.opened" />
</visibleWhen> </visibleWhen>
</command> </command>
</menuContribution> </menuContribution>
<menuContribution locationURI="menu:edit?after=copy"> <menuContribution locationURI="menu:edit?after=copy">
<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName" <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
style="push" tooltip="Copy Qualified Name"> style="push" tooltip="Copy Qualified Name">
<visibleWhen checkEnabled="false"> <visibleWhen checkEnabled="false">
<reference definitionId="com.minres.rdl.RDL.Editor.opened" /> <reference definitionId="com.minres.rdl.RDL.Editor.opened" />
</visibleWhen> </visibleWhen>
</command> </command>
</menuContribution> </menuContribution>
<menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions"> <menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions">
<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName" <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
style="push" tooltip="Copy Qualified Name"> style="push" tooltip="Copy Qualified Name">
<visibleWhen checkEnabled="false"> <visibleWhen checkEnabled="false">
<and> <and>
<reference definitionId="com.minres.rdl.RDL.XtextEditor.opened" /> <reference definitionId="com.minres.rdl.RDL.XtextEditor.opened" />
<iterate> <iterate>
<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" /> <adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
</iterate> </iterate>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
</menuContribution> </menuContribution>
</extension> </extension>
<extension point="org.eclipse.ui.menus"> <extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:#TextEditorContext?endof=group.find"> <menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
<command commandId="org.eclipse.xtext.ui.editor.FindReferences"> <command commandId="org.eclipse.xtext.ui.editor.FindReferences">
<visibleWhen checkEnabled="false"> <visibleWhen checkEnabled="false">
<reference definitionId="com.minres.rdl.RDL.Editor.opened"> <reference definitionId="com.minres.rdl.RDL.Editor.opened">
</reference> </reference>
</visibleWhen> </visibleWhen>
</command> </command>
</menuContribution> </menuContribution>
</extension> </extension>
<extension point="org.eclipse.ui.handlers"> <extension point="org.eclipse.ui.handlers">
<handler <handler
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
commandId="org.eclipse.xtext.ui.editor.FindReferences"> commandId="org.eclipse.xtext.ui.editor.FindReferences">
<activeWhen> <activeWhen>
<reference <reference
definitionId="com.minres.rdl.RDL.Editor.opened"> definitionId="com.minres.rdl.RDL.Editor.opened">
</reference> </reference>
</activeWhen> </activeWhen>
</handler> </handler>
</extension> </extension>
<extension point="org.eclipse.core.contenttype.contentTypes"> <extension point="org.eclipse.core.contenttype.contentTypes">
<content-type <content-type
base-type="org.eclipse.core.runtime.text" base-type="org.eclipse.core.runtime.text"
file-extensions="rdl" file-extensions="rdl"
id="com.minres.rdl.RDL.contenttype" id="com.minres.rdl.RDL.contenttype"
name="RDL File" name="RDL File"
priority="normal"> priority="normal">
</content-type> </content-type>
</extension> </extension>
<!-- adding resource factories --> <!-- adding resource factories -->
<extension <extension
point="org.eclipse.emf.ecore.extension_parser"> point="org.eclipse.emf.ecore.extension_parser">
<parser <parser
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
type="rdl"> type="rdl">
</parser> </parser>
</extension> </extension>
<extension point="org.eclipse.xtext.extension_resourceServiceProvider"> <extension point="org.eclipse.xtext.extension_resourceServiceProvider">
<resourceServiceProvider <resourceServiceProvider
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
uriExtension="rdl"> uriExtension="rdl">
</resourceServiceProvider> </resourceServiceProvider>
</extension> </extension>
<!-- marker definitions for com.minres.rdl.RDL --> <!-- marker definitions for com.minres.rdl.RDL -->
<extension <extension
id="rdl.check.fast" id="rdl.check.fast"
name="RDL Problem" name="RDL Problem"
point="org.eclipse.core.resources.markers"> point="org.eclipse.core.resources.markers">
<super type="org.eclipse.xtext.ui.check.fast"/> <super type="org.eclipse.xtext.ui.check.fast"/>
<persistent value="true"/> <persistent value="true"/>
</extension> </extension>
<extension <extension
id="rdl.check.normal" id="rdl.check.normal"
name="RDL Problem" name="RDL Problem"
point="org.eclipse.core.resources.markers"> point="org.eclipse.core.resources.markers">
<super type="org.eclipse.xtext.ui.check.normal"/> <super type="org.eclipse.xtext.ui.check.normal"/>
<persistent value="true"/> <persistent value="true"/>
</extension> </extension>
<extension <extension
id="rdl.check.expensive" id="rdl.check.expensive"
name="RDL Problem" name="RDL Problem"
point="org.eclipse.core.resources.markers"> point="org.eclipse.core.resources.markers">
<super type="org.eclipse.xtext.ui.check.expensive"/> <super type="org.eclipse.xtext.ui.check.expensive"/>
<persistent value="true"/> <persistent value="true"/>
</extension> </extension>
<extension point="org.eclipse.ui.preferencePages"> <extension point="org.eclipse.ui.preferencePages">
<page <page
category="com.minres.rdl.RDL" category="com.minres.rdl.RDL"
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.validation.ValidatorPreferencePage" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.validation.ValidatorPreferencePage"
id="com.minres.rdl.RDL.validator.preferencePage" id="com.minres.rdl.RDL.validator.preferencePage"
name="Errors/Warnings"> name="Errors/Warnings">
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
</page> </page>
</extension> </extension>
<extension point="org.eclipse.xtext.builder.participant"> <extension point="org.eclipse.ui.preferencePages">
<participant <page
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant" category="com.minres.rdl.RDL"
fileExtensions="rdl"/> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
</extension> id="com.minres.rdl.RDL.compiler.preferencePage"
<extension point="org.eclipse.ui.preferencePages"> name="Compiler">
<page <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
category="com.minres.rdl.RDL" </page>
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" </extension>
id="com.minres.rdl.RDL.compiler.preferencePage" <extension point="org.eclipse.ui.propertyPages">
name="Compiler"> <page
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> category="com.minres.rdl.RDL"
</page> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
</extension> id="com.minres.rdl.RDL.compiler.propertyPage"
<extension point="org.eclipse.ui.propertyPages"> name="Compiler">
<page <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
category="com.minres.rdl.RDL" <enabledWhen>
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" <adapt type="org.eclipse.core.resources.IProject"/>
id="com.minres.rdl.RDL.compiler.propertyPage" </enabledWhen>
name="Compiler"> <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> </page>
<enabledWhen> </extension>
<adapt type="org.eclipse.core.resources.IProject"/> <extension point="org.eclipse.ui.menus">
</enabledWhen> <menuContribution locationURI="popup:#TextEditorContext?after=xtext.ui.openDeclaration">
<filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> <command
</page> commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand"
</extension> id="com.minres.rdl.RDL.OpenGeneratedCode"
<extension point="org.eclipse.ui.menus"> style="push">
<menuContribution locationURI="popup:#TextEditorContext?after=xtext.ui.openDeclaration"> <visibleWhen checkEnabled="false">
<command <reference definitionId="com.minres.rdl.RDL.Editor.opened" />
commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand" </visibleWhen>
id="com.minres.rdl.RDL.OpenGeneratedCode" </command>
style="push"> </menuContribution>
<visibleWhen checkEnabled="false"> </extension>
<reference definitionId="com.minres.rdl.RDL.Editor.opened" /> <extension point="org.eclipse.ui.handlers">
</visibleWhen> <handler
</command> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.generator.trace.OpenGeneratedFileHandler"
</menuContribution> commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand">
</extension> <activeWhen>
<extension point="org.eclipse.ui.handlers"> <reference definitionId="com.minres.rdl.RDL.Editor.opened" />
<handler </activeWhen>
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.generator.trace.OpenGeneratedFileHandler" </handler>
commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand"> </extension>
<activeWhen> <!-- Quick Outline -->
<reference definitionId="com.minres.rdl.RDL.Editor.opened" /> <extension
</activeWhen> point="org.eclipse.ui.handlers">
</handler> <handler
</extension> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
<!-- Quick Outline --> commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
<extension <activeWhen>
point="org.eclipse.ui.handlers"> <reference
<handler definitionId="com.minres.rdl.RDL.Editor.opened">
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler" </reference>
commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"> </activeWhen>
<activeWhen> </handler>
<reference </extension>
definitionId="com.minres.rdl.RDL.Editor.opened"> <extension
</reference> point="org.eclipse.ui.commands">
</activeWhen> <command
</handler> description="Open the quick outline."
</extension> id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
<extension name="Quick Outline">
point="org.eclipse.ui.commands"> </command>
<command </extension>
description="Open the quick outline." <extension point="org.eclipse.ui.menus">
id="org.eclipse.xtext.ui.editor.outline.QuickOutline" <menuContribution
name="Quick Outline"> locationURI="popup:#TextEditorContext?after=group.open">
</command> <command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
</extension> style="push"
<extension point="org.eclipse.ui.menus"> tooltip="Open Quick Outline">
<menuContribution <visibleWhen checkEnabled="false">
locationURI="popup:#TextEditorContext?after=group.open"> <reference definitionId="com.minres.rdl.RDL.Editor.opened"/>
<command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline" </visibleWhen>
style="push" </command>
tooltip="Open Quick Outline"> </menuContribution>
<visibleWhen checkEnabled="false"> </extension>
<reference definitionId="com.minres.rdl.RDL.Editor.opened"/> <!-- quickfix marker resolution generator for com.minres.rdl.RDL -->
</visibleWhen> <extension
</command> point="org.eclipse.ui.ide.markerResolution">
</menuContribution> <markerResolutionGenerator
</extension> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
<!-- quickfix marker resolution generator for com.minres.rdl.RDL --> markerType="com.minres.rdl.ui.rdl.check.fast">
<extension <attribute
point="org.eclipse.ui.ide.markerResolution"> name="FIXABLE_KEY"
<markerResolutionGenerator value="true">
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" </attribute>
markerType="com.minres.rdl.ui.rdl.check.fast"> </markerResolutionGenerator>
<attribute <markerResolutionGenerator
name="FIXABLE_KEY" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
value="true"> markerType="com.minres.rdl.ui.rdl.check.normal">
</attribute> <attribute
</markerResolutionGenerator> name="FIXABLE_KEY"
<markerResolutionGenerator value="true">
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" </attribute>
markerType="com.minres.rdl.ui.rdl.check.normal"> </markerResolutionGenerator>
<attribute <markerResolutionGenerator
name="FIXABLE_KEY" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
value="true"> markerType="com.minres.rdl.ui.rdl.check.expensive">
</attribute> <attribute
</markerResolutionGenerator> name="FIXABLE_KEY"
<markerResolutionGenerator value="true">
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" </attribute>
markerType="com.minres.rdl.ui.rdl.check.expensive"> </markerResolutionGenerator>
<attribute </extension>
name="FIXABLE_KEY" <!-- Rename Refactoring -->
value="true"> <extension point="org.eclipse.ui.handlers">
</attribute> <handler
</markerResolutionGenerator> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler"
</extension> commandId="org.eclipse.xtext.ui.refactoring.RenameElement">
<!-- Rename Refactoring --> <activeWhen>
<extension point="org.eclipse.ui.handlers"> <reference
<handler definitionId="com.minres.rdl.RDL.Editor.opened">
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler" </reference>
commandId="org.eclipse.xtext.ui.refactoring.RenameElement"> </activeWhen>
<activeWhen> </handler>
<reference </extension>
definitionId="com.minres.rdl.RDL.Editor.opened"> <extension point="org.eclipse.ui.menus">
</reference> <menuContribution
</activeWhen> locationURI="popup:#TextEditorContext?after=group.edit">
</handler> <command commandId="org.eclipse.xtext.ui.refactoring.RenameElement"
</extension> style="push">
<extension point="org.eclipse.ui.menus"> <visibleWhen checkEnabled="false">
<menuContribution <reference
locationURI="popup:#TextEditorContext?after=group.edit"> definitionId="com.minres.rdl.RDL.Editor.opened">
<command commandId="org.eclipse.xtext.ui.refactoring.RenameElement" </reference>
style="push"> </visibleWhen>
<visibleWhen checkEnabled="false"> </command>
<reference </menuContribution>
definitionId="com.minres.rdl.RDL.Editor.opened"> </extension>
</reference> <extension point="org.eclipse.ui.preferencePages">
</visibleWhen> <page
</command> category="com.minres.rdl.RDL"
</menuContribution> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage"
</extension> id="com.minres.rdl.RDL.refactoring"
<extension point="org.eclipse.ui.preferencePages"> name="Refactoring">
<page <keywordReference id="com.minres.rdl.ui.keyword_RDL"/>
category="com.minres.rdl.RDL" </page>
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage" </extension>
id="com.minres.rdl.RDL.refactoring" <extension point="org.eclipse.compare.contentViewers">
name="Refactoring"> <viewer id="com.minres.rdl.RDL.compare.contentViewers"
<keywordReference id="com.minres.rdl.ui.keyword_RDL"/> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
</page> extensions="rdl">
</extension> </viewer>
<extension point="org.eclipse.compare.contentViewers"> <contentTypeBinding
<viewer id="com.minres.rdl.RDL.compare.contentViewers" contentTypeId="com.minres.rdl.RDL.contenttype"
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator" contentViewerId="com.minres.rdl.RDL.compare.contentViewers" />
extensions="rdl"> </extension>
</viewer> <extension point="org.eclipse.compare.contentMergeViewers">
<contentTypeBinding <viewer id="com.minres.rdl.RDL.compare.contentMergeViewers"
contentTypeId="com.minres.rdl.RDL.contenttype" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
contentViewerId="com.minres.rdl.RDL.compare.contentViewers" /> extensions="rdl" label="RDL Compare">
</extension> </viewer>
<extension point="org.eclipse.compare.contentMergeViewers"> <contentTypeBinding
<viewer id="com.minres.rdl.RDL.compare.contentMergeViewers" contentTypeId="com.minres.rdl.RDL.contenttype"
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator" contentMergeViewerId="com.minres.rdl.RDL.compare.contentMergeViewers" />
extensions="rdl" label="RDL Compare"> </extension>
</viewer> <extension point="org.eclipse.ui.editors.documentProviders">
<contentTypeBinding <provider id="com.minres.rdl.RDL.editors.documentProviders"
contentTypeId="com.minres.rdl.RDL.contenttype" class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
contentMergeViewerId="com.minres.rdl.RDL.compare.contentMergeViewers" /> extensions="rdl">
</extension> </provider>
<extension point="org.eclipse.ui.editors.documentProviders"> </extension>
<provider id="com.minres.rdl.RDL.editors.documentProviders" <extension point="org.eclipse.team.core.fileTypes">
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider" <fileTypes
extensions="rdl"> extension="rdl"
</provider> type="text">
</extension> </fileTypes>
<extension point="org.eclipse.team.core.fileTypes"> </extension>
<fileTypes <extension
extension="rdl" point="org.eclipse.ui.newWizards">
type="text"> <category id="com.minres.category" name="MINRES">
</fileTypes> </category>
</extension> <wizard
<extension category="com.minres.category"
point="org.eclipse.ui.newWizards"> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.wizard.template.TemplateNewProjectWizard"
<category id="com.minres.category" name="MINRES"> id="com.minres.rdl.ui.wizard.RDLNewProjectWizard"
</category> name="RDL Project"
<wizard icon="icons/new_RDL_proj.gif"
category="com.minres.category" project="true">
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.ui.wizard.template.TemplateNewProjectWizard" </wizard>
id="com.minres.rdl.ui.wizard.RDLNewProjectWizard" </extension>
name="RDL Project" <extension
icon="icons/new_RDL_proj.gif" point="org.eclipse.xtext.ui.projectTemplate">
project="true"> <projectTemplateProvider
</wizard> class="com.minres.rdl.ui.wizard.RDLProjectTemplateProvider"
</extension> grammarName="com.minres.rdl.RDL">
<extension </projectTemplateProvider>
point="org.eclipse.xtext.ui.projectTemplate"> </extension>
<projectTemplateProvider <extension
class="com.minres.rdl.ui.wizard.RDLProjectTemplateProvider" point="org.eclipse.ui.perspectiveExtensions">
grammarName="com.minres.rdl.RDL"> <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective">
</projectTemplateProvider> <newWizardShortcut id="com.minres.rdl.ui.wizard.RDLNewProjectWizard"/>
</extension> </perspectiveExtension>
<extension </extension>
point="org.eclipse.ui.perspectiveExtensions"> <!-- <extension point="org.eclipse.xtext.builder.participant">
<perspectiveExtension targetID="org.eclipse.ui.resourcePerspective"> <participant
<newWizardShortcut id="com.minres.rdl.ui.wizard.RDLNewProjectWizard"/> class="com.minres.rdl.ui.RDLExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"
</perspectiveExtension> fileExtensions="rdl"/>
</extension> </extension>-->
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.minres.rdl.ui.RDLExecutableExtensionFactory:com.minres.rdl.ui.builder.GenerationHandler"
commandId="com.minres.rdl.ui.handler.GenerationCommand">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command name="Generate Code from RDL"
id="com.minres.rdl.ui.handler.GenerationCommand">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu">
<command
commandId="com.minres.rdl.ui.handler.GenerationCommand"
style="push">
<visibleWhen
checkEnabled="false">
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name"
value="*.rdl"/>
</adapt>
</iterate>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:#TextEditorContext?after=additions">
<command
commandId="com.minres.rdl.ui.handler.GenerationCommand"
style="push">
<visibleWhen checkEnabled="false">
<reference
definitionId="com.minres.rdl.RDL.Editor.opened">
</reference>
</visibleWhen>
</command>
</menuContribution>
</extension>
</plugin> </plugin>

View File

@ -3,8 +3,8 @@
*/ */
package com.minres.rdl.ui package com.minres.rdl.ui
import com.minres.structural.ui.hyperlink.MyHyperlinkHelper import com.minres.rdl.ui.hyperlink.RdlHyperlinkHelper
import com.minres.structural.ui.hyperlink.MyXtextHyperlink import com.minres.rdl.ui.hyperlink.RdlXtextHyperlink
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider import org.eclipse.xtext.documentation.IEObjectDocumentationProvider
import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider
@ -36,11 +36,11 @@ class RDLUiModule extends AbstractRDLUiModule {
} }
def Class<? extends HyperlinkHelper> bindHyperlinkHelper() { def Class<? extends HyperlinkHelper> bindHyperlinkHelper() {
return MyHyperlinkHelper return RdlHyperlinkHelper
} }
def Class<? extends XtextHyperlink> bindHyperlink() { def Class<? extends XtextHyperlink> bindHyperlink() {
return MyXtextHyperlink return RdlXtextHyperlink
} }
} }

View File

@ -0,0 +1,134 @@
package com.minres.rdl.ui.builder;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
import org.eclipse.xtext.generator.IGenerator2;
import org.eclipse.xtext.resource.IResourceDescriptions;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.minres.rdl.generator.RdlGeneratorContext;
import com.minres.rdl.preferences.PreferenceConstants;
public class GenerationHandler extends AbstractHandler implements IHandler {
@Inject
private IGenerator2 generator;
@Inject
private Provider<EclipseResourceFileSystemAccess2> fileAccessProvider;
@Inject
IResourceDescriptions resourceDescriptions;
@Inject
IResourceSetProvider resourceSetProvider;
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE_NAME);
@Override
public Object execute(ExecutionEvent event) {
RdlGeneratorContext context = new RdlGeneratorContext();
context.cancelIndicator = CancelIndicator.NullImpl;
context.namespace = preferences.get(PreferenceConstants.P_NAMESPACE, "sysc");
context.forceOverwrite=preferences.getBoolean(PreferenceConstants.P_OVERWRITE_STUBS, false);
String whatToGenerate = preferences.get(PreferenceConstants.P_FILETYPES_TO_GENERATE, "all");
if(whatToGenerate=="sc-comp") {
context.generateFw=false;
} else if(whatToGenerate=="fw") {
context.generateSc=false;
}
context.forceOverwrite=preferences.getBoolean(PreferenceConstants.P_OVERWRITE_STUBS, false);
context.fwPathModifier=preferences.get(PreferenceConstants.P_FIRMWARE_PATH, "");
context.scPathModifier=preferences.get(PreferenceConstants.P_COMPONENT_PATH, "");
String outputDir = preferences.get("outlet.DEFAULT_OUTPUT.directory", "src-gen");
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activeEditor instanceof XtextEditor && activeEditor == activePart) {
IFile file = (IFile) activeEditor.getEditorInput().getAdapter(IFile.class);
if (file != null) {
final EclipseResourceFileSystemAccess2 fsa = getFsa(outputDir, file, context.fwPathModifier, context.scPathModifier);
((XtextEditor)activeEditor).getDocument().readOnly(new IUnitOfWork<Boolean, XtextResource>() {
@Override
public Boolean exec(XtextResource state) throws Exception {
generator.doGenerate(state, fsa, context);
return Boolean.TRUE;
}
});
}
} else {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
for (Object element : structuredSelection) {
if (element instanceof IFile) {
IFile file = (IFile) element;
final EclipseResourceFileSystemAccess2 fsa = getFsa(outputDir, file, context.fwPathModifier, context.scPathModifier);
URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
Resource r = resourceSetProvider.get(file.getProject()).getResource(uri, true);
try {
generator.doGenerate(r, fsa, context);
} finally {}
}
}
}
}
return null;
}
private EclipseResourceFileSystemAccess2 getFsa(String outputDir, IFile file, String fwPath, String scPath) {
IProject project = file.getProject();
IFolder srcGenFolder = project.getFolder(outputDir);
createIfNotExists(srcGenFolder);
if(fwPath.length()>0) createIfNotExists(srcGenFolder.getFolder(fwPath));
if(scPath.length()>0) createIfNotExists(srcGenFolder.getFolder(scPath));
final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
fsa.setOutputPath("src-gen");
String scGenFolderPath = (fwPath.length()>0? srcGenFolder.getFolder(scPath) : srcGenFolder).getProjectRelativePath().toString();
fsa.setOutputPath("sc-incl-out", scGenFolderPath);
fsa.setOutputPath("sc-src-out", scGenFolderPath);
String fwGenFolderPath = (fwPath.length()>0? srcGenFolder.getFolder(fwPath) : srcGenFolder).getProjectRelativePath().toString();
fsa.setOutputPath("fw-incl-out", fwGenFolderPath);
fsa.setOutputPath("fw-src-out", fwGenFolderPath);
fsa.setProject(project);
fsa.setMonitor(new NullProgressMonitor());
return fsa;
}
private void createIfNotExists(IFolder srcGenFolder) {
if (!srcGenFolder.exists()) {
try {
srcGenFolder.create(true, true, new NullProgressMonitor());
} catch (CoreException e) { }
}
}
@Override
public boolean isEnabled() {
return true;
}
}

View File

@ -1,4 +1,4 @@
package com.minres.structural.ui.hyperlink package com.minres.rdl.ui.hyperlink
import com.google.inject.Inject import com.google.inject.Inject
import org.eclipse.emf.common.util.URI import org.eclipse.emf.common.util.URI
@ -13,7 +13,7 @@ import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor
import org.eclipse.xtext.util.TextRegion import org.eclipse.xtext.util.TextRegion
import org.eclipse.jface.text.IRegion import org.eclipse.jface.text.IRegion
class MyHyperlinkHelper extends HyperlinkHelper { class RdlHyperlinkHelper extends HyperlinkHelper {
@Inject ImportUriResolver resolver; @Inject ImportUriResolver resolver;
@ -37,7 +37,7 @@ class MyHyperlinkHelper extends HyperlinkHelper {
result.setHyperlinkRegion(new Region(textRegion.getOffset(), textRegion.getLength()) as IRegion); result.setHyperlinkRegion(new Region(textRegion.getOffset(), textRegion.getLength()) as IRegion);
result.setURI(if(uri.isPlatformResource()) uri else resource.getResourceSet().getURIConverter().normalize(uri)); result.setURI(if(uri.isPlatformResource()) uri else resource.getResourceSet().getURIConverter().normalize(uri));
result.setHyperlinkText(labelProvider.getText(top)); result.setHyperlinkText(labelProvider.getText(top));
if(result instanceof MyXtextHyperlink) result.selectTarget=false if(result instanceof RdlXtextHyperlink) result.selectTarget=false
acceptor.accept(result); acceptor.accept(result);
} }
} }

View File

@ -1,10 +1,10 @@
package com.minres.structural.ui.hyperlink package com.minres.rdl.ui.hyperlink
import com.google.inject.Inject import com.google.inject.Inject
import org.eclipse.xtext.ui.editor.IURIEditorOpener import org.eclipse.xtext.ui.editor.IURIEditorOpener
import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink
class MyXtextHyperlink extends XtextHyperlink { class RdlXtextHyperlink extends XtextHyperlink {
var boolean select = true var boolean select = true

View File

@ -8,6 +8,7 @@ import com.minres.rdl.preferences.PreferenceConstants
import org.eclipse.ui.preferences.ScopedPreferenceStore import org.eclipse.ui.preferences.ScopedPreferenceStore
import org.eclipse.core.runtime.preferences.InstanceScope import org.eclipse.core.runtime.preferences.InstanceScope
import org.eclipse.jface.preference.ComboFieldEditor import org.eclipse.jface.preference.ComboFieldEditor
import org.eclipse.jface.preference.StringFieldEditor
class RdlPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { class RdlPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
@ -21,6 +22,11 @@ class RdlPreferencePage extends FieldEditorPreferencePage implements IWorkbenchP
override createFieldEditors() { override createFieldEditors() {
addField(new BooleanFieldEditor(PreferenceConstants.P_GENERATE_CSV, "Generate CSV:", getFieldEditorParent())); addField(new BooleanFieldEditor(PreferenceConstants.P_GENERATE_CSV, "Generate CSV:", getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceConstants.P_ADDRESSUNIT, "Address unit size", #[#["Byte (8bit)","byte"], #["Word (16bit)","word"], #["DWord (32bit)","dword"]], getFieldEditorParent())) addField(new ComboFieldEditor(PreferenceConstants.P_ADDRESSUNIT, "Address unit size", #[#["Byte (8bit)","byte"], #["Word (16bit)","word"], #["DWord (32bit)","dword"]], getFieldEditorParent()))
addField(new StringFieldEditor(PreferenceConstants.P_NAMESPACE, "Namespace of generated SystemC", 30, getFieldEditorParent()))
addField(new BooleanFieldEditor(PreferenceConstants.P_OVERWRITE_STUBS, "Always overwrite component stubs", getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceConstants.P_FILETYPES_TO_GENERATE, "File types to generate", #[#["All","all"], #["FW only","fw"], #["SC components","sc-comp"]], getFieldEditorParent()))
addField(new StringFieldEditor(PreferenceConstants.P_COMPONENT_PATH, "relative path for SystemC files", 30, getFieldEditorParent()))
addField(new StringFieldEditor(PreferenceConstants.P_FIRMWARE_PATH, "relative path for FW files", 30, getFieldEditorParent()))
} }
override init(IWorkbench workbench) { override init(IWorkbench workbench) {

View File

@ -26,4 +26,11 @@ class RDLRuntimeModule extends AbstractRDLRuntimeModule {
//return typeof(ResourceSetGlobalScopeProvider) //return typeof(ResourceSetGlobalScopeProvider)
return typeof(org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider) return typeof(org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider)
} }
// def Class<? extends IGeneratorConfiguration> bindIGeneratorConfiguration() {
// return GeneratorConfiguration;
// }
// def IGeneratorConfiguration bindIGeneratorConfiguration() {
// return new GeneratorConfiguration();
// }
} }

View File

@ -4,6 +4,7 @@ import com.minres.rdl.rdl.ComponentDefinition
import com.minres.rdl.rdl.ComponentDefinitionType import com.minres.rdl.rdl.ComponentDefinitionType
import static extension com.minres.rdl.RdlUtil.* import static extension com.minres.rdl.RdlUtil.*
import java.util.Date
class AddrmapGenerator extends RdlBaseGenerator { class AddrmapGenerator extends RdlBaseGenerator {
@ -18,8 +19,18 @@ class AddrmapGenerator extends RdlBaseGenerator {
} }
override generateHeader(String namespace) {''' override generateHeader(String namespace) {'''
#ifndef _«componentDefinition.effectiveName.toUpperCase»_MAP_H_ /*
#define _«componentDefinition.effectiveName.toUpperCase»_MAP_H_ * Copyright (c) 2019 -2022 MINRES Technologies GmbH
*
* SPDX-License-Identifier: Apache-2.0
*
* Created on: «new Date»
* * «componentDefinition.effectiveName».h Author: <RDL Generator>
*
*/
#pragma once
// need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191 // need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191
const std::array<scc::target_memory_map_entry<32>, «componentDefinition.instanceCount(ComponentDefinitionType.REGFILE)»> «componentDefinition.effectiveName»_map = {{ const std::array<scc::target_memory_map_entry<32>, «componentDefinition.instanceCount(ComponentDefinitionType.REGFILE)»> «componentDefinition.effectiveName»_map = {{
«FOR instantiation : componentDefinition.instantiationsOfType(ComponentDefinitionType.REGFILE)» «FOR instantiation : componentDefinition.instantiationsOfType(ComponentDefinitionType.REGFILE)»

View File

@ -21,43 +21,17 @@ class FwAddrmapGenerator extends RdlBaseGenerator {
} }
override generateHeader(String namespace) {''' override generateHeader(String namespace) {'''
//////////////////////////////////////////////////////////////////////////////// /*
// Copyright (C) 2020-2022, MINRES Technologies GmbH * Copyright (c) 2019 -2022 MINRES Technologies GmbH
// All rights reserved. *
// * SPDX-License-Identifier: Apache-2.0
// Redistribution and use in source and binary forms, with or without *
// modification, are permitted provided that the following conditions are met: * Created on: «new Date»
// * * «componentDefinition.effectiveName».h Author: <RDL Generator>
// 1. Redistributions of source code must retain the above copyright notice, *
// this list of conditions and the following disclaimer. */
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Created on: «new Date»
// * «componentDefinition.name».h Author: <RDL Generator>
//
////////////////////////////////////////////////////////////////////////////////
#ifndef _«componentDefinition.effectiveName.toUpperCase»_MAP_H_ #pragma once
#define _«componentDefinition.effectiveName.toUpperCase»_MAP_H_
«FOR instantiation : componentDefinition.instantiationsOfType(ComponentDefinitionType.REGFILE)» «FOR instantiation : componentDefinition.instantiationsOfType(ComponentDefinitionType.REGFILE)»
«IF instantiation.component !== null && !nameMap.contains(instantiation.component.name)» «IF instantiation.component !== null && !nameMap.contains(instantiation.component.name)»

View File

@ -22,43 +22,17 @@ class FwRegfileGenerator extends RdlBaseGenerator{
} }
override String generateHeader(String namespace)''' override String generateHeader(String namespace)'''
//////////////////////////////////////////////////////////////////////////////// /*
// Copyright (C) 2020-2022, MINRES Technologies GmbH * Copyright (c) 2019 -2022 MINRES Technologies GmbH
// All rights reserved. *
// * SPDX-License-Identifier: Apache-2.0
// Redistribution and use in source and binary forms, with or without *
// modification, are permitted provided that the following conditions are met: * Created on: «new Date»
// * * «componentDefinition.effectiveName».h Author: <RDL Generator>
// 1. Redistributions of source code must retain the above copyright notice, *
// this list of conditions and the following disclaimer. */
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Created on: «new Date»
// * «componentDefinition.name».h Author: <RDL Generator>
//
////////////////////////////////////////////////////////////////////////////////
#ifndef _«componentDefinition.name.toUpperCase»_H_ #pragma once
#define _«componentDefinition.name.toUpperCase»_H_
#include <util/bit_field.h> #include <util/bit_field.h>
#include <nonstd/span.hpp> #include <nonstd/span.hpp>

View File

@ -23,7 +23,9 @@ import java.io.File
class Main { class Main {
val USAGE_STR = "RDL2code [-h] [-v] [-f] [-n <namespace>] [-I <RDL include dir] [-o <output dir>] <input file> <input file>"; val USAGE_STR = '''
RDL2code [-h] [-v] [-f] [-fw] [-sc [-n <namespace>]] [-I <RDL include dir] [-o <output dir>] <input file> <input file>
'''
def static main(String[] args) { def static main(String[] args) {
if (args.empty) { if (args.empty) {
@ -56,7 +58,6 @@ class Main {
@Inject JavaIoFileSystemAccess fileAccess @Inject JavaIoFileSystemAccess fileAccess
def run(String[] args) { def run(String[] args) {
val opt = new Options(args, 0, Integer.MAX_VALUE); val opt = new Options(args, 0, Integer.MAX_VALUE);
opt.getSet().addOption("h", Multiplicity.ZERO_OR_ONE); opt.getSet().addOption("h", Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("v", Multiplicity.ZERO_OR_ONE); opt.getSet().addOption("v", Multiplicity.ZERO_OR_ONE);
@ -64,6 +65,8 @@ class Main {
opt.getSet().addOption("n", Separator.BLANK, Multiplicity.ZERO_OR_ONE); opt.getSet().addOption("n", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("o", Separator.BLANK, Multiplicity.ZERO_OR_ONE); opt.getSet().addOption("o", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("I", Separator.BLANK, Multiplicity.ZERO_OR_ONE); opt.getSet().addOption("I", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("fw", Multiplicity.ZERO_OR_ONE);
opt.getSet().addOption("sc", Multiplicity.ZERO_OR_ONE);
if (!opt.check(false, false)) { // Print usage hints if (!opt.check(false, false)) { // Print usage hints
System.err.println("Usage is: " + USAGE_STR); System.err.println("Usage is: " + USAGE_STR);
throw new MalformedParametersException(opt.getCheckErrors()); throw new MalformedParametersException(opt.getCheckErrors());
@ -87,19 +90,18 @@ class Main {
fileAccess.outputPath = opt.getSet().getOption('o').getResultValue(0) fileAccess.outputPath = opt.getSet().getOption('o').getResultValue(0)
fileAccess.outputConfigurations.get(IFileSystemAccess.DEFAULT_OUTPUT)?.setOverrideExistingResources(true) fileAccess.outputConfigurations.get(IFileSystemAccess.DEFAULT_OUTPUT)?.setOverrideExistingResources(true)
} }
// #{'incl-out' -> false, 'src-out' -> false, 'gen-out' -> true}.forEach[p1, p2| val context = new RdlGeneratorContext => [cancelIndicator = CancelIndicator.NullImpl]
// if(opt.getSet().isSet(p1.substring(0, 1))) context.forceOverwrite= opt.getSet().isSet('f')
// fileAccess.setOutputPath(p1, opt.getSet().getOption(p1.substring(0, 1)).getResultValue(0)+'/') if(opt.getSet().isSet('n'))
// else context.namespace=opt.getSet().getOption('n').getResultValue(0)
// fileAccess.setOutputPath(p1, 'src-gen/') context.generateFw=opt.getSet().isSet('fw')
// fileAccess.outputConfigurations.get(p1)?.setOverrideExistingResources(p2) context.generateSc=opt.getSet().isSet('sc')
// ] opt.getSet().getData().forEach [ String fileName |
opt.getSet().getData().forEach [ String string | if(verbose) println("Processing " + fileName);
if(verbose) println("Processing " + string);
// Load the resource // Load the resource
val resourceSet = resourceSetProvider.get as XtextResourceSet val resourceSet = resourceSetProvider.get as XtextResourceSet
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
val resource = resourceSet.getResource(URI.createFileURI(string), true) val resource = resourceSet.getResource(URI.createFileURI(fileName), true)
// Validate the resource // Validate the resource
val issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl) val issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)
if (!issues.empty) { if (!issues.empty) {
@ -107,22 +109,10 @@ class Main {
issues.forEach[System.err.println(it)] issues.forEach[System.err.println(it)]
throw new ParseException("error validating " + resource.URI, issues.size) throw new ParseException("error validating " + resource.URI, issues.size)
} }
val context = new RdlGeneratorContext => [cancelIndicator = CancelIndicator.NullImpl]
context.forceOverwrite= opt.getSet().isSet('f')
if(opt.getSet().isSet('n'))
context.namespace=opt.getSet().getOption('n').getResultValue(0)
generator.generate(resource, fileAccess, context) generator.generate(resource, fileAccess, context)
if(verbose) {
if(verbose) println('Code generation for ' + string + ' finished') println('Code generation for ' + fileName + ' finished')
try {
if(verbose) println('includes are in ' + fileAccess.getURI('', 'incl-out'))
} catch (Exception e) {
println('includes are in ' + fileAccess.getURI('')) println('includes are in ' + fileAccess.getURI(''))
}
try {
if(verbose) println('sources are in ' + fileAccess.getURI('', 'src-out'))
} catch (Exception e) {
println('sources are in ' + fileAccess.getURI('')) println('sources are in ' + fileAccess.getURI(''))
} }
] ]

View File

@ -1,58 +0,0 @@
/*
* generated by Xtext 2.14.0
*/
package com.minres.rdl.generator
import com.google.inject.Inject
import com.google.inject.Provider
import com.minres.rdl.RDLStandaloneSetup
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.xtext.generator.GeneratorContext
import org.eclipse.xtext.generator.GeneratorDelegate
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.xtext.util.CancelIndicator
import org.eclipse.xtext.validation.CheckMode
import org.eclipse.xtext.validation.IResourceValidator
class Main {
def static main(String[] args) {
if (args.empty) {
System::err.println('Aborting: no path to EMF resource provided!')
return
}
val injector = new RDLStandaloneSetup().createInjectorAndDoEMFRegistration
val main = injector.getInstance(Main)
main.runGenerator(args.get(0))
}
@Inject Provider<ResourceSet> resourceSetProvider
@Inject IResourceValidator validator
@Inject GeneratorDelegate generator
@Inject JavaIoFileSystemAccess fileAccess
def protected runGenerator(String string) {
// Load the resource
val set = resourceSetProvider.get
val resource = set.getResource(URI.createFileURI(string), true)
// Validate the resource
val issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)
if (!issues.empty) {
issues.forEach[System.err.println(it)]
return
}
// Configure and start the generator
fileAccess.outputPath = 'src-gen/'
val context = new GeneratorContext => [
cancelIndicator = CancelIndicator.NullImpl
]
generator.generate(resource, fileAccess, context)
System.out.println('Code generation finished.')
}
}

View File

@ -22,12 +22,12 @@ class ModuleGenerator extends RdlBaseGenerator {
override generateHeader(String namespace){ override generateHeader(String namespace){
if(componentDefinition.type!=ComponentDefinitionType.REGFILE) return '' if(componentDefinition.type!=ComponentDefinitionType.REGFILE) return ''
val addrMaps = componentDefinition.eResource.resourceSet.allContents // val addrMaps = componentDefinition.eResource.resourceSet.allContents
.filter[ it instanceof ComponentDefinition] // .filter[ it instanceof ComponentDefinition]
.map[it as ComponentDefinition] // .map[it as ComponentDefinition]
.filter[it.type == ComponentDefinitionType.ADDRMAP] // .filter[it.type == ComponentDefinitionType.ADDRMAP]
.filter[def | def.instantiations.filter[it.componentRef==componentDefinition].size>0] // .filter[def | def.instantiations.filter[it.componentRef==componentDefinition].size>0]
if(addrMaps.size==0) return '' // if(addrMaps.size==0) return ''
''' '''
/* /*
* Copyright (c) 2019 -2022 MINRES Technologies GmbH * Copyright (c) 2019 -2022 MINRES Technologies GmbH
@ -35,11 +35,13 @@ class ModuleGenerator extends RdlBaseGenerator {
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#ifndef _«namespace.toUpperCase»_«componentDefinition.effectiveName.toUpperCase»_H_ #pragma once
#define _«namespace.toUpperCase»_«componentDefinition.effectiveName.toUpperCase»_H_
#include <scc/tlm_target.h> #include <scc/tlm_target.h>
namespace «namespace» { «FOR ns : namespace.split('::')»
namespace «ns» {
«ENDFOR»
namespace gen { namespace gen {
class «componentDefinition.effectiveName»_regs; class «componentDefinition.effectiveName»_regs;
} }
@ -58,7 +60,9 @@ class ModuleGenerator extends RdlBaseGenerator {
std::unique_ptr<gen::«componentDefinition.effectiveName»_regs> regs; std::unique_ptr<gen::«componentDefinition.effectiveName»_regs> regs;
}; };
} /* namespace «namespace» */ «FOR ns : namespace.split('::').reverse»
} // namespace «ns»
«ENDFOR»
#endif /* _«namespace.toUpperCase»_«componentDefinition.effectiveName.toUpperCase»_H_ */ #endif /* _«namespace.toUpperCase»_«componentDefinition.effectiveName.toUpperCase»_H_ */
''' '''
@ -66,12 +70,12 @@ class ModuleGenerator extends RdlBaseGenerator {
override generateSource(String namespace) { override generateSource(String namespace) {
if(componentDefinition.type!=ComponentDefinitionType.REGFILE) return '' if(componentDefinition.type!=ComponentDefinitionType.REGFILE) return ''
val addrMaps = componentDefinition.eResource.resourceSet.allContents // val addrMaps = componentDefinition.eResource.resourceSet.allContents
.filter[ it instanceof ComponentDefinition] // .filter[ it instanceof ComponentDefinition]
.map[it as ComponentDefinition] // .map[it as ComponentDefinition]
.filter[it.type == ComponentDefinitionType.ADDRMAP] // .filter[it.type == ComponentDefinitionType.ADDRMAP]
.filter[def | def.instantiations.filter[it.componentRef==componentDefinition].size>0] // .filter[def | def.instantiations.filter[it.componentRef==componentDefinition].size>0]
if(addrMaps.size==0) return '' // if(addrMaps.size==0) return ''
''' '''
/* /*
* Copyright (c) 2019 -2022 MINRES Technologies GmbH * Copyright (c) 2019 -2022 MINRES Technologies GmbH
@ -84,7 +88,9 @@ class ModuleGenerator extends RdlBaseGenerator {
#include <scc/utilities.h> #include <scc/utilities.h>
namespace «namespace» { «FOR ns : namespace.split('::')»
namespace «ns» {
«ENDFOR»
SC_HAS_PROCESS(«componentDefinition.effectiveName»);// NOLINT SC_HAS_PROCESS(«componentDefinition.effectiveName»);// NOLINT
«componentDefinition.effectiveName»::«componentDefinition.effectiveName»(sc_core::sc_module_name nm) «componentDefinition.effectiveName»::«componentDefinition.effectiveName»(sc_core::sc_module_name nm)
@ -119,7 +125,9 @@ class ModuleGenerator extends RdlBaseGenerator {
} }
} }
} /* namespace «namespace» */ «FOR ns : namespace.split('::').reverse»
} // namespace «ns»
«ENDFOR»
''' '''
} }

View File

@ -12,28 +12,28 @@ import org.eclipse.xtext.generator.IGeneratorContext
import static extension com.minres.rdl.RdlUtil.* import static extension com.minres.rdl.RdlUtil.*
import java.util.Map import java.util.Map
/**
* Generates code from your model files on save.
*
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
*/
class RDLGenerator extends AbstractGenerator { class RDLGenerator extends AbstractGenerator {
override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) { override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
val force = if(context instanceof RdlGeneratorContext) context.forceOverwrite else false val force = if(context instanceof RdlGeneratorContext) context.forceOverwrite else false
val namespace = if(context instanceof RdlGeneratorContext) context.namespace else "sysc" val namespace = if(context instanceof RdlGeneratorContext) context.namespace else "sysc"
val genFW = if(context instanceof RdlGeneratorContext) context.generateFw else true
val genSC = if(context instanceof RdlGeneratorContext) context.generateSc else true
resource.resourceSet.allContents.filter[ it instanceof ComponentDefinition].map[it as ComponentDefinition].forEach[ resource.resourceSet.allContents.filter[ it instanceof ComponentDefinition].map[it as ComponentDefinition].forEach[
val genMap = it.fileGenerator val genMap = it.fileGenerator
if(genMap!==null) genMap.forEach[p1, gen | if(genMap!==null) genMap.forEach[p1, gen |
val header = gen.generateHeader(namespace) if((p1=='fw' && genFW) || (p1!='fw' && genSC)) {
val inclFileName = p1+'/'+it.effectiveName+'.h' val header = gen.generateHeader(namespace)
val inclCfg = fsa.outputConfig('incl-out') val prefix = if(p1=="fw") 'fw-' else 'sc-'
if((force || !fsa.isFile(inclFileName, inclCfg) || gen.overwrite) && header!==null && header.length>0) val inclFileName = p1+'/'+it.effectiveName+'.h'
fsa.generateFile(inclFileName, inclCfg, header) val inclCfg = fsa.outputConfig(prefix+'incl-out')
val source = gen.generateSource(namespace) if((force || !fsa.isFile(inclFileName, inclCfg) || gen.overwrite) && header!==null && header.length>0)
val srcFileName = p1+'/'+it.effectiveName+'.cpp' fsa.generateFile(inclFileName, inclCfg, header)
val srcCfg = fsa.outputConfig('src-out') val source = gen.generateSource(namespace)
if((force || !fsa.isFile(srcFileName, srcCfg) || gen.overwrite) && source!==null && source.length>0) val srcFileName = p1+'/'+it.effectiveName+'.cpp'
fsa.generateFile(srcFileName, srcCfg, source) val srcCfg = fsa.outputConfig(prefix+'src-out')
if((force || !fsa.isFile(srcFileName, srcCfg) || gen.overwrite) && source!==null && source.length>0)
fsa.generateFile(srcFileName, srcCfg, source)
}
] ]
] ]
} }

View File

@ -1,8 +1,26 @@
package com.minres.rdl.generator package com.minres.rdl.generator
import org.eclipse.xtext.generator.GeneratorContext import org.eclipse.xtext.util.CancelIndicator
import org.eclipse.xtext.generator.IGeneratorContext
class RdlGeneratorContext implements IGeneratorContext {
class RdlGeneratorContext extends GeneratorContext {
public boolean forceOverwrite = false public boolean forceOverwrite = false
public String namespace ="scc"
public String namespace ="sysc"
public CancelIndicator cancelIndicator;
public boolean generateFw = true;
public String fwPathModifier = ""
public boolean generateSc = true;
public String scPathModifier =""
override getCancelIndicator() {
return cancelIndicator
}
} }

View File

@ -32,8 +32,7 @@ class RegfileGenerator extends RdlBaseGenerator{
* *
*/ */
#ifndef _«namespace.toUpperCase»_GEN_«componentDefinition.effectiveName.toUpperCase»_H_ #pragma once
#define _«namespace.toUpperCase»_GEN_«componentDefinition.effectiveName.toUpperCase»_H_
#include <scc/utilities.h> #include <scc/utilities.h>
#include <util/bit_field.h> #include <util/bit_field.h>
@ -45,7 +44,9 @@ class RegfileGenerator extends RdlBaseGenerator{
«ENDIF» «ENDIF»
«ENDFOR» «ENDFOR»
namespace «namespace» { «FOR ns : namespace.split('::')»
namespace «ns» {
«ENDFOR»
namespace gen { namespace gen {
class «componentDefinition.effectiveName»_regs : class «componentDefinition.effectiveName»_regs :
@ -128,7 +129,9 @@ class RegfileGenerator extends RdlBaseGenerator{
void registerResources(scc::tlm_target<BUSWIDTH>& target, uint64_t offset=0); void registerResources(scc::tlm_target<BUSWIDTH>& target, uint64_t offset=0);
}; };
} // namespace gen } // namespace gen
} // namespace «namespace» «FOR ns : namespace.split('::').reverse»
} // namespace «ns»
«ENDFOR»
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// member functions // member functions
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

View File

@ -7,10 +7,19 @@ public class PreferenceConstants {
public static final String SCOPE_NAME = "com.minres.rdl.rdl"; public static final String SCOPE_NAME = "com.minres.rdl.rdl";
public static final String ADDRESSUNIT_PROP = "com.minres.rdl.addrunit";
public static final String P_GENERATE_CSV = "booleanCsvPreference"; public static final String P_GENERATE_CSV = "booleanCsvPreference";
public static final String P_ADDRESSUNIT = "choiceAddrunitPreference"; public static final String P_ADDRESSUNIT = "choiceAddrunitPreference";
public static final String ADDRESSUNIT_PROP = "com.minres.rdl.addrunit"; public static final String P_NAMESPACE = "setNamespacePreference";
public static final String P_OVERWRITE_STUBS = "overwriteStubs";
public static final String P_FILETYPES_TO_GENERATE = "filetypesToGenerate";
public static final String P_COMPONENT_PATH = "componentPath";
public static final String P_FIRMWARE_PATH = "firmwarePath";
} }

View File

@ -1,5 +1,8 @@
package com.minres.rdl.preferences; package com.minres.rdl.preferences;
import java.util.Arrays;
import java.util.HashSet;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@ -8,6 +11,7 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences;
*/ */
public class PreferenceInitializer extends AbstractPreferenceInitializer { public class PreferenceInitializer extends AbstractPreferenceInitializer {
private final HashSet<String> valid_addrunit_types = new HashSet<String>(Arrays.asList(new String[]{"byte", "word", "dword"}));
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -18,19 +22,17 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
IEclipsePreferences store = RdlPreferences.getPreferenceStore(); IEclipsePreferences store = RdlPreferences.getPreferenceStore();
store.putBoolean(PreferenceConstants.P_GENERATE_CSV, true); store.putBoolean(PreferenceConstants.P_GENERATE_CSV, true);
String value = System.getProperty(PreferenceConstants.ADDRESSUNIT_PROP); String value = System.getProperty(PreferenceConstants.ADDRESSUNIT_PROP);
if(value!=null){ if(valid_addrunit_types.contains(value)){
if("byte".equals(value)){ store.put(PreferenceConstants.P_ADDRESSUNIT, value);
store.put(PreferenceConstants.P_ADDRESSUNIT, "byte"); } else {
} else if("word".equals(value)){ System.err.println("Unknown configuration value: '"+value+"', using 'byte'");
store.put(PreferenceConstants.P_ADDRESSUNIT, "word");
} else if("dword".equals(value)){
store.put(PreferenceConstants.P_ADDRESSUNIT, "dword");
} else {
System.err.println("Unknown configuration value: '"+value+"', using 'byte'");
store.put(PreferenceConstants.P_ADDRESSUNIT, "byte");
}
} else
store.put(PreferenceConstants.P_ADDRESSUNIT, "byte"); store.put(PreferenceConstants.P_ADDRESSUNIT, "byte");
}
store.put(PreferenceConstants.P_NAMESPACE, "sysc");
store.putBoolean(PreferenceConstants.P_OVERWRITE_STUBS, false);
store.put(PreferenceConstants.P_FILETYPES_TO_GENERATE, "all");
store.put(PreferenceConstants.P_COMPONENT_PATH, "");
store.put(PreferenceConstants.P_FIRMWARE_PATH, "");
} }
} }

View File

@ -5,6 +5,10 @@ import org.eclipse.core.runtime.preferences.InstanceScope;
public class RdlPreferences { public class RdlPreferences {
public static IEclipsePreferences getPreferenceStore() {
return InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE_NAME);
}
public static boolean getGenerateCsv() { public static boolean getGenerateCsv() {
return getPreferenceStore().getBoolean(PreferenceConstants.P_GENERATE_CSV, true); return getPreferenceStore().getBoolean(PreferenceConstants.P_GENERATE_CSV, true);
} }
@ -13,7 +17,23 @@ public class RdlPreferences {
return getPreferenceStore().get(PreferenceConstants.P_ADDRESSUNIT, System.getProperty(PreferenceConstants.ADDRESSUNIT_PROP)); return getPreferenceStore().get(PreferenceConstants.P_ADDRESSUNIT, System.getProperty(PreferenceConstants.ADDRESSUNIT_PROP));
} }
public static IEclipsePreferences getPreferenceStore() { public static String getNamespace() {
return InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE_NAME); return getPreferenceStore().get(PreferenceConstants.P_NAMESPACE, "sysc");
}
public static boolean getOverwriteStubs() {
return getPreferenceStore().getBoolean(PreferenceConstants.P_OVERWRITE_STUBS, false);
}
public static int getFielTypesToGenerate() {
return getPreferenceStore().getInt(PreferenceConstants.P_FILETYPES_TO_GENERATE, 3);
}
public static String getComponentPath() {
return getPreferenceStore().get(PreferenceConstants.P_COMPONENT_PATH, "");
}
public static String getFirmwarePath() {
return getPreferenceStore().get(PreferenceConstants.P_FIRMWARE_PATH, "");
} }
} }