Search in sources :

Example 36 with Position

use of org.eclipse.lsp4j.Position in project xtext-core by eclipse.

the class FormattingTest method testRangeFormattingService.

@Test
public void testRangeFormattingService() {
    final Procedure1<RangeFormattingConfiguration> _function = (RangeFormattingConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type Foo{int bar} type Bar{Foo foo}");
        it.setModel(_builder.toString());
        Range _range = new Range();
        final Procedure1<Range> _function_1 = (Range it_1) -> {
            Position _position = new Position(0, 0);
            it_1.setStart(_position);
            Position _position_1 = new Position(0, 17);
            it_1.setEnd(_position_1);
        };
        Range _doubleArrow = ObjectExtensions.<Range>operator_doubleArrow(_range, _function_1);
        it.setRange(_doubleArrow);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type Foo{");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("int bar");
        _builder_1.newLine();
        _builder_1.append("} type Bar{Foo foo}");
        it.setExpectedText(_builder_1.toString());
    };
    this.testRangeFormatting(_function);
}
Also used : RangeFormattingConfiguration(org.eclipse.xtext.testing.RangeFormattingConfiguration) Position(org.eclipse.lsp4j.Position) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Range(org.eclipse.lsp4j.Range) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest) Test(org.junit.Test)

Example 37 with Position

use of org.eclipse.lsp4j.Position in project xtext-core by eclipse.

the class FormattingTest method testRangeFormattingService_02.

@Test
public void testRangeFormattingService_02() {
    final Procedure1<DocumentRangeFormattingParams> _function = (DocumentRangeFormattingParams it) -> {
        FormattingOptions _formattingOptions = new FormattingOptions(4, true);
        it.setOptions(_formattingOptions);
    };
    final Procedure1<RangeFormattingConfiguration> _function_1 = (RangeFormattingConfiguration it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type Foo{int bar} type Bar{Foo foo}");
        it.setModel(_builder.toString());
        Range _range = new Range();
        final Procedure1<Range> _function_2 = (Range it_1) -> {
            Position _position = new Position(0, 0);
            it_1.setStart(_position);
            Position _position_1 = new Position(0, 17);
            it_1.setEnd(_position_1);
        };
        Range _doubleArrow = ObjectExtensions.<Range>operator_doubleArrow(_range, _function_2);
        it.setRange(_doubleArrow);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("type Foo{");
        _builder_1.newLine();
        _builder_1.append("    ");
        _builder_1.append("int bar");
        _builder_1.newLine();
        _builder_1.append("} type Bar{Foo foo}");
        it.setExpectedText(_builder_1.toString());
    };
    this.testRangeFormatting(_function, _function_1);
}
Also used : FormattingOptions(org.eclipse.lsp4j.FormattingOptions) RangeFormattingConfiguration(org.eclipse.xtext.testing.RangeFormattingConfiguration) Position(org.eclipse.lsp4j.Position) DocumentRangeFormattingParams(org.eclipse.lsp4j.DocumentRangeFormattingParams) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Range(org.eclipse.lsp4j.Range) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest) Test(org.junit.Test)

Aggregations

Position (org.eclipse.lsp4j.Position)37 Range (org.eclipse.lsp4j.Range)18 Test (org.junit.Test)10 List (java.util.List)9 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)9 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)7 CompletionList (org.eclipse.lsp4j.CompletionList)6 TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)6 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)6 Extension (org.eclipse.xtext.xbase.lib.Extension)6 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)5 CompletionItem (org.eclipse.lsp4j.CompletionItem)4 Diagnostic (org.eclipse.lsp4j.Diagnostic)4 Location (org.eclipse.lsp4j.Location)4 TextEdit (org.eclipse.lsp4j.TextEdit)4 XtextResource (org.eclipse.xtext.resource.XtextResource)4 StringReader (java.io.StringReader)3 WorkspaceEdit (org.eclipse.lsp4j.WorkspaceEdit)3 Path (java.nio.file.Path)2 ISourceLocation (org.apache.flex.compiler.common.ISourceLocation)2