use of org.eclipse.lsp4j.TextDocumentIdentifier in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method isInXMLComment.
private boolean isInXMLComment(TextDocumentPositionParams params) {
TextDocumentIdentifier textDocument = params.getTextDocument();
Path path = LanguageServerUtils.getPathFromLanguageServerURI(textDocument.getUri());
if (path == null || !sourceByPath.containsKey(path)) {
return false;
}
String code = sourceByPath.get(path);
int startComment = code.lastIndexOf("<!--", currentOffset - 1);
if (startComment == -1) {
return false;
}
int endComment = code.indexOf("-->", startComment);
return endComment > currentOffset;
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project sonarlint-core by SonarSource.
the class ServerMainTest method cleanDiagnosticsOnClose.
@Test
public void cleanDiagnosticsOnClose() throws Exception {
String uri = getUri("foo.js");
lsProxy.getTextDocumentService().didClose(new DidCloseTextDocumentParams(new TextDocumentIdentifier(uri)));
assertThat(waitForDiagnostics(uri)).isEmpty();
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project erlide_eclipse by erlang.
the class LanguageServerEclipseUtils method toTextDocumentPosistionParams.
public static TextDocumentPositionParams toTextDocumentPosistionParams(final URI fileUri, final int offset, final IDocument document) throws BadLocationException {
final Position start = LanguageServerEclipseUtils.toPosition(offset, document);
final TextDocumentPositionParams param = new TextDocumentPositionParams();
param.setPosition(start);
final TextDocumentIdentifier id = new TextDocumentIdentifier(fileUri.toString());
param.setTextDocument(id);
return param;
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class AbstractQuickFixTest method evaluateCodeActions.
protected List<Command> evaluateCodeActions(ICompilationUnit cu) throws JavaModelException {
CompilationUnit astRoot = CoreASTProvider.getInstance().getAST(cu, CoreASTProvider.WAIT_YES, null);
IProblem[] problems = astRoot.getProblems();
Range range = getRange(cu, problems);
CodeActionParams parms = new CodeActionParams();
TextDocumentIdentifier textDocument = new TextDocumentIdentifier();
textDocument.setUri(JDTUtils.toURI(cu));
parms.setTextDocument(textDocument);
parms.setRange(range);
CodeActionContext context = new CodeActionContext();
context.setDiagnostics(DiagnosticsHandler.toDiagnosticsArray(cu, Arrays.asList(problems)));
parms.setContext(context);
List<Command> commands = new CodeActionHandler().getCodeActionCommands(parms, new NullProgressMonitor());
if (this.ignoredCommands != null) {
List<Command> filteredList = new ArrayList<>();
for (Command command : commands) {
for (String str : this.ignoredCommands) {
if (command.getTitle().matches(str)) {
filteredList.add(command);
break;
}
}
}
commands.removeAll(filteredList);
}
return commands;
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class CodeActionHandlerTest method testCodeAction_removeUnterminatedString.
@Test
public void testCodeAction_removeUnterminatedString() throws Exception {
ICompilationUnit unit = getWorkingCopy("src/java/Foo.java", "public class Foo {\n" + " void foo() {\n" + "String s = \"some str\n" + " }\n" + "}\n");
CodeActionParams params = new CodeActionParams();
params.setTextDocument(new TextDocumentIdentifier(JDTUtils.toURI(unit)));
final Range range = getRange(unit, "some str");
params.setRange(range);
params.setContext(new CodeActionContext(Arrays.asList(getDiagnostic(Integer.toString(IProblem.UnterminatedString), range))));
List<? extends Command> commands = server.codeAction(params).join();
Assert.assertNotNull(commands);
Assert.assertEquals(1, commands.size());
Command c = commands.get(0);
Assert.assertEquals(CodeActionHandler.COMMAND_ID_APPLY_EDIT, c.getCommand());
}
Aggregations