Search in sources :

Example 1 with IXtextGeneratorFileSystemAccess

use of org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess in project xtext-core by eclipse.

the class XtextAntlrIDEAGeneratorFragment method doGenerate.

@Override
protected void doGenerate() {
    boolean _isEnabled = this.getProjectConfig().getIdeaPlugin().isEnabled();
    boolean _not = (!_isEnabled);
    if (_not) {
        return;
    }
    final IXtextGeneratorFileSystemAccess fsa = this.getProjectConfig().getIdeaPlugin().getSrcGen();
    this.generator.generate(this.getGrammar(), this.getOptions(), fsa);
    final String encoding = this.getCodeConfig().getEncoding();
    final String grammarFileName = this._psiGrammarNaming.getParserGrammar(this.getGrammar()).getGrammarFileName();
    StringConcatenation _builder = new StringConcatenation();
    String _path = fsa.getPath();
    _builder.append(_path);
    _builder.append("/");
    _builder.append(grammarFileName);
    final String absoluteGrammarFileName = _builder.toString();
    this.addAntlrParam("-fo");
    this.addAntlrParam(absoluteGrammarFileName.substring(0, absoluteGrammarFileName.lastIndexOf("/")));
    this.getAntlrTool().runWithEncodingAndParams(absoluteGrammarFileName, encoding, this.getAntlrParams());
    this.simplifyUnorderedGroupPredicatesIfRequired(this.getGrammar(), fsa, this._psiGrammarNaming.getInternalParserClass(this.getGrammar()));
    this.splitParserAndLexerIfEnabled(fsa, this._psiGrammarNaming.getInternalParserClass(this.getGrammar()), this._psiGrammarNaming.getLexerClass(this.getGrammar()));
    this.normalizeTokens(fsa, this._psiGrammarNaming.getLexerGrammar(this.getGrammar()).getTokensFileName());
    this.suppressWarnings(fsa, this._psiGrammarNaming.getInternalParserClass(this.getGrammar()), this._psiGrammarNaming.getLexerClass(this.getGrammar()));
    this.normalizeLineDelimiters(fsa, this._psiGrammarNaming.getInternalParserClass(this.getGrammar()), this._psiGrammarNaming.getLexerClass(this.getGrammar()));
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) IXtextGeneratorFileSystemAccess(org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess)

Example 2 with IXtextGeneratorFileSystemAccess

use of org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess in project xtext-core by eclipse.

the class Junit4Fragment2 method generate.

@Override
public void generate() {
    ManifestAccess _manifest = this.getProjectConfig().getRuntimeTest().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        ManifestAccess _manifest_1 = this.getProjectConfig().getRuntimeTest().getManifest();
        final Procedure1<ManifestAccess> _function = (ManifestAccess it) -> {
            String _testingPackage = this.getTestingPackage();
            String _xbaseTestingPackage = this.getXbaseTestingPackage();
            String _xbaseLibVersionLowerBound = this.getProjectConfig().getRuntime().getXbaseLibVersionLowerBound();
            String _plus = ("org.eclipse.xtext.xbase.lib;bundle-version=\"" + _xbaseLibVersionLowerBound);
            String _plus_1 = (_plus + "\"");
            CollectionExtensions.<String>addAll(it.getRequiredBundles(), _testingPackage, _xbaseTestingPackage, _plus_1);
            String _runtimeTestBasePackage = this._xtextGeneratorNaming.getRuntimeTestBasePackage(this.getGrammar());
            String _plus_2 = (_runtimeTestBasePackage + ";x-internal=true");
            it.getExportedPackages().add(_plus_2);
        };
        ObjectExtensions.<ManifestAccess>operator_doubleArrow(_manifest_1, _function);
    }
    ManifestAccess _manifest_2 = this.getProjectConfig().getEclipsePluginTest().getManifest();
    boolean _tripleNotEquals_1 = (_manifest_2 != null);
    if (_tripleNotEquals_1) {
        ManifestAccess _manifest_3 = this.getProjectConfig().getEclipsePluginTest().getManifest();
        final Procedure1<ManifestAccess> _function_1 = (ManifestAccess it) -> {
            CollectionExtensions.<String>addAll(it.getRequiredBundles(), this.getTestingPackage(), this.getXbaseTestingPackage(), this.getUiTestingPackage(), this.getXbaseUiTestingPackage(), "org.eclipse.core.runtime", "org.eclipse.ui.workbench;resolution:=optional");
            String _eclipsePluginTestBasePackage = this._xtextGeneratorNaming.getEclipsePluginTestBasePackage(this.getGrammar());
            String _plus = (_eclipsePluginTestBasePackage + ";x-internal=true");
            it.getExportedPackages().add(_plus);
        };
        ObjectExtensions.<ManifestAccess>operator_doubleArrow(_manifest_3, _function_1);
    }
    ManifestAccess _manifest_4 = this.getProjectConfig().getEclipsePlugin().getManifest();
    boolean _tripleNotEquals_2 = (_manifest_4 != null);
    if (_tripleNotEquals_2) {
        this.getProjectConfig().getEclipsePlugin().getManifest().getExportedPackages().add(this._xtextGeneratorNaming.getEclipsePluginActivator().getPackageName());
    }
    ManifestAccess _manifest_5 = this.getProjectConfig().getRuntimeTest().getManifest();
    ManifestAccess _manifest_6 = this.getProjectConfig().getEclipsePluginTest().getManifest();
    final Consumer<ManifestAccess> _function_2 = (ManifestAccess it) -> {
        CollectionExtensions.<String>addAll(it.getImportedPackages(), "org.junit;version=\"4.5.0\"", "org.junit.runner;version=\"4.5.0\"", "org.junit.runner.manipulation;version=\"4.5.0\"", "org.junit.runner.notification;version=\"4.5.0\"", "org.junit.runners;version=\"4.5.0\"", "org.junit.runners.model;version=\"4.5.0\"", "org.hamcrest.core");
    };
    IterableExtensions.<ManifestAccess>filterNull(Collections.<ManifestAccess>unmodifiableList(CollectionLiterals.<ManifestAccess>newArrayList(_manifest_5, _manifest_6))).forEach(_function_2);
    this.generateInjectorProvider().writeTo(this.getProjectConfig().getRuntimeTest().getSrcGen());
    boolean _isGenerateStub = this.isGenerateStub();
    if (_isGenerateStub) {
        this.generateExampleRuntimeTest().writeTo(this.getProjectConfig().getRuntimeTest().getSrc());
    }
    IXtextGeneratorFileSystemAccess _srcGen = this.getProjectConfig().getEclipsePlugin().getSrcGen();
    boolean _tripleNotEquals_3 = (_srcGen != null);
    if (_tripleNotEquals_3) {
        this.generateUiInjectorProvider().writeTo(this.getProjectConfig().getEclipsePluginTest().getSrcGen());
    }
}
Also used : ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) IXtextGeneratorFileSystemAccess(org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess)

Example 3 with IXtextGeneratorFileSystemAccess

use of org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess in project xtext-core by eclipse.

the class OutlineTreeProviderFragment2 method generate.

@Override
public void generate() {
    ManifestAccess _manifest = this.getProjectConfig().getEclipsePlugin().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
        _requiredBundles.add("org.eclipse.xtext.ui");
    }
    boolean _isGenerateStub = this.isGenerateStub();
    boolean _not = (!_isGenerateStub);
    if (_not) {
        return;
    }
    IXtextGeneratorFileSystemAccess _src = this.getProjectConfig().getEclipsePlugin().getSrc();
    boolean _tripleNotEquals_1 = (_src != null);
    if (_tripleNotEquals_1) {
        boolean _isGenerateXtendStub = this.isGenerateXtendStub();
        if (_isGenerateXtendStub) {
            this.generateXtendOutlineTreeProvider();
        } else {
            this.generateJavaOutlineTreeProvider();
        }
    }
    GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
    TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.editor.outline.IOutlineTreeProvider");
    GuiceModuleAccess.BindingFactory _addTypeToType = _bindingFactory.addTypeToType(_typeReference, this.getOutlineTreeProviderClass(this.getGrammar()));
    TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.ui.editor.outline.impl.IOutlineTreeStructureProvider");
    _addTypeToType.addTypeToType(_typeReference_1, this.getOutlineTreeProviderClass(this.getGrammar())).contributeTo(this.getLanguage().getEclipsePluginGenModule());
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) IXtextGeneratorFileSystemAccess(org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 4 with IXtextGeneratorFileSystemAccess

use of org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess in project xtext-core by eclipse.

the class CodetemplatesGeneratorFragment2 method generate.

@Override
public void generate() {
    IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
    ManifestAccess _manifest = null;
    if (_eclipsePlugin != null) {
        _manifest = _eclipsePlugin.getManifest();
    }
    Set<String> _requiredBundles = null;
    if (_manifest != null) {
        _requiredBundles = _manifest.getRequiredBundles();
    }
    if (_requiredBundles != null) {
        _requiredBundles.addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext.ui", "org.eclipse.xtext.ui.codetemplates.ui")));
    }
    GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
    TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.preferences.TemplatesLanguageConfiguration");
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.AccessibleCodetemplatesActivator");
            _builder.append(_typeRef);
            _builder.append(".getTemplatesLanguageConfigurationProvider()");
        }
    };
    GuiceModuleAccess.BindingFactory _addTypeToProviderInstance = _bindingFactory.addTypeToProviderInstance(_typeRef, _client);
    TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.registry.LanguageRegistry");
    StringConcatenationClient _client_1 = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.AccessibleCodetemplatesActivator");
            _builder.append(_typeRef);
            _builder.append(".getLanguageRegistry()");
        }
    };
    _addTypeToProviderInstance.addTypeToProviderInstance(_typeRef_1, _client_1).addTypeToTypeEagerSingleton(TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.registry.LanguageRegistrar"), TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.registry.LanguageRegistrar")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"), TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.preferences.AdvancedTemplatesPreferencePage")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.partialEditing.IPartialEditingContentAssistParser"), this.getPartialContentAssistParserClass(this.getGrammar())).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.partialEditing.IPartialEditingContentAssistContextFactory"), TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.partialEditing.PartialEditingContentAssistContextFactory")).contributeTo(this.getLanguage().getEclipsePluginGenModule());
    IBundleProjectConfig _genericIde = this.getProjectConfig().getGenericIde();
    IXtextGeneratorFileSystemAccess _srcGen = null;
    if (_genericIde != null) {
        _srcGen = _genericIde.getSrcGen();
    }
    boolean _tripleNotEquals = (_srcGen != null);
    if (_tripleNotEquals) {
        GeneratedJavaFileAccess _createGeneratedJavaFile = this.fileAccessFactory.createGeneratedJavaFile(this.getPartialContentAssistParserClass(this.getGrammar()));
        final Procedure1<GeneratedJavaFileAccess> _function = (GeneratedJavaFileAccess it) -> {
            it.setContent(this.getGenPartialContentAssistParser());
            it.writeTo(this.getProjectConfig().getGenericIde().getSrcGen());
        };
        ObjectExtensions.<GeneratedJavaFileAccess>operator_doubleArrow(_createGeneratedJavaFile, _function);
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) IBundleProjectConfig(org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) IXtextGeneratorFileSystemAccess(org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess) GeneratedJavaFileAccess(org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 5 with IXtextGeneratorFileSystemAccess

use of org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess in project xtext-core by eclipse.

the class XtextDirectoryCleaner method clean.

public void clean() {
    if ((!this.enabled)) {
        return;
    }
    final ArrayList<String> directories = CollectionLiterals.<String>newArrayList();
    final Function1<ISubProjectConfig, IXtextGeneratorFileSystemAccess> _function = (ISubProjectConfig it) -> {
        return it.getSrcGen();
    };
    List<IXtextGeneratorFileSystemAccess> _map = ListExtensions.map(this.config.getEnabledProjects(), _function);
    IXtextGeneratorFileSystemAccess _ecoreModel = this.config.getRuntime().getEcoreModel();
    final Function1<IXtextGeneratorFileSystemAccess, String> _function_1 = (IXtextGeneratorFileSystemAccess it) -> {
        return it.getPath();
    };
    final Function1<String, Boolean> _function_2 = (String it) -> {
        return Boolean.valueOf(new File(it).isDirectory());
    };
    Iterable<String> _filter = IterableExtensions.<String>filter(IterableExtensions.<IXtextGeneratorFileSystemAccess, String>map(IterableExtensions.<IXtextGeneratorFileSystemAccess>filterNull(Iterables.<IXtextGeneratorFileSystemAccess>concat(_map, Collections.<IXtextGeneratorFileSystemAccess>unmodifiableList(CollectionLiterals.<IXtextGeneratorFileSystemAccess>newArrayList(_ecoreModel)))), _function_1), _function_2);
    Iterables.<String>addAll(directories, _filter);
    Iterables.<String>addAll(directories, this.extraDirectories);
    final DirectoryCleaner delegate = new DirectoryCleaner();
    delegate.setUseDefaultExcludes(this.useDefaultExcludes);
    final Consumer<String> _function_3 = (String it) -> {
        delegate.addExclude(it);
    };
    this.excludes.forEach(_function_3);
    final Consumer<String> _function_4 = (String it) -> {
        try {
            delegate.cleanFolder(it);
        } catch (Throwable _e) {
            throw Exceptions.sneakyThrow(_e);
        }
    };
    directories.forEach(_function_4);
}
Also used : ISubProjectConfig(org.eclipse.xtext.xtext.generator.model.project.ISubProjectConfig) IXtextGeneratorFileSystemAccess(org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess) DirectoryCleaner(org.eclipse.emf.mwe.utils.DirectoryCleaner) File(java.io.File)

Aggregations

IXtextGeneratorFileSystemAccess (org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess)12 ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)5 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)4 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)4 Extension (org.eclipse.xtext.xbase.lib.Extension)2 IBundleProjectConfig (org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig)2 ContentAssistGrammarNaming (org.eclipse.xtext.xtext.generator.parser.antlr.ContentAssistGrammarNaming)2 File (java.io.File)1 DirectoryCleaner (org.eclipse.emf.mwe.utils.DirectoryCleaner)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)1 Grammar (org.eclipse.xtext.Grammar)1 IXtextGeneratorLanguage (org.eclipse.xtext.xtext.generator.IXtextGeneratorLanguage)1 XtextGeneratorLanguage (org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage)1 GeneratedJavaFileAccess (org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess)1 PluginXmlAccess (org.eclipse.xtext.xtext.generator.model.PluginXmlAccess)1 ISubProjectConfig (org.eclipse.xtext.xtext.generator.model.project.ISubProjectConfig)1 AntlrGrammar (org.eclipse.xtext.xtext.generator.parser.antlr.AntlrGrammar)1 CombinedGrammarMarker (org.eclipse.xtext.xtext.generator.parser.antlr.CombinedGrammarMarker)1 GrammarNaming (org.eclipse.xtext.xtext.generator.parser.antlr.GrammarNaming)1