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

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_ast.dart

Issue 2225893003: Provide LINE_INFO from ResynthesizerResultProvider. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library serialization.summarize_ast; 5 library serialization.summarize_ast;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/dart/element/type.dart' show DartType; 10 import 'package:analyzer/dart/element/type.dart' show DartType;
11 import 'package:analyzer/src/generated/utilities_dart.dart'; 11 import 'package:analyzer/src/generated/utilities_dart.dart';
12 import 'package:analyzer/src/summary/format.dart'; 12 import 'package:analyzer/src/summary/format.dart';
13 import 'package:analyzer/src/summary/idl.dart'; 13 import 'package:analyzer/src/summary/idl.dart';
14 import 'package:analyzer/src/summary/public_namespace_computer.dart'; 14 import 'package:analyzer/src/summary/public_namespace_computer.dart';
15 import 'package:analyzer/src/summary/summarize_const_expr.dart'; 15 import 'package:analyzer/src/summary/summarize_const_expr.dart';
16 16
17 /** 17 /**
18 * Serialize all the declarations in [compilationUnit] to an unlinked summary. 18 * Serialize all the declarations in [compilationUnit] to an unlinked summary.
19 */ 19 */
20 UnlinkedUnitBuilder serializeAstUnlinked( 20 UnlinkedUnitBuilder serializeAstUnlinked(CompilationUnit compilationUnit) {
21 CompilationUnit compilationUnit, List<int> lineStarts) { 21 return new _SummarizeAstVisitor().serializeCompilationUnit(compilationUnit);
22 return new _SummarizeAstVisitor()
23 .serializeCompilationUnit(compilationUnit, lineStarts);
24 } 22 }
25 23
26 /** 24 /**
27 * Instances of this class keep track of intermediate state during 25 * Instances of this class keep track of intermediate state during
28 * serialization of a single constant [Expression]. 26 * serialization of a single constant [Expression].
29 */ 27 */
30 class _ConstExprSerializer extends AbstractConstExprSerializer { 28 class _ConstExprSerializer extends AbstractConstExprSerializer {
31 final _SummarizeAstVisitor visitor; 29 final _SummarizeAstVisitor visitor;
32 30
33 /** 31 /**
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 throw new StateError( 497 throw new StateError(
500 'Unexpected combinator type: ${combinator.runtimeType}'); 498 'Unexpected combinator type: ${combinator.runtimeType}');
501 } 499 }
502 return b; 500 return b;
503 } 501 }
504 502
505 /** 503 /**
506 * Main entry point for serializing an AST. 504 * Main entry point for serializing an AST.
507 */ 505 */
508 UnlinkedUnitBuilder serializeCompilationUnit( 506 UnlinkedUnitBuilder serializeCompilationUnit(
509 CompilationUnit compilationUnit, List<int> lineStarts) { 507 CompilationUnit compilationUnit) {
510 compilationUnit.directives.accept(this); 508 compilationUnit.directives.accept(this);
511 if (!hasCoreBeenImported) { 509 if (!hasCoreBeenImported) {
512 unlinkedImports.add(new UnlinkedImportBuilder(isImplicit: true)); 510 unlinkedImports.add(new UnlinkedImportBuilder(isImplicit: true));
513 } 511 }
514 compilationUnit.declarations.accept(this); 512 compilationUnit.declarations.accept(this);
515 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(); 513 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder();
516 b.lineStarts = lineStarts; 514 b.lineStarts = compilationUnit.lineInfo?.lineStarts;
517 b.libraryName = libraryName; 515 b.libraryName = libraryName;
518 b.libraryNameOffset = libraryNameOffset; 516 b.libraryNameOffset = libraryNameOffset;
519 b.libraryNameLength = libraryNameLength; 517 b.libraryNameLength = libraryNameLength;
520 b.libraryDocumentationComment = libraryDocumentationComment; 518 b.libraryDocumentationComment = libraryDocumentationComment;
521 b.libraryAnnotations = libraryAnnotations; 519 b.libraryAnnotations = libraryAnnotations;
522 b.codeRange = serializeCodeRange(compilationUnit); 520 b.codeRange = serializeCodeRange(compilationUnit);
523 b.classes = classes; 521 b.classes = classes;
524 b.enums = enums; 522 b.enums = enums;
525 b.executables = executables; 523 b.executables = executables;
526 b.exports = exports; 524 b.exports = exports;
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 /** 1377 /**
1380 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. 1378 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s.
1381 */ 1379 */
1382 class _TypeParameterScope extends _Scope { 1380 class _TypeParameterScope extends _Scope {
1383 /** 1381 /**
1384 * Get the number of [_ScopedTypeParameter]s defined in this 1382 * Get the number of [_ScopedTypeParameter]s defined in this
1385 * [_TypeParameterScope]. 1383 * [_TypeParameterScope].
1386 */ 1384 */
1387 int get length => _definedNames.length; 1385 int get length => _definedNames.length;
1388 } 1386 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/package_bundle_reader.dart ('k') | pkg/analyzer/test/src/summary/package_bundle_reader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698