Search in sources :

Example 41 with StringConcatenationClient

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

the class CodetemplatesGeneratorFragment2 method getGenPartialContentAssistParser.

private StringConcatenationClient getGenPartialContentAssistParser() {
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("public class ");
            String _simpleName = CodetemplatesGeneratorFragment2.this.getPartialContentAssistParserClass(CodetemplatesGeneratorFragment2.this.getGrammar()).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _parserClass = CodetemplatesGeneratorFragment2.this.caNaming.getParserClass(CodetemplatesGeneratorFragment2.this.getGrammar());
            _builder.append(_parserClass);
            _builder.append(" implements ");
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ide.editor.partialEditing.IPartialEditingContentAssistParser");
            _builder.append(_typeRef);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("private ");
            _builder.append(AbstractRule.class, "\t");
            _builder.append(" rule;");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("public void initializeFor(AbstractRule rule) {");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("this.rule = rule;");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@Override");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("protected ");
            _builder.append(Collection.class, "\t");
            _builder.append("<");
            TypeReference _followElementClass = CodetemplatesGeneratorFragment2.this.getFollowElementClass();
            _builder.append(_followElementClass, "\t");
            _builder.append("> getFollowElements(");
            TypeReference _abstractInternalContentAssistParserClass = CodetemplatesGeneratorFragment2.this.getAbstractInternalContentAssistParserClass();
            _builder.append(_abstractInternalContentAssistParserClass, "\t");
            _builder.append(" parser) {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("if (rule == null || rule.eIsProxy())");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("return ");
            _builder.append(Collections.class, "\t\t\t");
            _builder.append(".emptyList();");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append(String.class, "\t\t");
            _builder.append(" methodName = \"entryRule\" + rule.getName();");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append(PolymorphicDispatcher.class, "\t\t");
            _builder.append("<Collection<FollowElement>> dispatcher = ");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t\t");
            _builder.append("new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("dispatcher.invoke();");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("return parser.getFollowElements();");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    return _client;
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 42 with StringConcatenationClient

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

the class ValidatorFragment2 method generateValidationToDeprecateRules.

protected StringConcatenationClient generateValidationToDeprecateRules() {
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            {
                if (ValidatorFragment2.this.generateDeprecationValidation) {
                    {
                        List<AbstractRule> _deprecatedRulesFromGrammar = ValidatorFragment2.this.getDeprecatedRulesFromGrammar();
                        for (final AbstractRule deprecatedRule : _deprecatedRulesFromGrammar) {
                            EClassifier _classifier = deprecatedRule.getType().getClassifier();
                            ResourceSet _resourceSet = ValidatorFragment2.this.getGrammar().eResource().getResourceSet();
                            final TypeReference elementType = new TypeReference(((EClass) _classifier), _resourceSet);
                            _builder.newLineIfNotEmpty();
                            _builder.newLine();
                            _builder.append("@");
                            _builder.append(Check.class);
                            _builder.newLineIfNotEmpty();
                            _builder.append("public void checkDeprecated");
                            String _simpleName = elementType.getSimpleName();
                            _builder.append(_simpleName);
                            _builder.append("(");
                            _builder.append(elementType);
                            _builder.append(" element) {");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t");
                            _builder.append("warning(\"This part of the language is marked as deprecated and might get removed in the future!\", element, null);");
                            _builder.newLine();
                            _builder.append("}");
                            _builder.newLine();
                        }
                    }
                }
            }
        }
    };
    return _client;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) EClassifier(org.eclipse.emf.ecore.EClassifier) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference) AbstractRule(org.eclipse.xtext.AbstractRule)

Example 43 with StringConcatenationClient

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

the class ValidatorFragment2 method generateGenValidator.

protected GeneratedJavaFileAccess generateGenValidator() {
    GeneratedJavaFileAccess _xblockexpression = null;
    {
        TypeReference _xifexpression = null;
        boolean _isGenerateStub = this.isGenerateStub();
        if (_isGenerateStub) {
            _xifexpression = this._validatorNaming.getAbstractValidatorClass(this.getGrammar());
        } else {
            _xifexpression = this._validatorNaming.getValidatorClass(this.getGrammar());
        }
        final TypeReference genClass = _xifexpression;
        final GeneratedJavaFileAccess javaFile = this.fileAccessFactory.createGeneratedJavaFile(genClass);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                {
                    boolean _isEmpty = ValidatorFragment2.this.composedChecks.isEmpty();
                    boolean _not = (!_isEmpty);
                    if (_not) {
                        _builder.append("@");
                        _builder.append(ComposedChecks.class);
                        _builder.append("(validators = {");
                        {
                            boolean _hasElements = false;
                            for (final String validator : ValidatorFragment2.this.composedChecks) {
                                if (!_hasElements) {
                                    _hasElements = true;
                                } else {
                                    _builder.appendImmediate(", ", "");
                                }
                                TypeReference _typeRef = TypeReference.typeRef(validator);
                                _builder.append(_typeRef);
                                _builder.append(".class");
                            }
                        }
                        _builder.append("})");
                        _builder.newLineIfNotEmpty();
                    }
                }
                _builder.append("public ");
                {
                    boolean _isGenerateStub = ValidatorFragment2.this.isGenerateStub();
                    if (_isGenerateStub) {
                        _builder.append("abstract ");
                    }
                }
                _builder.append("class ");
                String _simpleName = genClass.getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _genValidatorSuperClass = ValidatorFragment2.this.getGenValidatorSuperClass(ValidatorFragment2.this.getGrammar());
                _builder.append(_genValidatorSuperClass);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("@Override");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("protected ");
                _builder.append(List.class, "\t");
                _builder.append("<");
                _builder.append(EPackage.class, "\t");
                _builder.append("> getEPackages() {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append(List.class, "\t\t");
                _builder.append("<");
                _builder.append(EPackage.class, "\t\t");
                _builder.append("> result = new ");
                _builder.append(ArrayList.class, "\t\t");
                _builder.append("<");
                _builder.append(EPackage.class, "\t\t");
                _builder.append(">(");
                {
                    if ((ValidatorFragment2.this.isInheritImplementation() && (GrammarUtil2.getNonTerminalsSuperGrammar(ValidatorFragment2.this.getGrammar()) != null))) {
                        _builder.append("super.getEPackages()");
                    }
                }
                _builder.append(");");
                _builder.newLineIfNotEmpty();
                {
                    Iterable<EPackage> _generatedPackagesToValidate = ValidatorFragment2.this.getGeneratedPackagesToValidate();
                    for (final EPackage e : _generatedPackagesToValidate) {
                        _builder.append("\t\t");
                        _builder.append("result.add(");
                        String _generatedEPackageName = ValidatorFragment2.this.getGeneratedEPackageName(e);
                        _builder.append(_generatedEPackageName, "\t\t");
                        _builder.append(".eINSTANCE);");
                        _builder.newLineIfNotEmpty();
                    }
                }
                {
                    Collection<EPackage> _registryPackagesToValidate = ValidatorFragment2.this.getRegistryPackagesToValidate();
                    for (final EPackage e_1 : _registryPackagesToValidate) {
                        _builder.append("\t\t");
                        _builder.append("result.add(EPackage.Registry.INSTANCE.getEPackage(\"");
                        String _nsURI = e_1.getNsURI();
                        _builder.append(_nsURI, "\t\t");
                        _builder.append("\"));");
                        _builder.newLineIfNotEmpty();
                    }
                }
                _builder.append("\t\t");
                _builder.append("return result;");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("\t");
                StringConcatenationClient _generateValidationToDeprecateRules = ValidatorFragment2.this.generateValidationToDeprecateRules();
                _builder.append(_generateValidationToDeprecateRules, "\t");
                _builder.newLineIfNotEmpty();
                _builder.append("}");
                _builder.newLine();
            }
        };
        javaFile.setContent(_client);
        _xblockexpression = javaFile;
    }
    return _xblockexpression;
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) ArrayList(java.util.ArrayList) GeneratedJavaFileAccess(org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess) ArrayList(java.util.ArrayList) List(java.util.List) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference) EPackage(org.eclipse.emf.ecore.EPackage)

Example 44 with StringConcatenationClient

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

the class ValidatorFragment2 method generateJavaValidatorStub.

protected void generateJavaValidatorStub() {
    TypeReference _validatorClass = this._validatorNaming.getValidatorClass(this.getGrammar());
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("/**");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("* This class contains custom validation rules. ");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("*");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("*/");
            _builder.newLine();
            _builder.append("public class ");
            String _simpleName = ValidatorFragment2.this._validatorNaming.getValidatorClass(ValidatorFragment2.this.getGrammar()).getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _abstractValidatorClass = ValidatorFragment2.this._validatorNaming.getAbstractValidatorClass(ValidatorFragment2.this.getGrammar());
            _builder.append(_abstractValidatorClass);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("//\tpublic static final INVALID_NAME = \'invalidName\'");
            _builder.newLine();
            _builder.append("//");
            _builder.newLine();
            _builder.append("//\t@Check");
            _builder.newLine();
            _builder.append("//\tpublic void checkGreetingStartsWithCapital(Greeting greeting) {");
            _builder.newLine();
            _builder.append("//\t\tif (!Character.isUpperCase(greeting.getName().charAt(0))) {");
            _builder.newLine();
            _builder.append("//\t\t\twarning(\"Name should start with a capital\",");
            _builder.newLine();
            _builder.append("//\t\t\t\t\t");
            String _simpleName_1 = GrammarUtil.getSimpleName(ValidatorFragment2.this.getGrammar());
            _builder.append(_simpleName_1);
            _builder.append("Package.Literals.GREETING__NAME,");
            _builder.newLineIfNotEmpty();
            _builder.append("//\t\t\t\t\tINVALID_NAME);");
            _builder.newLine();
            _builder.append("//\t\t}");
            _builder.newLine();
            _builder.append("//\t}");
            _builder.newLine();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    this.fileAccessFactory.createJavaFile(_validatorClass, _client).writeTo(this.getProjectConfig().getRuntime().getSrc());
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 45 with StringConcatenationClient

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

the class WebIntegrationFragment method generateIndexDoc.

protected void generateIndexDoc(final String hlModName) {
    boolean _isFile = this.getProjectConfig().getWeb().getAssets().isFile("index.html");
    if (_isFile) {
        return;
    }
    final TextFileAccess indexFile = this.fileAccessFactory.createTextFile();
    indexFile.setPath("index.html");
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("<html>");
            _builder.newLine();
            _builder.append("<head>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<meta http-equiv=\"Content-Language\" content=\"en-us\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<title>Example Web Editor</title>");
            _builder.newLine();
            {
                WebIntegrationFragment.Framework _get = WebIntegrationFragment.this.framework.get();
                boolean _equals = Objects.equal(_get, WebIntegrationFragment.Framework.ORION);
                if (_equals) {
                    _builder.append("\t");
                    _builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"orion/code_edit/built-codeEdit.css\"/>");
                    _builder.newLine();
                    _builder.append("\t");
                    _builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"xtext/");
                    XtextVersion _xtextVersion = WebIntegrationFragment.this.codeConfig.getXtextVersion();
                    _builder.append(_xtextVersion, "\t");
                    _builder.append("/xtext-orion.css\"/>");
                    _builder.newLineIfNotEmpty();
                } else {
                    WebIntegrationFragment.Framework _get_1 = WebIntegrationFragment.this.framework.get();
                    boolean _equals_1 = Objects.equal(_get_1, WebIntegrationFragment.Framework.ACE);
                    if (_equals_1) {
                        _builder.append("\t");
                        _builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"xtext/");
                        XtextVersion _xtextVersion_1 = WebIntegrationFragment.this.codeConfig.getXtextVersion();
                        _builder.append(_xtextVersion_1, "\t");
                        _builder.append("/xtext-ace.css\"/>");
                        _builder.newLineIfNotEmpty();
                    } else {
                        WebIntegrationFragment.Framework _get_2 = WebIntegrationFragment.this.framework.get();
                        boolean _equals_2 = Objects.equal(_get_2, WebIntegrationFragment.Framework.CODEMIRROR);
                        if (_equals_2) {
                            _builder.append("\t");
                            _builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"webjars/codemirror/");
                            _builder.append(WebIntegrationFragment.this.codeMirrorVersion, "\t");
                            _builder.append("/lib/codemirror.css\"/>");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t");
                            _builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"webjars/codemirror/");
                            _builder.append(WebIntegrationFragment.this.codeMirrorVersion, "\t");
                            _builder.append("/addon/hint/show-hint.css\"/>");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t");
                            _builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"xtext/");
                            XtextVersion _xtextVersion_2 = WebIntegrationFragment.this.codeConfig.getXtextVersion();
                            _builder.append(_xtextVersion_2, "\t");
                            _builder.append("/xtext-codemirror.css\"/>");
                            _builder.newLineIfNotEmpty();
                        }
                    }
                }
            }
            _builder.append("\t");
            _builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<script src=\"webjars/requirejs/");
            _builder.append(WebIntegrationFragment.this.requireJsVersion, "\t");
            _builder.append("/require.min.js\"></script>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("<script type=\"text/javascript\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("var baseUrl = window.location.pathname;");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("var fileIndex = baseUrl.indexOf(\"index.html\");");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("if (fileIndex > 0)");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("baseUrl = baseUrl.slice(0, fileIndex);");
            _builder.newLine();
            {
                WebIntegrationFragment.Framework _get_3 = WebIntegrationFragment.this.framework.get();
                boolean _equals_3 = Objects.equal(_get_3, WebIntegrationFragment.Framework.ORION);
                if (_equals_3) {
                    _builder.append("\t\t");
                    _builder.append("require.config({");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t");
                    _builder.append("baseUrl: baseUrl,");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t");
                    _builder.append("paths: {");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t\t");
                    _builder.append("\"text\": \"webjars/requirejs-text/");
                    _builder.append(WebIntegrationFragment.this.requireJsTextVersion, "\t\t\t\t");
                    _builder.append("/text\",");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("\t\t");
                    _builder.append("\"jquery\": \"webjars/jquery/");
                    _builder.append(WebIntegrationFragment.this.jQueryVersion, "\t\t\t\t");
                    _builder.append("/jquery.min\",");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("\t\t");
                    _builder.append("\"xtext/xtext-orion\": \"xtext/");
                    XtextVersion _xtextVersion_3 = WebIntegrationFragment.this.codeConfig.getXtextVersion();
                    _builder.append(_xtextVersion_3, "\t\t\t\t");
                    _builder.append("/xtext-orion\"");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("\t");
                    _builder.append("}");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("});");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("require([\"orion/code_edit/built-codeEdit-amd\"], function() {");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t");
                    _builder.append("require([\"xtext/xtext-orion\"], function(xtext) {");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t\t");
                    _builder.append("xtext.createEditor({");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t\t\t");
                    _builder.append("baseUrl: baseUrl,");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t\t\t");
                    _builder.append("syntaxDefinition: \"");
                    String _xifexpression = null;
                    boolean _get_4 = WebIntegrationFragment.this.generateJsHighlighting.get();
                    if (_get_4) {
                        _xifexpression = hlModName;
                    } else {
                        _xifexpression = "none";
                    }
                    _builder.append(_xifexpression, "\t\t\t\t\t");
                    _builder.append("\"");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("\t\t");
                    _builder.append("});");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("\t");
                    _builder.append("});");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("});");
                    _builder.newLine();
                } else {
                    WebIntegrationFragment.Framework _get_5 = WebIntegrationFragment.this.framework.get();
                    boolean _equals_4 = Objects.equal(_get_5, WebIntegrationFragment.Framework.ACE);
                    if (_equals_4) {
                        _builder.append("\t\t");
                        _builder.append("require.config({");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("\t");
                        _builder.append("baseUrl: baseUrl,");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("\t");
                        _builder.append("paths: {");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("\t\t");
                        _builder.append("\"jquery\": \"webjars/jquery/");
                        _builder.append(WebIntegrationFragment.this.jQueryVersion, "\t\t\t\t");
                        _builder.append("/jquery.min\",");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t\t");
                        _builder.append("\t\t");
                        _builder.append("\"ace/ext/language_tools\": \"webjars/ace/");
                        _builder.append(WebIntegrationFragment.this.aceVersion, "\t\t\t\t");
                        _builder.append("/src/ext-language_tools\",");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t\t");
                        _builder.append("\t\t");
                        _builder.append("\"xtext/xtext-ace\": \"xtext/");
                        XtextVersion _xtextVersion_4 = WebIntegrationFragment.this.codeConfig.getXtextVersion();
                        _builder.append(_xtextVersion_4, "\t\t\t\t");
                        _builder.append("/xtext-ace\"");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t\t");
                        _builder.append("\t");
                        _builder.append("}");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("});");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("require([\"webjars/ace/");
                        _builder.append(WebIntegrationFragment.this.aceVersion, "\t\t");
                        _builder.append("/src/ace\"], function() {");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t\t");
                        _builder.append("\t");
                        _builder.append("require([\"xtext/xtext-ace\"], function(xtext) {");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("\t\t");
                        _builder.append("xtext.createEditor({");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("\t\t\t");
                        _builder.append("baseUrl: baseUrl,");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("\t\t\t");
                        _builder.append("syntaxDefinition: \"");
                        String _xifexpression_1 = null;
                        boolean _get_6 = WebIntegrationFragment.this.generateJsHighlighting.get();
                        if (_get_6) {
                            _xifexpression_1 = hlModName;
                        } else {
                            _xifexpression_1 = "none";
                        }
                        _builder.append(_xifexpression_1, "\t\t\t\t\t");
                        _builder.append("\"");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t\t");
                        _builder.append("\t\t");
                        _builder.append("});");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("\t");
                        _builder.append("});");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("});");
                        _builder.newLine();
                    } else {
                        WebIntegrationFragment.Framework _get_7 = WebIntegrationFragment.this.framework.get();
                        boolean _equals_5 = Objects.equal(_get_7, WebIntegrationFragment.Framework.CODEMIRROR);
                        if (_equals_5) {
                            _builder.append("\t\t");
                            _builder.append("require.config({");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("baseUrl: baseUrl,");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("paths: {");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("\t\t");
                            _builder.append("\"jquery\": \"webjars/jquery/");
                            _builder.append(WebIntegrationFragment.this.jQueryVersion, "\t\t\t\t");
                            _builder.append("/jquery.min\",");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t\t");
                            _builder.append("\t\t");
                            _builder.append("\"xtext/xtext-codemirror\": \"xtext/");
                            XtextVersion _xtextVersion_5 = WebIntegrationFragment.this.codeConfig.getXtextVersion();
                            _builder.append(_xtextVersion_5, "\t\t\t\t");
                            _builder.append("/xtext-codemirror\"");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("},");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("packages: [{");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("\t\t");
                            _builder.append("name: \"codemirror\",");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("\t\t");
                            _builder.append("location: \"webjars/codemirror/");
                            _builder.append(WebIntegrationFragment.this.codeMirrorVersion, "\t\t\t\t");
                            _builder.append("\",");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t\t");
                            _builder.append("\t\t");
                            _builder.append("main: \"lib/codemirror\"");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("}]");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("});");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("require([");
                            {
                                boolean _get_8 = WebIntegrationFragment.this.generateJsHighlighting.get();
                                if (_get_8) {
                                    _builder.append("\"");
                                    _builder.append(hlModName, "\t\t");
                                    _builder.append("\", ");
                                }
                            }
                            _builder.append("\"xtext/xtext-codemirror\"], function(");
                            {
                                boolean _get_9 = WebIntegrationFragment.this.generateJsHighlighting.get();
                                if (_get_9) {
                                    _builder.append("mode, ");
                                }
                            }
                            _builder.append("xtext) {");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("xtext.createEditor({");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("\t\t");
                            _builder.append("baseUrl: baseUrl");
                            {
                                boolean _get_10 = WebIntegrationFragment.this.generateJsHighlighting.get();
                                boolean _not = (!_get_10);
                                if (_not) {
                                    _builder.append(",");
                                    _builder.newLineIfNotEmpty();
                                    _builder.append("\t\t");
                                    _builder.append("\t\t");
                                    _builder.append("syntaxDefinition: \"none\"");
                                    _builder.newLine();
                                }
                            }
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("});");
                            _builder.newLine();
                            _builder.append("\t\t");
                            _builder.append("});");
                            _builder.newLine();
                        }
                    }
                }
            }
            _builder.append("\t");
            _builder.append("</script>");
            _builder.newLine();
            _builder.append("</head>");
            _builder.newLine();
            _builder.append("<body>");
            _builder.newLine();
            _builder.newLine();
            _builder.append("<div class=\"container\">");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<div class=\"header\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<h1>Example ");
            String _simpleName = GrammarUtil.getSimpleName(WebIntegrationFragment.this.getGrammar());
            _builder.append(_simpleName, "\t\t");
            _builder.append(" Web Editor</h1>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</div>");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("<div class=\"content\">");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("<div id=\"xtext-editor\" data-editor-xtext-lang=\"");
            String _head = IterableExtensions.<String>head(WebIntegrationFragment.this.getLanguage().getFileExtensions());
            _builder.append(_head, "\t\t");
            _builder.append("\"></div>");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("</div>");
            _builder.newLine();
            _builder.append("</div>");
            _builder.newLine();
            _builder.newLine();
            _builder.append("</body>");
            _builder.newLine();
            _builder.append("</html>");
            _builder.newLine();
        }
    };
    indexFile.setContent(_client);
    indexFile.writeTo(this.getProjectConfig().getWeb().getAssets());
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) XtextVersion(org.eclipse.xtext.util.XtextVersion) TextFileAccess(org.eclipse.xtext.xtext.generator.model.TextFileAccess)

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