|
|
@ -715,7 +715,10 @@ export class QuickInfoAdapter extends Adapter implements languages.HoverProvider
|
|
|
|
|
|
|
|
|
|
|
|
// --- occurrences ------
|
|
|
|
// --- occurrences ------
|
|
|
|
|
|
|
|
|
|
|
|
export class OccurrencesAdapter extends Adapter implements languages.DocumentHighlightProvider {
|
|
|
|
export class DocumentHighlightAdapter
|
|
|
|
|
|
|
|
extends Adapter
|
|
|
|
|
|
|
|
implements languages.DocumentHighlightProvider
|
|
|
|
|
|
|
|
{
|
|
|
|
public async provideDocumentHighlights(
|
|
|
|
public async provideDocumentHighlights(
|
|
|
|
model: editor.ITextModel,
|
|
|
|
model: editor.ITextModel,
|
|
|
|
position: Position,
|
|
|
|
position: Position,
|
|
|
@ -729,20 +732,25 @@ export class OccurrencesAdapter extends Adapter implements languages.DocumentHig
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const entries = await worker.getOccurrencesAtPosition(resource.toString(), offset);
|
|
|
|
const entries = await worker.getDocumentHighlights(resource.toString(), offset, [
|
|
|
|
|
|
|
|
resource.toString()
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
if (!entries || model.isDisposed()) {
|
|
|
|
if (!entries || model.isDisposed()) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return entries.map((entry) => {
|
|
|
|
return entries.flatMap((entry) => {
|
|
|
|
|
|
|
|
return entry.highlightSpans.map((highlightSpans) => {
|
|
|
|
return <languages.DocumentHighlight>{
|
|
|
|
return <languages.DocumentHighlight>{
|
|
|
|
range: this._textSpanToRange(model, entry.textSpan),
|
|
|
|
range: this._textSpanToRange(model, highlightSpans.textSpan),
|
|
|
|
kind: entry.isWriteAccess
|
|
|
|
kind:
|
|
|
|
|
|
|
|
highlightSpans.kind === 'writtenReference'
|
|
|
|
? languages.DocumentHighlightKind.Write
|
|
|
|
? languages.DocumentHighlightKind.Write
|
|
|
|
: languages.DocumentHighlightKind.Text
|
|
|
|
: languages.DocumentHighlightKind.Text
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -865,39 +873,31 @@ export class OutlineAdapter extends Adapter implements languages.DocumentSymbolP
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const items = await worker.getNavigationBarItems(resource.toString());
|
|
|
|
const root = await worker.getNavigationTree(resource.toString());
|
|
|
|
|
|
|
|
|
|
|
|
if (!items || model.isDisposed()) {
|
|
|
|
if (!root || model.isDisposed()) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const convert = (
|
|
|
|
const convert = (
|
|
|
|
bucket: languages.DocumentSymbol[],
|
|
|
|
item: ts.NavigationTree,
|
|
|
|
item: ts.NavigationBarItem,
|
|
|
|
|
|
|
|
containerLabel?: string
|
|
|
|
containerLabel?: string
|
|
|
|
): void => {
|
|
|
|
): languages.DocumentSymbol => {
|
|
|
|
let result: languages.DocumentSymbol = {
|
|
|
|
const result: languages.DocumentSymbol = {
|
|
|
|
name: item.text,
|
|
|
|
name: item.text,
|
|
|
|
detail: '',
|
|
|
|
detail: '',
|
|
|
|
kind: <languages.SymbolKind>(outlineTypeTable[item.kind] || languages.SymbolKind.Variable),
|
|
|
|
kind: <languages.SymbolKind>(outlineTypeTable[item.kind] || languages.SymbolKind.Variable),
|
|
|
|
range: this._textSpanToRange(model, item.spans[0]),
|
|
|
|
range: this._textSpanToRange(model, item.spans[0]),
|
|
|
|
selectionRange: this._textSpanToRange(model, item.spans[0]),
|
|
|
|
selectionRange: this._textSpanToRange(model, item.spans[0]),
|
|
|
|
tags: []
|
|
|
|
tags: [],
|
|
|
|
|
|
|
|
children: item.childItems?.map((child) => convert(child, result.name)),
|
|
|
|
|
|
|
|
containerName: containerLabel
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
return result;
|
|
|
|
if (containerLabel) result.containerName = containerLabel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item.childItems && item.childItems.length > 0) {
|
|
|
|
|
|
|
|
for (let child of item.childItems) {
|
|
|
|
|
|
|
|
convert(bucket, child, result.name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bucket.push(result);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let result: languages.DocumentSymbol[] = [];
|
|
|
|
// Exclude the root node, as it alwas spans the entire document.
|
|
|
|
items.forEach((item) => convert(result, item));
|
|
|
|
const result = root.childItems ? root.childItems.map((item) => convert(item)) : [];
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|