use of org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService in project sts4 by spring-projects.
the class BootJavaCodeLensEngine method handle.
@Override
public List<? extends CodeLens> handle(CodeLensParams params) {
SimpleTextDocumentService documents = server.getTextDocumentService();
String docURI = params.getTextDocument().getUri();
if (documents.get(docURI) != null) {
TextDocument doc = documents.get(docURI).copy();
try {
List<? extends CodeLens> codeLensesResult = provideCodeLenses(doc);
if (codeLensesResult != null) {
return codeLensesResult;
}
} catch (Exception e) {
}
}
return SimpleTextDocumentService.NO_CODELENS;
}
use of org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService in project sts4 by spring-projects.
the class VscodeHoverEngineAdapter method handle.
@Override
public Hover handle(TextDocumentPositionParams params) {
// a trivial pre-resolved future.
try {
SimpleTextDocumentService documents = server.getTextDocumentService();
TextDocument doc = documents.get(params);
if (doc != null) {
int offset = doc.toOffset(params.getPosition());
Tuple2<Renderable, IRegion> hoverTuple = hoverInfoProvider.getHoverInfo(doc, offset);
if (hoverTuple != null) {
Renderable hoverInfo = hoverTuple.getT1();
IRegion region = hoverTuple.getT2();
Range range = doc.toRange(region.getOffset(), region.getLength());
String rendered = render(hoverInfo, type);
if (StringUtil.hasText(rendered)) {
Hover hover = new Hover(ImmutableList.of(Either.forLeft(rendered)), range);
return hover;
}
}
}
} catch (Exception e) {
logger.error("error computing hover", e);
}
return SimpleTextDocumentService.NO_HOVER;
}
use of org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService in project sts4 by spring-projects.
the class BootJavaDocumentHighlightEngine method handle.
@Override
public List<DocumentHighlight> handle(TextDocumentPositionParams params) {
SimpleTextDocumentService documents = server.getTextDocumentService();
String docURI = params.getTextDocument().getUri();
if (documents.get(docURI) != null) {
TextDocument doc = documents.get(docURI).copy();
try {
return provideDocumentHighlights(doc, params.getPosition());
} catch (Exception e) {
log.error("", e);
}
}
return SimpleTextDocumentService.NO_HIGHLIGHTS;
}
use of org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService in project sts4 by spring-projects.
the class BootJavaHoverProvider method handle.
@Override
public Hover handle(TextDocumentPositionParams params) {
SimpleTextDocumentService documents = server.getTextDocumentService();
if (documents.get(params) != null) {
TextDocument doc = documents.get(params).copy();
try {
int offset = doc.toOffset(params.getPosition());
Hover hoverResult = provideHover(doc, offset);
if (hoverResult != null) {
return hoverResult;
}
} catch (Exception e) {
}
}
return SimpleTextDocumentService.NO_HOVER;
}
use of org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService in project sts4 by spring-projects.
the class BootJavaReferencesHandler method handle.
@Override
public List<? extends Location> handle(ReferenceParams params) {
SimpleTextDocumentService documents = server.getTextDocumentService();
TextDocument doc = documents.get(params).copy();
if (doc != null) {
try {
int offset = doc.toOffset(params.getPosition());
List<? extends Location> referencesResult = provideReferences(doc, offset);
if (referencesResult != null) {
return referencesResult;
}
} catch (Exception e) {
}
}
return SimpleTextDocumentService.NO_REFERENCES;
}
Aggregations