|
|
|
@ -1221,3 +1221,49 @@ export class RenameAdapter extends Adapter implements languages.RenameProvider {
|
|
|
|
|
return { edits };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- inlay hints ----
|
|
|
|
|
|
|
|
|
|
export class InlayHintsAdapter extends Adapter implements languages.InlayHintsProvider {
|
|
|
|
|
public async provideInlayHints(
|
|
|
|
|
model: editor.ITextModel,
|
|
|
|
|
range: Range,
|
|
|
|
|
token: CancellationToken
|
|
|
|
|
): Promise<languages.InlayHint[]> {
|
|
|
|
|
const resource = model.uri;
|
|
|
|
|
const fileName = resource.toString();
|
|
|
|
|
const start = model.getOffsetAt({
|
|
|
|
|
lineNumber: range.startLineNumber,
|
|
|
|
|
column: range.startColumn
|
|
|
|
|
});
|
|
|
|
|
const end = model.getOffsetAt({
|
|
|
|
|
lineNumber: range.endLineNumber,
|
|
|
|
|
column: range.endColumn
|
|
|
|
|
});
|
|
|
|
|
const worker = await this._worker(resource);
|
|
|
|
|
if (model.isDisposed()) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hints = await worker.provideInlayHints(fileName, start, end);
|
|
|
|
|
|
|
|
|
|
return hints.map(hint => {
|
|
|
|
|
return {
|
|
|
|
|
...hint,
|
|
|
|
|
position: model.getPositionAt(hint.position),
|
|
|
|
|
kind: this._convertHintKind(hint.kind)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private _convertHintKind (kind?: ts.InlayHintKind) {
|
|
|
|
|
switch (kind) {
|
|
|
|
|
case "Parameter":
|
|
|
|
|
return languages.InlayHintKind.Parameter;
|
|
|
|
|
case "Type":
|
|
|
|
|
return languages.InlayHintKind.Type;
|
|
|
|
|
default:
|
|
|
|
|
return languages.InlayHintKind.Other;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|