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

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

Issue 2897273002: Add FunctionEntity.asyncMarker and refactor SourceInformationStrategy to avoid ResolvedAst (Closed)
Patch Set: Created 3 years, 6 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
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' 11 import '../elements/elements.dart'
12 show AstElement, ResolvedAst, ResolvedAstKind; 12 show AstElement, MemberElement, ResolvedAst, ResolvedAstKind;
13 import '../js/js.dart' as js; 13 import '../js/js.dart' as js;
14 import '../js/js_debug.dart'; 14 import '../js/js_debug.dart';
15 import '../js/js_source_mapping.dart'; 15 import '../js/js_source_mapping.dart';
16 import '../tree/tree.dart' show Node, Send; 16 import '../tree/tree.dart' show Node, Send;
17 import 'code_output.dart' show BufferedCodeOutput; 17 import 'code_output.dart' show BufferedCodeOutput;
18 import 'source_file.dart'; 18 import 'source_file.dart';
19 import 'source_information.dart'; 19 import 'source_information.dart';
20 20
21 /// [SourceInformation] that consists of an offset position into the source 21 /// [SourceInformation] that consists of an offset position into the source
22 /// code. 22 /// code.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return _computeText('${closingPosition.sourceUri}'); 94 return _computeText('${closingPosition.sourceUri}');
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 class PositionSourceInformationStrategy 99 class PositionSourceInformationStrategy
100 implements JavaScriptSourceInformationStrategy { 100 implements JavaScriptSourceInformationStrategy {
101 const PositionSourceInformationStrategy(); 101 const PositionSourceInformationStrategy();
102 102
103 @override 103 @override
104 SourceInformationBuilder createBuilderForContext(ResolvedAst resolvedAst) { 104 SourceInformationBuilder createBuilderForContext(MemberElement member) {
105 return new PositionSourceInformationBuilder(resolvedAst); 105 return new PositionSourceInformationBuilder(member);
106 } 106 }
107 107
108 @override 108 @override
109 SourceInformationProcessor createProcessor( 109 SourceInformationProcessor createProcessor(
110 SourceMapperProvider provider, SourceInformationReader reader) { 110 SourceMapperProvider provider, SourceInformationReader reader) {
111 return new PositionSourceInformationProcessor(provider, reader); 111 return new PositionSourceInformationProcessor(provider, reader);
112 } 112 }
113 113
114 @override 114 @override
115 void onComplete() {} 115 void onComplete() {}
(...skipping 21 matching lines...) Expand all
137 @override 137 @override
138 SourceSpan get sourceSpan => new SourceSpan(null, null, null); 138 SourceSpan get sourceSpan => new SourceSpan(null, null, null);
139 } 139 }
140 140
141 /// [SourceInformationBuilder] that generates [PositionSourceInformation]. 141 /// [SourceInformationBuilder] that generates [PositionSourceInformation].
142 class PositionSourceInformationBuilder implements SourceInformationBuilder { 142 class PositionSourceInformationBuilder implements SourceInformationBuilder {
143 final SourceFile sourceFile; 143 final SourceFile sourceFile;
144 final String name; 144 final String name;
145 final ResolvedAst resolvedAst; 145 final ResolvedAst resolvedAst;
146 146
147 PositionSourceInformationBuilder(ResolvedAst resolvedAst) 147 PositionSourceInformationBuilder(MemberElement member)
148 : this.resolvedAst = resolvedAst, 148 : this.resolvedAst = member.resolvedAst,
149 sourceFile = computeSourceFile(resolvedAst), 149 sourceFile = computeSourceFile(member.resolvedAst),
150 name = computeElementNameForSourceMaps(resolvedAst.element); 150 name = computeElementNameForSourceMaps(member.resolvedAst.element);
151 151
152 SourceInformation buildDeclaration(ResolvedAst resolvedAst) { 152 SourceInformation buildDeclaration(MemberElement member) {
153 ResolvedAst resolvedAst = member.resolvedAst;
153 if (resolvedAst.kind != ResolvedAstKind.PARSED) { 154 if (resolvedAst.kind != ResolvedAstKind.PARSED) {
154 SourceSpan span = resolvedAst.element.sourcePosition; 155 SourceSpan span = resolvedAst.element.sourcePosition;
155 return new PositionSourceInformation( 156 return new PositionSourceInformation(
156 new OffsetSourceLocation(sourceFile, span.begin, name)); 157 new OffsetSourceLocation(sourceFile, span.begin, name));
157 } else { 158 } else {
158 return new PositionSourceInformation( 159 return new PositionSourceInformation(
159 new OffsetSourceLocation( 160 new OffsetSourceLocation(
160 sourceFile, resolvedAst.node.getBeginToken().charOffset, name), 161 sourceFile, resolvedAst.node.getBeginToken().charOffset, name),
161 new OffsetSourceLocation( 162 new OffsetSourceLocation(
162 sourceFile, resolvedAst.node.getEndToken().charOffset, name)); 163 sourceFile, resolvedAst.node.getEndToken().charOffset, name));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 Node body = resolvedAst.body; 244 Node body = resolvedAst.body;
244 if (body != null) { 245 if (body != null) {
245 return buildBegin(body); 246 return buildBegin(body);
246 } 247 }
247 // TODO(johnniwinther): Are there other cases? 248 // TODO(johnniwinther): Are there other cases?
248 } 249 }
249 return null; 250 return null;
250 } 251 }
251 252
252 @override 253 @override
253 SourceInformationBuilder forContext(ResolvedAst resolvedAst) { 254 SourceInformationBuilder forContext(MemberElement member) {
254 return new PositionSourceInformationBuilder(resolvedAst); 255 return new PositionSourceInformationBuilder(member);
255 } 256 }
256 257
257 @override 258 @override
258 SourceInformation buildForeignCode(Node node) => buildBegin(node); 259 SourceInformation buildForeignCode(Node node) => buildBegin(node);
259 260
260 @override 261 @override
261 SourceInformation buildStringInterpolation(Node node) => buildBegin(node); 262 SourceInformation buildStringInterpolation(Node node) => buildBegin(node);
262 263
263 @override 264 @override
264 SourceInformation buildForInIterator(Node node) => buildBegin(node); 265 SourceInformation buildForInIterator(Node node) => buildBegin(node);
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 1337
1337 @override 1338 @override
1338 CodePosition operator [](js.Node node) { 1339 CodePosition operator [](js.Node node) {
1339 CodePosition codePosition = codePositions[node]; 1340 CodePosition codePosition = codePositions[node];
1340 if (codePosition == null) { 1341 if (codePosition == null) {
1341 coverage.registerNodesWithoutOffset(node); 1342 coverage.registerNodesWithoutOffset(node);
1342 } 1343 }
1343 return codePosition; 1344 return codePosition;
1344 } 1345 }
1345 } 1346 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/io/multi_information.dart ('k') | pkg/compiler/lib/src/io/source_information.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698