mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
Merge pull request #1450 from eclipse/cd_moreX2Jconv
[eclipse/xtext#1679] converted Xtend code to Java
This commit is contained in:
commit
c0a8631f7b
74 changed files with 1104 additions and 2299 deletions
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import org.eclipse.emf.mwe2.runtime.Mandatory;
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.XtextGeneratorFileSystemAccess;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Generator fragment that allows to write files to arbitrary, user configurable
|
||||
* locations.
|
||||
*
|
||||
* @author Sebastian Zarnekow - Initial contribution and API
|
||||
*/
|
||||
public abstract class AbstractExternalFolderAwareFragment extends AbstractXtextGeneratorFragment {
|
||||
private String absolutePath;
|
||||
|
||||
private boolean override = false;
|
||||
|
||||
private IXtextGeneratorFileSystemAccess outputLocation;
|
||||
|
||||
protected IXtextGeneratorFileSystemAccess getOutputLocation() {
|
||||
return outputLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Injector injector) {
|
||||
super.initialize(injector);
|
||||
outputLocation = new XtextGeneratorFileSystemAccess(absolutePath, override);
|
||||
injector.injectMembers(outputLocation);
|
||||
}
|
||||
|
||||
protected String getAbsolutePath() {
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
@Mandatory
|
||||
public void setAbsolutePath(String absolutePath) {
|
||||
this.absolutePath = absolutePath;
|
||||
}
|
||||
|
||||
protected boolean isOverride() {
|
||||
return override;
|
||||
}
|
||||
|
||||
public void setOverride(boolean override) {
|
||||
this.override = override;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import com.google.inject.Injector
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess
|
||||
import org.eclipse.xtext.xtext.generator.model.XtextGeneratorFileSystemAccess
|
||||
import org.eclipse.emf.mwe2.runtime.Mandatory
|
||||
|
||||
/**
|
||||
* Generator fragment that allows to write files to arbitrary, user configurable
|
||||
* locations.
|
||||
*
|
||||
* @author Sebastian Zarnekow - Initial contribution and API
|
||||
*/
|
||||
abstract class AbstractExternalFolderAwareFragment extends AbstractXtextGeneratorFragment {
|
||||
|
||||
String absolutePath
|
||||
|
||||
@Accessors(PROTECTED_GETTER, PUBLIC_SETTER)
|
||||
boolean ^override = false
|
||||
|
||||
IXtextGeneratorFileSystemAccess outputLocation
|
||||
|
||||
protected def getOutputLocation() {
|
||||
return outputLocation
|
||||
}
|
||||
|
||||
override initialize(Injector injector) {
|
||||
super.initialize(injector)
|
||||
this.outputLocation = new XtextGeneratorFileSystemAccess(absolutePath, override)
|
||||
injector.injectMembers(outputLocation)
|
||||
}
|
||||
|
||||
protected def getAbsolutePath() {
|
||||
return absolutePath
|
||||
}
|
||||
|
||||
@Mandatory
|
||||
def void setAbsolutePath(String absolutePath) {
|
||||
this.absolutePath = absolutePath
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import org.eclipse.xtext.xtext.generator.util.BooleanGeneratorOption;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* A fragment that generates a <em>stub</em>, that is a class where the user can
|
||||
* add custom behavior, e.g. validation or formatting rules. The stub is
|
||||
* generated into the source folder that is not overwritten when the generator
|
||||
* is executed again ({@code src} for plain project layout,
|
||||
* {@code src/main/java} for Maven/Gradle project layout). If you want the stub
|
||||
* to be generated again, delete the already existing file.
|
||||
*/
|
||||
public abstract class AbstractStubGeneratingFragment extends AbstractXtextGeneratorFragment {
|
||||
@Inject
|
||||
private CodeConfig codeConfig;
|
||||
|
||||
private final BooleanGeneratorOption generateStub = new BooleanGeneratorOption(true);
|
||||
|
||||
private final BooleanGeneratorOption generateXtendStub = new BooleanGeneratorOption();
|
||||
|
||||
public boolean isGenerateStub() {
|
||||
return generateStub.get();
|
||||
}
|
||||
|
||||
public void setGenerateStub(boolean generateStub) {
|
||||
this.generateStub.set(generateStub);
|
||||
}
|
||||
|
||||
public boolean isGenerateXtendStub() {
|
||||
if (generateXtendStub.isSet()) {
|
||||
return generateXtendStub.get();
|
||||
} else {
|
||||
return codeConfig.isPreferXtendStubs();
|
||||
}
|
||||
}
|
||||
|
||||
public void setGenerateXtendStub(boolean generateXtendStub) {
|
||||
this.generateXtendStub.set(generateXtendStub);
|
||||
}
|
||||
|
||||
public BooleanGeneratorOption getGenerateStub() {
|
||||
return generateStub;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import com.google.inject.Inject
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.xtext.generator.util.BooleanGeneratorOption
|
||||
|
||||
/**
|
||||
* A fragment that generates a <em>stub</em>, that is a class where the user can add
|
||||
* custom behavior, e.g. validation or formatting rules. The stub is generated into
|
||||
* the source folder that is not overwritten when the generator is executed again
|
||||
* ({@code src} for plain project layout, {@code src/main/java} for Maven/Gradle
|
||||
* project layout). If you want the stub to be generated again, delete the already
|
||||
* existing file.
|
||||
*/
|
||||
abstract class AbstractStubGeneratingFragment extends AbstractXtextGeneratorFragment {
|
||||
|
||||
@Inject
|
||||
extension CodeConfig
|
||||
|
||||
@Accessors(PUBLIC_GETTER)
|
||||
val generateStub = new BooleanGeneratorOption(true)
|
||||
|
||||
val generateXtendStub = new BooleanGeneratorOption
|
||||
|
||||
def boolean isGenerateStub() {
|
||||
generateStub.get
|
||||
}
|
||||
|
||||
def void setGenerateStub(boolean generateStub) {
|
||||
this.generateStub.set(generateStub)
|
||||
}
|
||||
|
||||
def boolean isGenerateXtendStub() {
|
||||
if (generateXtendStub.isSet)
|
||||
generateXtendStub.get
|
||||
else
|
||||
preferXtendStubs
|
||||
}
|
||||
|
||||
def void setGenerateXtendStub(boolean generateXtendStub) {
|
||||
this.generateXtendStub.set(generateXtendStub)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IXtextProjectConfig;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Convenience class for implementing generator fragments. Provides access to
|
||||
* the {@link IXtextProjectConfig project configuration} and the
|
||||
* {@link IXtextGeneratorLanguage language configuration}.
|
||||
*/
|
||||
public abstract class AbstractXtextGeneratorFragment implements IXtextGeneratorFragment {
|
||||
@Inject
|
||||
private IXtextProjectConfig projectConfig;
|
||||
|
||||
@Inject
|
||||
private IXtextGeneratorLanguage language;
|
||||
|
||||
@Inject
|
||||
private Grammar grammar;
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(Issues issues) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Injector injector) {
|
||||
injector.injectMembers(this);
|
||||
}
|
||||
|
||||
protected IXtextProjectConfig getProjectConfig() {
|
||||
return projectConfig;
|
||||
}
|
||||
|
||||
protected IXtextGeneratorLanguage getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
protected Grammar getGrammar() {
|
||||
return grammar;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import com.google.inject.Inject
|
||||
import com.google.inject.Injector
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.Grammar
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IXtextProjectConfig
|
||||
|
||||
/**
|
||||
* Convenience class for implementing generator fragments. Provides access to the
|
||||
* {@link IXtextProjectConfig project configuration} and the {@link IXtextGeneratorLanguage language configuration}.
|
||||
*/
|
||||
abstract class AbstractXtextGeneratorFragment implements IXtextGeneratorFragment {
|
||||
|
||||
@Accessors(PROTECTED_GETTER)
|
||||
@Inject IXtextProjectConfig projectConfig
|
||||
|
||||
@Accessors(PROTECTED_GETTER)
|
||||
@Inject IXtextGeneratorLanguage language
|
||||
|
||||
@Accessors(PROTECTED_GETTER)
|
||||
@Inject Grammar grammar
|
||||
|
||||
override checkConfiguration(Issues issues) {
|
||||
}
|
||||
|
||||
override initialize(Injector injector) {
|
||||
injector.injectMembers(this)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class CompositeGeneratorException extends RuntimeException {
|
||||
private static final long serialVersionUID = 2875516656439737396L;
|
||||
private final List<Exception> exceptions = new ArrayList<>();
|
||||
|
||||
public boolean addException(Exception exception) {
|
||||
return exceptions.add(exception);
|
||||
}
|
||||
|
||||
public boolean hasExceptions() {
|
||||
return !exceptions.isEmpty();
|
||||
}
|
||||
|
||||
public List<Exception> getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import java.lang.RuntimeException
|
||||
import java.util.List
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
|
||||
package class CompositeGeneratorException extends RuntimeException {
|
||||
@Accessors
|
||||
val List<Exception> exceptions = newArrayList
|
||||
|
||||
def addException(Exception exception) {
|
||||
exceptions.add(exception)
|
||||
}
|
||||
|
||||
def hasExceptions() {
|
||||
exceptions.size > 0
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* A generator fragment that delegates to a list of contained fragments. This
|
||||
* can be useful for extracting parts of a language configuration to a separate
|
||||
* mwe2 file, for example.
|
||||
*/
|
||||
public class CompositeGeneratorFragment2 implements IXtextGeneratorFragment {
|
||||
private final List<IXtextGeneratorFragment> fragments = new ArrayList<>();
|
||||
|
||||
public void addFragment(IXtextGeneratorFragment fragment) {
|
||||
if (fragment == this) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
fragments.add(fragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(Issues issues) {
|
||||
for (IXtextGeneratorFragment fragment : fragments) {
|
||||
fragment.checkConfiguration(issues);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
CompositeGeneratorException composite = new CompositeGeneratorException();
|
||||
for (IXtextGeneratorFragment fragment : fragments) {
|
||||
try {
|
||||
fragment.generate();
|
||||
} catch (Exception e) {
|
||||
composite.addException(e);
|
||||
}
|
||||
}
|
||||
if (composite.hasExceptions()) {
|
||||
throw composite;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Injector injector) {
|
||||
for (IXtextGeneratorFragment fragment : fragments) {
|
||||
fragment.initialize(injector);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<IXtextGeneratorFragment> getFragments() {
|
||||
return fragments;
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import com.google.inject.Injector
|
||||
import java.util.List
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
|
||||
/**
|
||||
* A generator fragment that delegates to a list of contained fragments. This can be
|
||||
* useful for extracting parts of a language configuration to a separate mwe2 file,
|
||||
* for example.
|
||||
*/
|
||||
class CompositeGeneratorFragment2 implements IXtextGeneratorFragment {
|
||||
|
||||
@Accessors(PROTECTED_GETTER)
|
||||
val List<IXtextGeneratorFragment> fragments = newArrayList
|
||||
|
||||
def void addFragment(IXtextGeneratorFragment fragment) {
|
||||
if (fragment === this)
|
||||
throw new IllegalArgumentException
|
||||
this.fragments.add(fragment)
|
||||
}
|
||||
|
||||
override checkConfiguration(Issues issues) {
|
||||
for (fragment : fragments) {
|
||||
fragment.checkConfiguration(issues)
|
||||
}
|
||||
}
|
||||
|
||||
override generate() {
|
||||
val composite = new CompositeGeneratorException
|
||||
for (fragment : fragments) {
|
||||
try {
|
||||
fragment.generate
|
||||
} catch (Exception e) {
|
||||
composite.addException(e)
|
||||
}
|
||||
}
|
||||
if (composite.hasExceptions) {
|
||||
throw composite
|
||||
}
|
||||
}
|
||||
|
||||
override initialize(Injector injector) {
|
||||
for (fragment : fragments) {
|
||||
fragment.initialize(injector)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Copyright (c) 2017, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Generator fragment that wraps another fragment and can be toggled via a
|
||||
* property
|
||||
*
|
||||
* @author Christian Dietrich - Initial contribution and API
|
||||
*
|
||||
* @since 2.13
|
||||
*/
|
||||
public class ConditionalXtextGeneratorFragment implements IXtextGeneratorFragment {
|
||||
private IXtextGeneratorFragment fragment;
|
||||
|
||||
private boolean enabled = true;
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(Issues issues) {
|
||||
if (fragment == null) {
|
||||
issues.addError("The property 'fragment' must be set.", this);
|
||||
} else {
|
||||
fragment.checkConfiguration(issues);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
if (enabled) {
|
||||
fragment.generate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Injector injector) {
|
||||
fragment.initialize(injector);
|
||||
}
|
||||
|
||||
public IXtextGeneratorFragment getFragment() {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void setFragment(IXtextGeneratorFragment fragment) {
|
||||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import com.google.inject.Injector
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
|
||||
/**
|
||||
* Generator fragment that wraps another fragment and can be toggled via a property
|
||||
*
|
||||
* @author Christian Dietrich - Initial contribution and API
|
||||
*
|
||||
* @since 2.13
|
||||
*/
|
||||
class ConditionalXtextGeneratorFragment implements IXtextGeneratorFragment {
|
||||
|
||||
@Accessors
|
||||
IXtextGeneratorFragment fragment
|
||||
|
||||
@Accessors
|
||||
boolean enabled = true
|
||||
|
||||
override checkConfiguration(Issues issues) {
|
||||
if (fragment === null)
|
||||
issues.addError('The property \'fragment\' must be set.', this)
|
||||
else
|
||||
fragment.checkConfiguration(issues)
|
||||
}
|
||||
|
||||
override generate() {
|
||||
if (enabled) {
|
||||
fragment.generate()
|
||||
}
|
||||
}
|
||||
|
||||
override initialize(Injector injector) {
|
||||
fragment.initialize(injector)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet;
|
||||
import org.eclipse.xtext.formatting.ILineSeparatorInformation;
|
||||
import org.eclipse.xtext.parser.IEncodingProvider;
|
||||
import org.eclipse.xtext.resource.XtextResourceSet;
|
||||
import org.eclipse.xtext.service.AbstractGenericModule;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IXtextProjectConfig;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.StandardProjectConfig;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.XtextProjectConfig;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
|
||||
/**
|
||||
* An instance of this module is assigned to the {@code configuration} property
|
||||
* of {@link XtextGenerator}. It contains the {@link XtextProjectConfig project
|
||||
* configuration} and the {@link CodeConfig code configuration}. If you need to
|
||||
* configure more aspects of the generator, create a subclass and bind your
|
||||
* custom configuration classes. For example, in order to adapt the
|
||||
* {@link XtextGeneratorNaming naming} of the generated code, use the following:
|
||||
*
|
||||
* <pre>
|
||||
* class MyGeneratorModule extends DefaultGeneratorModule {
|
||||
* def Class<? extends XtextGeneratorNaming> bindXtextGeneratorNaming() {
|
||||
* MyGeneratorNaming
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public class DefaultGeneratorModule extends AbstractGenericModule {
|
||||
private XtextProjectConfig project = new StandardProjectConfig();
|
||||
|
||||
private CodeConfig code = new CodeConfig();
|
||||
|
||||
protected void checkConfiguration(Issues issues) {
|
||||
project.checkConfiguration(issues);
|
||||
}
|
||||
|
||||
public void configureXtextProjectConfig(Binder binder) {
|
||||
binder.bind(IXtextProjectConfig.class).toInstance(project);
|
||||
}
|
||||
|
||||
public void configureCodeConfig(Binder binder) {
|
||||
binder.bind(CodeConfig.class).toInstance(code);
|
||||
}
|
||||
|
||||
public void configureResourceSet(Binder binder) {
|
||||
binder.bind(ResourceSet.class).to(XtextResourceSet.class);
|
||||
}
|
||||
|
||||
public void configureLineSeparatorInformation(Binder binder) {
|
||||
binder.bind(ILineSeparatorInformation.class).toInstance(() -> code.getLineDelimiter());
|
||||
}
|
||||
|
||||
public void configureIEncodingProvider(Binder binder) {
|
||||
IEncodingProvider.Runtime runtime = new IEncodingProvider.Runtime();
|
||||
runtime.setDefaultEncoding(code.getEncoding());
|
||||
binder.bind(IEncodingProvider.class).toInstance(runtime);
|
||||
}
|
||||
|
||||
public XtextProjectConfig getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(XtextProjectConfig project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public CodeConfig getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(CodeConfig code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import com.google.inject.Binder
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.formatting.ILineSeparatorInformation
|
||||
import org.eclipse.xtext.parser.IEncodingProvider
|
||||
import org.eclipse.xtext.resource.XtextResourceSet
|
||||
import org.eclipse.xtext.service.AbstractGenericModule
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IXtextProjectConfig
|
||||
import org.eclipse.xtext.xtext.generator.model.project.StandardProjectConfig
|
||||
import org.eclipse.xtext.xtext.generator.model.project.XtextProjectConfig
|
||||
|
||||
/**
|
||||
* An instance of this module is assigned to the {@code configuration} property of
|
||||
* {@link XtextGenerator}. It contains the {@link XtextProjectConfig project configuration}
|
||||
* and the {@link CodeConfig code configuration}. If you need to configure more aspects of
|
||||
* the generator, create a subclass and bind your custom configuration classes. For example,
|
||||
* in order to adapt the {@link XtextGeneratorNaming naming} of the generated code, use
|
||||
* the following:
|
||||
* <pre>
|
||||
* class MyGeneratorModule extends DefaultGeneratorModule {
|
||||
* def Class<? extends XtextGeneratorNaming> bindXtextGeneratorNaming() {
|
||||
* MyGeneratorNaming
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
class DefaultGeneratorModule extends AbstractGenericModule {
|
||||
|
||||
@Accessors
|
||||
XtextProjectConfig project = new StandardProjectConfig
|
||||
|
||||
@Accessors
|
||||
CodeConfig code = new CodeConfig
|
||||
|
||||
protected def void checkConfiguration(Issues issues) {
|
||||
project.checkConfiguration(issues)
|
||||
}
|
||||
|
||||
def void configureXtextProjectConfig(Binder binder) {
|
||||
binder.bind(IXtextProjectConfig).toInstance(project)
|
||||
}
|
||||
|
||||
def void configureCodeConfig(Binder binder) {
|
||||
binder.bind(CodeConfig).toInstance(code)
|
||||
}
|
||||
|
||||
def void configureResourceSet(Binder binder) {
|
||||
binder.bind(ResourceSet).to(XtextResourceSet)
|
||||
}
|
||||
|
||||
def void configureLineSeparatorInformation(Binder binder) {
|
||||
binder.bind(ILineSeparatorInformation).toInstance[code.lineDelimiter]
|
||||
}
|
||||
|
||||
def void configureIEncodingProvider(Binder binder) {
|
||||
binder.bind(IEncodingProvider).toInstance(new IEncodingProvider.Runtime => [
|
||||
defaultEncoding = code.encoding
|
||||
])
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.service.AbstractGenericModule;
|
||||
import org.eclipse.xtext.xtext.RuleNames;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
|
||||
/**
|
||||
* Language-specific Guice module that is used in a child injector of the global
|
||||
* injector derived from {@link DefaultGeneratorModule}.
|
||||
*/
|
||||
class LanguageModule extends AbstractGenericModule {
|
||||
private final XtextGeneratorLanguage language;
|
||||
|
||||
public void configureLanguage(Binder binder) {
|
||||
binder.bind(IXtextGeneratorLanguage.class).toProvider(() -> language);
|
||||
}
|
||||
|
||||
public void configureGrammar(Binder binder) {
|
||||
binder.bind(Grammar.class).toProvider(() -> language.getGrammar());
|
||||
}
|
||||
|
||||
public void configureRuleNames(Binder binder) {
|
||||
binder.bind(RuleNames.class).toProvider(() -> language.getRuleNames());
|
||||
}
|
||||
|
||||
public void configureAdditionalBindings(Binder binder) {
|
||||
binder.install(language.getGuiceModule());
|
||||
}
|
||||
|
||||
public LanguageModule(XtextGeneratorLanguage language) {
|
||||
this.language = language;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import com.google.inject.Binder
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
|
||||
import org.eclipse.xtext.Grammar
|
||||
import org.eclipse.xtext.service.AbstractGenericModule
|
||||
import org.eclipse.xtext.xtext.RuleNames
|
||||
|
||||
/**
|
||||
* Language-specific Guice module that is used in a child injector of the global injector
|
||||
* derived from {@link DefaultGeneratorModule}.
|
||||
*/
|
||||
@FinalFieldsConstructor
|
||||
package class LanguageModule extends AbstractGenericModule {
|
||||
|
||||
val XtextGeneratorLanguage language
|
||||
|
||||
def void configureLanguage(Binder binder) {
|
||||
binder.bind(IXtextGeneratorLanguage).toProvider[language]
|
||||
}
|
||||
|
||||
def void configureGrammar(Binder binder) {
|
||||
binder.bind(Grammar).toProvider[language.grammar]
|
||||
}
|
||||
|
||||
def void configureRuleNames(Binder binder) {
|
||||
binder.bind(RuleNames).toProvider[language.ruleNames]
|
||||
}
|
||||
|
||||
def void configureAdditionalBindings(Binder binder) {
|
||||
binder.install(language.guiceModule)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
/**
|
||||
* {@link Issues} implementation for MWE2 workflows.
|
||||
*/
|
||||
public class MweIssues implements Issues {
|
||||
private final XtextGenerator owner;
|
||||
|
||||
private final org.eclipse.emf.mwe.core.issues.Issues delegate;
|
||||
|
||||
public MweIssues(XtextGenerator owner, org.eclipse.emf.mwe.core.issues.Issues delegate) {
|
||||
this.owner = owner;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addError(String message) {
|
||||
delegate.addError(owner, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addError(String message, Object source) {
|
||||
delegate.addError(owner, message, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWarning(String message) {
|
||||
delegate.addWarning(owner, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWarning(String message, Object source) {
|
||||
delegate.addWarning(owner, message, source);
|
||||
}
|
||||
|
||||
public XtextGenerator getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public org.eclipse.emf.mwe.core.issues.Issues getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator
|
||||
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
|
||||
|
||||
/**
|
||||
* {@link Issues} implementation for MWE2 workflows.
|
||||
*/
|
||||
@FinalFieldsConstructor
|
||||
class MweIssues implements Issues {
|
||||
|
||||
@Accessors val XtextGenerator owner
|
||||
@Accessors val org.eclipse.emf.mwe.core.issues.Issues delegate
|
||||
|
||||
override addError(String message) {
|
||||
delegate.addError(owner, message)
|
||||
}
|
||||
|
||||
override addError(String message, Object source) {
|
||||
delegate.addError(owner, message, source)
|
||||
}
|
||||
|
||||
override addWarning(String message) {
|
||||
delegate.addWarning(owner, message)
|
||||
}
|
||||
|
||||
override addWarning(String message, Object source) {
|
||||
delegate.addWarning(owner, message, source)
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -19,10 +19,12 @@ import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
|||
*
|
||||
* @author Christian Schneider - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class Ecore2XtextValueConverterServiceFragment2 extends AbstractXtextGeneratorFragment {
|
||||
@Override
|
||||
public void generate() {
|
||||
new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IValueConverterService.class), TypeReference.typeRef(Ecore2XtextTerminalConverters.class)).contributeTo(this.getLanguage().getRuntimeGenModule());
|
||||
}
|
||||
@Override
|
||||
public void generate() {
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType(TypeReference.typeRef(IValueConverterService.class),
|
||||
TypeReference.typeRef(Ecore2XtextTerminalConverters.class))
|
||||
.contributeTo(getLanguage().getRuntimeGenModule());
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.ecore2xtext
|
||||
|
||||
import org.eclipse.xtext.common.services.Ecore2XtextTerminalConverters
|
||||
import org.eclipse.xtext.conversion.IValueConverterService
|
||||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
|
||||
|
||||
import static extension org.eclipse.xtext.xtext.generator.model.TypeReference.*
|
||||
import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment
|
||||
|
||||
/**
|
||||
* Contributes the registration of the {@link Ecore2XtextTerminalConverters}.
|
||||
*
|
||||
* @author Christian Schneider - Initial contribution and API
|
||||
*/
|
||||
class Ecore2XtextValueConverterServiceFragment2 extends AbstractXtextGeneratorFragment {
|
||||
|
||||
override generate() {
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType(IValueConverterService.typeRef(), Ecore2XtextTerminalConverters.typeRef())
|
||||
.contributeTo(language.runtimeGenModule)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.exporting;
|
||||
|
||||
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
|
||||
import org.eclipse.xtext.naming.IQualifiedNameProvider;
|
||||
import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment;
|
||||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
|
||||
public class QualifiedNamesFragment2 extends AbstractXtextGeneratorFragment {
|
||||
@Override
|
||||
public void generate() {
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType(TypeReference.typeRef(IQualifiedNameProvider.class),
|
||||
TypeReference.typeRef(DefaultDeclarativeQualifiedNameProvider.class))
|
||||
.contributeTo(getLanguage().getRuntimeGenModule());
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher"),
|
||||
TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.FQNPrefixMatcher"))
|
||||
.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator"),
|
||||
TypeReference
|
||||
.typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator"))
|
||||
.contributeTo(getLanguage().getEclipsePluginGenModule());
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.IPrefixMatcher"),
|
||||
TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.FQNPrefixMatcher"))
|
||||
.contributeTo(getLanguage().getIdeGenModule());
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2016 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.exporting
|
||||
|
||||
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider
|
||||
import org.eclipse.xtext.naming.IQualifiedNameProvider
|
||||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
|
||||
|
||||
import static extension org.eclipse.xtext.xtext.generator.model.TypeReference.*
|
||||
import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment
|
||||
|
||||
class QualifiedNamesFragment2 extends AbstractXtextGeneratorFragment {
|
||||
|
||||
override generate() {
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType(IQualifiedNameProvider.typeRef, DefaultDeclarativeQualifiedNameProvider.typeRef)
|
||||
.contributeTo(language.runtimeGenModule)
|
||||
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType('org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher'.typeRef,
|
||||
'org.eclipse.xtext.ui.editor.contentassist.FQNPrefixMatcher'.typeRef)
|
||||
.addTypeToType('org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator'.typeRef,
|
||||
'org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator'.typeRef)
|
||||
.contributeTo(language.eclipsePluginGenModule)
|
||||
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType('org.eclipse.xtext.ide.editor.contentassist.IPrefixMatcher'.typeRef,
|
||||
'org.eclipse.xtext.ide.editor.contentassist.FQNPrefixMatcher'.typeRef)
|
||||
.contributeTo(language.ideGenModule)
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -14,12 +14,17 @@ import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment;
|
|||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class SimpleNamesFragment2 extends AbstractXtextGeneratorFragment {
|
||||
@Override
|
||||
public void generate() {
|
||||
new GuiceModuleAccess.BindingFactory().addfinalTypeToType(TypeReference.typeRef(IQualifiedNameProvider.class), TypeReference.typeRef(SimpleNameProvider.class)).contributeTo(this.getLanguage().getRuntimeGenModule());
|
||||
new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator"),
|
||||
TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator")).contributeTo(this.getLanguage().getEclipsePluginGenModule());
|
||||
}
|
||||
@Override
|
||||
public void generate() {
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addfinalTypeToType(TypeReference.typeRef(IQualifiedNameProvider.class),
|
||||
TypeReference.typeRef(SimpleNameProvider.class))
|
||||
.contributeTo(getLanguage().getRuntimeGenModule());
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator"),
|
||||
TypeReference
|
||||
.typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator"))
|
||||
.contributeTo(getLanguage().getEclipsePluginGenModule());
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.exporting
|
||||
|
||||
import org.eclipse.xtext.naming.IQualifiedNameProvider
|
||||
import org.eclipse.xtext.naming.SimpleNameProvider
|
||||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess
|
||||
|
||||
import static extension org.eclipse.xtext.xtext.generator.model.TypeReference.*
|
||||
import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment
|
||||
|
||||
class SimpleNamesFragment2 extends AbstractXtextGeneratorFragment {
|
||||
|
||||
override generate() {
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addfinalTypeToType(IQualifiedNameProvider.typeRef, SimpleNameProvider.typeRef)
|
||||
.contributeTo(language.runtimeGenModule)
|
||||
new GuiceModuleAccess.BindingFactory()
|
||||
.addTypeToType('org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator'.typeRef,
|
||||
'org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator'.typeRef)
|
||||
.contributeTo(language.eclipsePluginGenModule)
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2018 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -14,6 +14,5 @@ import org.eclipse.xtext.xtext.generator.junit.JUnitFragment;
|
|||
* @deprecated Use JUnitFragment instead
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("all")
|
||||
public class Junit4Fragment2 extends JUnitFragment {
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2018 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.junit
|
||||
|
||||
/**
|
||||
* @deprecated Use JUnitFragment instead
|
||||
*/
|
||||
@Deprecated
|
||||
class Junit4Fragment2 extends JUnitFragment {
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* Copyright (c) 2017, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2;
|
||||
|
||||
/**
|
||||
* A utility class for generating binary files.
|
||||
*/
|
||||
public class BinaryFileAccess {
|
||||
private String path;
|
||||
|
||||
protected byte[] internalContents;
|
||||
|
||||
public void setContent(byte[] content) {
|
||||
this.internalContents = content;
|
||||
}
|
||||
|
||||
public byte[] getContent() {
|
||||
return Arrays.copyOf(internalContents, internalContents.length);
|
||||
}
|
||||
|
||||
public void writeTo(IFileSystemAccess2 fileSystemAccess) {
|
||||
if (fileSystemAccess != null) {
|
||||
fileSystemAccess.generateFile(path, new ByteArrayInputStream(internalContents));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean existIn(IXtextGeneratorFileSystemAccess fileSystemAccess) {
|
||||
if (fileSystemAccess == null) {
|
||||
return false;
|
||||
}
|
||||
return fileSystemAccess.isFile(path);
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.model
|
||||
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.util.Arrays
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2
|
||||
|
||||
/**
|
||||
* A utility class for generating binary files.
|
||||
*/
|
||||
class BinaryFileAccess {
|
||||
|
||||
@Accessors
|
||||
String path
|
||||
|
||||
protected byte[] internalContents
|
||||
|
||||
def void setContent(byte[] content) {
|
||||
internalContents = content
|
||||
}
|
||||
|
||||
def byte[] getContent() {
|
||||
return Arrays.copyOf(internalContents, internalContents.length)
|
||||
}
|
||||
|
||||
def void writeTo(IFileSystemAccess2 fileSystemAccess) {
|
||||
if (fileSystemAccess !== null) {
|
||||
fileSystemAccess.generateFile(path, new ByteArrayInputStream(internalContents))
|
||||
}
|
||||
}
|
||||
|
||||
def existIn(IXtextGeneratorFileSystemAccess fileSystemAccess) {
|
||||
if (fileSystemAccess === null) {
|
||||
return false
|
||||
}
|
||||
return fileSystemAccess.isFile(path)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient;
|
||||
import org.eclipse.xtext.xtext.generator.CodeConfig;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Factory for creating text files, Java files, and Xtend files.
|
||||
*/
|
||||
public class FileAccessFactory {
|
||||
@Inject
|
||||
private CodeConfig codeConfig;
|
||||
|
||||
public TextFileAccess createTextFile() {
|
||||
return new TextFileAccess();
|
||||
}
|
||||
|
||||
public TextFileAccess createTextFile(String path) {
|
||||
TextFileAccess result = createTextFile();
|
||||
result.setPath(path);
|
||||
return result;
|
||||
}
|
||||
|
||||
public TextFileAccess createTextFile(String path, StringConcatenationClient content) {
|
||||
TextFileAccess result = createTextFile(path);
|
||||
result.setContent(content);
|
||||
return result;
|
||||
}
|
||||
|
||||
public JavaFileAccess createJavaFile(TypeReference typeRef) {
|
||||
return new JavaFileAccess(typeRef, codeConfig);
|
||||
}
|
||||
|
||||
public JavaFileAccess createJavaFile(TypeReference typeRef, StringConcatenationClient content) {
|
||||
JavaFileAccess result = createJavaFile(typeRef);
|
||||
result.setContent(content);
|
||||
return result;
|
||||
}
|
||||
|
||||
public XtendFileAccess createXtendFile(TypeReference typeRef) {
|
||||
return new XtendFileAccess(typeRef, codeConfig);
|
||||
}
|
||||
|
||||
public XtendFileAccess createXtendFile(TypeReference typeRef, StringConcatenationClient content) {
|
||||
XtendFileAccess result = createXtendFile(typeRef);
|
||||
result.setContent(content);
|
||||
return result;
|
||||
}
|
||||
|
||||
public GeneratedJavaFileAccess createGeneratedJavaFile(TypeReference typeRef) {
|
||||
return new GeneratedJavaFileAccess(typeRef, codeConfig);
|
||||
}
|
||||
|
||||
public BinaryFileAccess createBinaryFile() {
|
||||
return new BinaryFileAccess();
|
||||
}
|
||||
|
||||
public BinaryFileAccess createBinaryFile(String path) {
|
||||
BinaryFileAccess result = createBinaryFile();
|
||||
result.setPath(path);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.model
|
||||
|
||||
import com.google.inject.Inject
|
||||
import org.eclipse.xtext.xtext.generator.CodeConfig
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient
|
||||
|
||||
/**
|
||||
* Factory for creating text files, Java files, and Xtend files.
|
||||
*/
|
||||
class FileAccessFactory {
|
||||
|
||||
@Inject CodeConfig codeConfig
|
||||
|
||||
def TextFileAccess createTextFile() {
|
||||
new TextFileAccess()
|
||||
}
|
||||
|
||||
def TextFileAccess createTextFile(String path) {
|
||||
val result = createTextFile()
|
||||
result.path = path
|
||||
return result
|
||||
}
|
||||
|
||||
def TextFileAccess createTextFile(String path, StringConcatenationClient content) {
|
||||
val result = createTextFile(path)
|
||||
result.content = content
|
||||
return result
|
||||
}
|
||||
|
||||
def JavaFileAccess createJavaFile(TypeReference typeRef) {
|
||||
new JavaFileAccess(typeRef, codeConfig)
|
||||
}
|
||||
|
||||
def JavaFileAccess createJavaFile(TypeReference typeRef, StringConcatenationClient content) {
|
||||
val result = createJavaFile(typeRef)
|
||||
result.content = content
|
||||
return result
|
||||
}
|
||||
|
||||
def XtendFileAccess createXtendFile(TypeReference typeRef) {
|
||||
new XtendFileAccess(typeRef, codeConfig)
|
||||
}
|
||||
|
||||
def XtendFileAccess createXtendFile(TypeReference typeRef, StringConcatenationClient content) {
|
||||
val result = createXtendFile(typeRef)
|
||||
result.content = content
|
||||
return result
|
||||
}
|
||||
|
||||
def GeneratedJavaFileAccess createGeneratedJavaFile(TypeReference typeRef) {
|
||||
new GeneratedJavaFileAccess(typeRef, codeConfig)
|
||||
}
|
||||
|
||||
def BinaryFileAccess createBinaryFile() {
|
||||
new BinaryFileAccess()
|
||||
}
|
||||
|
||||
def BinaryFileAccess createBinaryFile(String path) {
|
||||
val result = createBinaryFile()
|
||||
result.path = path
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient;
|
||||
|
||||
/**
|
||||
* Configuration object for the generated standalone setup class. This class is
|
||||
* responsible for adding required EMF packages to the global registries.
|
||||
*/
|
||||
public class StandaloneSetupAccess {
|
||||
private final List<StringConcatenationClient> registrations = new ArrayList<>();
|
||||
|
||||
@Deprecated
|
||||
private final Set<TypeReference> imports = new HashSet<>();
|
||||
|
||||
/**
|
||||
* @deprecated this set is required for backwards-compatibility to Xpand
|
||||
* templates included with
|
||||
* {@code org.eclipse.xtext.generator.adapter.FragmentAdapter}.
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<TypeReference> getImports() {
|
||||
return imports;
|
||||
}
|
||||
|
||||
public List<StringConcatenationClient> getRegistrations() {
|
||||
return registrations;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.model
|
||||
|
||||
import java.util.List
|
||||
import java.util.Set
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient
|
||||
|
||||
/**
|
||||
* Configuration object for the generated standalone setup class. This class is responsible for adding
|
||||
* required EMF packages to the global registries.
|
||||
*/
|
||||
@Accessors
|
||||
class StandaloneSetupAccess {
|
||||
|
||||
val List<StringConcatenationClient> registrations = newArrayList
|
||||
|
||||
@Deprecated
|
||||
val Set<TypeReference> imports = newHashSet
|
||||
|
||||
/**
|
||||
* @deprecated this set is required for backwards-compatibility to Xpand templates included with
|
||||
* {@code org.eclipse.xtext.generator.adapter.FragmentAdapter}.
|
||||
*/
|
||||
@Deprecated
|
||||
def getImports() {
|
||||
imports
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient;
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2;
|
||||
|
||||
/**
|
||||
* A utility class for generating plain text files.
|
||||
*/
|
||||
public class TextFileAccess {
|
||||
private String path;
|
||||
|
||||
protected CharSequence internalContents;
|
||||
|
||||
public void setContent(StringConcatenationClient content) {
|
||||
StringConcatenation stringConcatenation = new StringConcatenation();
|
||||
stringConcatenation.append(content);
|
||||
internalContents = stringConcatenation;
|
||||
}
|
||||
|
||||
public CharSequence getContent() {
|
||||
return internalContents.toString();
|
||||
}
|
||||
|
||||
public String getContentString() {
|
||||
return getContent().toString();
|
||||
}
|
||||
|
||||
public void writeTo(IFileSystemAccess2 fileSystemAccess) {
|
||||
if (fileSystemAccess != null) {
|
||||
fileSystemAccess.generateFile(path, getContent());
|
||||
}
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.model
|
||||
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient
|
||||
import org.eclipse.xtend2.lib.StringConcatenation
|
||||
|
||||
/**
|
||||
* A utility class for generating plain text files.
|
||||
*/
|
||||
class TextFileAccess {
|
||||
|
||||
@Accessors
|
||||
String path
|
||||
|
||||
protected CharSequence internalContents
|
||||
|
||||
def void setContent(StringConcatenationClient content) {
|
||||
internalContents = new StringConcatenation() => [
|
||||
append(content)
|
||||
]
|
||||
}
|
||||
|
||||
def CharSequence getContent() {
|
||||
return internalContents.toString
|
||||
}
|
||||
|
||||
def String getContentString() {
|
||||
return getContent.toString
|
||||
}
|
||||
|
||||
def void writeTo(IFileSystemAccess2 fileSystemAccess) {
|
||||
if (fileSystemAccess !== null) {
|
||||
fileSystemAccess.generateFile(path, content)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
|
||||
import org.eclipse.xtext.generator.OutputConfiguration;
|
||||
import org.eclipse.xtext.xbase.lib.IterableExtensions;
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess;
|
||||
|
||||
public class XtextGeneratorFileSystemAccess extends JavaIoFileSystemAccess implements IXtextGeneratorFileSystemAccess {
|
||||
public XtextGeneratorFileSystemAccess(String path, boolean overwrite) {
|
||||
setOutputPath(removeTrailingPathSeparator(path));
|
||||
getDefaultOutput().setOverrideExistingResources(overwrite);
|
||||
}
|
||||
|
||||
private String removeTrailingPathSeparator(String s) {
|
||||
if (s.endsWith("/")) {
|
||||
return s.substring(0, s.length() - 1);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private OutputConfiguration getDefaultOutput() {
|
||||
return IterableExtensions.head(getOutputConfigurations().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Injector injector) {
|
||||
injector.injectMembers(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return getDefaultOutput().getOutputDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOverwrite() {
|
||||
return getDefaultOutput().isOverrideExistingResources();
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.model
|
||||
|
||||
import com.google.inject.Injector
|
||||
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
|
||||
|
||||
class XtextGeneratorFileSystemAccess extends JavaIoFileSystemAccess implements IXtextGeneratorFileSystemAccess {
|
||||
|
||||
new(String path, boolean overwrite) {
|
||||
outputPath = path.removeTrailingPathSeparator
|
||||
defaultOutput.overrideExistingResources = overwrite
|
||||
}
|
||||
|
||||
private def String removeTrailingPathSeparator(String s) {
|
||||
if (s.endsWith('/')) s.substring(0, s.length - 1) else s
|
||||
}
|
||||
|
||||
private def getDefaultOutput() {
|
||||
outputConfigurations.values.head
|
||||
}
|
||||
|
||||
override initialize(Injector injector) {
|
||||
injector.injectMembers(this)
|
||||
}
|
||||
|
||||
override getPath() {
|
||||
defaultOutput.outputDirectory
|
||||
}
|
||||
|
||||
override isOverwrite() {
|
||||
defaultOutput.overrideExistingResources
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -16,35 +16,34 @@ import org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation;
|
|||
/**
|
||||
* A class annotation configuration for the <code>@Singleton</code> annotation.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class SingletonClassAnnotation implements IClassAnnotation {
|
||||
@Override
|
||||
public CharSequence generate() {
|
||||
return "@Singleton";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesTo(final JavaFileAccess javaFile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeReference getAnnotationImport() {
|
||||
return new TypeReference(Singleton.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.generate().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return (obj instanceof SingletonClassAnnotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getClass().getName().hashCode();
|
||||
}
|
||||
@Override
|
||||
public CharSequence generate() {
|
||||
return "@Singleton";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesTo(JavaFileAccess javaFile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeReference getAnnotationImport() {
|
||||
return new TypeReference(Singleton.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return generate().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof SingletonClassAnnotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().getName().hashCode();
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.model.annotations
|
||||
|
||||
import com.google.inject.Singleton
|
||||
import org.eclipse.xtext.xtext.generator.model.JavaFileAccess
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference
|
||||
|
||||
/**
|
||||
* A class annotation configuration for the <code>@Singleton</code> annotation.
|
||||
*/
|
||||
class SingletonClassAnnotation implements IClassAnnotation {
|
||||
|
||||
override generate() {
|
||||
'@Singleton'
|
||||
}
|
||||
|
||||
override appliesTo(JavaFileAccess javaFile) {
|
||||
true
|
||||
}
|
||||
|
||||
override getAnnotationImport() {
|
||||
return new TypeReference(Singleton)
|
||||
}
|
||||
|
||||
override toString() {
|
||||
generate.toString
|
||||
}
|
||||
|
||||
override equals(Object obj) {
|
||||
return obj instanceof SingletonClassAnnotation
|
||||
}
|
||||
|
||||
override hashCode() {
|
||||
return class.name.hashCode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model.project;
|
||||
|
||||
import org.eclipse.xtext.xtext.generator.Issues;
|
||||
import org.eclipse.xtext.xtext.generator.model.ManifestAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Configuration of subprojects that can be used as Eclipse bundles.
|
||||
*
|
||||
* @noextend This class should not be extended by clients.
|
||||
*/
|
||||
public class BundleProjectConfig extends SubProjectConfig implements IBundleProjectConfig {
|
||||
private ManifestAccess manifest;
|
||||
|
||||
private PluginXmlAccess pluginXml;
|
||||
|
||||
@Override
|
||||
public void initialize(Injector injector) {
|
||||
super.initialize(injector);
|
||||
if (manifest != null) {
|
||||
manifest.initialize(injector);
|
||||
}
|
||||
if (pluginXml != null) {
|
||||
pluginXml.initialize(injector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(Issues issues) {
|
||||
super.checkConfiguration(issues);
|
||||
if (manifest != null && getMetaInf() == null) {
|
||||
issues.addError("The 'metaInf' outlet must be configured for projects with a manifest", this);
|
||||
}
|
||||
if (pluginXml != null && getRoot() == null) {
|
||||
issues.addError("The 'root' outlet must be configured for projects with a plugin.xml", this);
|
||||
}
|
||||
}
|
||||
|
||||
public ManifestAccess getManifest() {
|
||||
return manifest;
|
||||
}
|
||||
|
||||
public void setManifest(ManifestAccess manifest) {
|
||||
this.manifest = manifest;
|
||||
}
|
||||
|
||||
public PluginXmlAccess getPluginXml() {
|
||||
return pluginXml;
|
||||
}
|
||||
|
||||
public void setPluginXml(PluginXmlAccess pluginXml) {
|
||||
this.pluginXml = pluginXml;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.model.project
|
||||
|
||||
import com.google.inject.Injector
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.xtext.generator.Issues
|
||||
import org.eclipse.xtext.xtext.generator.model.ManifestAccess
|
||||
import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess
|
||||
|
||||
/**
|
||||
* Configuration of subprojects that can be used as Eclipse bundles.
|
||||
*
|
||||
* @noextend This class should not be extended by clients.
|
||||
*/
|
||||
@Accessors
|
||||
class BundleProjectConfig extends SubProjectConfig implements IBundleProjectConfig {
|
||||
|
||||
ManifestAccess manifest
|
||||
PluginXmlAccess pluginXml
|
||||
|
||||
override initialize(Injector injector) {
|
||||
super.initialize(injector)
|
||||
manifest?.initialize(injector)
|
||||
pluginXml?.initialize(injector)
|
||||
}
|
||||
|
||||
override checkConfiguration(Issues issues) {
|
||||
super.checkConfiguration(issues)
|
||||
if (manifest !== null && metaInf === null) {
|
||||
issues.addError("The 'metaInf' outlet must be configured for projects with a manifest", this)
|
||||
}
|
||||
if (pluginXml !== null && root === null) {
|
||||
issues.addError("The 'root' outlet must be configured for projects with a plugin.xml", this)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model.project;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IWebProjectConfig;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.SubProjectConfig;
|
||||
|
||||
/**
|
||||
* Configuration of the web project.
|
||||
*
|
||||
* @noextend This class should not be extended by clients.
|
||||
*/
|
||||
public class WebProjectConfig extends SubProjectConfig implements IWebProjectConfig {
|
||||
private String assetsPath;
|
||||
|
||||
private IXtextGeneratorFileSystemAccess assets;
|
||||
|
||||
public void setAssets(String path) {
|
||||
this.assetsPath = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(Injector injector) {
|
||||
super.initialize(injector);
|
||||
if (this.assetsPath != null) {
|
||||
assets = getOwner().newFileSystemAccess(assetsPath, true);
|
||||
assets.initialize(injector);
|
||||
}
|
||||
}
|
||||
|
||||
public String getAssetsPath() {
|
||||
return assetsPath;
|
||||
}
|
||||
|
||||
public IXtextGeneratorFileSystemAccess getAssets() {
|
||||
return assets;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.model.project
|
||||
|
||||
import com.google.inject.Injector
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess
|
||||
|
||||
/**
|
||||
* Configuration of the web project.
|
||||
*
|
||||
* @noextend This class should not be extended by clients.
|
||||
*/
|
||||
class WebProjectConfig extends SubProjectConfig implements IWebProjectConfig {
|
||||
|
||||
@Accessors(PUBLIC_GETTER)
|
||||
String assetsPath
|
||||
|
||||
@Accessors(PUBLIC_GETTER)
|
||||
IXtextGeneratorFileSystemAccess assets
|
||||
|
||||
def void setAssets(String path) {
|
||||
assetsPath = path
|
||||
}
|
||||
|
||||
override initialize(Injector injector) {
|
||||
super.initialize(injector)
|
||||
if (assetsPath !== null) {
|
||||
assets = owner.newFileSystemAccess(assetsPath, true)
|
||||
assets.initialize(injector)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr;
|
||||
|
||||
import org.eclipse.xtext.Grammar;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class AntlrDebugGrammarGenerator extends AbstractAntlrGrammarGenerator {
|
||||
@Inject
|
||||
private DebugGrammarNaming naming;
|
||||
|
||||
@Override
|
||||
protected GrammarNaming getGrammarNaming() {
|
||||
return naming;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence compileParserOptions(Grammar it, AntlrOptions options) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence compileParserHeader(Grammar it, AntlrOptions options) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence compileLexerHeader(Grammar it, AntlrOptions options) {
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr
|
||||
|
||||
import com.google.inject.Inject
|
||||
import org.eclipse.xtext.Grammar
|
||||
|
||||
class AntlrDebugGrammarGenerator extends AbstractAntlrGrammarGenerator {
|
||||
|
||||
@Inject DebugGrammarNaming naming
|
||||
|
||||
override protected getGrammarNaming() {
|
||||
naming
|
||||
}
|
||||
|
||||
override protected compileParserOptions(Grammar it, AntlrOptions options) {
|
||||
""
|
||||
}
|
||||
|
||||
override protected compileParserHeader(Grammar it, AntlrOptions options) {
|
||||
""
|
||||
}
|
||||
|
||||
override protected compileLexerHeader(Grammar it, AntlrOptions options) {
|
||||
""
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr;
|
||||
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class ContentAssistGrammarNaming extends GrammarNaming {
|
||||
@Inject
|
||||
private XtextGeneratorNaming xtextGeneratorNaming;
|
||||
|
||||
@Override
|
||||
protected String getParserPackage(Grammar it) {
|
||||
return xtextGeneratorNaming.getGenericIdeBasePackage(it) + ".contentassist.antlr";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeReference getLexerSuperClass(Grammar it) {
|
||||
return new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeReference getInternalParserSuperClass(Grammar it) {
|
||||
return new TypeReference(
|
||||
"org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeReference getParserSuperClass(Grammar it, boolean partialParsing) {
|
||||
if (partialParsing) {
|
||||
return new TypeReference(
|
||||
"org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractPartialContentAssistParser");
|
||||
} else {
|
||||
return new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractContentAssistParser");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr
|
||||
|
||||
import com.google.inject.Inject
|
||||
import org.eclipse.xtext.Grammar
|
||||
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference
|
||||
|
||||
class ContentAssistGrammarNaming extends GrammarNaming {
|
||||
|
||||
@Inject
|
||||
extension XtextGeneratorNaming
|
||||
|
||||
protected override String getParserPackage(Grammar it) '''«genericIdeBasePackage».contentassist.antlr'''
|
||||
|
||||
override getLexerSuperClass(Grammar it) {
|
||||
new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer")
|
||||
}
|
||||
|
||||
override getInternalParserSuperClass(Grammar it) {
|
||||
new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser")
|
||||
}
|
||||
|
||||
override getParserSuperClass(Grammar it, boolean partialParsing) {
|
||||
if (partialParsing)
|
||||
new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractPartialContentAssistParser")
|
||||
else
|
||||
new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractContentAssistParser")
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -12,20 +12,19 @@ import org.eclipse.xtext.Grammar;
|
|||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.GrammarNaming;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class DebugGrammarNaming extends GrammarNaming {
|
||||
@Override
|
||||
public TypeReference getInternalParserSuperClass(final Grammar it) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCombinedGrammar(final Grammar it) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGrammarNamePrefix(final Grammar it) {
|
||||
return "Debug";
|
||||
}
|
||||
@Override
|
||||
public TypeReference getInternalParserSuperClass(Grammar it) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCombinedGrammar(Grammar it) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGrammarNamePrefix(Grammar it) {
|
||||
return "Debug";
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr
|
||||
|
||||
import org.eclipse.xtext.Grammar
|
||||
|
||||
class DebugGrammarNaming extends GrammarNaming {
|
||||
|
||||
override getInternalParserSuperClass(Grammar it) {
|
||||
null
|
||||
}
|
||||
|
||||
override isCombinedGrammar(Grammar it) {
|
||||
true
|
||||
}
|
||||
|
||||
override protected getGrammarNamePrefix(Grammar it) {
|
||||
"Debug"
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.validation;
|
||||
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.GrammarUtil;
|
||||
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Separates the composition of the generated validator classes' names from the
|
||||
* template of those classes (which may be specialized by clients), since the
|
||||
* name is used in the template of the generated quickfix provider classes, too.
|
||||
*
|
||||
* @author Christian Schneider - Initial contribution and API
|
||||
*/
|
||||
public class ValidatorNaming {
|
||||
@Inject
|
||||
private XtextGeneratorNaming xtextGeneratorNaming;
|
||||
|
||||
public TypeReference getValidatorClass(Grammar grammar) {
|
||||
String runtimeBasePackage = xtextGeneratorNaming.getRuntimeBasePackage(grammar);
|
||||
return new TypeReference(
|
||||
runtimeBasePackage + ".validation." + GrammarUtil.getSimpleName(grammar) + "Validator");
|
||||
}
|
||||
|
||||
protected TypeReference getAbstractValidatorClass(Grammar grammar) {
|
||||
String runtimeBasePackage = xtextGeneratorNaming.getRuntimeBasePackage(grammar);
|
||||
return new TypeReference(
|
||||
runtimeBasePackage + ".validation.Abstract" + GrammarUtil.getSimpleName(grammar) + "Validator");
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.validation
|
||||
|
||||
import com.google.inject.Inject
|
||||
import org.eclipse.xtext.Grammar
|
||||
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference
|
||||
|
||||
import static extension org.eclipse.xtext.GrammarUtil.*
|
||||
|
||||
/**
|
||||
* Separates the composition of the generated validator classes' names from
|
||||
* the template of those classes (which may be specialized by clients),
|
||||
* since the name is used in the template of the generated quickfix provider classes, too.
|
||||
*
|
||||
* @author Christian Schneider - Initial contribution and API
|
||||
*/
|
||||
class ValidatorNaming {
|
||||
|
||||
@Inject
|
||||
extension XtextGeneratorNaming
|
||||
|
||||
def TypeReference getValidatorClass(Grammar grammar) {
|
||||
new TypeReference(grammar.runtimeBasePackage + '.validation.' + grammar.simpleName + 'Validator')
|
||||
}
|
||||
|
||||
protected def TypeReference getAbstractValidatorClass(Grammar grammar) {
|
||||
new TypeReference(grammar.runtimeBasePackage + '.validation.Abstract' + grammar.simpleName + 'Validator')
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.eclipse.emf.mwe2.runtime.Mandatory;
|
||||
import org.eclipse.xtend.lib.annotations.AccessorType;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment;
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.XtextGeneratorFileSystemAccess;
|
||||
|
||||
/**
|
||||
* Generator fragment that allows to write files to arbitrary, user configurable
|
||||
* locations.
|
||||
*
|
||||
* @author Sebastian Zarnekow - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public abstract class AbstractExternalFolderAwareFragment extends AbstractXtextGeneratorFragment {
|
||||
private String absolutePath;
|
||||
|
||||
@Accessors({ AccessorType.PROTECTED_GETTER, AccessorType.PUBLIC_SETTER })
|
||||
private boolean override = false;
|
||||
|
||||
private IXtextGeneratorFileSystemAccess outputLocation;
|
||||
|
||||
protected IXtextGeneratorFileSystemAccess getOutputLocation() {
|
||||
return this.outputLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(final Injector injector) {
|
||||
super.initialize(injector);
|
||||
XtextGeneratorFileSystemAccess _xtextGeneratorFileSystemAccess = new XtextGeneratorFileSystemAccess(this.absolutePath, this.override);
|
||||
this.outputLocation = _xtextGeneratorFileSystemAccess;
|
||||
injector.injectMembers(this.outputLocation);
|
||||
}
|
||||
|
||||
protected String getAbsolutePath() {
|
||||
return this.absolutePath;
|
||||
}
|
||||
|
||||
@Mandatory
|
||||
public void setAbsolutePath(final String absolutePath) {
|
||||
this.absolutePath = absolutePath;
|
||||
}
|
||||
|
||||
@Pure
|
||||
protected boolean isOverride() {
|
||||
return this.override;
|
||||
}
|
||||
|
||||
public void setOverride(final boolean override) {
|
||||
this.override = override;
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.xtend.lib.annotations.AccessorType;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.xbase.lib.Extension;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment;
|
||||
import org.eclipse.xtext.xtext.generator.CodeConfig;
|
||||
import org.eclipse.xtext.xtext.generator.util.BooleanGeneratorOption;
|
||||
|
||||
/**
|
||||
* A fragment that generates a <em>stub</em>, that is a class where the user can add
|
||||
* custom behavior, e.g. validation or formatting rules. The stub is generated into
|
||||
* the source folder that is not overwritten when the generator is executed again
|
||||
* ({@code src} for plain project layout, {@code src/main/java} for Maven/Gradle
|
||||
* project layout). If you want the stub to be generated again, delete the already
|
||||
* existing file.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public abstract class AbstractStubGeneratingFragment extends AbstractXtextGeneratorFragment {
|
||||
@Inject
|
||||
@Extension
|
||||
private CodeConfig _codeConfig;
|
||||
|
||||
@Accessors(AccessorType.PUBLIC_GETTER)
|
||||
private final BooleanGeneratorOption generateStub = new BooleanGeneratorOption(true);
|
||||
|
||||
private final BooleanGeneratorOption generateXtendStub = new BooleanGeneratorOption();
|
||||
|
||||
public boolean isGenerateStub() {
|
||||
return this.generateStub.get();
|
||||
}
|
||||
|
||||
public void setGenerateStub(final boolean generateStub) {
|
||||
this.generateStub.set(generateStub);
|
||||
}
|
||||
|
||||
public boolean isGenerateXtendStub() {
|
||||
boolean _xifexpression = false;
|
||||
boolean _isSet = this.generateXtendStub.isSet();
|
||||
if (_isSet) {
|
||||
_xifexpression = this.generateXtendStub.get();
|
||||
} else {
|
||||
_xifexpression = this._codeConfig.isPreferXtendStubs();
|
||||
}
|
||||
return _xifexpression;
|
||||
}
|
||||
|
||||
public void setGenerateXtendStub(final boolean generateXtendStub) {
|
||||
this.generateXtendStub.set(generateXtendStub);
|
||||
}
|
||||
|
||||
@Pure
|
||||
public BooleanGeneratorOption getGenerateStub() {
|
||||
return this.generateStub;
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import org.eclipse.xtend.lib.annotations.AccessorType;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.IXtextGeneratorFragment;
|
||||
import org.eclipse.xtext.xtext.generator.IXtextGeneratorLanguage;
|
||||
import org.eclipse.xtext.xtext.generator.Issues;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IXtextProjectConfig;
|
||||
|
||||
/**
|
||||
* Convenience class for implementing generator fragments. Provides access to the
|
||||
* {@link IXtextProjectConfig project configuration} and the {@link IXtextGeneratorLanguage language configuration}.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public abstract class AbstractXtextGeneratorFragment implements IXtextGeneratorFragment {
|
||||
@Accessors(AccessorType.PROTECTED_GETTER)
|
||||
@Inject
|
||||
private IXtextProjectConfig projectConfig;
|
||||
|
||||
@Accessors(AccessorType.PROTECTED_GETTER)
|
||||
@Inject
|
||||
private IXtextGeneratorLanguage language;
|
||||
|
||||
@Accessors(AccessorType.PROTECTED_GETTER)
|
||||
@Inject
|
||||
private Grammar grammar;
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(final Issues issues) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(final Injector injector) {
|
||||
injector.injectMembers(this);
|
||||
}
|
||||
|
||||
@Pure
|
||||
protected IXtextProjectConfig getProjectConfig() {
|
||||
return this.projectConfig;
|
||||
}
|
||||
|
||||
@Pure
|
||||
protected IXtextGeneratorLanguage getLanguage() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
@Pure
|
||||
protected Grammar getGrammar() {
|
||||
return this.grammar;
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import java.util.List;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
class CompositeGeneratorException extends RuntimeException {
|
||||
@Accessors
|
||||
private final List<Exception> exceptions = CollectionLiterals.<Exception>newArrayList();
|
||||
|
||||
public boolean addException(final Exception exception) {
|
||||
return this.exceptions.add(exception);
|
||||
}
|
||||
|
||||
public boolean hasExceptions() {
|
||||
int _size = this.exceptions.size();
|
||||
return (_size > 0);
|
||||
}
|
||||
|
||||
@Pure
|
||||
public List<Exception> getExceptions() {
|
||||
return this.exceptions;
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import java.util.List;
|
||||
import org.eclipse.xtend.lib.annotations.AccessorType;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.CompositeGeneratorException;
|
||||
import org.eclipse.xtext.xtext.generator.IXtextGeneratorFragment;
|
||||
import org.eclipse.xtext.xtext.generator.Issues;
|
||||
|
||||
/**
|
||||
* A generator fragment that delegates to a list of contained fragments. This can be
|
||||
* useful for extracting parts of a language configuration to a separate mwe2 file,
|
||||
* for example.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class CompositeGeneratorFragment2 implements IXtextGeneratorFragment {
|
||||
@Accessors(AccessorType.PROTECTED_GETTER)
|
||||
private final List<IXtextGeneratorFragment> fragments = CollectionLiterals.<IXtextGeneratorFragment>newArrayList();
|
||||
|
||||
public void addFragment(final IXtextGeneratorFragment fragment) {
|
||||
if ((fragment == this)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.fragments.add(fragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(final Issues issues) {
|
||||
for (final IXtextGeneratorFragment fragment : this.fragments) {
|
||||
fragment.checkConfiguration(issues);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
final CompositeGeneratorException composite = new CompositeGeneratorException();
|
||||
for (final IXtextGeneratorFragment fragment : this.fragments) {
|
||||
try {
|
||||
fragment.generate();
|
||||
} catch (final Throwable _t) {
|
||||
if (_t instanceof Exception) {
|
||||
final Exception e = (Exception)_t;
|
||||
composite.addException(e);
|
||||
} else {
|
||||
throw Exceptions.sneakyThrow(_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean _hasExceptions = composite.hasExceptions();
|
||||
if (_hasExceptions) {
|
||||
throw composite;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(final Injector injector) {
|
||||
for (final IXtextGeneratorFragment fragment : this.fragments) {
|
||||
fragment.initialize(injector);
|
||||
}
|
||||
}
|
||||
|
||||
@Pure
|
||||
protected List<IXtextGeneratorFragment> getFragments() {
|
||||
return this.fragments;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.IXtextGeneratorFragment;
|
||||
import org.eclipse.xtext.xtext.generator.Issues;
|
||||
|
||||
/**
|
||||
* Generator fragment that wraps another fragment and can be toggled via a property
|
||||
*
|
||||
* @author Christian Dietrich - Initial contribution and API
|
||||
*
|
||||
* @since 2.13
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class ConditionalXtextGeneratorFragment implements IXtextGeneratorFragment {
|
||||
@Accessors
|
||||
private IXtextGeneratorFragment fragment;
|
||||
|
||||
@Accessors
|
||||
private boolean enabled = true;
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(final Issues issues) {
|
||||
if ((this.fragment == null)) {
|
||||
issues.addError("The property \'fragment\' must be set.", this);
|
||||
} else {
|
||||
this.fragment.checkConfiguration(issues);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
if (this.enabled) {
|
||||
this.fragment.generate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(final Injector injector) {
|
||||
this.fragment.initialize(injector);
|
||||
}
|
||||
|
||||
@Pure
|
||||
public IXtextGeneratorFragment getFragment() {
|
||||
return this.fragment;
|
||||
}
|
||||
|
||||
public void setFragment(final IXtextGeneratorFragment fragment) {
|
||||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.binder.AnnotatedBindingBuilder;
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.formatting.ILineSeparatorInformation;
|
||||
import org.eclipse.xtext.parser.IEncodingProvider;
|
||||
import org.eclipse.xtext.resource.XtextResourceSet;
|
||||
import org.eclipse.xtext.service.AbstractGenericModule;
|
||||
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.CodeConfig;
|
||||
import org.eclipse.xtext.xtext.generator.Issues;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IXtextProjectConfig;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.StandardProjectConfig;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.XtextProjectConfig;
|
||||
|
||||
/**
|
||||
* An instance of this module is assigned to the {@code configuration} property of
|
||||
* {@link XtextGenerator}. It contains the {@link XtextProjectConfig project configuration}
|
||||
* and the {@link CodeConfig code configuration}. If you need to configure more aspects of
|
||||
* the generator, create a subclass and bind your custom configuration classes. For example,
|
||||
* in order to adapt the {@link XtextGeneratorNaming naming} of the generated code, use
|
||||
* the following:
|
||||
* <pre>
|
||||
* class MyGeneratorModule extends DefaultGeneratorModule {
|
||||
* def Class<? extends XtextGeneratorNaming> bindXtextGeneratorNaming() {
|
||||
* MyGeneratorNaming
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class DefaultGeneratorModule extends AbstractGenericModule {
|
||||
@Accessors
|
||||
private XtextProjectConfig project = new StandardProjectConfig();
|
||||
|
||||
@Accessors
|
||||
private CodeConfig code = new CodeConfig();
|
||||
|
||||
protected void checkConfiguration(final Issues issues) {
|
||||
this.project.checkConfiguration(issues);
|
||||
}
|
||||
|
||||
public void configureXtextProjectConfig(final Binder binder) {
|
||||
binder.<IXtextProjectConfig>bind(IXtextProjectConfig.class).toInstance(this.project);
|
||||
}
|
||||
|
||||
public void configureCodeConfig(final Binder binder) {
|
||||
binder.<CodeConfig>bind(CodeConfig.class).toInstance(this.code);
|
||||
}
|
||||
|
||||
public void configureResourceSet(final Binder binder) {
|
||||
binder.<ResourceSet>bind(ResourceSet.class).to(XtextResourceSet.class);
|
||||
}
|
||||
|
||||
public void configureLineSeparatorInformation(final Binder binder) {
|
||||
final ILineSeparatorInformation _function = () -> {
|
||||
return this.code.getLineDelimiter();
|
||||
};
|
||||
binder.<ILineSeparatorInformation>bind(ILineSeparatorInformation.class).toInstance(_function);
|
||||
}
|
||||
|
||||
public void configureIEncodingProvider(final Binder binder) {
|
||||
AnnotatedBindingBuilder<IEncodingProvider> _bind = binder.<IEncodingProvider>bind(IEncodingProvider.class);
|
||||
IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
|
||||
final Procedure1<IEncodingProvider.Runtime> _function = (IEncodingProvider.Runtime it) -> {
|
||||
it.setDefaultEncoding(this.code.getEncoding());
|
||||
};
|
||||
IEncodingProvider.Runtime _doubleArrow = ObjectExtensions.<IEncodingProvider.Runtime>operator_doubleArrow(_runtime, _function);
|
||||
_bind.toInstance(_doubleArrow);
|
||||
}
|
||||
|
||||
@Pure
|
||||
public XtextProjectConfig getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
public void setProject(final XtextProjectConfig project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public CodeConfig getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public void setCode(final CodeConfig code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provider;
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.service.AbstractGenericModule;
|
||||
import org.eclipse.xtext.xtext.RuleNames;
|
||||
import org.eclipse.xtext.xtext.generator.IXtextGeneratorLanguage;
|
||||
import org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage;
|
||||
|
||||
/**
|
||||
* Language-specific Guice module that is used in a child injector of the global injector
|
||||
* derived from {@link DefaultGeneratorModule}.
|
||||
*/
|
||||
@FinalFieldsConstructor
|
||||
@SuppressWarnings("all")
|
||||
class LanguageModule extends AbstractGenericModule {
|
||||
private final XtextGeneratorLanguage language;
|
||||
|
||||
public void configureLanguage(final Binder binder) {
|
||||
final Provider<IXtextGeneratorLanguage> _function = () -> {
|
||||
return this.language;
|
||||
};
|
||||
binder.<IXtextGeneratorLanguage>bind(IXtextGeneratorLanguage.class).toProvider(_function);
|
||||
}
|
||||
|
||||
public void configureGrammar(final Binder binder) {
|
||||
final Provider<Grammar> _function = () -> {
|
||||
return this.language.getGrammar();
|
||||
};
|
||||
binder.<Grammar>bind(Grammar.class).toProvider(_function);
|
||||
}
|
||||
|
||||
public void configureRuleNames(final Binder binder) {
|
||||
final Provider<RuleNames> _function = () -> {
|
||||
return this.language.getRuleNames();
|
||||
};
|
||||
binder.<RuleNames>bind(RuleNames.class).toProvider(_function);
|
||||
}
|
||||
|
||||
public void configureAdditionalBindings(final Binder binder) {
|
||||
binder.install(this.language.getGuiceModule());
|
||||
}
|
||||
|
||||
public LanguageModule(final XtextGeneratorLanguage language) {
|
||||
super();
|
||||
this.language = language;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator;
|
||||
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.Issues;
|
||||
import org.eclipse.xtext.xtext.generator.XtextGenerator;
|
||||
|
||||
/**
|
||||
* {@link Issues} implementation for MWE2 workflows.
|
||||
*/
|
||||
@FinalFieldsConstructor
|
||||
@SuppressWarnings("all")
|
||||
public class MweIssues implements Issues {
|
||||
@Accessors
|
||||
private final XtextGenerator owner;
|
||||
|
||||
@Accessors
|
||||
private final org.eclipse.emf.mwe.core.issues.Issues delegate;
|
||||
|
||||
@Override
|
||||
public void addError(final String message) {
|
||||
this.delegate.addError(this.owner, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addError(final String message, final Object source) {
|
||||
this.delegate.addError(this.owner, message, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWarning(final String message) {
|
||||
this.delegate.addWarning(this.owner, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWarning(final String message, final Object source) {
|
||||
this.delegate.addWarning(this.owner, message, source);
|
||||
}
|
||||
|
||||
public MweIssues(final XtextGenerator owner, final org.eclipse.emf.mwe.core.issues.Issues delegate) {
|
||||
super();
|
||||
this.owner = owner;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public XtextGenerator getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public org.eclipse.emf.mwe.core.issues.Issues getDelegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
}
|
|
@ -373,9 +373,10 @@ public class XtextGenerator extends AbstractWorkflowComponent2 {
|
|||
if (_isModified) {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
merge.write(out);
|
||||
String _path = manifest.getPath();
|
||||
byte[] _byteArray = out.toByteArray();
|
||||
ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(_byteArray);
|
||||
metaInf.generateFile(manifest.getPath(), _byteArrayInputStream);
|
||||
metaInf.generateFile(_path, _byteArrayInputStream);
|
||||
}
|
||||
} finally {
|
||||
if ((in != null)) {
|
||||
|
|
|
@ -569,6 +569,7 @@ public class EMFGeneratorFragment2 extends AbstractXtextGeneratorFragment {
|
|||
genPackage.getClassPackageName(),
|
||||
genPackage.getUtilitiesPackageName());
|
||||
}
|
||||
List<StringConcatenationClient> _registrations = this.getLanguage().getRuntimeGenSetup().getRegistrations();
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
|
||||
|
@ -594,7 +595,7 @@ public class EMFGeneratorFragment2 extends AbstractXtextGeneratorFragment {
|
|||
_builder.newLine();
|
||||
}
|
||||
};
|
||||
this.getLanguage().getRuntimeGenSetup().getRegistrations().add(_client);
|
||||
_registrations.add(_client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2016 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.exporting;
|
||||
|
||||
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
|
||||
import org.eclipse.xtext.naming.IQualifiedNameProvider;
|
||||
import org.eclipse.xtext.xtext.generator.AbstractXtextGeneratorFragment;
|
||||
import org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class QualifiedNamesFragment2 extends AbstractXtextGeneratorFragment {
|
||||
@Override
|
||||
public void generate() {
|
||||
new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IQualifiedNameProvider.class), TypeReference.typeRef(DefaultDeclarativeQualifiedNameProvider.class)).contributeTo(this.getLanguage().getRuntimeGenModule());
|
||||
new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher"),
|
||||
TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.FQNPrefixMatcher")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator"),
|
||||
TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator")).contributeTo(this.getLanguage().getEclipsePluginGenModule());
|
||||
new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.IPrefixMatcher"),
|
||||
TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.FQNPrefixMatcher")).contributeTo(this.getLanguage().getIdeGenModule());
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Arrays;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess;
|
||||
|
||||
/**
|
||||
* A utility class for generating binary files.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class BinaryFileAccess {
|
||||
@Accessors
|
||||
private String path;
|
||||
|
||||
protected byte[] internalContents;
|
||||
|
||||
public void setContent(final byte[] content) {
|
||||
this.internalContents = content;
|
||||
}
|
||||
|
||||
public byte[] getContent() {
|
||||
return Arrays.copyOf(this.internalContents, this.internalContents.length);
|
||||
}
|
||||
|
||||
public void writeTo(final IFileSystemAccess2 fileSystemAccess) {
|
||||
if ((fileSystemAccess != null)) {
|
||||
ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(this.internalContents);
|
||||
fileSystemAccess.generateFile(this.path, _byteArrayInputStream);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean existIn(final IXtextGeneratorFileSystemAccess fileSystemAccess) {
|
||||
if ((fileSystemAccess == null)) {
|
||||
return false;
|
||||
}
|
||||
return fileSystemAccess.isFile(this.path);
|
||||
}
|
||||
|
||||
@Pure
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public void setPath(final String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient;
|
||||
import org.eclipse.xtext.xtext.generator.CodeConfig;
|
||||
import org.eclipse.xtext.xtext.generator.model.BinaryFileAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.JavaFileAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.TextFileAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
import org.eclipse.xtext.xtext.generator.model.XtendFileAccess;
|
||||
|
||||
/**
|
||||
* Factory for creating text files, Java files, and Xtend files.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class FileAccessFactory {
|
||||
@Inject
|
||||
private CodeConfig codeConfig;
|
||||
|
||||
public TextFileAccess createTextFile() {
|
||||
return new TextFileAccess();
|
||||
}
|
||||
|
||||
public TextFileAccess createTextFile(final String path) {
|
||||
final TextFileAccess result = this.createTextFile();
|
||||
result.setPath(path);
|
||||
return result;
|
||||
}
|
||||
|
||||
public TextFileAccess createTextFile(final String path, final StringConcatenationClient content) {
|
||||
final TextFileAccess result = this.createTextFile(path);
|
||||
result.setContent(content);
|
||||
return result;
|
||||
}
|
||||
|
||||
public JavaFileAccess createJavaFile(final TypeReference typeRef) {
|
||||
return new JavaFileAccess(typeRef, this.codeConfig);
|
||||
}
|
||||
|
||||
public JavaFileAccess createJavaFile(final TypeReference typeRef, final StringConcatenationClient content) {
|
||||
final JavaFileAccess result = this.createJavaFile(typeRef);
|
||||
result.setContent(content);
|
||||
return result;
|
||||
}
|
||||
|
||||
public XtendFileAccess createXtendFile(final TypeReference typeRef) {
|
||||
return new XtendFileAccess(typeRef, this.codeConfig);
|
||||
}
|
||||
|
||||
public XtendFileAccess createXtendFile(final TypeReference typeRef, final StringConcatenationClient content) {
|
||||
final XtendFileAccess result = this.createXtendFile(typeRef);
|
||||
result.setContent(content);
|
||||
return result;
|
||||
}
|
||||
|
||||
public GeneratedJavaFileAccess createGeneratedJavaFile(final TypeReference typeRef) {
|
||||
return new GeneratedJavaFileAccess(typeRef, this.codeConfig);
|
||||
}
|
||||
|
||||
public BinaryFileAccess createBinaryFile() {
|
||||
return new BinaryFileAccess();
|
||||
}
|
||||
|
||||
public BinaryFileAccess createBinaryFile(final String path) {
|
||||
final BinaryFileAccess result = this.createBinaryFile();
|
||||
result.setPath(path);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -270,9 +270,10 @@ public class ManifestAccess extends TextFileAccess implements IGuiceAwareGenerat
|
|||
mergeableManifest.setLineDelimiter(this.lineDelimiter);
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
mergeableManifest.write(bout);
|
||||
String _path = this.getPath();
|
||||
byte[] _byteArray = bout.toByteArray();
|
||||
ByteArrayInputStream _byteArrayInputStream_1 = new ByteArrayInputStream(_byteArray);
|
||||
fileSystemAccess.generateFile(this.getPath(), _byteArrayInputStream_1);
|
||||
fileSystemAccess.generateFile(_path, _byteArrayInputStream_1);
|
||||
}
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
|
||||
/**
|
||||
* Configuration object for the generated standalone setup class. This class is responsible for adding
|
||||
* required EMF packages to the global registries.
|
||||
*/
|
||||
@Accessors
|
||||
@SuppressWarnings("all")
|
||||
public class StandaloneSetupAccess {
|
||||
private final List<StringConcatenationClient> registrations = CollectionLiterals.<StringConcatenationClient>newArrayList();
|
||||
|
||||
@Deprecated
|
||||
private final Set<TypeReference> imports = CollectionLiterals.<TypeReference>newHashSet();
|
||||
|
||||
/**
|
||||
* @deprecated this set is required for backwards-compatibility to Xpand templates included with
|
||||
* {@code org.eclipse.xtext.generator.adapter.FragmentAdapter}.
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<TypeReference> getImports() {
|
||||
return this.imports;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public List<StringConcatenationClient> getRegistrations() {
|
||||
return this.registrations;
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtend2.lib.StringConcatenationClient;
|
||||
import org.eclipse.xtext.generator.IFileSystemAccess2;
|
||||
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
|
||||
/**
|
||||
* A utility class for generating plain text files.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class TextFileAccess {
|
||||
@Accessors
|
||||
private String path;
|
||||
|
||||
protected CharSequence internalContents;
|
||||
|
||||
public void setContent(final StringConcatenationClient content) {
|
||||
StringConcatenation _stringConcatenation = new StringConcatenation();
|
||||
final Procedure1<StringConcatenation> _function = (StringConcatenation it) -> {
|
||||
it.append(content);
|
||||
};
|
||||
StringConcatenation _doubleArrow = ObjectExtensions.<StringConcatenation>operator_doubleArrow(_stringConcatenation, _function);
|
||||
this.internalContents = _doubleArrow;
|
||||
}
|
||||
|
||||
public CharSequence getContent() {
|
||||
return this.internalContents.toString();
|
||||
}
|
||||
|
||||
public String getContentString() {
|
||||
return this.getContent().toString();
|
||||
}
|
||||
|
||||
public void writeTo(final IFileSystemAccess2 fileSystemAccess) {
|
||||
if ((fileSystemAccess != null)) {
|
||||
fileSystemAccess.generateFile(this.path, this.getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@Pure
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public void setPath(final String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
|
||||
import org.eclipse.xtext.generator.OutputConfiguration;
|
||||
import org.eclipse.xtext.xbase.lib.IterableExtensions;
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class XtextGeneratorFileSystemAccess extends JavaIoFileSystemAccess implements IXtextGeneratorFileSystemAccess {
|
||||
public XtextGeneratorFileSystemAccess(final String path, final boolean overwrite) {
|
||||
this.setOutputPath(this.removeTrailingPathSeparator(path));
|
||||
OutputConfiguration _defaultOutput = this.getDefaultOutput();
|
||||
_defaultOutput.setOverrideExistingResources(overwrite);
|
||||
}
|
||||
|
||||
private String removeTrailingPathSeparator(final String s) {
|
||||
String _xifexpression = null;
|
||||
boolean _endsWith = s.endsWith("/");
|
||||
if (_endsWith) {
|
||||
int _length = s.length();
|
||||
int _minus = (_length - 1);
|
||||
_xifexpression = s.substring(0, _minus);
|
||||
} else {
|
||||
_xifexpression = s;
|
||||
}
|
||||
return _xifexpression;
|
||||
}
|
||||
|
||||
private OutputConfiguration getDefaultOutput() {
|
||||
return IterableExtensions.<OutputConfiguration>head(this.getOutputConfigurations().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(final Injector injector) {
|
||||
injector.injectMembers(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return this.getDefaultOutput().getOutputDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOverwrite() {
|
||||
return this.getDefaultOutput().isOverrideExistingResources();
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model.project;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.Issues;
|
||||
import org.eclipse.xtext.xtext.generator.model.ManifestAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.SubProjectConfig;
|
||||
|
||||
/**
|
||||
* Configuration of subprojects that can be used as Eclipse bundles.
|
||||
*
|
||||
* @noextend This class should not be extended by clients.
|
||||
*/
|
||||
@Accessors
|
||||
@SuppressWarnings("all")
|
||||
public class BundleProjectConfig extends SubProjectConfig implements IBundleProjectConfig {
|
||||
private ManifestAccess manifest;
|
||||
|
||||
private PluginXmlAccess pluginXml;
|
||||
|
||||
@Override
|
||||
public void initialize(final Injector injector) {
|
||||
super.initialize(injector);
|
||||
if (this.manifest!=null) {
|
||||
this.manifest.initialize(injector);
|
||||
}
|
||||
if (this.pluginXml!=null) {
|
||||
this.pluginXml.initialize(injector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(final Issues issues) {
|
||||
super.checkConfiguration(issues);
|
||||
if (((this.manifest != null) && (this.getMetaInf() == null))) {
|
||||
issues.addError("The \'metaInf\' outlet must be configured for projects with a manifest", this);
|
||||
}
|
||||
if (((this.pluginXml != null) && (this.getRoot() == null))) {
|
||||
issues.addError("The \'root\' outlet must be configured for projects with a plugin.xml", this);
|
||||
}
|
||||
}
|
||||
|
||||
@Pure
|
||||
public ManifestAccess getManifest() {
|
||||
return this.manifest;
|
||||
}
|
||||
|
||||
public void setManifest(final ManifestAccess manifest) {
|
||||
this.manifest = manifest;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public PluginXmlAccess getPluginXml() {
|
||||
return this.pluginXml;
|
||||
}
|
||||
|
||||
public void setPluginXml(final PluginXmlAccess pluginXml) {
|
||||
this.pluginXml = pluginXml;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2017 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.model.project;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.eclipse.xtend.lib.annotations.AccessorType;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.IWebProjectConfig;
|
||||
import org.eclipse.xtext.xtext.generator.model.project.SubProjectConfig;
|
||||
|
||||
/**
|
||||
* Configuration of the web project.
|
||||
*
|
||||
* @noextend This class should not be extended by clients.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class WebProjectConfig extends SubProjectConfig implements IWebProjectConfig {
|
||||
@Accessors(AccessorType.PUBLIC_GETTER)
|
||||
private String assetsPath;
|
||||
|
||||
@Accessors(AccessorType.PUBLIC_GETTER)
|
||||
private IXtextGeneratorFileSystemAccess assets;
|
||||
|
||||
public void setAssets(final String path) {
|
||||
this.assetsPath = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(final Injector injector) {
|
||||
super.initialize(injector);
|
||||
if ((this.assetsPath != null)) {
|
||||
this.assets = this.getOwner().newFileSystemAccess(this.assetsPath, true);
|
||||
this.assets.initialize(injector);
|
||||
}
|
||||
}
|
||||
|
||||
@Pure
|
||||
public String getAssetsPath() {
|
||||
return this.assetsPath;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public IXtextGeneratorFileSystemAccess getAssets() {
|
||||
return this.assets;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGrammarGenerator;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.AntlrOptions;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.DebugGrammarNaming;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.GrammarNaming;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class AntlrDebugGrammarGenerator extends AbstractAntlrGrammarGenerator {
|
||||
@Inject
|
||||
private DebugGrammarNaming naming;
|
||||
|
||||
@Override
|
||||
protected GrammarNaming getGrammarNaming() {
|
||||
return this.naming;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence compileParserOptions(final Grammar it, final AntlrOptions options) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence compileParserHeader(final Grammar it, final AntlrOptions options) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharSequence compileLexerHeader(final Grammar it, final AntlrOptions options) {
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.xbase.lib.Extension;
|
||||
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.GrammarNaming;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class ContentAssistGrammarNaming extends GrammarNaming {
|
||||
@Inject
|
||||
@Extension
|
||||
private XtextGeneratorNaming _xtextGeneratorNaming;
|
||||
|
||||
@Override
|
||||
protected String getParserPackage(final Grammar it) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
String _genericIdeBasePackage = this._xtextGeneratorNaming.getGenericIdeBasePackage(it);
|
||||
_builder.append(_genericIdeBasePackage);
|
||||
_builder.append(".contentassist.antlr");
|
||||
return _builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeReference getLexerSuperClass(final Grammar it) {
|
||||
return new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.internal.Lexer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeReference getInternalParserSuperClass(final Grammar it) {
|
||||
return new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.internal.AbstractInternalContentAssistParser");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeReference getParserSuperClass(final Grammar it, final boolean partialParsing) {
|
||||
TypeReference _xifexpression = null;
|
||||
if (partialParsing) {
|
||||
_xifexpression = new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractPartialContentAssistParser");
|
||||
} else {
|
||||
_xifexpression = new TypeReference("org.eclipse.xtext.ide.editor.contentassist.antlr.AbstractContentAssistParser");
|
||||
}
|
||||
return _xifexpression;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ public class ResourceFactoryFragment2 extends AbstractXtextGeneratorFragment {
|
|||
|
||||
@Override
|
||||
public void generate() {
|
||||
List<StringConcatenationClient> _registrations = this.getLanguage().getRuntimeGenSetup().getRegistrations();
|
||||
StringConcatenationClient _client = new StringConcatenationClient() {
|
||||
@Override
|
||||
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
|
||||
|
@ -69,7 +70,7 @@ public class ResourceFactoryFragment2 extends AbstractXtextGeneratorFragment {
|
|||
}
|
||||
}
|
||||
};
|
||||
this.getLanguage().getRuntimeGenSetup().getRegistrations().add(_client);
|
||||
_registrations.add(_client);
|
||||
IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
|
||||
PluginXmlAccess _pluginXml = null;
|
||||
if (_eclipsePlugin!=null) {
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.xtext.generator.validation;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.GrammarUtil;
|
||||
import org.eclipse.xtext.xbase.lib.Extension;
|
||||
import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming;
|
||||
import org.eclipse.xtext.xtext.generator.model.TypeReference;
|
||||
|
||||
/**
|
||||
* Separates the composition of the generated validator classes' names from
|
||||
* the template of those classes (which may be specialized by clients),
|
||||
* since the name is used in the template of the generated quickfix provider classes, too.
|
||||
*
|
||||
* @author Christian Schneider - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class ValidatorNaming {
|
||||
@Inject
|
||||
@Extension
|
||||
private XtextGeneratorNaming _xtextGeneratorNaming;
|
||||
|
||||
public TypeReference getValidatorClass(final Grammar grammar) {
|
||||
String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(grammar);
|
||||
String _plus = (_runtimeBasePackage + ".validation.");
|
||||
String _simpleName = GrammarUtil.getSimpleName(grammar);
|
||||
String _plus_1 = (_plus + _simpleName);
|
||||
String _plus_2 = (_plus_1 + "Validator");
|
||||
return new TypeReference(_plus_2);
|
||||
}
|
||||
|
||||
protected TypeReference getAbstractValidatorClass(final Grammar grammar) {
|
||||
String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(grammar);
|
||||
String _plus = (_runtimeBasePackage + ".validation.Abstract");
|
||||
String _simpleName = GrammarUtil.getSimpleName(grammar);
|
||||
String _plus_1 = (_plus + _simpleName);
|
||||
String _plus_2 = (_plus_1 + "Validator");
|
||||
return new TypeReference(_plus_2);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue