Search in sources :

Example 31 with Position

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

the class RenameTest method testRenameOnDeclaration.

@Test
public void testRenameOnDeclaration() {
    Position _position = new Position(0, 5);
    this.doTest(this.firstFile, _position);
}
Also used : Position(org.eclipse.lsp4j.Position) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 32 with Position

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

the class RenameTest method testRenameOnReference.

@Test
public void testRenameOnReference() {
    Position _position = new Position(1, 5);
    this.doTest(this.firstFile, _position);
}
Also used : Position(org.eclipse.lsp4j.Position) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 33 with Position

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

the class RenameTest method testRenameOnReferenceInOtherFile.

@Test
public void testRenameOnReferenceInOtherFile() {
    Position _position = new Position(1, 5);
    this.doTest(this.secondFile, _position);
}
Also used : Position(org.eclipse.lsp4j.Position) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 34 with Position

use of org.eclipse.lsp4j.Position 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 35 with Position

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

the class DocumentHighlightComparatorTest method newRange.

private Range newRange(final int startLine, final int startChar, final int endLine, final int endChar) {
    Position _position = new Position(startLine, startChar);
    Position _position_1 = new Position(endLine, endChar);
    return new Range(_position, _position_1);
}
Also used : Position(org.eclipse.lsp4j.Position) Range(org.eclipse.lsp4j.Range)

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