use a parent pointer instead of 2d array, #67872

This commit is contained in:
Johannes Rieken
2019-03-12 09:56:49 +01:00
parent a86ff6a4da
commit 4f8dbd4544
9 changed files with 51 additions and 24 deletions

View File

@@ -944,14 +944,19 @@ class SelectionRangeAdapter {
const oneResult: modes.SelectionRange[] = [];
allResults.push(oneResult);
const oneProviderRanges = allProviderRanges[i];
let last: vscode.Position | vscode.Range = positions[i];
for (const selectionRange of oneProviderRanges) {
let selectionRange = allProviderRanges[i];
while (true) {
if (!selectionRange.range.contains(last)) {
throw new Error('INVALID selection range, must contain the previous range');
}
oneResult.push(typeConvert.SelectionRange.from(selectionRange));
if (!selectionRange.parent) {
break;
}
last = selectionRange.range;
selectionRange = selectionRange.parent;
}
}
return allResults;

View File

@@ -1098,9 +1098,11 @@ CodeActionKind.SourceFixAll = CodeActionKind.Source.append('fixAll');
export class SelectionRange {
range: Range;
parent?: SelectionRange;
constructor(range: Range) {
constructor(range: Range, parent?: SelectionRange) {
this.range = range;
this.parent = parent;
}
}