mirror of https://github.com/Minres/RDL-Editor.git
Cleanup and fix of old settings
This commit is contained in:
parent
acb5b95f5a
commit
c7d8d6c417
|
@ -18,7 +18,7 @@
|
|||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-surefire-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<!-- <version>${tycho-version}</version> -->
|
||||
<configuration>
|
||||
<failIfNoTests>false</failIfNoTests>
|
||||
</configuration>
|
||||
|
|
|
@ -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
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 493 B |
|
@ -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<? extends IContentFormatterFactory> bindIContentFormatterFactory() {
|
||||
return ContentFormatterFactory.class;
|
||||
}
|
||||
|
||||
// contributed by org.eclipse.xtext.xtext.generator.ui.labeling.LabelProviderFragment2
|
||||
public Class<? extends ILabelProvider> 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<? extends IProjectCreator> bindIProjectCreator() {
|
||||
return RDLProjectCreator.class;
|
||||
return DefaultTemplateProjectCreator.class;
|
||||
}
|
||||
|
||||
// contributed by org.eclipse.xtext.xtext.generator.exporting.SimpleNamesFragment2
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<EclipseResourceFileSystemAccess2> 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<String> getAllFolders() {
|
||||
Set<OutputConfiguration> 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<String> 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<String, OutputConfiguration> outputConfigurations = new HashMap<String, OutputConfiguration>();
|
||||
outputConfigurations.put(IFileSystemAccess.DEFAULT_OUTPUT, defaultOutput);
|
||||
access.setOutputConfigurations(outputConfigurations);
|
||||
return access;
|
||||
}
|
||||
}
|
|
@ -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};
|
||||
}
|
||||
}
|
|
@ -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<? extends IProjectCreator> bindIProjectCreator() {
|
||||
return JDTFreeStructuralProjectCreator;
|
||||
}
|
||||
// override Class<? extends IProjectCreator> bindIProjectCreator() {
|
||||
// return JDTFreeStructuralProjectCreator;
|
||||
// }
|
||||
|
||||
override Class<? extends IResourceSetProvider> bindIResourceSetProvider() {
|
||||
return SimpleResourceSetProvider
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
}
|
|
@ -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!
|
||||
'''
|
||||
)
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
||||
}
|
|
@ -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="<p><b>Hello World</b></p>
|
||||
<p>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.</p>")
|
||||
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»!
|
||||
''')
|
||||
])
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
HelloWorldProject_Label=Hello World
|
||||
HelloWorldProject_Description=<p><b>Hello World</b></p> <p>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.</p>
|
|
@ -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<? extends IProjectCreator> bindIProjectCreator() {
|
||||
return JDTFreeStructuralProjectCreator.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IResourceSetProvider> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 = "<p><b>Hello World</b></p>\n<p>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.</p>")
|
||||
@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<PluginProjectFactory> _function = (PluginProjectFactory it) -> {
|
||||
it.setProjectName(this.getProjectInfo().getProjectName());
|
||||
it.setLocation(this.getProjectInfo().getLocationPath());
|
||||
List<String> _projectNatures = it.getProjectNatures();
|
||||
Iterables.<String>addAll(_projectNatures, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID)));
|
||||
List<String> _builderIds = it.getBuilderIds();
|
||||
_builderIds.add(JavaCore.BUILDER_ID);
|
||||
List<String> _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.<PluginProjectFactory>operator_doubleArrow(_pluginProjectFactory, _function);
|
||||
generator.generate(_doubleArrow);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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 };
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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">
|
||||
<genPackages prefix="Rdl" basePackage="com.minres.rdl" disposableProviderFactory="true"
|
||||
fileExtensions="rdl" ecorePackage="RDL.ecore#/">
|
||||
<genEnums typeSafeEnumCompatible="false" ecoreEnum="RDL.ecore#//PropertyTypeName">
|
||||
|
|
|
@ -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<? extends IFormatter2> 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<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
|
||||
return SimpleNameProvider.class;
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -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(')');
|
||||
|
|
|
@ -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(')');
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -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(')');
|
||||
|
|
|
@ -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(')');
|
||||
|
|
|
@ -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(')');
|
||||
|
|
|
@ -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(')');
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -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(')');
|
||||
|
|
|
@ -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(')');
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -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: ");
|
||||
|
|
|
@ -299,7 +299,7 @@ public class RdlPackageImpl extends EPackageImpl implements RdlPackage
|
|||
|
||||
/**
|
||||
* Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
|
||||
*
|
||||
*
|
||||
* <p>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.
|
||||
* <!-- begin-user-doc -->
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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<Include> _includes = root.getIncludes();
|
||||
for (final Include include : _includes) {
|
||||
document.<Include>format(include);
|
||||
}
|
||||
EList<ComponentDefinition> _componentDefinitions = root.getComponentDefinitions();
|
||||
for (final ComponentDefinition componentDefinition : _componentDefinitions) {
|
||||
document.<ComponentDefinition>format(componentDefinition);
|
||||
}
|
||||
EList<EnumDefinition> _enumDefinitions = root.getEnumDefinitions();
|
||||
for (final EnumDefinition enumDefinition : _enumDefinitions) {
|
||||
document.<EnumDefinition>format(enumDefinition);
|
||||
}
|
||||
EList<Instantiation> _instantiations = root.getInstantiations();
|
||||
for (final Instantiation instantiation : _instantiations) {
|
||||
document.<Instantiation>format(instantiation);
|
||||
}
|
||||
EList<PropertyAssignment> _propertyAssignments = root.getPropertyAssignments();
|
||||
for (final PropertyAssignment propertyAssignment : _propertyAssignments) {
|
||||
document.<PropertyAssignment>format(propertyAssignment);
|
||||
}
|
||||
EList<PropertyDefinition> _propertyDefinitions = root.getPropertyDefinitions();
|
||||
for (final PropertyDefinition propertyDefinition : _propertyDefinitions) {
|
||||
document.<PropertyDefinition>format(propertyDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
protected void _format(final PropertyDefinition propertyDefinition, @Extension final IFormattableDocument document) {
|
||||
document.<PropertyUsage>format(propertyDefinition.getUsage());
|
||||
document.<PropertyDefault>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.<Object>asList(propertyDefinition, document).toString());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue