Search in sources :

Example 1 with Property

use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property in project xtext-core by eclipse.

the class TestLanguageGenerator method doGenerate.

@Override
public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) {
    String _scheme = fsa.getURI("").scheme();
    boolean _equals = Objects.equal(_scheme, "inmemory");
    if (_equals) {
        return;
    }
    List<TypeDeclaration> _list = IteratorExtensions.<TypeDeclaration>toList(Iterators.<TypeDeclaration>filter(resource.getAllContents(), TypeDeclaration.class));
    for (final TypeDeclaration type : _list) {
        String _name = type.getName();
        String _plus = (_name + ".java");
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("public class ");
        String _name_1 = type.getName();
        _builder.append(_name_1);
        _builder.append(" {");
        _builder.newLineIfNotEmpty();
        {
            Iterable<Property> _filter = Iterables.<Property>filter(type.getMembers(), Property.class);
            for (final Property p : _filter) {
                _builder.append("\t");
                _builder.append("private ");
                String _java = this.toJava(p.getType());
                _builder.append(_java, "\t");
                _builder.append(" ");
                String _name_2 = p.getName();
                _builder.append(_name_2, "\t");
                _builder.append(";");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("public void set");
                String _firstUpper = StringExtensions.toFirstUpper(p.getName());
                _builder.append(_firstUpper, "\t");
                _builder.append("(");
                String _java_1 = this.toJava(p.getType());
                _builder.append(_java_1, "\t");
                _builder.append(" ");
                String _name_3 = p.getName();
                _builder.append(_name_3, "\t");
                _builder.append(") {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("\t");
                _builder.append("this.");
                String _name_4 = p.getName();
                _builder.append(_name_4, "\t\t");
                _builder.append(" = ");
                String _name_5 = p.getName();
                _builder.append(_name_5, "\t\t");
                _builder.append(";");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("\t");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("public ");
                String _java_2 = this.toJava(p.getType());
                _builder.append(_java_2, "\t");
                _builder.append(" get");
                String _firstUpper_1 = StringExtensions.toFirstUpper(p.getName());
                _builder.append(_firstUpper_1, "\t");
                _builder.append("() {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("\t");
                _builder.append("return this.");
                String _name_6 = p.getName();
                _builder.append(_name_6, "\t\t");
                _builder.append(";");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
            }
        }
        _builder.append("}");
        _builder.newLine();
        fsa.generateFile(_plus, _builder);
    }
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TypeDeclaration(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.TypeDeclaration) Property(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property)

Example 2 with Property

use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property in project xtext-core by eclipse.

the class ColoringServiceImpl method getColoring.

@Override
public List<? extends ColoringInformation> getColoring(final XtextResource resource, final Document document) {
    if ((resource == null)) {
        return CollectionLiterals.<ColoringInformation>emptyList();
    }
    final ImmutableList.Builder<ColoringInformation> builder = ImmutableList.<ColoringInformation>builder();
    final Procedure1<Object> _function = (Object it) -> {
        List<INode> _xifexpression = null;
        if ((it instanceof Property)) {
            _xifexpression = NodeModelUtils.findNodesForFeature(((EObject) it), TestLanguagePackage.Literals.MEMBER__NAME);
        } else {
            List<INode> _xifexpression_1 = null;
            if ((it instanceof Operation)) {
                _xifexpression_1 = NodeModelUtils.findNodesForFeature(((EObject) it), TestLanguagePackage.Literals.MEMBER__NAME);
            } else {
                _xifexpression_1 = CollectionLiterals.<INode>emptyList();
            }
            _xifexpression = _xifexpression_1;
        }
        final List<INode> nodes = _xifexpression;
        final Consumer<INode> _function_1 = (INode it_1) -> {
            final int start = it_1.getOffset();
            int _offset = it_1.getOffset();
            int _length = it_1.getLength();
            final int end = (_offset + _length);
            Position _position = document.getPosition(start);
            Position _position_1 = document.getPosition(end);
            final Range range = new Range(_position, _position_1);
            ColoringInformation _coloringInformation = new ColoringInformation(range, ColoringServiceImpl.STYLE_IDS);
            builder.add(_coloringInformation);
        };
        nodes.forEach(_function_1);
    };
    IteratorExtensions.<Object>forEach(EcoreUtil.<Object>getAllContents(resource, true), _function);
    return builder.build();
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) Position(org.eclipse.lsp4j.Position) ImmutableList(com.google.common.collect.ImmutableList) Operation(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Operation) Range(org.eclipse.lsp4j.Range) Consumer(java.util.function.Consumer) EObject(org.eclipse.emf.ecore.EObject) ColoringInformation(org.eclipse.lsp4j.ColoringInformation) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Property(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property)

Example 3 with Property

use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property in project xtext-core by eclipse.

the class TestLanguageFormatter method _format.

protected void _format(final TypeDeclaration type, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.newLine();
    };
    document.append(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getLeftCurlyBracketKeyword_3()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.newLine();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.newLine();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getRightCurlyBracketKeyword_5()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.indent();
    };
    document.<ISemanticRegion, ISemanticRegion>interior(this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getLeftCurlyBracketKeyword_3()), this.textRegionExtensions.regionFor(type).keyword(this._testLanguageGrammarAccess.getTypeDeclarationAccess().getRightCurlyBracketKeyword_5()), _function_3);
    Iterable<Property> _filter = Iterables.<Property>filter(type.getMembers(), Property.class);
    for (final Property property : _filter) {
        document.<Property>format(property);
    }
}
Also used : IHiddenRegionFormatter(org.eclipse.xtext.formatting2.IHiddenRegionFormatter) ISemanticRegion(org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion) Property(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property)

Example 4 with Property

use of org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property in project xtext-core by eclipse.

the class TestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == TestLanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case TestLanguagePackage.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
            case TestLanguagePackage.OPERATION:
                sequence_Operation(context, (Operation) semanticObject);
                return;
            case TestLanguagePackage.OPERATION_CALL:
                sequence_OperationCall(context, (OperationCall) semanticObject);
                return;
            case TestLanguagePackage.PACKAGE_DECLARATION:
                sequence_PackageDeclaration(context, (PackageDeclaration) semanticObject);
                return;
            case TestLanguagePackage.PARAMETER:
                sequence_Parameter(context, (org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Parameter) semanticObject);
                return;
            case TestLanguagePackage.PRIMITIVE_TYPE:
                if (rule == grammarAccess.getPrimitiveTypeRule()) {
                    sequence_PrimitiveType(context, (PrimitiveType) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeRule()) {
                    sequence_PrimitiveType_Type(context, (PrimitiveType) semanticObject);
                    return;
                } else
                    break;
            case TestLanguagePackage.PROPERTY:
                sequence_Property(context, (Property) semanticObject);
                return;
            case TestLanguagePackage.TYPE_DECLARATION:
                sequence_TypeDeclaration(context, (TypeDeclaration) semanticObject);
                return;
            case TestLanguagePackage.TYPE_REFERENCE:
                if (rule == grammarAccess.getTypeReferenceRule()) {
                    sequence_TypeReference(context, (TypeReference) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTypeRule()) {
                    sequence_Type_TypeReference(context, (TypeReference) semanticObject);
                    return;
                } else
                    break;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Operation(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Operation) EPackage(org.eclipse.emf.ecore.EPackage) OperationCall(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.OperationCall) Model(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Model) Parameter(org.eclipse.xtext.Parameter) PrimitiveType(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.PrimitiveType) TypeReference(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.TypeReference) Property(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property) TypeDeclaration(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.TypeDeclaration) PackageDeclaration(org.eclipse.xtext.ide.tests.testlanguage.testLanguage.PackageDeclaration)

Aggregations

Property (org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property)4 Operation (org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Operation)2 TypeDeclaration (org.eclipse.xtext.ide.tests.testlanguage.testLanguage.TypeDeclaration)2 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 EObject (org.eclipse.emf.ecore.EObject)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ColoringInformation (org.eclipse.lsp4j.ColoringInformation)1 Position (org.eclipse.lsp4j.Position)1 Range (org.eclipse.lsp4j.Range)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)1 ISemanticRegion (org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion)1 Model (org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Model)1 OperationCall (org.eclipse.xtext.ide.tests.testlanguage.testLanguage.OperationCall)1 PackageDeclaration (org.eclipse.xtext.ide.tests.testlanguage.testLanguage.PackageDeclaration)1