Skip to content

Commit

Permalink
renames: range/selectionRange #34968
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 18, 2018
1 parent 1967f69 commit 7753381
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ export interface DocumentSymbol {
detail: string;
kind: SymbolKind;
containerName?: string;
fullRange: IRange;
identifierRange: IRange;
range: IRange;
selectionRange: IRange;
children?: DocumentSymbol[];
}

Expand Down
10 changes: 5 additions & 5 deletions src/vs/editor/contrib/documentSymbols/outlineModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/documentSymbols/outlineTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ suite('OutlineModel', function () {
name,
detail: 'fake',
kind: SymbolKind.Boolean,
identifierRange: range,
fullRange: range
selectionRange: range,
range: range
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/contrib/quickOpen/quickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/standalone/browser/quickOpen/quickOutline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4876,8 +4876,8 @@ declare namespace monaco.languages {
detail: string;
kind: SymbolKind;
containerName?: string;
fullRange: IRange;
identifierRange: IRange;
range: IRange;
selectionRange: IRange;
children?: DocumentSymbol[];
}

Expand Down
14 changes: 7 additions & 7 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/api/node/extHostLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
};

Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/api/node/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/vs/workbench/api/node/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
});
});
Expand Down

0 comments on commit 7753381

Please sign in to comment.