Chromium Code Reviews| Index: pkg/kernel/lib/analyzer/ast_from_analyzer.dart |
| diff --git a/pkg/kernel/lib/analyzer/ast_from_analyzer.dart b/pkg/kernel/lib/analyzer/ast_from_analyzer.dart |
| index 25add69328fc71ba8c719477e8919ce22c694f2e..83042b44f58df0f21fc4f1515573a2808f61a517 100644 |
| --- a/pkg/kernel/lib/analyzer/ast_from_analyzer.dart |
| +++ b/pkg/kernel/lib/analyzer/ast_from_analyzer.dart |
| @@ -469,7 +469,7 @@ class TypeScope extends ReferenceScope { |
| positionalParameters: positional, |
| namedParameters: named, |
| requiredParameterCount: requiredParameterCount, |
| - returnType: returnType); |
| + returnType: returnType)..fileOffset = element.nameOffset; |
| } |
| } |
| @@ -563,6 +563,9 @@ class ExpressionScope extends TypeScope { |
| break; |
| } |
| } |
| + int offset = formalParameters?.offset ?? body.offset; |
| + // Debug-stop on the "}" of a function, not after. |
|
Kevin Millikin (Google)
2017/01/04 14:36:58
Debug-stop is not really a word. Can't the end to
jensj
2017/01/05 09:07:55
It was an attempt to explain the use of "endToken.
|
| + int endOffset = body.endToken.offset; |
| return new ast.FunctionNode(buildOptionalFunctionBody(body), |
| typeParameters: typeParameters, |
| positionalParameters: positional, |
| @@ -572,7 +575,9 @@ class ExpressionScope extends TypeScope { |
| inferredReturnType ?? |
| const ast.DynamicType(), |
| asyncMarker: getAsyncMarker( |
| - isAsync: body.isAsynchronous, isStar: body.isGenerator)); |
| + isAsync: body.isAsynchronous, isStar: body.isGenerator)) |
| + ..fileOffset = offset |
| + ..fileEndOffset = endOffset; |
| } |
| ast.Expression buildOptionalTopLevelExpression(Expression node) { |
| @@ -633,7 +638,8 @@ class ExpressionScope extends TypeScope { |
| ast.VariableDeclaration getVariableReference(LocalElement element) { |
| return localVariables.putIfAbsent(element, () { |
| return new ast.VariableDeclaration(element.name, |
| - isFinal: isFinal(element), isConst: isConst(element)); |
| + isFinal: isFinal(element), |
| + isConst: isConst(element))..fileOffset = element.nameOffset; |
| }); |
| } |
| @@ -897,11 +903,19 @@ class StatementBuilder extends GeneralizingAstVisitor<ast.Statement> { |
| StatementBuilder(this.scope, [this.breakStack, this.continueStack]); |
| ast.Statement build(Statement node) { |
| - return node.accept(this); |
| + ast.Statement result = node.accept(this); |
| + result.fileOffset = _getOffset(node); |
| + return result; |
| } |
| ast.Statement buildOptional(Statement node) { |
| - return node?.accept(this); |
| + ast.Statement result = node?.accept(this); |
| + result?.fileOffset = _getOffset(node); |
| + return result; |
| + } |
| + |
| + int _getOffset(AstNode node) { |
| + return node.offset; |
| } |
| ast.Statement buildInScope( |
| @@ -1282,7 +1296,7 @@ class StatementBuilder extends GeneralizingAstVisitor<ast.Statement> { |
| scope.buildFunctionNode(expression.parameters, expression.body, |
| typeParameters: |
| scope.buildOptionalTypeParameterList(expression.typeParameters), |
| - returnType: declaration.returnType)); |
| + returnType: declaration.returnType))..fileOffset = node.offset; |
| } |
| @override |
| @@ -1316,6 +1330,14 @@ class ExpressionBuilder |
| return node.identifier.offset; |
| } else if (node is AssignmentExpression) { |
| return _getOffset(node.leftHandSide); |
| + } else if (node is PropertyAccess) { |
| + return node.propertyName.offset; |
| + } else if (node is IsExpression) { |
| + return node.isOperator.offset; |
| + } else if (node is StringLiteral) { |
| + // Use a catch-all for StringInterpolation and AdjacentStrings: |
|
Kevin Millikin (Google)
2017/01/04 14:36:58
I wouldn't tie this to the debugger, there are a l
jensj
2017/01/05 09:07:55
The reason I put the comment (and tied it to the d
|
| + // the debugger stops at the end. |
| + return node.end; |
| } |
| return node.offset; |
| } |
| @@ -1348,7 +1370,7 @@ class ExpressionBuilder |
| } else { |
| // Cut off the trailing '='. |
| var name = new ast.Name(operator.substring(0, operator.length - 1)); |
| - return leftHand.buildCompoundAssignment(name, rightHand, |
| + return leftHand.buildCompoundAssignment(name, rightHand, node.offset, |
| voidContext: voidContext, |
| interfaceTarget: scope.resolveInterfaceMethod(node.staticElement)); |
| } |
| @@ -1372,7 +1394,7 @@ class ExpressionBuilder |
| ast.Expression leftOperand = build(node.leftOperand); |
| if (leftOperand is ast.VariableGet) { |
| return new ast.ConditionalExpression( |
| - buildIsNull(leftOperand), |
| + buildIsNull(leftOperand, offset: node.leftOperand.offset), |
| build(node.rightOperand), |
| new ast.VariableGet(leftOperand.variable), |
| scope.getInferredType(node)); |
| @@ -1381,7 +1403,8 @@ class ExpressionBuilder |
| return new ast.Let( |
| variable, |
| new ast.ConditionalExpression( |
| - buildIsNull(new ast.VariableGet(variable)), |
| + buildIsNull(new ast.VariableGet(variable), |
| + offset: leftOperand.fileOffset), |
| build(node.rightOperand), |
| new ast.VariableGet(variable), |
| scope.getInferredType(node))); |
| @@ -1885,7 +1908,7 @@ class ExpressionBuilder |
| new ast.VariableGet(receiver), |
| scope.buildName(node.methodName), |
| buildArgumentsForInvocation(node), |
| - element), |
| + element)..fileOffset = node.methodName.offset, |
| scope.buildType(node.staticType))); |
| } else { |
| return buildDecomposableMethodInvocation( |
| @@ -1919,7 +1942,7 @@ class ExpressionBuilder |
| case '--': |
| var leftHand = buildLeftHandValue(node.operand); |
| var binaryOperator = new ast.Name(operator[0]); |
| - return leftHand.buildPostfixIncrement(binaryOperator, |
| + return leftHand.buildPostfixIncrement(binaryOperator, node.offset, |
| voidContext: isInVoidContext(node), |
| interfaceTarget: scope.resolveInterfaceMethod(node.staticElement)); |
| @@ -1952,7 +1975,7 @@ class ExpressionBuilder |
| case '--': |
| var leftHand = buildLeftHandValue(node.operand); |
| var binaryOperator = new ast.Name(operator[0]); |
| - return leftHand.buildPrefixIncrement(binaryOperator, |
| + return leftHand.buildPrefixIncrement(binaryOperator, node.offset, |
| interfaceTarget: scope.resolveInterfaceMethod(node.staticElement)); |
| default: |
| @@ -2332,7 +2355,8 @@ class ClassBodyBuilder extends GeneralizingAstVisitor<Null> { |
| currentClass.name = element.name; |
| currentClass.supertype = scope.getRootClassReference().asRawSupertype; |
| currentClass.constructors.add( |
| - new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement()))); |
| + new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement())) |
| + ..fileOffset = element.nameOffset); |
| } |
| void addAnnotations(List<Annotation> annotations) { |
| @@ -2481,7 +2505,7 @@ class ClassBodyBuilder extends GeneralizingAstVisitor<Null> { |
| initializers: [ |
| new ast.FieldInitializer(indexField, new ast.VariableGet(parameter)), |
| new ast.SuperInitializer(superConstructor, new ast.Arguments.empty()) |
| - ]); |
| + ])..fileOffset = element.nameOffset; |
| classNode.addMember(constructor); |
| int index = 0; |
| var enumConstantFields = <ast.Field>[]; |
| @@ -2557,6 +2581,8 @@ class MemberBodyBuilder extends GeneralizingAstVisitor<Null> { |
| void build(AstNode node) { |
| if (node != null) { |
| + // Debug-stop on the "}" of a member, not after. |
|
Kevin Millikin (Google)
2017/01/04 14:36:58
Same comment as above.
jensj
2017/01/05 09:07:55
I'll remove that too.
|
| + currentMember.fileEndOffset = node.endToken.offset; |
| node.accept(this); |
| } else { |
| buildBrokenMember(); |