Skip to content

Commit

Permalink
add DocumentSymbol#detail, #34968
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 13, 2018
1 parent a9a9195 commit ae9063f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider
private static convertNavTree(resource: vscode.Uri, bucket: vscode.DocumentSymbol[], item: Proto.NavigationTree): boolean {
const symbolInfo = new vscode.DocumentSymbol(
item.text,
'',
getSymbolKind(item.kind),
typeConverters.Range.fromTextSpan(item.spans[0]),
typeConverters.Range.fromTextSpan(item.spans[0]),
Expand Down
1 change: 1 addition & 0 deletions src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ export const symbolKindToCssClass = (function () {

export interface DocumentSymbol {
name: string;
detail: string;
kind: SymbolKind;
containerName?: string;
fullRange: IRange;
Expand Down
1 change: 1 addition & 0 deletions src/vs/editor/contrib/quickOpen/quickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function flatten(bucket: DocumentSymbol[], entries: DocumentSymbol[], overrideCo
bucket.push({
kind: entry.kind,
name: entry.name,
detail: entry.detail,
containerName: entry.containerName || overrideContainerLabel,
fullRange: entry.fullRange,
identifierRange: entry.identifierRange,
Expand Down
1 change: 1 addition & 0 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4873,6 +4873,7 @@ declare namespace monaco.languages {

export interface DocumentSymbol {
name: string;
detail: string;
kind: SymbolKind;
containerName?: string;
fullRange: IRange;
Expand Down
8 changes: 7 additions & 1 deletion src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ declare module 'vscode' {
*/
name: string;

/**
* More detail for this symbol, e.g the signature of a function.
*/
detail: string;

/**
* The kind of this symbol.
*/
Expand All @@ -411,11 +416,12 @@ declare module 'vscode' {
* Creates a new document symbol.
*
* @param name The name of the symbol.
* @param detail Details for the symbol.
* @param kind The kind of the symbol.
* @param fullRange The full range of the symbol.
* @param gotoRange The range that should be reveal.
*/
constructor(name: string, kind: SymbolKind, fullRange: Range, gotoRange: Range);
constructor(name: string, detail: string, kind: SymbolKind, fullRange: Range, gotoRange: Range);
}

export interface DocumentSymbolProvider {
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/api/node/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ export namespace DocumentSymbol {
export function from(info: vscode.DocumentSymbol): modes.DocumentSymbol {
let result: modes.DocumentSymbol = {
name: info.name,
detail: info.detail,
fullRange: Range.from(info.fullRange),
identifierRange: Range.from(info.gotoRange),
kind: SymbolKind.from(info.kind)
Expand All @@ -391,6 +392,7 @@ export namespace DocumentSymbol {
export function to(info: modes.DocumentSymbol): vscode.DocumentSymbol {
let result = new types.DocumentSymbol(
info.name,
info.detail,
SymbolKind.to(info.kind),
Range.to(info.fullRange),
Range.to(info.identifierRange),
Expand Down
8 changes: 7 additions & 1 deletion src/vs/workbench/api/node/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,17 +883,23 @@ export class SymbolInformation {

export class DocumentSymbol {
name: string;
detail: string;
kind: SymbolKind;
fullRange: Range;
gotoRange: Range;
children: DocumentSymbol[];

constructor(name: string, kind: SymbolKind, fullRange: Range, gotoRange: Range) {
constructor(name: string, detail: string, kind: SymbolKind, fullRange: Range, gotoRange: Range) {
this.name = name;
this.detail = detail;
this.kind = kind;
this.fullRange = fullRange;
this.gotoRange = gotoRange;
this.children = [];

if (!this.fullRange.contains(this.gotoRange)) {
throw new Error('gotoRange must be contained in fullRange');
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ suite('OutlineModel', function () {
function fakeSymbolInformation(range: Range, name: string = 'foo'): DocumentSymbol {
return {
name,
detail: 'fake',
kind: SymbolKind.Boolean,
identifierRange: range,
fullRange: range
Expand Down

0 comments on commit ae9063f

Please sign in to comment.