本文整理汇总了TypeScript中vscode-languageserver.TextDocuments.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextDocuments.get方法的具体用法?TypeScript TextDocuments.get怎么用?TypeScript TextDocuments.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode-languageserver.TextDocuments
的用法示例。
在下文中一共展示了TextDocuments.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
connection.onReferences(referenceParams => {
let document = documents.get(referenceParams.textDocument.uri);
let mode = languageModes.getModeAtPosition(document, referenceParams.position);
if (mode && mode.findReferences) {
return mode.findReferences(document, referenceParams.position);
}
return [];
});
示例2: format
connection.onDocumentRangeFormatting(formatParams => {
let document = documents.get(formatParams.textDocument.uri);
let unformattedTags: string = settings && settings.html && settings.html.format && settings.html.format.unformatted || '';
let enabledModes = { css: !unformattedTags.match(/\bstyle\b/), javascript: !unformattedTags.match(/\bscript\b/) };
return format(languageModes, document, formatParams.range, formatParams.options, enabledModes);
});
示例3:
connection.onCompletionResolve(item => {
const data = item.data;
if (data && data.languageId && data.uri) {
const document = documents.get(data.uri);
return vls.doResolve(document, data.languageId, item);
}
return item;
});
示例4:
connection.onDocumentRangeFormatting(formatParams => {
let document = documents.get(formatParams.textDocument.uri);
let startMode = languageModes.getModeAtPosition(document, formatParams.range.start);
let endMode = languageModes.getModeAtPosition(document, formatParams.range.end);
if (startMode && startMode === endMode && startMode.format) {
return startMode.format(document, formatParams.range, formatParams.options);
}
return null;
});
示例5:
connection.onCompletion((textDocumentPositionParams: TextDocumentPositionParams): CompletionItem[] => {
let document = documents.get(textDocumentPositionParams.textDocument.uri)
let lang = document.languageId || 'javascript'
let offset = document.offsetAt(textDocumentPositionParams.position)
return {
'xquery-ml': completeXQuery,
'javascript': completeSJS
}[lang](document, offset)
})
示例6:
connection.onRequest(ColorPresentationRequest.type, params => {
let document = documents.get(params.textDocument.uri);
if (document) {
let mode = languageModes.getModeAtPosition(document, params.colorInfo.range.start);
if (mode && mode.getColorPresentations) {
return mode.getColorPresentations(document, params.colorInfo);
}
}
return [];
});
示例7:
connection.onDocumentSymbol(documentSymbolParms => {
let document = documents.get(documentSymbolParms.textDocument.uri);
let symbols: SymbolInformation[] = [];
languageModes.getAllModesInDocument(document).forEach(m => {
if (m.findDocumentSymbols) {
pushAll(symbols, m.findDocumentSymbols(document));
}
});
return symbols;
});