Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: pkg/compiler/lib/src/io/position_information.dart

Issue 1902363002: Derive source information from ResolvedAst. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/io/source_information.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Source information system mapping that attempts a semantic mapping between 5 /// Source information system mapping that attempts a semantic mapping between
6 /// offsets of JavaScript code points to offsets of Dart code points. 6 /// offsets of JavaScript code points to offsets of Dart code points.
7 7
8 library dart2js.source_information.position; 8 library dart2js.source_information.position;
9 9
10 import '../common.dart'; 10 import '../common.dart';
11 import '../elements/elements.dart' show AstElement, FieldElement; 11 import '../elements/elements.dart' show AstElement, FieldElement, ResolvedAst, R esolvedAstKind;
12 import '../js/js.dart' as js; 12 import '../js/js.dart' as js;
13 import '../js/js_debug.dart'; 13 import '../js/js_debug.dart';
14 import '../js/js_source_mapping.dart'; 14 import '../js/js_source_mapping.dart';
15 import '../tree/tree.dart' show FunctionExpression, Node, Send; 15 import '../tree/tree.dart' show FunctionExpression, Node, Send;
16 import 'code_output.dart' show CodeBuffer; 16 import 'code_output.dart' show CodeBuffer;
17 import 'source_file.dart'; 17 import 'source_file.dart';
18 import 'source_information.dart'; 18 import 'source_information.dart';
19 19
20 /// [SourceInformation] that consists of an offset position into the source 20 /// [SourceInformation] that consists of an offset position into the source
21 /// code. 21 /// code.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 class PositionSourceInformationBuilder implements SourceInformationBuilder { 140 class PositionSourceInformationBuilder implements SourceInformationBuilder {
141 final SourceFile sourceFile; 141 final SourceFile sourceFile;
142 final String name; 142 final String name;
143 final AstElement element; 143 final AstElement element;
144 144
145 PositionSourceInformationBuilder(AstElement element) 145 PositionSourceInformationBuilder(AstElement element)
146 : this.element = element, 146 : this.element = element,
147 sourceFile = element.implementation.compilationUnit.script.file, 147 sourceFile = element.implementation.compilationUnit.script.file,
148 name = computeElementNameForSourceMaps(element); 148 name = computeElementNameForSourceMaps(element);
149 149
150 SourceInformation buildDeclaration(AstElement element) { 150 SourceInformation buildDeclaration(ResolvedAst resolvedAst) {
151 if (element.isSynthesized) { 151 if (resolvedAst.kind != ResolvedAstKind.PARSED) {
152 SourceSpan span = resolvedAst.element.sourcePosition;
152 return new PositionSourceInformation(new OffsetSourceLocation( 153 return new PositionSourceInformation(new OffsetSourceLocation(
153 sourceFile, element.position.charOffset, name)); 154 sourceFile, span.begin, name));
154 } else { 155 } else {
155 return new PositionSourceInformation( 156 return new PositionSourceInformation(
156 new OffsetSourceLocation(sourceFile, 157 new OffsetSourceLocation(sourceFile,
157 element.resolvedAst.node.getBeginToken().charOffset, name), 158 resolvedAst.node.getBeginToken().charOffset, name),
158 new OffsetSourceLocation(sourceFile, 159 new OffsetSourceLocation(sourceFile,
159 element.resolvedAst.node.getEndToken().charOffset, name)); 160 resolvedAst.node.getEndToken().charOffset, name));
160 } 161 }
161 } 162 }
162 163
163 /// Builds a source information object pointing the start position of [node]. 164 /// Builds a source information object pointing the start position of [node].
164 SourceInformation buildBegin(Node node) { 165 SourceInformation buildBegin(Node node) {
165 return new PositionSourceInformation(new OffsetSourceLocation( 166 return new PositionSourceInformation(new OffsetSourceLocation(
166 sourceFile, node.getBeginToken().charOffset, name)); 167 sourceFile, node.getBeginToken().charOffset, name));
167 } 168 }
168 169
169 @override 170 @override
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 1281
1281 @override 1282 @override
1282 CodePosition operator [](js.Node node) { 1283 CodePosition operator [](js.Node node) {
1283 CodePosition codePosition = codePositions[node]; 1284 CodePosition codePosition = codePositions[node];
1284 if (codePosition == null) { 1285 if (codePosition == null) {
1285 coverage.registerNodesWithoutOffset(node); 1286 coverage.registerNodesWithoutOffset(node);
1286 } 1287 }
1287 return codePosition; 1288 return codePosition;
1288 } 1289 }
1289 } 1290 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/io/source_information.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698