Search in sources :

Example 36 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class SimpleProjectWizardFragment2 method generateNewProjectWizard.

public void generateNewProjectWizard() {
    final TypeReference genClass = TypeReference.typeRef(this.getProjectWizardClassName());
    final TypeReference projectInfoClass = TypeReference.typeRef(this.getProjectInfoClassName());
    final TypeReference creationPageClassName = TypeReference.typeRef(this.getProjectWizardCreationPageClassName());
    final GeneratedJavaFileAccess file = this.fileAccessFactory.createGeneratedJavaFile(genClass);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("import org.eclipse.xtext.ui.wizard.IExtendedProjectInfo;");
            _builder.newLine();
            _builder.append("import org.eclipse.xtext.ui.wizard.IProjectCreator;");
            _builder.newLine();
            _builder.append("import com.google.inject.Inject;");
            _builder.newLine();
            _builder.newLine();
            _builder.append("public class ");
            String _simpleName = genClass.getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.wizard.XtextNewProjectWizard");
            _builder.append(_typeRef);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("private ");
            _builder.append(creationPageClassName, "\t");
            _builder.append(" mainPage;");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Inject");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public ");
            String _simpleName_1 = genClass.getSimpleName();
            _builder.append(_simpleName_1, "\t");
            _builder.append("(IProjectCreator projectCreator) {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("super(projectCreator);");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("setWindowTitle(\"New ");
            String _simpleName_2 = GrammarUtil.getSimpleName(SimpleProjectWizardFragment2.this.getGrammar());
            _builder.append(_simpleName_2, "\t\t");
            _builder.append(" Project\");");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("protected ");
            _builder.append(creationPageClassName, "\t");
            _builder.append(" getMainPage() {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("return mainPage;");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("/**");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* Use this method to add pages to the wizard.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* The one-time generated version of this class will add a default new project page to the wizard.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*/");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public void addPages() {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("mainPage = createMainPage(\"basicNewProjectPage\");");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("mainPage.setTitle(\"");
            String _simpleName_3 = GrammarUtil.getSimpleName(SimpleProjectWizardFragment2.this.getGrammar());
            _builder.append(_simpleName_3, "\t\t");
            _builder.append(" Project\");");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("mainPage.setDescription(\"Create a new ");
            String _simpleName_4 = GrammarUtil.getSimpleName(SimpleProjectWizardFragment2.this.getGrammar());
            _builder.append(_simpleName_4, "\t\t");
            _builder.append(" project.\");");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("addPage(mainPage);");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("protected ");
            _builder.append(creationPageClassName, "\t");
            _builder.append(" createMainPage(String pageName) {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("return new ");
            _builder.append(creationPageClassName, "\t\t");
            _builder.append("(pageName);");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("/**");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* Use this method to read the project settings from the wizard pages and feed them into the project info class.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*/");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("protected IExtendedProjectInfo getProjectInfo() {");
            _builder.newLine();
            _builder.append("\t\t");
            String _simpleName_5 = projectInfoClass.getSimpleName();
            _builder.append(_simpleName_5, "\t\t");
            _builder.append(" projectInfo = new ");
            String _simpleName_6 = projectInfoClass.getSimpleName();
            _builder.append(_simpleName_6, "\t\t");
            _builder.append("();");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("projectInfo.setProjectName(mainPage.getProjectName());");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("if (!mainPage.useDefaults()) {");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("projectInfo.setLocationPath(mainPage.getLocationPath());");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("return projectInfo;");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    file.setContent(_client);
    file.writeTo(this.getProjectConfig().getEclipsePlugin().getSrcGen());
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) GeneratedJavaFileAccess(org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 37 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class QuickfixProviderFragment2 method generateGenQuickfixProvider.

public void generateGenQuickfixProvider() {
    final TypeReference genClass = this.getQuickfixProviderClass(this.getGrammar());
    final GeneratedJavaFileAccess file = this.fileAccessFactory.createGeneratedJavaFile(genClass);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = genClass.getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _quickfixProviderSuperClass = QuickfixProviderFragment2.this.getQuickfixProviderSuperClass(QuickfixProviderFragment2.this.getGrammar());
            _builder.append(_quickfixProviderSuperClass);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.append("}");
            _builder.newLine();
        }
    };
    file.setContent(_client);
    file.writeTo(this.getProjectConfig().getEclipsePlugin().getSrcGen());
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) GeneratedJavaFileAccess(org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 38 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class QuickfixProviderFragment2 method generateJavaQuickfixProvider.

protected void generateJavaQuickfixProvider() {
    TypeReference _quickfixProviderClass = this.getQuickfixProviderClass(this.getGrammar());
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("/**");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("* Custom quickfixes.");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("*");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#quick-fixes");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("*/");
            _builder.newLine();
            _builder.append("public class ");
            String _simpleName = QuickfixProviderFragment2.this.getQuickfixProviderClass(QuickfixProviderFragment2.this.getGrammar()).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _quickfixProviderSuperClass = QuickfixProviderFragment2.this.getQuickfixProviderSuperClass(QuickfixProviderFragment2.this.getGrammar());
            _builder.append(_quickfixProviderSuperClass);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("//\t@Fix(");
            String _simpleName_1 = QuickfixProviderFragment2.this._validatorNaming.getValidatorClass(QuickfixProviderFragment2.this.getGrammar()).getSimpleName();
            _builder.append(_simpleName_1);
            _builder.append(".INVALID_NAME)");
            _builder.newLineIfNotEmpty();
            _builder.append("//\tpublic void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) {");
            _builder.newLine();
            _builder.append("//\t\tacceptor.accept(issue, \"Capitalize name\", \"Capitalize the name.\", \"upcase.png\", new IModification() {");
            _builder.newLine();
            _builder.append("//\t\t\tpublic void apply(IModificationContext context) throws BadLocationException {");
            _builder.newLine();
            _builder.append("//\t\t\t\tIXtextDocument xtextDocument = context.getXtextDocument();");
            _builder.newLine();
            _builder.append("//\t\t\t\tString firstLetter = xtextDocument.get(issue.getOffset(), 1);");
            _builder.newLine();
            _builder.append("//\t\t\t\txtextDocument.replace(issue.getOffset(), 1, firstLetter.toUpperCase());");
            _builder.newLine();
            _builder.append("//\t\t\t}");
            _builder.newLine();
            _builder.append("//\t\t});");
            _builder.newLine();
            _builder.append("//\t}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    this.fileAccessFactory.createJavaFile(_quickfixProviderClass, _client).writeTo(this.getProjectConfig().getEclipsePlugin().getSrc());
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 39 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class RefactorElementNameFragment2 method generate.

@Override
public void generate() {
    IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
    ManifestAccess _manifest = null;
    if (_eclipsePlugin != null) {
        _manifest = _eclipsePlugin.getManifest();
    }
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
        _requiredBundles.add("org.eclipse.xtext.ui");
    }
    final GuiceModuleAccess.BindingFactory uiBindings = new GuiceModuleAccess.BindingFactory();
    String _join = IterableExtensions.join(TypeReference.typeRef("org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreInitializer").getSimpleNames(), ".");
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("binder.bind(");
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreInitializer");
            _builder.append(_typeRef);
            _builder.append(".class)");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append(".annotatedWith(");
            _builder.append(Names.class, "\t");
            _builder.append(".named(\"RefactoringPreferences\"))");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append(".to(");
            TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.refactoring.ui", "RefactoringPreferences.Initializer");
            _builder.append(_typeReference, "\t");
            _builder.append(".class);");
            _builder.newLineIfNotEmpty();
        }
    };
    uiBindings.addConfiguredBinding(_join, _client);
    boolean _isUseChangeSerializer = this.isUseChangeSerializer(this.getGrammar());
    if (_isUseChangeSerializer) {
        TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ide.refactoring.IRenameStrategy2");
        TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ide.refactoring", "IRenameStrategy2.DefaultImpl");
        uiBindings.addTypeToType(_typeRef, _typeReference).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.impl.AbstractRenameProcessor"), TypeReference.typeRef("org.eclipse.xtext.ui.refactoring2.rename.RenameElementProcessor2")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.ILinkedPositionGroupCalculator"), TypeReference.typeRef("org.eclipse.xtext.ui.refactoring2.rename.DefaultLinkedPositionGroupCalculator2"));
    } else {
        uiBindings.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IRenameStrategy"), TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultRenameStrategy")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IReferenceUpdater"), TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultReferenceUpdater"));
    }
    boolean _isUseJdtRefactoring = this.isUseJdtRefactoring(this.getGrammar());
    if (_isUseJdtRefactoring) {
        GuiceModuleAccess.BindingFactory _addTypeToType = uiBindings.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.ui.IRenameContextFactory"), TypeReference.typeRef("org.eclipse.xtext.common.types.ui.refactoring.JdtRefactoringContextFactory")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IRenameRefactoringProvider"), TypeReference.typeRef("org.eclipse.xtext.common.types.ui.refactoring.JvmRenameRefactoringProvider"));
        TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.ui.refactoring.ui", "IRenameSupport.Factory");
        TypeReference _typeReference_2 = new TypeReference("org.eclipse.xtext.common.types.ui.refactoring", "JdtRenameSupport.Factory");
        GuiceModuleAccess.BindingFactory _addTypeToType_1 = _addTypeToType.addTypeToType(_typeReference_1, _typeReference_2);
        TypeReference _typeReference_3 = new TypeReference("org.eclipse.xtext.ui.refactoring", "IRenameStrategy.Provider");
        TypeReference _typeReference_4 = new TypeReference("org.eclipse.xtext.common.types.ui.refactoring.participant", "JvmMemberRenameStrategy.Provider");
        GuiceModuleAccess.BindingFactory _addTypeToType_2 = _addTypeToType_1.addTypeToType(_typeReference_3, _typeReference_4);
        StringConcatenationClient _client_1 = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("binder.bind(");
                TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.refactoring", "IRenameStrategy.Provider");
                _builder.append(_typeReference);
                _builder.append(".class).annotatedWith(");
                TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.common.types.ui.refactoring.participant", "JvmMemberRenameStrategy.Provider.Delegate");
                _builder.append(_typeReference_1);
                _builder.append(".class).to(");
                TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultRenameStrategyProvider");
                _builder.append(_typeRef);
                _builder.append(".class);");
                _builder.newLineIfNotEmpty();
            }
        };
        _addTypeToType_2.addConfiguredBinding("JvmMemberRenameStrategy.Provider.Delegate", _client_1);
    } else {
        GuiceModuleAccess.BindingFactory _addTypeToType_3 = uiBindings.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IRenameRefactoringProvider"), TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultRenameRefactoringProvider"));
        TypeReference _typeReference_5 = new TypeReference("org.eclipse.xtext.ui.refactoring.ui", "IRenameSupport.Factory");
        TypeReference _typeReference_6 = new TypeReference("org.eclipse.xtext.ui.refactoring.ui", "DefaultRenameSupport.Factory");
        _addTypeToType_3.addTypeToType(_typeReference_5, _typeReference_6);
    }
    uiBindings.contributeTo(this.getLanguage().getEclipsePluginGenModule());
    IBundleProjectConfig _eclipsePlugin_1 = this.getProjectConfig().getEclipsePlugin();
    PluginXmlAccess _pluginXml = null;
    if (_eclipsePlugin_1 != null) {
        _pluginXml = _eclipsePlugin_1.getPluginXml();
    }
    boolean _tripleNotEquals_1 = (_pluginXml != null);
    if (_tripleNotEquals_1) {
        List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("<!-- Rename Refactoring -->");
        _builder.newLine();
        _builder.append("<extension point=\"org.eclipse.ui.handlers\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<handler ");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("class=\"");
        TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
        _builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
        _builder.append(":org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("commandId=\"org.eclipse.xtext.ui.refactoring.RenameElement\">");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("<activeWhen>");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("<reference");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("definitionId=\"");
        String _name = this.getGrammar().getName();
        _builder.append(_name, "\t\t\t\t");
        _builder.append(".Editor.opened\">");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t\t");
        _builder.append("</reference>");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("</activeWhen>");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("</handler>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _builder.append("<extension point=\"org.eclipse.ui.menus\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<menuContribution");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("locationURI=\"popup:#TextEditorContext?after=group.edit\">");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("<command commandId=\"org.eclipse.xtext.ui.refactoring.RenameElement\"");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("style=\"push\">");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("<visibleWhen checkEnabled=\"false\">");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("<reference");
        _builder.newLine();
        _builder.append("\t\t\t\t\t");
        _builder.append("definitionId=\"");
        String _name_1 = this.getGrammar().getName();
        _builder.append(_name_1, "\t\t\t\t\t");
        _builder.append(".Editor.opened\">");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t\t\t");
        _builder.append("</reference>");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("</visibleWhen>");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("</command>");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("</menuContribution>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _builder.append("<extension point=\"org.eclipse.ui.preferencePages\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<page");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("category=\"");
        String _name_2 = this.getGrammar().getName();
        _builder.append(_name_2, "\t\t");
        _builder.append("\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("class=\"");
        TypeReference _eclipsePluginExecutableExtensionFactory_1 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
        _builder.append(_eclipsePluginExecutableExtensionFactory_1, "\t\t");
        _builder.append(":org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("id=\"");
        String _name_3 = this.getGrammar().getName();
        _builder.append(_name_3, "\t\t");
        _builder.append(".refactoring\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("name=\"Refactoring\">");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("<keywordReference id=\"");
        String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(this.getGrammar());
        String _plus = (_runtimeBasePackage + ".ui.keyword_");
        String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
        String _plus_1 = (_plus + _simpleName);
        _builder.append(_plus_1, "\t\t");
        _builder.append("\"/>");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("</page>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _entries.add(_builder.toString());
    }
    boolean _isEnabled = this.getProjectConfig().getGenericIde().isEnabled();
    if (_isEnabled) {
        final GuiceModuleAccess.BindingFactory ideBindings = new GuiceModuleAccess.BindingFactory();
        ideBindings.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.server.rename.IRenameService"), TypeReference.typeRef("org.eclipse.xtext.ide.server.rename.RenameService"));
        TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.ide.refactoring.IRenameStrategy2");
        TypeReference _typeReference_7 = new TypeReference("org.eclipse.xtext.ide.refactoring", "IRenameStrategy2.DefaultImpl");
        ideBindings.addTypeToType(_typeRef_1, _typeReference_7);
        ideBindings.contributeTo(this.getLanguage().getIdeGenModule());
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) IBundleProjectConfig(org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig) PluginXmlAccess(org.eclipse.xtext.xtext.generator.model.PluginXmlAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 40 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient 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)

Aggregations

StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)194 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)119 GeneratedJavaFileAccess (org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess)24 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)24 Grammar (org.eclipse.xtext.Grammar)23 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)19 List (java.util.List)18 Test (org.junit.Test)18 Set (java.util.Set)14 JavaFileAccess (org.eclipse.xtext.xtext.generator.model.JavaFileAccess)12 ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)12 EClass (org.eclipse.emf.ecore.EClass)11 EList (org.eclipse.emf.common.util.EList)10 AbstractRule (org.eclipse.xtext.AbstractRule)10 IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)10 EObject (org.eclipse.emf.ecore.EObject)9 IClassAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)8 SuppressWarningsAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.SuppressWarningsAnnotation)8 ArrayList (java.util.ArrayList)7