Search in sources :

Example 1 with StringConcatenation

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

the class IdeaPluginGenerator method compileCodeBlockModificationListener.

public CharSequence compileCodeBlockModificationListener(final Grammar grammar) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = this._ideaPluginClassNames.toPackageName(this._ideaPluginClassNames.getCodeBlockModificationListenerName(grammar));
    _builder.append(_packageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    {
        boolean _doesUseXbase = XbaseGeneratorFragment.doesUseXbase(grammar);
        if (_doesUseXbase) {
            _builder.append("import com.intellij.psi.impl.PsiTreeChangeEventImpl;");
            _builder.newLine();
        }
    }
    _builder.append("import com.intellij.psi.util.PsiModificationTracker;");
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.psi.BaseXtextCodeBlockModificationListener;");
    _builder.newLine();
    _builder.append("import ");
    String _languageName = this._ideaPluginClassNames.getLanguageName(grammar);
    _builder.append(_languageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("public class ");
    String _simpleName = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getCodeBlockModificationListenerName(grammar));
    _builder.append(_simpleName);
    _builder.append(" extends BaseXtextCodeBlockModificationListener {");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public ");
    String _simpleName_1 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getCodeBlockModificationListenerName(grammar));
    _builder.append(_simpleName_1, "\t");
    _builder.append("(PsiModificationTracker psiModificationTracker) {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t");
    _builder.append("super(");
    String _simpleName_2 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_simpleName_2, "\t\t");
    _builder.append(".INSTANCE, psiModificationTracker);");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    {
        boolean _doesUseXbase_1 = XbaseGeneratorFragment.doesUseXbase(grammar);
        if (_doesUseXbase_1) {
            _builder.newLine();
            _builder.append("\t");
            _builder.append("protected boolean hasJavaStructuralChanges(PsiTreeChangeEventImpl event) {");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("\t");
            _builder.append("return true;");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 2 with StringConcatenation

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

the class IdeaPluginGenerator method compileFileImpl.

public CharSequence compileFileImpl(final Grammar grammar) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _psiImplPackageName = this._ideaPluginClassNames.getPsiImplPackageName(grammar);
    _builder.append(_psiImplPackageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.psi.impl.BaseXtextFile;");
    _builder.newLine();
    _builder.append("import ");
    String _fileTypeName = this._ideaPluginClassNames.getFileTypeName(grammar);
    _builder.append(_fileTypeName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.append("import ");
    String _languageName = this._ideaPluginClassNames.getLanguageName(grammar);
    _builder.append(_languageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import com.intellij.openapi.fileTypes.FileType;");
    _builder.newLine();
    _builder.append("import com.intellij.psi.FileViewProvider;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public final class ");
    String _simpleName = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getFileImplName(grammar));
    _builder.append(_simpleName);
    _builder.append(" extends BaseXtextFile {");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public ");
    String _simpleName_1 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getFileImplName(grammar));
    _builder.append(_simpleName_1, "\t");
    _builder.append("(FileViewProvider viewProvider) {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t");
    _builder.append("super(viewProvider, ");
    String _simpleName_2 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_simpleName_2, "\t\t");
    _builder.append(".INSTANCE);");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("@Override");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public FileType getFileType() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("return ");
    String _simpleName_3 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getFileTypeName(grammar));
    _builder.append(_simpleName_3, "\t\t");
    _builder.append(".INSTANCE;");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 3 with StringConcatenation

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

the class IdeaPluginGenerator method compileGuiceModuleIdeaGenerated.

public CharSequence compileGuiceModuleIdeaGenerated(final Grammar grammar, final Set<Binding> bindings) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = this._ideaPluginClassNames.toPackageName(this._ideaPluginClassNames.getAbstractIdeaModuleName(grammar));
    _builder.append(_packageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("public class ");
    String _simpleName = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getAbstractIdeaModuleName(grammar));
    _builder.append(_simpleName);
    _builder.append(" extends org.eclipse.xtext.idea.DefaultIdeaModule {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.newLine();
    {
        for (final Binding it : bindings) {
            {
                if (((!it.getValue().isProvider()) && ((List<String>) Conversions.doWrapArray(it.getValue().getStatements())).isEmpty())) {
                    _builder.append("\t");
                    _builder.append("// contributed by ");
                    String _contributedBy = it.getContributedBy();
                    _builder.append(_contributedBy, "\t");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    {
                        boolean _isSingleton = it.getKey().isSingleton();
                        if (_isSingleton) {
                            _builder.append("@org.eclipse.xtext.service.SingletonBinding");
                            {
                                boolean _isEagerSingleton = it.getKey().isEagerSingleton();
                                if (_isEagerSingleton) {
                                    _builder.append("(eager=true)");
                                }
                            }
                        }
                    }
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("public ");
                    {
                        String _expression = it.getValue().getExpression();
                        boolean _tripleEquals = (_expression == null);
                        if (_tripleEquals) {
                            _builder.append("Class<? extends ");
                            String _type = it.getKey().getType();
                            _builder.append(_type, "\t");
                            _builder.append(">");
                        } else {
                            String _type_1 = it.getKey().getType();
                            _builder.append(_type_1, "\t");
                        }
                    }
                    _builder.append(" ");
                    String _bindMethodName = this.bindMethodName(it);
                    _builder.append(_bindMethodName, "\t");
                    _builder.append("() {");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("\t");
                    _builder.append("return ");
                    {
                        String _expression_1 = it.getValue().getExpression();
                        boolean _tripleNotEquals = (_expression_1 != null);
                        if (_tripleNotEquals) {
                            String _expression_2 = it.getValue().getExpression();
                            _builder.append(_expression_2, "\t\t");
                        } else {
                            String _typeName = it.getValue().getTypeName();
                            _builder.append(_typeName, "\t\t");
                            _builder.append(".class");
                        }
                    }
                    _builder.append(";");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("}");
                    _builder.newLine();
                } else {
                    boolean _isEmpty = ((List<String>) Conversions.doWrapArray(it.getValue().getStatements())).isEmpty();
                    if (_isEmpty) {
                        _builder.append("\t");
                        _builder.append("// contributed by ");
                        String _contributedBy_1 = it.getContributedBy();
                        _builder.append(_contributedBy_1, "\t");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        {
                            boolean _isSingleton_1 = it.getKey().isSingleton();
                            if (_isSingleton_1) {
                                _builder.append("@org.eclipse.xtext.service.SingletonBinding");
                                {
                                    boolean _isEagerSingleton_1 = it.getKey().isEagerSingleton();
                                    if (_isEagerSingleton_1) {
                                        _builder.append("(eager=true)");
                                    }
                                }
                            }
                        }
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("public ");
                        {
                            String _expression_3 = it.getValue().getExpression();
                            boolean _tripleEquals_1 = (_expression_3 == null);
                            if (_tripleEquals_1) {
                                _builder.append("Class<? extends com.google.inject.Provider<");
                                String _type_2 = it.getKey().getType();
                                _builder.append(_type_2, "\t");
                                _builder.append(">>");
                            } else {
                                _builder.append("com.google.inject.Provider<");
                                String _type_3 = it.getKey().getType();
                                _builder.append(_type_3, "\t");
                                _builder.append(">");
                            }
                        }
                        _builder.append(" ");
                        String _bindMethodName_1 = this.bindMethodName(it);
                        _builder.append(_bindMethodName_1, "\t");
                        _builder.append("() {");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("\t");
                        _builder.append("return ");
                        {
                            String _expression_4 = it.getValue().getExpression();
                            boolean _tripleNotEquals_1 = (_expression_4 != null);
                            if (_tripleNotEquals_1) {
                                String _expression_5 = it.getValue().getExpression();
                                _builder.append(_expression_5, "\t\t");
                            } else {
                                String _typeName_1 = it.getValue().getTypeName();
                                _builder.append(_typeName_1, "\t\t");
                                _builder.append(".class");
                            }
                        }
                        _builder.append(";");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("}");
                        _builder.newLine();
                    } else {
                        _builder.append("\t");
                        _builder.append("// contributed by ");
                        String _contributedBy_2 = it.getContributedBy();
                        _builder.append(_contributedBy_2, "\t");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("public void ");
                        String _bindMethodName_2 = this.bindMethodName(it);
                        _builder.append(_bindMethodName_2, "\t");
                        _builder.append("(com.google.inject.Binder binder) {");
                        _builder.newLineIfNotEmpty();
                        {
                            String[] _statements = it.getValue().getStatements();
                            for (final String statement : _statements) {
                                _builder.append("\t");
                                _builder.append("\t");
                                _builder.append(statement, "\t\t");
                                {
                                    boolean _endsWith = statement.endsWith(";");
                                    boolean _not = (!_endsWith);
                                    if (_not) {
                                        _builder.append(";");
                                    }
                                }
                                _builder.newLineIfNotEmpty();
                            }
                        }
                        _builder.append("\t");
                        _builder.append("}");
                        _builder.newLine();
                    }
                }
            }
        }
    }
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : Binding(org.eclipse.xtext.generator.Binding) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) List(java.util.List)

Example 4 with StringConcatenation

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

the class IdeaPluginGenerator method compileLanguage.

public CharSequence compileLanguage(final Grammar grammar) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = this._ideaPluginClassNames.toPackageName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_packageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.idea.lang.AbstractXtextLanguage;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public final class ");
    String _simpleName = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_simpleName);
    _builder.append(" extends AbstractXtextLanguage {");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public static final ");
    String _simpleName_1 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_simpleName_1, "\t");
    _builder.append(" INSTANCE = new ");
    String _simpleName_2 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_simpleName_2, "\t");
    _builder.append("();");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("private ");
    String _simpleName_3 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getLanguageName(grammar));
    _builder.append(_simpleName_3, "\t");
    _builder.append("() {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t");
    _builder.append("super(\"");
    String _languageID = this._ideaPluginExtension.getLanguageID(grammar);
    _builder.append(_languageID, "\t\t");
    _builder.append("\");");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 5 with StringConcatenation

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

the class IdeaPluginGenerator method compileIdeaModule.

public CharSequence compileIdeaModule(final Grammar grammar) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    String _packageName = this._ideaPluginClassNames.toPackageName(this._ideaPluginClassNames.getIdeaModuleName(grammar));
    _builder.append(_packageName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("public class ");
    String _simpleName = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getIdeaModuleName(grammar));
    _builder.append(_simpleName);
    _builder.append(" extends ");
    String _simpleName_1 = this._ideaPluginClassNames.toSimpleName(this._ideaPluginClassNames.getAbstractIdeaModuleName(grammar));
    _builder.append(_simpleName_1);
    _builder.append(" {");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5377 Test (org.junit.Test)4633 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)384 ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)202 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)135 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)132 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)131 IFile (org.eclipse.core.resources.IFile)123 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)117 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)103 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)101 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)99 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)89 XExpression (org.eclipse.xtext.xbase.XExpression)82 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)80 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)76 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)73 EList (org.eclipse.emf.common.util.EList)67 List (java.util.List)66 Ignore (org.junit.Ignore)60