提交 f9dac592 编写于 作者: J Johannes Rieken

add warning/'missing name'-message when symbol has no name, fixes #65545

上级 3cd48529
......@@ -29,7 +29,7 @@ import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
// --- adapter
class OutlineAdapter {
class DocumentSymbolAdapter {
private _documents: ExtHostDocuments;
private _provider: vscode.DocumentSymbolProvider;
......@@ -44,16 +44,15 @@ class OutlineAdapter {
return asPromise(() => this._provider.provideDocumentSymbols(doc, token)).then(value => {
if (isFalsyOrEmpty(value)) {
return undefined;
}
if (value[0] instanceof DocumentSymbol) {
} else if (value[0] instanceof DocumentSymbol) {
return (<DocumentSymbol[]>value).map(typeConvert.DocumentSymbol.from);
} else {
return OutlineAdapter._asDocumentSymbolTree(resource, <SymbolInformation[]>value);
return DocumentSymbolAdapter._asDocumentSymbolTree(<SymbolInformation[]>value);
}
});
}
private static _asDocumentSymbolTree(resource: URI, infos: SymbolInformation[]): modes.DocumentSymbol[] {
private static _asDocumentSymbolTree(infos: SymbolInformation[]): modes.DocumentSymbol[] {
// first sort by start (and end) and then loop over all elements
// and build a tree based on containment.
infos = infos.slice(0).sort((a, b) => {
......@@ -67,7 +66,7 @@ class OutlineAdapter {
let parentStack: modes.DocumentSymbol[] = [];
for (const info of infos) {
let element = <modes.DocumentSymbol>{
name: info.name,
name: info.name || '!!MISSING: name!!',
kind: typeConvert.SymbolKind.from(info.kind),
containerName: info.containerName,
range: typeConvert.Range.from(info.location.range),
......@@ -96,7 +95,7 @@ class OutlineAdapter {
class CodeLensAdapter {
private static _badCmd: vscode.Command = { command: 'missing', title: '<<MISSING COMMAND>>' };
private static _badCmd: vscode.Command = { command: 'missing', title: '!!MISSING: command!!' };
constructor(
private readonly _documents: ExtHostDocuments,
......@@ -875,7 +874,7 @@ class SelectionRangeAdapter {
}
}
type Adapter = OutlineAdapter | CodeLensAdapter | DefinitionAdapter | HoverAdapter
type Adapter = DocumentSymbolAdapter | CodeLensAdapter | DefinitionAdapter | HoverAdapter
| DocumentHighlightAdapter | ReferenceAdapter | CodeActionAdapter | DocumentFormattingAdapter
| RangeFormattingAdapter | OnTypeFormattingAdapter | NavigateTypeAdapter | RenameAdapter
| SuggestAdapter | SignatureHelpAdapter | LinkProviderAdapter | ImplementationAdapter | TypeDefinitionAdapter
......@@ -1002,14 +1001,14 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
// --- outline
registerDocumentSymbolProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.DocumentSymbolProvider, metadata?: vscode.DocumentSymbolProviderMetadata): vscode.Disposable {
const handle = this._addNewAdapter(new OutlineAdapter(this._documents, provider), extension);
const handle = this._addNewAdapter(new DocumentSymbolAdapter(this._documents, provider), extension);
const displayName = (metadata && metadata.label) || (extension && (extension.displayName || extension.name)) || undefined;
this._proxy.$registerOutlineSupport(handle, this._transformDocumentSelector(selector), displayName);
return this._createDisposable(handle);
}
$provideDocumentSymbols(handle: number, resource: UriComponents, token: CancellationToken): Promise<modes.DocumentSymbol[]> {
return this._withAdapter(handle, OutlineAdapter, adapter => adapter.provideDocumentSymbols(URI.revive(resource), token));
return this._withAdapter(handle, DocumentSymbolAdapter, adapter => adapter.provideDocumentSymbols(URI.revive(resource), token));
}
// --- code lens
......
......@@ -543,7 +543,7 @@ export namespace WorkspaceSymbol {
export namespace DocumentSymbol {
export function from(info: vscode.DocumentSymbol): modes.DocumentSymbol {
const result: modes.DocumentSymbol = {
name: info.name,
name: info.name || '!!MISSING: name!!',
detail: info.detail,
range: Range.from(info.range),
selectionRange: Range.from(info.selectionRange),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册