Java Code Examples for org.eclipse.lsp4j.Range#setEnd()
The following examples show how to use
org.eclipse.lsp4j.Range#setEnd() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeActionHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testCodeAction_exception() throws JavaModelException { URI uri = project.getFile("nopackage/Test.java").getRawLocationURI(); ICompilationUnit cu = JDTUtils.resolveCompilationUnit(uri); try { cu.becomeWorkingCopy(new NullProgressMonitor()); CodeActionParams params = new CodeActionParams(); params.setTextDocument(new TextDocumentIdentifier(uri.toString())); final Range range = new Range(); range.setStart(new Position(0, 17)); range.setEnd(new Position(0, 17)); params.setRange(range); CodeActionContext context = new CodeActionContext(); context.setDiagnostics(Collections.emptyList()); params.setContext(context); List<Either<Command, CodeAction>> codeActions = getCodeActions(params); Assert.assertNotNull(codeActions); } finally { cu.discardWorkingCopy(); } }
Example 2
Source File: DocumentTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private TextDocumentContentChangeEvent change(final Position startPos, final Position endPos, final String newText) { TextDocumentContentChangeEvent _textDocumentContentChangeEvent = new TextDocumentContentChangeEvent(); final Procedure1<TextDocumentContentChangeEvent> _function = (TextDocumentContentChangeEvent it) -> { if ((startPos != null)) { Range _range = new Range(); final Procedure1<Range> _function_1 = (Range it_1) -> { it_1.setStart(startPos); it_1.setEnd(endPos); }; Range _doubleArrow = ObjectExtensions.<Range>operator_doubleArrow(_range, _function_1); it.setRange(_doubleArrow); } it.setText(newText); }; return ObjectExtensions.<TextDocumentContentChangeEvent>operator_doubleArrow(_textDocumentContentChangeEvent, _function); }
Example 3
Source File: DocumentTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private TextEdit textEdit(final Position startPos, final Position endPos, final String newText) { TextEdit _textEdit = new TextEdit(); final Procedure1<TextEdit> _function = (TextEdit it) -> { if ((startPos != null)) { Range _range = new Range(); final Procedure1<Range> _function_1 = (Range it_1) -> { it_1.setStart(startPos); it_1.setEnd(endPos); }; Range _doubleArrow = ObjectExtensions.<Range>operator_doubleArrow(_range, _function_1); it.setRange(_doubleArrow); } it.setNewText(newText); }; return ObjectExtensions.<TextEdit>operator_doubleArrow(_textEdit, _function); }
Example 4
Source File: FormattingTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 5
Source File: AbstractCodeActionTest.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected void performTest(Project project, String moduleName, N4JSTestCodeActionConfiguration tcac) throws InterruptedException, ExecutionException { CodeActionParams codeActionParams = new CodeActionParams(); Range range = new Range(); Position posStart = new Position(tcac.getLine(), tcac.getColumn()); Position posEnd = tcac.getEndLine() >= 0 && tcac.getEndColumn() >= 0 ? new Position(tcac.getEndLine(), tcac.getEndColumn()) : posStart; range.setStart(posStart); range.setEnd(posEnd); codeActionParams.setRange(range); CodeActionContext context = new CodeActionContext(); FileURI uri = getFileURIFromModuleName(moduleName); context.setDiagnostics(Lists.newArrayList(getIssues(uri))); codeActionParams.setContext(context); TextDocumentIdentifier textDocument = new TextDocumentIdentifier(); textDocument.setUri(uri.toString()); codeActionParams.setTextDocument(textDocument); CompletableFuture<List<Either<Command, CodeAction>>> future = languageServer.codeAction(codeActionParams); List<Either<Command, CodeAction>> result = future.get(); if (tcac.getAssertCodeActions() != null) { tcac.getAssertCodeActions().apply(result); } else { String resultStr = result.stream() .map(cmdOrAction -> getStringLSP4J().toString3(cmdOrAction)) .collect(Collectors.joining("\n-----\n")); assertEquals(tcac.getExpectedCodeActions().trim(), resultStr.trim()); } }
Example 6
Source File: LSPUtils.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
public static Diagnostic createDiagnosticWithoutRange() { Diagnostic diagnostic = new Diagnostic(); Range range = new Range(); range.setStart(new Position()); range.setEnd(new Position()); diagnostic.setRange(range); return diagnostic; }
Example 7
Source File: LanguageServerCompilerUtils.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
/** * Converts a compiler source location to a language server range. May * return null if the line or column of the source location is -1. */ public static Range getRangeFromSourceLocation(ISourceLocation sourceLocation) { int line = sourceLocation.getLine(); int column = sourceLocation.getColumn(); if (line == -1 || column == -1) { //this is probably generated by the compiler somehow return null; } Position start = new Position(); start.setLine(line); start.setCharacter(column); int endLine = sourceLocation.getEndLine(); int endColumn = sourceLocation.getEndColumn(); if (endLine == -1 || endColumn == -1) { endLine = line; endColumn = column; } Position end = new Position(); end.setLine(endLine); end.setCharacter(endColumn); Range range = new Range(); range.setStart(start); range.setEnd(end); return range; }
Example 8
Source File: DefinitionTextUtils.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
public Range toRange() { Position start = new Position(); start.setLine(startLine); start.setCharacter(startColumn); Position end = new Position(); end.setLine(endLine); end.setCharacter(endColumn); Range range = new Range(); range.setStart(start); range.setEnd(end); return range; }