提交 7753381e 编写于 作者: J Johannes Rieken

renames: range/selectionRange #34968

上级 1967f696
......@@ -648,8 +648,8 @@ export interface DocumentSymbol {
detail: string;
kind: SymbolKind;
containerName?: string;
fullRange: IRange;
identifierRange: IRange;
range: IRange;
selectionRange: IRange;
children?: DocumentSymbol[];
}
......
......@@ -32,7 +32,7 @@ export abstract class TreeElement {
} else {
candidateId = `${container.id}/${candidate.name}`;
if (container.children[candidateId] !== void 0) {
candidateId = `${container.id}/${candidate.name}_${candidate.fullRange.startLineNumber}_${candidate.fullRange.startColumn}`;
candidateId = `${container.id}/${candidate.name}_${candidate.range.startLineNumber}_${candidate.range.startColumn}`;
}
}
......@@ -131,7 +131,7 @@ export class OutlineGroup extends TreeElement {
private _getItemEnclosingPosition(position: IPosition, children: { [id: string]: OutlineElement }): OutlineElement {
for (let key in children) {
let item = children[key];
if (!Range.containsPosition(item.symbol.fullRange, position)) {
if (!Range.containsPosition(item.symbol.range, position)) {
continue;
}
return this._getItemEnclosingPosition(position, item.children) || item;
......@@ -150,11 +150,11 @@ export class OutlineGroup extends TreeElement {
item.marker = undefined;
// find the proper start index to check for item/marker overlap.
let idx = binarySearch<IRange>(markers, item.symbol.fullRange, Range.compareRangesUsingStarts);
let idx = binarySearch<IRange>(markers, item.symbol.range, Range.compareRangesUsingStarts);
let start: number;
if (idx < 0) {
start = ~idx;
if (start > 0 && Range.areIntersecting(markers[start - 1], item.symbol.fullRange)) {
if (start > 0 && Range.areIntersecting(markers[start - 1], item.symbol.range)) {
start -= 1;
}
} else {
......@@ -164,7 +164,7 @@ export class OutlineGroup extends TreeElement {
let myMarkers: IMarker[] = [];
let myTopSev: MarkerSeverity;
while (start < markers.length && Range.areIntersecting(markers[start], item.symbol.fullRange)) {
while (start < markers.length && Range.areIntersecting(markers[start], item.symbol.range)) {
// remove markers intersecting with this outline element
// and store them in a 'private' array.
let marker = markers.splice(start, 1)[0];
......
......@@ -49,7 +49,7 @@ export class OutlineItemComparator implements ISorter {
return a.symbol.name.localeCompare(b.symbol.name);
case OutlineItemCompareType.ByPosition:
default:
return Range.compareRangesUsingStarts(a.symbol.fullRange, b.symbol.fullRange);
return Range.compareRangesUsingStarts(a.symbol.range, b.symbol.range);
}
}
......
......@@ -75,8 +75,8 @@ suite('OutlineModel', function () {
name,
detail: 'fake',
kind: SymbolKind.Boolean,
identifierRange: range,
fullRange: range
selectionRange: range,
range: range
};
}
......
......@@ -39,7 +39,7 @@ export function getDocumentSymbols(model: ITextModel): TPromise<DocumentSymbol[]
}
function compareEntriesUsingStart(a: DocumentSymbol, b: DocumentSymbol): number {
return Range.compareRangesUsingStarts(a.fullRange, b.fullRange);
return Range.compareRangesUsingStarts(a.range, b.range);
}
function flatten(bucket: DocumentSymbol[], entries: DocumentSymbol[], overrideContainerLabel: string): void {
......@@ -49,8 +49,8 @@ function flatten(bucket: DocumentSymbol[], entries: DocumentSymbol[], overrideCo
name: entry.name,
detail: entry.detail,
containerName: entry.containerName || overrideContainerLabel,
fullRange: entry.fullRange,
identifierRange: entry.identifierRange,
range: entry.range,
selectionRange: entry.selectionRange,
children: undefined, // we flatten it...
});
if (entry.children) {
......
......@@ -197,7 +197,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
}
// Add
results.push(this.symbolEntry(label, symbolKindToCssClass(element.kind), description, element.fullRange, highlights, editor, controller));
results.push(this.symbolEntry(label, symbolKindToCssClass(element.kind), description, element.range, highlights, editor, controller));
}
}
......
......@@ -4876,8 +4876,8 @@ declare namespace monaco.languages {
detail: string;
kind: SymbolKind;
containerName?: string;
fullRange: IRange;
identifierRange: IRange;
range: IRange;
selectionRange: IRange;
children?: DocumentSymbol[];
}
......
......@@ -397,15 +397,15 @@ declare module 'vscode' {
kind: SymbolKind;
/**
* The full range of this symbol not including leading/trailing whitespace but everything else.
* The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g comments and code.
*/
fullRange: Range;
range: Range;
/**
* The range that should be revealed when this symbol is being selected, e.g the name of a function.
* The range that should be selected and reveal when this symbol is being pciked, e.g the name of a function.
* Must be contained by the [`fullRange`](#DocumentSymbol.fullRange).
*/
gotoRange: Range;
selectionRange: Range;
/**
* Children of this symbol, e.g. properties of a class.
......@@ -418,10 +418,10 @@ declare module 'vscode' {
* @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.
* @param range The full range of the symbol.
* @param selectionRange The range that should be reveal.
*/
constructor(name: string, detail: string, kind: SymbolKind, fullRange: Range, gotoRange: Range);
constructor(name: string, detail: string, kind: SymbolKind, range: Range, selectionRange: Range);
}
export interface DocumentSymbolProvider {
......
......@@ -69,8 +69,8 @@ class OutlineAdapter {
name: info[i].name,
kind: typeConvert.SymbolKind.from(info[i].kind),
containerName: info[i].containerName,
fullRange: typeConvert.Range.from(info[i].location.range),
identifierRange: typeConvert.Range.from(info[i].location.range),
range: typeConvert.Range.from(info[i].location.range),
selectionRange: typeConvert.Range.from(info[i].location.range),
children: []
};
......@@ -81,7 +81,7 @@ class OutlineAdapter {
break;
}
let parent = parentStack[parentStack.length - 1];
if (EditorRange.containsRange(parent.fullRange, element.fullRange) && !EditorRange.equalsRange(parent.fullRange, element.fullRange)) {
if (EditorRange.containsRange(parent.range, element.range) && !EditorRange.equalsRange(parent.range, element.range)) {
parent.children.push(element);
parentStack.push(element);
break;
......
......@@ -374,8 +374,8 @@ export namespace DocumentSymbol {
let result: modes.DocumentSymbol = {
name: info.name,
detail: info.detail,
fullRange: Range.from(info.fullRange),
identifierRange: Range.from(info.gotoRange),
range: Range.from(info.range),
selectionRange: Range.from(info.selectionRange),
kind: SymbolKind.from(info.kind)
};
if (info.children) {
......@@ -388,8 +388,8 @@ export namespace DocumentSymbol {
info.name,
info.detail,
SymbolKind.to(info.kind),
Range.to(info.fullRange),
Range.to(info.identifierRange),
Range.to(info.range),
Range.to(info.selectionRange),
);
if (info.children) {
result.children = info.children.map(to) as any;
......
......@@ -885,20 +885,20 @@ export class DocumentSymbol {
name: string;
detail: string;
kind: SymbolKind;
fullRange: Range;
gotoRange: Range;
range: Range;
selectionRange: Range;
children: DocumentSymbol[];
constructor(name: string, detail: string, kind: SymbolKind, fullRange: Range, gotoRange: Range) {
constructor(name: string, detail: string, kind: SymbolKind, range: Range, selectionRange: Range) {
this.name = name;
this.detail = detail;
this.kind = kind;
this.fullRange = fullRange;
this.gotoRange = gotoRange;
this.range = range;
this.selectionRange = selectionRange;
this.children = [];
if (!this.fullRange.contains(this.gotoRange)) {
throw new Error('gotoRange must be contained in fullRange');
if (!this.range.contains(this.selectionRange)) {
throw new Error('selectionRange must be contained in fullRange');
}
}
}
......
......@@ -631,7 +631,7 @@ export class OutlinePanel extends ViewletPanel {
private async _revealTreeSelection(model: OutlineModel, element: OutlineElement, focus: boolean, aside: boolean): TPromise<void> {
let input = this._editorService.createInput({ resource: model.textModel.uri });
await this._editorService.openEditor(input, { preserveFocus: !focus, selection: Range.collapseToStart(element.symbol.identifierRange), revealInCenterIfOutsideViewport: true, forceOpen: true }, aside ? SIDE_GROUP : ACTIVE_GROUP);
await this._editorService.openEditor(input, { preserveFocus: !focus, selection: Range.collapseToStart(element.symbol.selectionRange), revealInCenterIfOutsideViewport: true, forceOpen: true }, aside ? SIDE_GROUP : ACTIVE_GROUP);
}
private async _revealEditorSelection(model: OutlineModel, selection: Selection): TPromise<void> {
......
......@@ -450,7 +450,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
// Add
results.push(new SymbolEntry(i,
label, icon, description, icon,
element.fullRange, null, this.editorService, this
element.range, null, this.editorService, this
));
}
......
......@@ -182,7 +182,7 @@ suite('ExtHostLanguageFeatures', function () {
let entry = value[0];
assert.equal(entry.name, 'test');
assert.deepEqual(entry.fullRange, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册