提交 043a0654 编写于 作者: J Johannes Rieken

add SymbolInformation.tags, render deprecated items in quick outline and workspace symbol search

上级 87c7042e
......@@ -20,11 +20,6 @@
color: var(--outline-element-color);
}
.monaco-list .outline-element .deprecated {
text-decoration: line-through;
opacity: 0.66;
}
.monaco-tree .monaco-tree-row.focused .outline-element .outline-element-detail {
visibility: inherit;
}
......
......@@ -3,6 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.monaco-workbench .monaco-icon-label.deprecated {
text-decoration: line-through;
opacity: 0.66;
}
.monaco-workbench .symbol-icon.inline {
background-position: left center;
padding-left: 20px;
......
......@@ -51,7 +51,7 @@ function flatten(bucket: DocumentSymbol[], entries: DocumentSymbol[], overrideCo
for (let entry of entries) {
bucket.push({
kind: entry.kind,
tags: [],
tags: entry.tags,
name: entry.name,
detail: entry.detail,
containerName: entry.containerName || overrideContainerLabel,
......
......@@ -1144,6 +1144,13 @@ declare module 'vscode' {
Deprecated = 1
}
export interface SymbolInformation {
/**
*
*/
tags?: ReadonlyArray<SymbolTag>;
}
export interface DocumentSymbol {
/**
*
......
......@@ -70,8 +70,8 @@ class DocumentSymbolAdapter {
const element = <modes.DocumentSymbol>{
name: info.name || '!!MISSING: name!!',
kind: typeConvert.SymbolKind.from(info.kind),
tags: [],
detail: undefined!, // Strict null override — avoid changing behavior
tags: info.tags && info.tags.map(typeConvert.SymbolTag.from),
detail: '',
containerName: info.containerName,
range: typeConvert.Range.from(info.location.range),
selectionRange: typeConvert.Range.from(info.location.range),
......
......@@ -576,17 +576,20 @@ export namespace WorkspaceSymbol {
return <search.IWorkspaceSymbol>{
name: info.name,
kind: SymbolKind.from(info.kind),
tags: info.tags && info.tags.map(SymbolTag.from),
containerName: info.containerName,
location: location.from(info.location)
};
}
export function to(info: search.IWorkspaceSymbol): types.SymbolInformation {
return new types.SymbolInformation(
const result = new types.SymbolInformation(
info.name,
SymbolKind.to(info.kind),
info.containerName,
location.to(info.location)
);
result.tags = info.tags && info.tags.map(SymbolTag.to);
return result;
}
}
......
......@@ -995,6 +995,7 @@ export class SymbolInformation {
name: string;
location!: Location;
kind: SymbolKind;
tags?: SymbolTag[];
containerName: string | undefined;
constructor(name: string, kind: SymbolKind, containerName: string | undefined, location: Location);
......
......@@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
import * as types from 'vs/base/common/types';
import * as strings from 'vs/base/common/strings';
import { IEntryRunContext, Mode, IAutoFocus } from 'vs/base/parts/quickopen/common/quickOpen';
import { QuickOpenModel, IHighlight } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { QuickOpenHandler, EditorQuickOpenEntryGroup, QuickOpenAction } from 'vs/workbench/browser/quickopen';
import * as filters from 'vs/base/common/filters';
import { IEditor, IDiffEditorModel, IEditorViewState, ScrollType } from 'vs/editor/common/editorCommon';
......@@ -16,15 +16,15 @@ import { IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDeltaDecorati
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/quickOpen';
import { DocumentSymbolProviderRegistry, DocumentSymbol, symbolKindToCssClass, SymbolKind } from 'vs/editor/common/modes';
import { DocumentSymbolProviderRegistry, DocumentSymbol, symbolKindToCssClass, SymbolKind, SymbolTag } from 'vs/editor/common/modes';
import { IRange } from 'vs/editor/common/core/range';
import { themeColorFromId } from 'vs/platform/theme/common/themeService';
import { overviewRulerRangeHighlight } from 'vs/editor/common/view/editorColorRegistry';
import { GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor';
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { asPromise } from 'vs/base/common/async';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
import { IIconLabelValueOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
export const GOTO_SYMBOL_PREFIX = '@';
export const SCOPE_PREFIX = ':';
......@@ -235,29 +235,20 @@ class OutlineModel extends QuickOpenModel {
}
class SymbolEntry extends EditorQuickOpenEntryGroup {
private editorService: IEditorService;
private index: number;
private name: string;
private kind: SymbolKind;
private icon: string;
private description: string;
private range: IRange;
private revealRange: IRange;
private handler: GotoSymbolHandler;
constructor(index: number, name: string, kind: SymbolKind, description: string, icon: string, range: IRange, revealRange: IRange, highlights: IHighlight[], editorService: IEditorService, handler: GotoSymbolHandler) {
super();
this.index = index;
this.name = name;
this.kind = kind;
this.icon = icon;
this.description = description;
this.range = range;
this.revealRange = revealRange || range;
this.setHighlights(highlights);
this.editorService = editorService;
this.handler = handler;
constructor(
private index: number,
private name: string,
private kind: SymbolKind,
private description: string,
private icon: string,
private deprecated: boolean,
private range: IRange,
private revealRange: IRange,
private editorService: IEditorService,
private handler: GotoSymbolHandler
) {
super();
}
getIndex(): number {
......@@ -276,6 +267,10 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
return this.icon;
}
getLabelOptions(): IIconLabelValueOptions | undefined {
return this.deprecated ? { extraClasses: ['deprecated'] } : undefined;
}
getDescription(): string {
return this.description;
}
......@@ -479,8 +474,8 @@ export class GotoSymbolHandler extends QuickOpenHandler {
// Add
results.push(new SymbolEntry(i,
label, element.kind, description, `symbol-icon ${icon}`,
element.range, element.selectionRange, [], this.editorService, this
label, element.kind, description, `symbol-icon ${icon}`, element.tags && element.tags.indexOf(SymbolTag.Deprecated) >= 0,
element.range, element.selectionRange, this.editorService, this
));
}
......@@ -504,7 +499,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
}
if (model && types.isFunction((<ITextModel>model).getLanguageIdentifier)) {
const entries = await asPromise(() => getDocumentSymbols(<ITextModel>model, true, this.pendingOutlineRequest!.token));
const entries = await getDocumentSymbols(<ITextModel>model, true, this.pendingOutlineRequest!.token);
return new OutlineModel(this.toQuickOpenEntries(entries));
}
......
......@@ -14,7 +14,7 @@ import * as filters from 'vs/base/common/filters';
import * as strings from 'vs/base/common/strings';
import { Range } from 'vs/editor/common/core/range';
import { IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { symbolKindToCssClass } from 'vs/editor/common/modes';
import { symbolKindToCssClass, SymbolTag } from 'vs/editor/common/modes';
import { IResourceInput } from 'vs/platform/editor/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
......@@ -25,6 +25,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Schemas } from 'vs/base/common/network';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IIconLabelValueOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
class SymbolEntry extends EditorQuickOpenEntry {
private bearingResolve: Promise<this | undefined> | undefined;
......@@ -65,6 +66,12 @@ class SymbolEntry extends EditorQuickOpenEntry {
return symbolKindToCssClass(this.bearing.kind);
}
getLabelOptions(): IIconLabelValueOptions | undefined {
return this.bearing.tags && this.bearing.tags.indexOf(SymbolTag.Deprecated) >= 0
? { extraClasses: ['deprecated'] }
: undefined;
}
getResource(): URI {
return this.bearing.location.uri;
}
......
......@@ -6,7 +6,7 @@
import { onUnexpectedError } from 'vs/base/common/errors';
import { IDisposable } from 'vs/base/common/lifecycle';
import { ISearchConfiguration, ISearchConfigurationProperties } from 'vs/workbench/services/search/common/search';
import { SymbolKind, Location, ProviderResult } from 'vs/editor/common/modes';
import { SymbolKind, Location, ProviderResult, SymbolTag } from 'vs/editor/common/modes';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { URI } from 'vs/base/common/uri';
import { toResource, SideBySideEditor } from 'vs/workbench/common/editor';
......@@ -19,6 +19,7 @@ export interface IWorkspaceSymbol {
name: string;
containerName?: string;
kind: SymbolKind;
tags?: SymbolTag[];
location: Location;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册