diff --git a/com.minres.rdl.parent/com.minres.rdl.tests/pom.xml b/com.minres.rdl.parent/com.minres.rdl.tests/pom.xml index ba7a401..e78a3cb 100644 --- a/com.minres.rdl.parent/com.minres.rdl.tests/pom.xml +++ b/com.minres.rdl.parent/com.minres.rdl.tests/pom.xml @@ -18,7 +18,7 @@ org.eclipse.tycho tycho-surefire-plugin - ${tycho-version} + false diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/META-INF/MANIFEST.MF b/com.minres.rdl.parent/com.minres.rdl.ui/META-INF/MANIFEST.MF index 5ffeb3d..ad46953 100644 --- a/com.minres.rdl.parent/com.minres.rdl.ui/META-INF/MANIFEST.MF +++ b/com.minres.rdl.parent/com.minres.rdl.ui/META-INF/MANIFEST.MF @@ -19,10 +19,14 @@ Require-Bundle: com.minres.rdl, org.eclipse.xtext.xbase.lib;bundle-version="2.14.0", org.eclipse.xtend.lib;resolution:=optional, org.eclipse.core.runtime, - org.eclipse.core.resources + org.eclipse.core.resources, + org.eclipse.jdt.core, + org.eclipse.pde.core, + org.eclipse.ui.forms Import-Package: org.apache.log4j Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: com.minres.rdl.ui.internal, com.minres.rdl.ui.contentassist, - com.minres.rdl.ui.quickfix + com.minres.rdl.ui.quickfix, + com.minres.rdl.ui.wizard Bundle-Activator: com.minres.rdl.ui.internal.RdlActivator diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/icons/new_RDL_proj.gif b/com.minres.rdl.parent/com.minres.rdl.ui/icons/new_RDL_proj.gif new file mode 100644 index 0000000..984bc91 Binary files /dev/null and b/com.minres.rdl.parent/com.minres.rdl.ui/icons/new_RDL_proj.gif differ diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/icons/project_template.png b/com.minres.rdl.parent/com.minres.rdl.ui/icons/project_template.png new file mode 100644 index 0000000..fddcb8c Binary files /dev/null and b/com.minres.rdl.parent/com.minres.rdl.ui/icons/project_template.png differ diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/AbstractRDLUiModule.java b/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/AbstractRDLUiModule.java index 4d8d3e8..490e46b 100644 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/AbstractRDLUiModule.java +++ b/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/AbstractRDLUiModule.java @@ -14,7 +14,6 @@ import com.minres.rdl.ui.labeling.RDLDescriptionLabelProvider; import com.minres.rdl.ui.labeling.RDLLabelProvider; import com.minres.rdl.ui.outline.RDLOutlineTreeProvider; import com.minres.rdl.ui.quickfix.RDLQuickfixProvider; -import com.minres.rdl.ui.wizard.RDLProjectCreator; import com.minres.rdl.validation.RDLValidatorConfigurationBlock; import org.eclipse.compare.IViewerCreator; import org.eclipse.core.resources.IWorkspaceRoot; @@ -60,6 +59,8 @@ import org.eclipse.xtext.ui.editor.contentassist.IProposalConflictHelper; import org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher; import org.eclipse.xtext.ui.editor.contentassist.antlr.AntlrProposalConflictHelper; import org.eclipse.xtext.ui.editor.contentassist.antlr.DelegatingContentAssistContextFactory; +import org.eclipse.xtext.ui.editor.formatting.IContentFormatterFactory; +import org.eclipse.xtext.ui.editor.formatting2.ContentFormatterFactory; import org.eclipse.xtext.ui.editor.outline.IOutlineTreeProvider; import org.eclipse.xtext.ui.editor.outline.impl.IOutlineTreeStructureProvider; import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreInitializer; @@ -80,6 +81,7 @@ import org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider; import org.eclipse.xtext.ui.shared.Access; import org.eclipse.xtext.ui.validation.AbstractValidatorConfigurationBlock; import org.eclipse.xtext.ui.wizard.IProjectCreator; +import org.eclipse.xtext.ui.wizard.template.DefaultTemplateProjectCreator; /** * Manual modifications go to {@link RDLUiModule}. @@ -189,6 +191,11 @@ public abstract class AbstractRDLUiModule extends DefaultUiModule { .to(BuilderPreferenceAccess.Initializer.class); } + // contributed by org.eclipse.xtext.xtext.generator.formatting.Formatter2Fragment2 + public Class bindIContentFormatterFactory() { + return ContentFormatterFactory.class; + } + // contributed by org.eclipse.xtext.xtext.generator.ui.labeling.LabelProviderFragment2 public Class bindILabelProvider() { return RDLLabelProvider.class; @@ -287,9 +294,9 @@ public abstract class AbstractRDLUiModule extends DefaultUiModule { binder.bind(String.class).annotatedWith(Names.named(UIBindings.COMPARE_VIEWER_TITLE)).toInstance("RDL Compare"); } - // contributed by org.eclipse.xtext.xtext.generator.ui.projectWizard.SimpleProjectWizardFragment2 + // contributed by org.eclipse.xtext.xtext.generator.ui.projectWizard.TemplateProjectWizardFragment public Class bindIProjectCreator() { - return RDLProjectCreator.class; + return DefaultTemplateProjectCreator.class; } // contributed by org.eclipse.xtext.xtext.generator.exporting.SimpleNamesFragment2 diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/wizard/RDLNewProjectWizard.java b/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/wizard/RDLNewProjectWizard.java deleted file mode 100644 index 87489d2..0000000 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/wizard/RDLNewProjectWizard.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * generated by Xtext 2.14.0 - */ -package com.minres.rdl.ui.wizard; - -import org.eclipse.xtext.ui.wizard.XtextNewProjectWizard; - -import org.eclipse.xtext.ui.wizard.IExtendedProjectInfo; -import org.eclipse.xtext.ui.wizard.IProjectCreator; -import com.google.inject.Inject; - -public class RDLNewProjectWizard extends XtextNewProjectWizard { - - private RDLWizardNewProjectCreationPage mainPage; - - @Inject - public RDLNewProjectWizard(IProjectCreator projectCreator) { - super(projectCreator); - setWindowTitle("New RDL Project"); - } - - protected RDLWizardNewProjectCreationPage getMainPage() { - return mainPage; - } - - /** - * Use this method to add pages to the wizard. - * The one-time generated version of this class will add a default new project page to the wizard. - */ - @Override - public void addPages() { - mainPage = createMainPage("basicNewProjectPage"); - mainPage.setTitle("RDL Project"); - mainPage.setDescription("Create a new RDL project."); - addPage(mainPage); - } - - protected RDLWizardNewProjectCreationPage createMainPage(String pageName) { - return new RDLWizardNewProjectCreationPage(pageName); - } - - /** - * Use this method to read the project settings from the wizard pages and feed them into the project info class. - */ - @Override - protected IExtendedProjectInfo getProjectInfo() { - RDLProjectInfo projectInfo = new RDLProjectInfo(); - projectInfo.setProjectName(mainPage.getProjectName()); - if (!mainPage.useDefaults()) { - projectInfo.setLocationPath(mainPage.getLocationPath()); - } - return projectInfo; - } - -} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/wizard/RDLProjectCreator.java b/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/wizard/RDLProjectCreator.java deleted file mode 100644 index 3c222b9..0000000 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src-gen/com/minres/rdl/ui/wizard/RDLProjectCreator.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * generated by Xtext 2.14.0 - */ -package com.minres.rdl.ui.wizard; - -import org.eclipse.xtext.ui.wizard.AbstractPluginProjectCreator; - -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2; -import org.eclipse.xtext.generator.IFileSystemAccess; -import org.eclipse.xtext.generator.IFileSystemAccess2; -import org.eclipse.xtext.generator.IOutputConfigurationProvider; -import org.eclipse.xtext.generator.OutputConfiguration; -import org.eclipse.xtext.ui.util.PluginProjectFactory; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.inject.Inject; -import com.google.inject.Provider; - -public class RDLProjectCreator extends AbstractPluginProjectCreator { - protected static final String DSL_PROJECT_NAME = "com.minres.rdl"; - - @Inject - private RDLNewProjectWizardInitialContents initialContents; - - @Inject - private Provider fileSystemAccessProvider; - - @Inject - private IOutputConfigurationProvider outputConfigurationProvider; - - @Override - protected PluginProjectFactory createProjectFactory() { - PluginProjectFactory projectFactory = super.createProjectFactory(); - projectFactory.setWithPluginXml(false); - return projectFactory; - } - - @Override - protected RDLProjectInfo getProjectInfo() { - return (RDLProjectInfo) super.getProjectInfo(); - } - - @Override - protected String getModelFolderName() { - return "src"; - } - - @Override - protected List getAllFolders() { - Set outputConfigurations = outputConfigurationProvider.getOutputConfigurations(); - String outputFolder = "src-gen"; - for (OutputConfiguration outputConfiguration : outputConfigurations) { - if (IFileSystemAccess.DEFAULT_OUTPUT.equals(outputConfiguration.getName())) { - outputFolder = outputConfiguration.getOutputDirectory(); - break; - } - } - return ImmutableList.of(getModelFolderName(), outputFolder); - } - - @Override - protected List getRequiredBundles() { - return Lists.newArrayList(DSL_PROJECT_NAME); - } - - @Override - protected void enhanceProject(final IProject project, final IProgressMonitor monitor) throws CoreException { - IFileSystemAccess2 access = getFileSystemAccess(project, monitor); - initialContents.generateInitialContents(access); - project.refreshLocal(IResource.DEPTH_INFINITE, monitor); - } - - protected IFileSystemAccess2 getFileSystemAccess(final IProject project, final IProgressMonitor monitor) { - EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get(); - access.setContext(project); - access.setMonitor(monitor); - OutputConfiguration defaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT); - defaultOutput.setDescription("Output Folder"); - defaultOutput.setOutputDirectory("./"); - defaultOutput.setOverrideExistingResources(true); - defaultOutput.setCreateOutputDirectory(true); - defaultOutput.setCleanUpDerivedResources(false); - defaultOutput.setSetDerivedProperty(false); - defaultOutput.setKeepLocalHistory(false); - HashMap outputConfigurations = new HashMap(); - outputConfigurations.put(IFileSystemAccess.DEFAULT_OUTPUT, defaultOutput); - access.setOutputConfigurations(outputConfigurations); - return access; - } -} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/JDTFreeStructuralProjectCreator.java b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/JDTFreeStructuralProjectCreator.java deleted file mode 100644 index b5985d5..0000000 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/JDTFreeStructuralProjectCreator.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.minres.rdl.ui; - -import org.eclipse.xtext.ui.XtextProjectHelper; - -import com.minres.rdl.ui.wizard.RDLProjectCreator; - - -public class JDTFreeStructuralProjectCreator extends RDLProjectCreator { - @Override - protected String[] getProjectNatures() { - return new String[] {XtextProjectHelper.NATURE_ID}; - } - @Override - protected String[] getBuilders() { - return new String[] {XtextProjectHelper.BUILDER_ID}; - } -} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/RDLUiModule.xtend b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/RDLUiModule.xtend index 7f93637..62c09b9 100644 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/RDLUiModule.xtend +++ b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/RDLUiModule.xtend @@ -3,16 +3,15 @@ */ package com.minres.rdl.ui +import com.minres.structural.ui.hyperlink.MyHyperlinkHelper +import com.minres.structural.ui.hyperlink.MyXtextHyperlink import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor -import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider import org.eclipse.xtext.documentation.IEObjectDocumentationProvider -import org.eclipse.xtext.ui.wizard.IProjectCreator +import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider +import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper +import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink import org.eclipse.xtext.ui.resource.IResourceSetProvider import org.eclipse.xtext.ui.resource.SimpleResourceSetProvider -import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper -import com.minres.structural.ui.hyperlink.MyHyperlinkHelper -import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink -import com.minres.structural.ui.hyperlink.MyXtextHyperlink /** * Use this class to register components to be used within the Eclipse IDE. @@ -28,9 +27,9 @@ class RDLUiModule extends AbstractRDLUiModule { typeof(RDLEObjectDocumentationProvider); } - override Class bindIProjectCreator() { - return JDTFreeStructuralProjectCreator; - } +// override Class bindIProjectCreator() { +// return JDTFreeStructuralProjectCreator; +// } override Class bindIResourceSetProvider() { return SimpleResourceSetProvider diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/Messages.java b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/Messages.java new file mode 100644 index 0000000..7e3c31f --- /dev/null +++ b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/Messages.java @@ -0,0 +1,18 @@ +package com.minres.rdl.ui.wizard; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "com.minres.rdl.ui.wizard.messages"; //$NON-NLS-1$ + + public static String HelloWorldProject_Label; + public static String HelloWorldProject_Description; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLNewProjectWizardInitialContents.xtend b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLNewProjectWizardInitialContents.xtend deleted file mode 100644 index 955db94..0000000 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLNewProjectWizardInitialContents.xtend +++ /dev/null @@ -1,26 +0,0 @@ -/* - * generated by Xtext 2.14.0 - */ -package com.minres.rdl.ui.wizard - - -import com.google.inject.Inject -import org.eclipse.xtext.generator.IFileSystemAccess2 -import org.eclipse.xtext.resource.FileExtensionProvider - -class RDLNewProjectWizardInitialContents { - @Inject - FileExtensionProvider fileExtensionProvider - - def generateInitialContents(IFileSystemAccess2 fsa) { - fsa.generateFile( - "src/model/Model." + fileExtensionProvider.primaryFileExtension, - ''' - /* - * This is an example model - */ - Hello Xtext! - ''' - ) - } -} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectInfo.java b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectInfo.java deleted file mode 100644 index fdbeab9..0000000 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectInfo.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * generated by Xtext 2.14.0 - */ -package com.minres.rdl.ui.wizard; - -import org.eclipse.xtext.ui.wizard.DefaultProjectInfo; - -public class RDLProjectInfo extends DefaultProjectInfo { - -} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.xtend b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.xtend new file mode 100644 index 0000000..f4969de --- /dev/null +++ b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.xtend @@ -0,0 +1,68 @@ +/* + * generated by Xtext 2.14.0 + */ +package com.minres.rdl.ui.wizard + + +import org.eclipse.core.runtime.Status +import org.eclipse.jdt.core.JavaCore +import org.eclipse.xtext.ui.XtextProjectHelper +import org.eclipse.xtext.ui.util.PluginProjectFactory +import org.eclipse.xtext.ui.wizard.template.IProjectGenerator +import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider +import org.eclipse.xtext.ui.wizard.template.ProjectTemplate + +import static org.eclipse.core.runtime.IStatus.* + +/** + * Create a list with all project templates to be shown in the template new project wizard. + * + * Each template is able to generate one or more projects. Each project can be configured such that any number of files are included. + */ +class RDLProjectTemplateProvider implements IProjectTemplateProvider { + override getProjectTemplates() { + #[new HelloWorldProject] + } +} + +@ProjectTemplate(label="Hello World", icon="project_template.png", description="

Hello World

+

This is a parameterized hello world for RDL. You can set a parameter to modify the content in the generated file +and a parameter to set the package the file is created in.

") +final class HelloWorldProject { + val advanced = check("Advanced:", false) + val advancedGroup = group("Properties") + val name = combo("Name:", #["Xtext", "World", "Foo", "Bar"], "The name to say 'Hello' to", advancedGroup) + val path = text("Package:", "mydsl", "The package path to place the files in", advancedGroup) + + override protected updateVariables() { + name.enabled = advanced.value + path.enabled = advanced.value + if (!advanced.value) { + name.value = "Xtext" + path.value = "rdl" + } + } + + override protected validate() { + if (path.value.matches('[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*')) + null + else + new Status(ERROR, "Wizard", "'" + path + "' is not a valid package name") + } + + override generateProjects(IProjectGenerator generator) { + generator.generate(new PluginProjectFactory => [ + projectName = projectInfo.projectName + location = projectInfo.locationPath + projectNatures += #[JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID] + builderIds += JavaCore.BUILDER_ID + folders += "src" + addFile('''src/«path»/Model.rdl''', ''' + /* + * This is an example model + */ + Hello «name»! + ''') + ]) + } +} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLWizardNewProjectCreationPage.java b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLWizardNewProjectCreationPage.java deleted file mode 100644 index b1d11ec..0000000 --- a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/RDLWizardNewProjectCreationPage.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * generated by Xtext 2.14.0 - */ -package com.minres.rdl.ui.wizard; - -import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; - -public class RDLWizardNewProjectCreationPage extends WizardNewProjectCreationPage { - - public RDLWizardNewProjectCreationPage(String pageName) { - super(pageName); - } - -} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/messages.properties b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/messages.properties new file mode 100644 index 0000000..0a4a053 --- /dev/null +++ b/com.minres.rdl.parent/com.minres.rdl.ui/src/com/minres/rdl/ui/wizard/messages.properties @@ -0,0 +1,2 @@ +HelloWorldProject_Label=Hello World +HelloWorldProject_Description=

Hello World

This is a parameterized hello world for RDL. You can set a parameter to modify the content in the generated file and a parameter to set the package the file is created in.

diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/RDLUiModule.java b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/RDLUiModule.java index 3ca590d..699aff6 100644 --- a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/RDLUiModule.java +++ b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/RDLUiModule.java @@ -4,7 +4,6 @@ package com.minres.rdl.ui; import com.minres.rdl.ui.AbstractRDLUiModule; -import com.minres.rdl.ui.JDTFreeStructuralProjectCreator; import com.minres.rdl.ui.RDLEObjectDocumentationProvider; import com.minres.rdl.ui.RDLEObjectHoverProvider; import com.minres.structural.ui.hyperlink.MyHyperlinkHelper; @@ -17,7 +16,6 @@ import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper; import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink; import org.eclipse.xtext.ui.resource.IResourceSetProvider; import org.eclipse.xtext.ui.resource.SimpleResourceSetProvider; -import org.eclipse.xtext.ui.wizard.IProjectCreator; /** * Use this class to register components to be used within the Eclipse IDE. @@ -33,11 +31,6 @@ public class RDLUiModule extends AbstractRDLUiModule { return RDLEObjectDocumentationProvider.class; } - @Override - public Class bindIProjectCreator() { - return JDTFreeStructuralProjectCreator.class; - } - @Override public Class bindIResourceSetProvider() { return SimpleResourceSetProvider.class; @@ -51,7 +44,7 @@ public class RDLUiModule extends AbstractRDLUiModule { return MyXtextHyperlink.class; } - public RDLUiModule(final AbstractUIPlugin arg0) { - super(arg0); + public RDLUiModule(final AbstractUIPlugin plugin) { + super(plugin); } } diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/HelloWorldProject.java b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/HelloWorldProject.java new file mode 100644 index 0000000..1aabef6 --- /dev/null +++ b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/HelloWorldProject.java @@ -0,0 +1,95 @@ +/** + * generated by Xtext 2.14.0 + */ +package com.minres.rdl.ui.wizard; + +import com.google.common.collect.Iterables; +import java.util.Collections; +import java.util.List; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.xtend2.lib.StringConcatenation; +import org.eclipse.xtext.ui.XtextProjectHelper; +import org.eclipse.xtext.ui.util.PluginProjectFactory; +import org.eclipse.xtext.ui.wizard.template.AbstractProjectTemplate; +import org.eclipse.xtext.ui.wizard.template.BooleanTemplateVariable; +import org.eclipse.xtext.ui.wizard.template.GroupTemplateVariable; +import org.eclipse.xtext.ui.wizard.template.IProjectGenerator; +import org.eclipse.xtext.ui.wizard.template.ProjectTemplate; +import org.eclipse.xtext.ui.wizard.template.StringSelectionTemplateVariable; +import org.eclipse.xtext.ui.wizard.template.StringTemplateVariable; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.ObjectExtensions; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; + +@ProjectTemplate(label = "Hello World", icon = "project_template.png", description = "

Hello World

\n

This is a parameterized hello world for RDL. You can set a parameter to modify the content in the generated file\nand a parameter to set the package the file is created in.

") +@SuppressWarnings("all") +public final class HelloWorldProject extends AbstractProjectTemplate { + private final BooleanTemplateVariable advanced = this.check("Advanced:", false); + + private final GroupTemplateVariable advancedGroup = this.group("Properties"); + + private final StringSelectionTemplateVariable name = this.combo("Name:", new String[] { "Xtext", "World", "Foo", "Bar" }, "The name to say \'Hello\' to", this.advancedGroup); + + private final StringTemplateVariable path = this.text("Package:", "mydsl", "The package path to place the files in", this.advancedGroup); + + @Override + protected void updateVariables() { + this.name.setEnabled(this.advanced.getValue()); + this.path.setEnabled(this.advanced.getValue()); + boolean _value = this.advanced.getValue(); + boolean _not = (!_value); + if (_not) { + this.name.setValue("Xtext"); + this.path.setValue("rdl"); + } + } + + @Override + protected IStatus validate() { + Status _xifexpression = null; + boolean _matches = this.path.getValue().matches("[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*"); + if (_matches) { + _xifexpression = null; + } else { + _xifexpression = new Status(IStatus.ERROR, "Wizard", (("\'" + this.path) + "\' is not a valid package name")); + } + return _xifexpression; + } + + @Override + public void generateProjects(final IProjectGenerator generator) { + PluginProjectFactory _pluginProjectFactory = new PluginProjectFactory(); + final Procedure1 _function = (PluginProjectFactory it) -> { + it.setProjectName(this.getProjectInfo().getProjectName()); + it.setLocation(this.getProjectInfo().getLocationPath()); + List _projectNatures = it.getProjectNatures(); + Iterables.addAll(_projectNatures, Collections.unmodifiableList(CollectionLiterals.newArrayList(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID))); + List _builderIds = it.getBuilderIds(); + _builderIds.add(JavaCore.BUILDER_ID); + List _folders = it.getFolders(); + _folders.add("src"); + StringConcatenation _builder = new StringConcatenation(); + _builder.append("src/"); + _builder.append(this.path); + _builder.append("/Model.rdl"); + StringConcatenation _builder_1 = new StringConcatenation(); + _builder_1.append("/*"); + _builder_1.newLine(); + _builder_1.append(" "); + _builder_1.append("* This is an example model"); + _builder_1.newLine(); + _builder_1.append(" "); + _builder_1.append("*/"); + _builder_1.newLine(); + _builder_1.append("Hello "); + _builder_1.append(this.name); + _builder_1.append("!"); + _builder_1.newLineIfNotEmpty(); + this.addFile(it, _builder, _builder_1); + }; + PluginProjectFactory _doubleArrow = ObjectExtensions.operator_doubleArrow(_pluginProjectFactory, _function); + generator.generate(_doubleArrow); + } +} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLNewProjectWizardInitialContents.java b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLNewProjectWizardInitialContents.java deleted file mode 100644 index e720aa1..0000000 --- a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLNewProjectWizardInitialContents.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * generated by Xtext 2.14.0 - */ -package com.minres.rdl.ui.wizard; - -import com.google.inject.Inject; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.generator.IFileSystemAccess2; -import org.eclipse.xtext.resource.FileExtensionProvider; - -@SuppressWarnings("all") -public class RDLNewProjectWizardInitialContents { - @Inject - private FileExtensionProvider fileExtensionProvider; - - public void generateInitialContents(final IFileSystemAccess2 fsa) { - String _primaryFileExtension = this.fileExtensionProvider.getPrimaryFileExtension(); - String _plus = ("src/model/Model." + _primaryFileExtension); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("/*"); - _builder.newLine(); - _builder.append(" "); - _builder.append("* This is an example model"); - _builder.newLine(); - _builder.append(" "); - _builder.append("*/"); - _builder.newLine(); - _builder.append("Hello Xtext!"); - _builder.newLine(); - fsa.generateFile(_plus, _builder); - } -} diff --git a/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.java b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.java new file mode 100644 index 0000000..613aed2 --- /dev/null +++ b/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/wizard/RDLProjectTemplateProvider.java @@ -0,0 +1,22 @@ +/** + * generated by Xtext 2.14.0 + */ +package com.minres.rdl.ui.wizard; + +import com.minres.rdl.ui.wizard.HelloWorldProject; +import org.eclipse.xtext.ui.wizard.template.AbstractProjectTemplate; +import org.eclipse.xtext.ui.wizard.template.IProjectTemplateProvider; + +/** + * Create a list with all project templates to be shown in the template new project wizard. + * + * Each template is able to generate one or more projects. Each project can be configured such that any number of files are included. + */ +@SuppressWarnings("all") +public class RDLProjectTemplateProvider implements IProjectTemplateProvider { + @Override + public AbstractProjectTemplate[] getProjectTemplates() { + HelloWorldProject _helloWorldProject = new HelloWorldProject(); + return new AbstractProjectTemplate[] { _helloWorldProject }; + } +} diff --git a/com.minres.rdl.parent/com.minres.rdl/META-INF/MANIFEST.MF b/com.minres.rdl.parent/com.minres.rdl/META-INF/MANIFEST.MF index 2d88a9b..8dd0502 100644 --- a/com.minres.rdl.parent/com.minres.rdl/META-INF/MANIFEST.MF +++ b/com.minres.rdl.parent/com.minres.rdl/META-INF/MANIFEST.MF @@ -28,5 +28,6 @@ Export-Package: com.minres.rdl, com.minres.rdl.scoping, com.minres.rdl.serializer, com.minres.rdl.services, - com.minres.rdl.validation + com.minres.rdl.validation, + com.minres.rdl.formatting2 Import-Package: org.apache.log4j diff --git a/com.minres.rdl.parent/com.minres.rdl/model/generated/RDL.genmodel b/com.minres.rdl.parent/com.minres.rdl/model/generated/RDL.genmodel index 214f2c5..1a725c6 100644 --- a/com.minres.rdl.parent/com.minres.rdl/model/generated/RDL.genmodel +++ b/com.minres.rdl.parent/com.minres.rdl/model/generated/RDL.genmodel @@ -3,7 +3,7 @@ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="generated by Xtext 2.14.0" modelDirectory="/com.minres.rdl/src-gen" modelPluginID="com.minres.rdl" forceOverwrite="true" modelName="RDL" updateClasspath="false" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" complianceLevel="6.0" - copyrightFields="false" runtimeVersion="2.12"> + copyrightFields="false" runtimeVersion="2.14"> diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/AbstractRDLRuntimeModule.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/AbstractRDLRuntimeModule.java index 4edc1e6..471951d 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/AbstractRDLRuntimeModule.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/AbstractRDLRuntimeModule.java @@ -6,6 +6,7 @@ package com.minres.rdl; import com.google.inject.Binder; import com.google.inject.Provider; import com.google.inject.name.Names; +import com.minres.rdl.formatting2.RDLFormatter; import com.minres.rdl.generator.RDLGenerator; import com.minres.rdl.parser.antlr.RDLAntlrTokenFileProvider; import com.minres.rdl.parser.antlr.RDLParser; @@ -19,6 +20,9 @@ import com.minres.rdl.validation.RDLValidator; import java.util.Properties; import org.eclipse.xtext.Constants; import org.eclipse.xtext.IGrammarAccess; +import org.eclipse.xtext.formatting2.FormatterPreferenceValuesProvider; +import org.eclipse.xtext.formatting2.FormatterPreferences; +import org.eclipse.xtext.formatting2.IFormatter2; import org.eclipse.xtext.generator.IGenerator2; import org.eclipse.xtext.naming.IQualifiedNameProvider; import org.eclipse.xtext.naming.SimpleNameProvider; @@ -31,6 +35,7 @@ import org.eclipse.xtext.parser.antlr.ITokenDefProvider; import org.eclipse.xtext.parser.antlr.Lexer; import org.eclipse.xtext.parser.antlr.LexerBindings; import org.eclipse.xtext.parser.antlr.LexerProvider; +import org.eclipse.xtext.preferences.IPreferenceValuesProvider; import org.eclipse.xtext.resource.IContainer; import org.eclipse.xtext.resource.IResourceDescriptions; import org.eclipse.xtext.resource.containers.IAllContainersState; @@ -193,6 +198,16 @@ public abstract class AbstractRDLRuntimeModule extends DefaultRuntimeModule { return RDLGenerator.class; } + // contributed by org.eclipse.xtext.xtext.generator.formatting.Formatter2Fragment2 + public Class bindIFormatter2() { + return RDLFormatter.class; + } + + // contributed by org.eclipse.xtext.xtext.generator.formatting.Formatter2Fragment2 + public void configureFormatterPreferences(Binder binder) { + binder.bind(IPreferenceValuesProvider.class).annotatedWith(FormatterPreferences.class).to(FormatterPreferenceValuesProvider.class); + } + // contributed by org.eclipse.xtext.xtext.generator.exporting.SimpleNamesFragment2 public Class bindIQualifiedNameProvider() { return SimpleNameProvider.class; diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ComponentDefinitionImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ComponentDefinitionImpl.java index cbc6818..7b608cb 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ComponentDefinitionImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ComponentDefinitionImpl.java @@ -402,7 +402,7 @@ public class ComponentDefinitionImpl extends MinimalEObjectImpl.Container implem { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (type: "); result.append(type); result.append(", name: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ComponentInstanceImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ComponentInstanceImpl.java index 520981d..8b4a017 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ComponentInstanceImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ComponentInstanceImpl.java @@ -417,7 +417,7 @@ public class ComponentInstanceImpl extends EntityImpl implements ComponentInstan { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (reset: "); result.append(reset); result.append(", address: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ConcatElemImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ConcatElemImpl.java index 92ba393..f206288 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ConcatElemImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ConcatElemImpl.java @@ -256,7 +256,7 @@ public class ConcatElemImpl extends MinimalEObjectImpl.Container implements Conc { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (value: "); result.append(value); result.append(')'); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EntityImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EntityImpl.java index 8eeb7be..9925fa9 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EntityImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EntityImpl.java @@ -168,7 +168,7 @@ public class EntityImpl extends MinimalEObjectImpl.Container implements Entity { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (name: "); result.append(name); result.append(')'); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumEntryImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumEntryImpl.java index b880d61..f14e771 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumEntryImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumEntryImpl.java @@ -285,7 +285,7 @@ public class EnumEntryImpl extends MinimalEObjectImpl.Container implements EnumE { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (name: "); result.append(name); result.append(", index: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumInstanceTypeImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumInstanceTypeImpl.java index 88fcb24..0878074 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumInstanceTypeImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumInstanceTypeImpl.java @@ -222,7 +222,7 @@ public class EnumInstanceTypeImpl extends MinimalEObjectImpl.Container implement { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (EXTERNAL: "); result.append(external); result.append(", INTERNAL: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumPropertyImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumPropertyImpl.java index 27afb1a..1ec2dda 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumPropertyImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/EnumPropertyImpl.java @@ -222,7 +222,7 @@ public class EnumPropertyImpl extends MinimalEObjectImpl.Container implements En { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (name: "); result.append(name); result.append(", value: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ExplicitPropertyAssignmentImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ExplicitPropertyAssignmentImpl.java index fa4dbf7..51b74df 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ExplicitPropertyAssignmentImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/ExplicitPropertyAssignmentImpl.java @@ -311,7 +311,7 @@ public class ExplicitPropertyAssignmentImpl extends PropertyAssignmentImpl imple { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (modifier: "); result.append(modifier); result.append(", name: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/IncludeImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/IncludeImpl.java index 4b03b4b..1d341d0 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/IncludeImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/IncludeImpl.java @@ -168,7 +168,7 @@ public class IncludeImpl extends MinimalEObjectImpl.Container implements Include { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (importURI: "); result.append(importURI); result.append(')'); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/InstancePropertyRefImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/InstancePropertyRefImpl.java index d8d7788..bf83d82 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/InstancePropertyRefImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/InstancePropertyRefImpl.java @@ -323,7 +323,7 @@ public class InstancePropertyRefImpl extends MinimalEObjectImpl.Container implem { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (propertyEnum: "); result.append(propertyEnum); result.append(')'); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/InstantiationImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/InstantiationImpl.java index ace3bef..51b9089 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/InstantiationImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/InstantiationImpl.java @@ -440,7 +440,7 @@ public class InstantiationImpl extends MinimalEObjectImpl.Container implements I { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (alias: "); result.append(alias); result.append(')'); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PostPropertyAssignmentImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PostPropertyAssignmentImpl.java index 1f49b0d..0ce4b21 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PostPropertyAssignmentImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PostPropertyAssignmentImpl.java @@ -394,7 +394,7 @@ public class PostPropertyAssignmentImpl extends PropertyAssignmentImpl implement { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (propertyEnum: "); result.append(propertyEnum); result.append(')'); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyDefaultImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyDefaultImpl.java index b681c1e..49af695 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyDefaultImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyDefaultImpl.java @@ -222,7 +222,7 @@ public class PropertyDefaultImpl extends MinimalEObjectImpl.Container implements { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (string: "); result.append(string); result.append(", value: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyDefinitionImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyDefinitionImpl.java index 298154b..00e8d5f 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyDefinitionImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyDefinitionImpl.java @@ -328,7 +328,7 @@ public class PropertyDefinitionImpl extends EntityImpl implements PropertyDefini { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (type: "); result.append(type); result.append(')'); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyUsageImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyUsageImpl.java index 06d1c14..ddea28c 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyUsageImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/PropertyUsageImpl.java @@ -155,7 +155,7 @@ public class PropertyUsageImpl extends MinimalEObjectImpl.Container implements P { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (components: "); result.append(components); result.append(')'); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RValueImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RValueImpl.java index 837a984..fcded16 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RValueImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RValueImpl.java @@ -277,7 +277,7 @@ public class RValueImpl extends MinimalEObjectImpl.Container implements RValue { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (val: "); result.append(val); result.append(", num: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RangeImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RangeImpl.java index 0f3f6f0..64c2990 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RangeImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RangeImpl.java @@ -276,7 +276,7 @@ public class RangeImpl extends MinimalEObjectImpl.Container implements Range { if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); + StringBuilder result = new StringBuilder(super.toString()); result.append(" (left: "); result.append(left); result.append(", right: "); diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RdlPackageImpl.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RdlPackageImpl.java index a1ffd43..bb0e740 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RdlPackageImpl.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/rdl/impl/RdlPackageImpl.java @@ -299,7 +299,7 @@ public class RdlPackageImpl extends EPackageImpl implements RdlPackage /** * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. - * + * *

This method is used to initialize {@link RdlPackage#eINSTANCE} when that field is accessed. * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. * @@ -314,7 +314,8 @@ public class RdlPackageImpl extends EPackageImpl implements RdlPackage if (isInited) return (RdlPackage)EPackage.Registry.INSTANCE.getEPackage(RdlPackage.eNS_URI); // Obtain or create and register package - RdlPackageImpl theRdlPackage = (RdlPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof RdlPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new RdlPackageImpl()); + Object registeredRdlPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + RdlPackageImpl theRdlPackage = registeredRdlPackage instanceof RdlPackageImpl ? (RdlPackageImpl)registeredRdlPackage : new RdlPackageImpl(); isInited = true; @@ -327,7 +328,6 @@ public class RdlPackageImpl extends EPackageImpl implements RdlPackage // Mark meta-data to indicate it can't be changed theRdlPackage.freeze(); - // Update the registry and return the package EPackage.Registry.INSTANCE.put(RdlPackage.eNS_URI, theRdlPackage); return theRdlPackage; diff --git a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/validation/AbstractRDLValidator.java b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/validation/AbstractRDLValidator.java index 2951309..166f37b 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/validation/AbstractRDLValidator.java +++ b/com.minres.rdl.parent/com.minres.rdl/src-gen/com/minres/rdl/validation/AbstractRDLValidator.java @@ -7,7 +7,10 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.emf.ecore.EPackage; import org.eclipse.xtext.validation.AbstractDeclarativeValidator; +import org.eclipse.xtext.validation.ComposedChecks; +import org.eclipse.xtext.validation.ImportUriValidator; +@ComposedChecks(validators = {ImportUriValidator.class}) public abstract class AbstractRDLValidator extends AbstractDeclarativeValidator { @Override diff --git a/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/GenerateRDL.mwe2 b/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/GenerateRDL.mwe2 index e09fe93..a0fe5b9 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/GenerateRDL.mwe2 +++ b/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/GenerateRDL.mwe2 @@ -43,16 +43,25 @@ Workflow { backtrack = true } } + + formatter = { + generateStub = true + } + serializer = { generateStub = false } + validator = { // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator" + composedCheck = "org.eclipse.xtext.validation.ImportUriValidator" } + generator = { generateXtendMain = true } - newProjectWizardForEclipse = { + + projectWizard = { generate = true } } diff --git a/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/formatting2/RDLFormatter.xtend b/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/formatting2/RDLFormatter.xtend new file mode 100644 index 0000000..719a27c --- /dev/null +++ b/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/formatting2/RDLFormatter.xtend @@ -0,0 +1,44 @@ +/* + * generated by Xtext 2.14.0 + */ +package com.minres.rdl.formatting2 + +import com.minres.rdl.rdl.PropertyDefinition +import com.minres.rdl.rdl.Root +import org.eclipse.xtext.formatting2.AbstractFormatter2 +import org.eclipse.xtext.formatting2.IFormattableDocument + +class RDLFormatter extends AbstractFormatter2 { + + //@Inject extension RDLGrammarAccess + + def dispatch void format(Root root, extension IFormattableDocument document) { + // TODO: format HiddenRegions around keywords, attributes, cross references, etc. + for (include : root.includes) { + include.format + } + for (componentDefinition : root.componentDefinitions) { + componentDefinition.format + } + for (enumDefinition : root.enumDefinitions) { + enumDefinition.format + } + for (instantiation : root.instantiations) { + instantiation.format + } + for (propertyAssignment : root.propertyAssignments) { + propertyAssignment.format + } + for (propertyDefinition : root.propertyDefinitions) { + propertyDefinition.format + } + } + + def dispatch void format(PropertyDefinition propertyDefinition, extension IFormattableDocument document) { + // TODO: format HiddenRegions around keywords, attributes, cross references, etc. + propertyDefinition.usage.format + propertyDefinition.^default.format + } + + // TODO: implement for ComponentDefinition, Instantiation, ComponentInstance, ExplicitPropertyAssignment, PostPropertyAssignment, InstancePropertyRef, InstanceRef, PropertyAssignmentRhs, Concat, ConcatElem, EnumDefinition, EnumBody, EnumEntry +} diff --git a/com.minres.rdl.parent/com.minres.rdl/xtend-gen/com/minres/rdl/formatting2/RDLFormatter.java b/com.minres.rdl.parent/com.minres.rdl/xtend-gen/com/minres/rdl/formatting2/RDLFormatter.java new file mode 100644 index 0000000..ac1a0fc --- /dev/null +++ b/com.minres.rdl.parent/com.minres.rdl/xtend-gen/com/minres/rdl/formatting2/RDLFormatter.java @@ -0,0 +1,81 @@ +/** + * generated by Xtext 2.14.0 + */ +package com.minres.rdl.formatting2; + +import com.minres.rdl.rdl.ComponentDefinition; +import com.minres.rdl.rdl.EnumDefinition; +import com.minres.rdl.rdl.Include; +import com.minres.rdl.rdl.Instantiation; +import com.minres.rdl.rdl.PropertyAssignment; +import com.minres.rdl.rdl.PropertyDefault; +import com.minres.rdl.rdl.PropertyDefinition; +import com.minres.rdl.rdl.PropertyUsage; +import com.minres.rdl.rdl.Root; +import java.util.Arrays; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.formatting2.AbstractFormatter2; +import org.eclipse.xtext.formatting2.IFormattableDocument; +import org.eclipse.xtext.resource.XtextResource; +import org.eclipse.xtext.xbase.lib.Extension; + +@SuppressWarnings("all") +public class RDLFormatter extends AbstractFormatter2 { + protected void _format(final Root root, @Extension final IFormattableDocument document) { + EList _includes = root.getIncludes(); + for (final Include include : _includes) { + document.format(include); + } + EList _componentDefinitions = root.getComponentDefinitions(); + for (final ComponentDefinition componentDefinition : _componentDefinitions) { + document.format(componentDefinition); + } + EList _enumDefinitions = root.getEnumDefinitions(); + for (final EnumDefinition enumDefinition : _enumDefinitions) { + document.format(enumDefinition); + } + EList _instantiations = root.getInstantiations(); + for (final Instantiation instantiation : _instantiations) { + document.format(instantiation); + } + EList _propertyAssignments = root.getPropertyAssignments(); + for (final PropertyAssignment propertyAssignment : _propertyAssignments) { + document.format(propertyAssignment); + } + EList _propertyDefinitions = root.getPropertyDefinitions(); + for (final PropertyDefinition propertyDefinition : _propertyDefinitions) { + document.format(propertyDefinition); + } + } + + protected void _format(final PropertyDefinition propertyDefinition, @Extension final IFormattableDocument document) { + document.format(propertyDefinition.getUsage()); + document.format(propertyDefinition.getDefault()); + } + + public void format(final Object propertyDefinition, final IFormattableDocument document) { + if (propertyDefinition instanceof XtextResource) { + _format((XtextResource)propertyDefinition, document); + return; + } else if (propertyDefinition instanceof PropertyDefinition) { + _format((PropertyDefinition)propertyDefinition, document); + return; + } else if (propertyDefinition instanceof Root) { + _format((Root)propertyDefinition, document); + return; + } else if (propertyDefinition instanceof EObject) { + _format((EObject)propertyDefinition, document); + return; + } else if (propertyDefinition == null) { + _format((Void)null, document); + return; + } else if (propertyDefinition != null) { + _format(propertyDefinition, document); + return; + } else { + throw new IllegalArgumentException("Unhandled parameter types: " + + Arrays.asList(propertyDefinition, document).toString()); + } + } +}