本文整理汇总了Java中org.eclipse.lsp4j.DocumentHighlight类的典型用法代码示例。如果您正苦于以下问题:Java DocumentHighlight类的具体用法?Java DocumentHighlight怎么用?Java DocumentHighlight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentHighlight类属于org.eclipse.lsp4j包,在下文中一共展示了DocumentHighlight类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convertToHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
private DocumentHighlight convertToHighlight(ITypeRoot unit, OccurrenceLocation occurrence)
throws JavaModelException {
DocumentHighlight h = new DocumentHighlight();
if ((occurrence.getFlags() | IOccurrencesFinder.F_WRITE_OCCURRENCE) == IOccurrencesFinder.F_WRITE_OCCURRENCE) {
h.setKind(DocumentHighlightKind.Write);
} else if ((occurrence.getFlags()
| IOccurrencesFinder.F_READ_OCCURRENCE) == IOccurrencesFinder.F_READ_OCCURRENCE) {
h.setKind(DocumentHighlightKind.Read);
}
int[] loc = JsonRpcHelpers.toLine(unit.getBuffer(), occurrence.getOffset());
int[] endLoc = JsonRpcHelpers.toLine(unit.getBuffer(), occurrence.getOffset() + occurrence.getLength());
h.setRange(new Range(
new Position(loc[0], loc[1]),
new Position(endLoc[0],endLoc[1])
));
return h;
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:DocumentHighlightHandler.java
示例2: withNull
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Test
public void withNull() {
final List<? extends DocumentHighlight> input = this.sort(CollectionLiterals.<DocumentHighlight>newArrayList(null, this.newHighlight(DocumentHighlightKind.Text, this.newRange(1, 1, 1, 1)),
this.newHighlight(DocumentHighlightKind.Write, this.newRange(1, 1, 1, 1)), this.newHighlight(DocumentHighlightKind.Read, this.newRange(1, 1, 1, 1))));
Assert.assertEquals(1, input.get(0).getRange().getStart().getLine());
Assert.assertEquals(1, input.get(0).getRange().getStart().getCharacter());
Assert.assertEquals(1, input.get(0).getRange().getEnd().getLine());
Assert.assertEquals(1, input.get(0).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Text, input.get(0).getKind());
Assert.assertEquals(1, input.get(1).getRange().getStart().getLine());
Assert.assertEquals(1, input.get(1).getRange().getStart().getCharacter());
Assert.assertEquals(1, input.get(1).getRange().getEnd().getLine());
Assert.assertEquals(1, input.get(1).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Read, input.get(1).getKind());
Assert.assertEquals(1, input.get(2).getRange().getStart().getLine());
Assert.assertEquals(1, input.get(2).getRange().getStart().getCharacter());
Assert.assertEquals(1, input.get(2).getRange().getEnd().getLine());
Assert.assertEquals(1, input.get(2).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Write, input.get(2).getKind());
Assert.assertNull(IterableExtensions.last(input));
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:DocumentHighlightComparatorTest.java
示例3: documentHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(final TextDocumentPositionParams params) {
final Function1<CancelIndicator, List<? extends DocumentHighlight>> _function = (CancelIndicator cancelIndicator) -> {
final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
final IResourceServiceProvider serviceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
IDocumentHighlightService _get = null;
if (serviceProvider!=null) {
_get=serviceProvider.<IDocumentHighlightService>get(IDocumentHighlightService.class);
}
final IDocumentHighlightService service = _get;
if ((service == null)) {
return CollectionLiterals.<DocumentHighlight>emptyList();
}
final Function2<Document, XtextResource, List<? extends DocumentHighlight>> _function_1 = (Document doc, XtextResource resource) -> {
return service.getDocumentHighlights(doc, resource, params, cancelIndicator);
};
return this.workspaceManager.<List<? extends DocumentHighlight>>doRead(uri, _function_1);
};
return this.requestManager.<List<? extends DocumentHighlight>>runRead(_function);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:LanguageServerImpl.java
示例4: documentHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(
final TextDocumentPositionParams position) {
// TODO: this is wrong, it should be something entirely different.
// this feature is about marking the occurrences of a selected element
// like a variable, where it is used.
// so, this should actually return multiple results.
// The spec is currently broken for that.
DocumentHighlight result = som.getHighlight(position.getTextDocument().getUri(),
position.getPosition().getLine() + 1, position.getPosition().getCharacter() + 1);
ArrayList<DocumentHighlight> list = new ArrayList<>(1);
list.add(result);
return CompletableFuture.completedFuture(list);
}
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:15,代码来源:SomLanguageServer.java
示例5: computeOccurrences
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
private List<DocumentHighlight> computeOccurrences(ITypeRoot unit, int line, int column, IProgressMonitor monitor) {
if (unit != null) {
try {
int offset = JsonRpcHelpers.toOffset(unit.getBuffer(), line, column);
OccurrencesFinder finder = new OccurrencesFinder();
CompilationUnit ast = SharedASTProvider.getInstance().getAST(unit, monitor);
if (ast != null) {
String error = finder.initialize(ast, offset, 0);
if (error == null){
List<DocumentHighlight> result = new ArrayList<>();
OccurrenceLocation[] occurrences = finder.getOccurrences();
if (occurrences != null) {
for (OccurrenceLocation loc : occurrences) {
if (monitor.isCanceled()) {
return Collections.emptyList();
}
result.add(convertToHighlight(unit, loc));
}
}
return result;
}
}
} catch (JavaModelException e) {
JavaLanguageServerPlugin.logException("Problem with compute occurrences for" + unit.getElementName(), e);
}
}
return Collections.emptyList();
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:29,代码来源:DocumentHighlightHandler.java
示例6: testDocumentHighlightHandler
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Test
public void testDocumentHighlightHandler() throws Exception {
String uri = ClassFileUtil.getURI(project, "org.sample.Highlight");
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uri);
TextDocumentPositionParams params = new TextDocumentPositionParams(identifier, new Position(5, 10));
List<? extends DocumentHighlight> highlights = handler.documentHighlight(params, monitor);
assertEquals(4, highlights.size());
assertHighlight(highlights.get(0), 5, 9, 15, DocumentHighlightKind.Write);
assertHighlight(highlights.get(1), 6, 2, 8, DocumentHighlightKind.Read);
assertHighlight(highlights.get(2), 7, 2, 8, DocumentHighlightKind.Write);
assertHighlight(highlights.get(3), 8, 2, 8, DocumentHighlightKind.Read);
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:DocumentHighlightHandlerTest.java
示例7: withoutNull
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Test
public void withoutNull() {
final List<? extends DocumentHighlight> input = this.sort(CollectionLiterals.<DocumentHighlight>newArrayList(this.newHighlight(DocumentHighlightKind.Text, this.newRange(2, 2, 2, 2)), this.newHighlight(DocumentHighlightKind.Text, this.newRange(1, 1, 1, 1)),
this.newHighlight(DocumentHighlightKind.Write, this.newRange(2, 2, 2, 2)), this.newHighlight(DocumentHighlightKind.Write, this.newRange(1, 1, 1, 1)),
this.newHighlight(DocumentHighlightKind.Read, this.newRange(2, 2, 2, 2)), this.newHighlight(DocumentHighlightKind.Read, this.newRange(1, 1, 1, 1))));
Assert.assertEquals(1, input.get(0).getRange().getStart().getLine());
Assert.assertEquals(1, input.get(0).getRange().getStart().getCharacter());
Assert.assertEquals(1, input.get(0).getRange().getEnd().getLine());
Assert.assertEquals(1, input.get(0).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Text, input.get(0).getKind());
Assert.assertEquals(1, input.get(1).getRange().getStart().getLine());
Assert.assertEquals(1, input.get(1).getRange().getStart().getCharacter());
Assert.assertEquals(1, input.get(1).getRange().getEnd().getLine());
Assert.assertEquals(1, input.get(1).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Read, input.get(1).getKind());
Assert.assertEquals(1, input.get(2).getRange().getStart().getLine());
Assert.assertEquals(1, input.get(2).getRange().getStart().getCharacter());
Assert.assertEquals(1, input.get(2).getRange().getEnd().getLine());
Assert.assertEquals(1, input.get(2).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Write, input.get(2).getKind());
Assert.assertEquals(2, input.get(3).getRange().getStart().getLine());
Assert.assertEquals(2, input.get(3).getRange().getStart().getCharacter());
Assert.assertEquals(2, input.get(3).getRange().getEnd().getLine());
Assert.assertEquals(2, input.get(3).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Text, input.get(3).getKind());
Assert.assertEquals(2, input.get(4).getRange().getStart().getLine());
Assert.assertEquals(2, input.get(4).getRange().getStart().getCharacter());
Assert.assertEquals(2, input.get(4).getRange().getEnd().getLine());
Assert.assertEquals(2, input.get(4).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Read, input.get(4).getKind());
Assert.assertEquals(2, input.get(5).getRange().getStart().getLine());
Assert.assertEquals(2, input.get(5).getRange().getStart().getCharacter());
Assert.assertEquals(2, input.get(5).getRange().getEnd().getLine());
Assert.assertEquals(2, input.get(5).getRange().getEnd().getCharacter());
Assert.assertEquals(DocumentHighlightKind.Write, input.get(5).getKind());
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:37,代码来源:DocumentHighlightComparatorTest.java
示例8: _toExpectation
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
protected String _toExpectation(final DocumentHighlight it) {
String _xblockexpression = null;
{
StringConcatenation _builder = new StringConcatenation();
{
Range _range = it.getRange();
boolean _tripleEquals = (_range == null);
if (_tripleEquals) {
_builder.append("[NaN, NaN]:[NaN, NaN]");
} else {
String _expectation = this.toExpectation(it.getRange());
_builder.append(_expectation);
}
}
final String rangeString = _builder.toString();
StringConcatenation _builder_1 = new StringConcatenation();
{
DocumentHighlightKind _kind = it.getKind();
boolean _tripleEquals_1 = (_kind == null);
if (_tripleEquals_1) {
_builder_1.append("NaN");
} else {
String _expectation_1 = this.toExpectation(it.getKind());
_builder_1.append(_expectation_1);
}
}
_builder_1.append(" ");
_builder_1.append(rangeString);
_xblockexpression = _builder_1.toString();
}
return _xblockexpression;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:33,代码来源:AbstractLanguageServerTest.java
示例9: apply
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public DocumentHighlight apply(final Document document, final ITextRegion region,
final DocumentHighlightKind kind) {
Preconditions.checkNotNull(document, "document");
Preconditions.checkNotNull(region, "region");
Preconditions.checkNotNull(kind, "kind");
final int offset = region.getOffset();
final Position start = document.getPosition(offset);
final Position end = document.getPosition(offset + region.getLength());
return new DocumentHighlight(new Range(start, end), kind);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:15,代码来源:ITextRegionTransformer.java
示例10: documentHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(TextDocumentPositionParams position) {
LOGGER.info("documentHighlight: " + position.getTextDocument());
return CompletableFuture.completedFuture(Collections.emptyList());
}
开发者ID:lhein,项目名称:camel-language-server,代码行数:6,代码来源:CamelTextDocumentService.java
示例11: getHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
public DocumentHighlight getHighlight(final String documentUri,
final int line, final int character) {
// TODO: this is wrong, it should be something entierly different.
// this feature is about marking the occurrences of a selected element
// like a variable, where it is used.
// so, this should actually return multiple results.
// The spec is currently broken for that.
// XXX: the code here doesn't make any sense for what it is supposed to do
// Map<SourceSection, Set<Class<? extends Tags>>> sections = Highlight.
// getSourceSections();
// SourceSection[] all = sections.entrySet().stream().map(e -> e.getKey()).toArray(size ->
// new SourceSection[size]);
//
// Stream<Entry<SourceSection, Set<Class<? extends Tags>>>> filtered = sections.
// entrySet().stream().filter(
// (final Entry<SourceSection, Set<Class<? extends Tags>>> e) -> in(e.getKey(), line,
// character));
//
// @SuppressWarnings("rawtypes")
// Entry[] matching = filtered.toArray(size -> new Entry[size]);
//
// for (Entry<SourceSection, Set<Class<? extends Tags>>> e : matching) {
// int kind;
// if (e.getValue().contains(LiteralTag.class)) {
// kind = DocumentHighlight.KIND_READ;
// } else {
// kind = DocumentHighlight.KIND_TEXT;
// }
// DocumentHighlightImpl highlight = new DocumentHighlightImpl();
// highlight.setKind(kind);
// highlight.setRange(getRange(e.getKey()));
// return highlight;
// }
//
// DocumentHighlightImpl highlight = new DocumentHighlightImpl();
// highlight.setKind(DocumentHighlight.KIND_TEXT);
// RangeImpl range = new RangeImpl();
// range.setStart(pos(line, character));
// range.setEnd(pos(line, character + 1));
// highlight.setRange(range);
// return highlight;
return null;
}
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:46,代码来源:SomAdapter.java
示例12: documentHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
public List<? extends DocumentHighlight> documentHighlight(TextDocumentPositionParams position, IProgressMonitor monitor) {
ITypeRoot type = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri());
return computeOccurrences(type, position.getPosition().getLine(),
position.getPosition().getCharacter(), monitor);
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:6,代码来源:DocumentHighlightHandler.java
示例13: documentHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(TextDocumentPositionParams position) {
logInfo(">> document/documentHighlight");
DocumentHighlightHandler handler = new DocumentHighlightHandler();
return computeAsync((cc) -> handler.documentHighlight(position, toMonitor(cc)));
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:7,代码来源:JDTLanguageServer.java
示例14: assertHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
private void assertHighlight(DocumentHighlight highlight, int expectedLine, int expectedStart, int expectedEnd, DocumentHighlightKind expectedKind) {
Lsp4jAssertions.assertRange(expectedLine, expectedStart, expectedEnd, highlight.getRange());
assertEquals(expectedKind, highlight.getKind());
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:5,代码来源:DocumentHighlightHandlerTest.java
示例15: newHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
private DocumentHighlight newHighlight(final DocumentHighlightKind kind, final Range range) {
return new DocumentHighlight(range, kind);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:4,代码来源:DocumentHighlightComparatorTest.java
示例16: sort
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
private List<? extends DocumentHighlight> sort(final List<? extends DocumentHighlight> toSort) {
toSort.sort(this.comparator);
return toSort;
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:5,代码来源:DocumentHighlightComparatorTest.java
示例17: getDocumentHighlights
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public List<? extends DocumentHighlight> getDocumentHighlights(Document document, XtextResource resource, TextDocumentPositionParams params, CancelIndicator cancelIndicator) {
int offset = document.getOffSet(params.getPosition());
return getDocumentHighlights(resource, offset);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:6,代码来源:DefaultDocumentHighlightService.java
示例18: compare
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public int compare(final DocumentHighlight left, final DocumentHighlight right) {
return Ordering.from(delegate).nullsLast().compare(left, right);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:5,代码来源:DocumentHighlightComparator.java
示例19: documentHighlight
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(TextDocumentPositionParams position) {
throw new UnsupportedOperationException();
}
开发者ID:eclipse,项目名称:lsp4j,代码行数:5,代码来源:MockLanguageServer.java
示例20: computeOccurrences
import org.eclipse.lsp4j.DocumentHighlight; //导入依赖的package包/类
@Override
public JsPromise<OrionOccurrenceOverlay[]> computeOccurrences(
OrionOccurrenceContextOverlay context) {
final EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor == null || !(activeEditor instanceof TextEditor)) {
return null;
}
final TextEditor editor = ((TextEditor) activeEditor);
if (!(editor.getConfiguration() instanceof LanguageServerEditorConfiguration)) {
return null;
}
final LanguageServerEditorConfiguration configuration =
(LanguageServerEditorConfiguration) editor.getConfiguration();
if (configuration.getServerCapabilities().getDocumentHighlightProvider() == null
|| !configuration.getServerCapabilities().getDocumentHighlightProvider()) {
return null;
}
final Document document = editor.getDocument();
final TextDocumentPositionParams paramsDTO = helper.createTDPP(document, context.getStart());
Promise<List<DocumentHighlight>> promise = client.documentHighlight(paramsDTO);
Promise<OrionOccurrenceOverlay[]> then =
promise.then(
new Function<List<DocumentHighlight>, OrionOccurrenceOverlay[]>() {
@Override
public OrionOccurrenceOverlay[] apply(List<DocumentHighlight> highlights)
throws FunctionException {
final OrionOccurrenceOverlay[] occurrences =
new OrionOccurrenceOverlay[highlights.size()];
for (int i = 0; i < occurrences.length; i++) {
DocumentHighlight highlight = highlights.get(i);
final OrionOccurrenceOverlay occurrence = OrionOccurrenceOverlay.create();
Position start = highlight.getRange().getStart();
Position end = highlight.getRange().getEnd();
int startIndex =
document.getIndexFromPosition(
new TextPosition(start.getLine(), start.getCharacter()));
int endIndex =
document.getIndexFromPosition(
new TextPosition(end.getLine(), end.getCharacter()));
occurrence.setStart(startIndex);
occurrence.setEnd(endIndex + 1);
occurrences[i] = occurrence;
}
return occurrences;
}
});
return (JsPromise<OrionOccurrenceOverlay[]>) then;
}
开发者ID:eclipse,项目名称:che,代码行数:50,代码来源:OccurrencesProvider.java
注:本文中的org.eclipse.lsp4j.DocumentHighlight类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论