Skip to content

Commit

Permalink
experiment with internal hierarchical model, #34968
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed May 4, 2018
1 parent 66b2786 commit 6b4f889
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 73 deletions.
10 changes: 10 additions & 0 deletions src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,10 @@ export interface SymbolInformation {
* The name of this symbol.
*/
name: string;
/**
* The detail of this symbol.
*/
detail?: string;
/**
* The name of the symbol containing this symbol.
*/
Expand All @@ -659,6 +663,12 @@ export interface SymbolInformation {
* The location of this symbol.
*/
location: Location;
/**
* The defining range of this symbol.
*/
definingRange: IRange;

children?: SymbolInformation[];
}
/**
* The document symbol provider interface defines the contract between extensions and
Expand Down
20 changes: 12 additions & 8 deletions src/vs/editor/contrib/quickOpen/quickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ import { asWinJsPromise } from 'vs/base/common/async';

export function getDocumentSymbols(model: ITextModel): TPromise<IOutline> {

let entries: SymbolInformation[] = [];
let roots: SymbolInformation[] = [];

let promises = DocumentSymbolProviderRegistry.all(model).map(support => {

return asWinJsPromise((token) => {
return support.provideDocumentSymbols(model, token);
}).then(result => {
return asWinJsPromise(token => support.provideDocumentSymbols(model, token)).then(result => {
if (Array.isArray(result)) {
entries.push(...result);
roots.push(...result);
}
}, err => {
onUnexpectedExternalError(err);
Expand All @@ -34,7 +32,7 @@ export function getDocumentSymbols(model: ITextModel): TPromise<IOutline> {

return TPromise.join(promises).then(() => {
let flatEntries: SymbolInformation[] = [];
flatten(flatEntries, entries, '');
flatten(flatEntries, roots, '');
flatEntries.sort(compareEntriesUsingStart);

return {
Expand All @@ -51,10 +49,16 @@ function flatten(bucket: SymbolInformation[], entries: SymbolInformation[], over
for (let entry of entries) {
bucket.push({
kind: entry.kind,
location: entry.location,
name: entry.name,
containerName: entry.containerName || overrideContainerLabel
detail: entry.detail,
containerName: entry.containerName || overrideContainerLabel,
location: entry.location,
definingRange: entry.definingRange,
children: undefined, // we flatten it...
});
if (entry.children) {
flatten(bucket, entry.children, entry.name);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4861,6 +4861,10 @@ declare namespace monaco.languages {
* The name of this symbol.
*/
name: string;
/**
* The detail of this symbol.
*/
detail?: string;
/**
* The name of the symbol containing this symbol.
*/
Expand All @@ -4873,6 +4877,11 @@ declare namespace monaco.languages {
* The location of this symbol.
*/
location: Location;
/**
* The defining range of this symbol.
*/
definingRange: IRange;
children?: SymbolInformation[];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHostApiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class ExtHostApiCommands {
const result: types.SymbolInformation[] = [];
if (Array.isArray(value)) {
for (let tuple of value) {
result.push(...tuple[1].map(typeConverters.toSymbolInformation));
result.push(...tuple[1].map(typeConverters.SymbolInformation.to));
}
}
return result;
Expand Down Expand Up @@ -418,7 +418,7 @@ export class ExtHostApiCommands {
};
return this._commands.executeCommand<modes.IOutline>('_executeDocumentSymbolProvider', args).then(value => {
if (value && Array.isArray(value.entries)) {
return value.entries.map(typeConverters.toSymbolInformation);
return value.entries.map(typeConverters.SymbolInformation.to);
}
return undefined;
});
Expand Down
Loading

0 comments on commit 6b4f889

Please sign in to comment.