提交 ef6b3de1 编写于 作者: I isidor

inlineValues: respect stackFrame lineNumber and column

上级 812472eb
...@@ -56,7 +56,7 @@ export class DebugEditorContribution implements IDebugEditorContribution { ...@@ -56,7 +56,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
private breakpointHintDecoration: string[]; private breakpointHintDecoration: string[];
private breakpointWidget: BreakpointWidget; private breakpointWidget: BreakpointWidget;
private breakpointWidgetVisible: IContextKey<boolean>; private breakpointWidgetVisible: IContextKey<boolean>;
private wordToLineNumbersMap: Map<string, number[]>; private wordToLineNumbersMap: Map<string, IPosition[]>;
private configurationWidget: FloatingClickWidget; private configurationWidget: FloatingClickWidget;
...@@ -361,15 +361,21 @@ export class DebugEditorContribution implements IDebugEditorContribution { ...@@ -361,15 +361,21 @@ export class DebugEditorContribution implements IDebugEditorContribution {
stackFrame.getScopes() stackFrame.getScopes()
// Get all top level children in the scope chain // Get all top level children in the scope chain
.then(scopes => TPromise.join(scopes.map(scope => scope.getChildren()))) .then(scopes => TPromise.join(scopes.filter(s => !s.expensive).map(scope => scope.getChildren()
.then(children => { .then(children => {
const expressions = children.reduce((previous, current) => previous.concat(current), []); let range = new Range(0, 0, stackFrame.lineNumber, stackFrame.column);
const decorations = this.createAllInlineValueDecorations(expressions); if (scope.range) {
this.editor.setDecorations(INLINE_VALUE_DECORATION_KEY, decorations); range = range.setStartPosition(scope.range.startLineNumber, scope.range.startColumn);
}); }
return this.createInlineValueDecorationsInsideRange(children, range);
}))).then(decorationsPerScope => {
const allDecorations = decorationsPerScope.reduce((previous, current) => previous.concat(current), []);
this.editor.setDecorations(INLINE_VALUE_DECORATION_KEY, allDecorations);
}));
} }
private createAllInlineValueDecorations(expressions: IExpression[]): IDecorationOptions[] { private createInlineValueDecorationsInsideRange(expressions: IExpression[], range: Range): IDecorationOptions[] {
const nameValueMap = new Map<string, string>(); const nameValueMap = new Map<string, string>();
for (let expr of expressions) { for (let expr of expressions) {
nameValueMap.set(expr.name, expr.value); nameValueMap.set(expr.name, expr.value);
...@@ -380,17 +386,19 @@ export class DebugEditorContribution implements IDebugEditorContribution { ...@@ -380,17 +386,19 @@ export class DebugEditorContribution implements IDebugEditorContribution {
} }
const lineToNamesMap: Map<number, string[]> = new Map<number, string[]>(); const lineToNamesMap: Map<number, string[]> = new Map<number, string[]>();
const wordToLineNumbersMap = this.getWordToLineNumbersMap(); const wordToPositionsMap = this.getWordToPositionsMap();
// Compute unique set of names on each line // Compute unique set of names on each line
nameValueMap.forEach((value, name) => { nameValueMap.forEach((value, name) => {
if (wordToLineNumbersMap.has(name)) { if (wordToPositionsMap.has(name)) {
for (let lineNumber of wordToLineNumbersMap.get(name)) { for (let position of wordToPositionsMap.get(name)) {
if (!lineToNamesMap.has(lineNumber)) { if (range.containsPosition(position)) {
lineToNamesMap.set(lineNumber, []); if (!lineToNamesMap.has(position.lineNumber)) {
} lineToNamesMap.set(position.lineNumber, []);
}
lineToNamesMap.get(lineNumber).push(name); lineToNamesMap.get(position.lineNumber).push(name);
}
} }
} }
}); });
...@@ -439,9 +447,9 @@ export class DebugEditorContribution implements IDebugEditorContribution { ...@@ -439,9 +447,9 @@ export class DebugEditorContribution implements IDebugEditorContribution {
}; };
} }
private getWordToLineNumbersMap(): Map<string, number[]> { private getWordToPositionsMap(): Map<string, IPosition[]> {
if (!this.wordToLineNumbersMap) { if (!this.wordToLineNumbersMap) {
this.wordToLineNumbersMap = new Map<string, number[]>(); this.wordToLineNumbersMap = new Map<string, IPosition[]>();
const model = this.editor.getModel(); const model = this.editor.getModel();
// For every word in every line, map its ranges for fast lookup // For every word in every line, map its ranges for fast lookup
for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) { for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) {
...@@ -467,7 +475,7 @@ export class DebugEditorContribution implements IDebugEditorContribution { ...@@ -467,7 +475,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
this.wordToLineNumbersMap.set(word, []); this.wordToLineNumbersMap.set(word, []);
} }
this.wordToLineNumbersMap.get(word).push(lineNumber); this.wordToLineNumbersMap.get(word).push({ lineNumber, column: token.startOffset });
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册