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

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/analysis_impl.dart

Issue 2681143002: Parse using FileState, so use all analysis options. (Closed)
Patch Set: Created 3 years, 10 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 | no next file » | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analyzer/context/declared_variables.dart'; 5 import 'package:analyzer/context/declared_variables.dart';
6 import 'package:analyzer/dart/ast/ast.dart'; 6 import 'package:analyzer/dart/ast/ast.dart';
7 import 'package:analyzer/dart/ast/token.dart';
8 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/error/error.dart'; 8 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/error/listener.dart'; 9 import 'package:analyzer/error/listener.dart';
11 import 'package:analyzer/src/context/context.dart'; 10 import 'package:analyzer/src/context/context.dart';
12 import 'package:analyzer/src/dart/analysis/file_state.dart'; 11 import 'package:analyzer/src/dart/analysis/file_state.dart';
13 import 'package:analyzer/src/dart/ast/ast.dart'; 12 import 'package:analyzer/src/dart/ast/ast.dart';
14 import 'package:analyzer/src/dart/constant/evaluation.dart'; 13 import 'package:analyzer/src/dart/constant/evaluation.dart';
15 import 'package:analyzer/src/dart/constant/utilities.dart'; 14 import 'package:analyzer/src/dart/constant/utilities.dart';
16 import 'package:analyzer/src/dart/scanner/scanner.dart';
17 import 'package:analyzer/src/error/codes.dart'; 15 import 'package:analyzer/src/error/codes.dart';
18 import 'package:analyzer/src/error/pending_error.dart'; 16 import 'package:analyzer/src/error/pending_error.dart';
19 import 'package:analyzer/src/generated/declaration_resolver.dart'; 17 import 'package:analyzer/src/generated/declaration_resolver.dart';
20 import 'package:analyzer/src/generated/engine.dart'; 18 import 'package:analyzer/src/generated/engine.dart';
21 import 'package:analyzer/src/generated/error_verifier.dart'; 19 import 'package:analyzer/src/generated/error_verifier.dart';
22 import 'package:analyzer/src/generated/parser.dart';
23 import 'package:analyzer/src/generated/resolver.dart'; 20 import 'package:analyzer/src/generated/resolver.dart';
24 import 'package:analyzer/src/generated/source.dart'; 21 import 'package:analyzer/src/generated/source.dart';
25 import 'package:analyzer/src/summary/package_bundle_reader.dart'; 22 import 'package:analyzer/src/summary/package_bundle_reader.dart';
26 import 'package:analyzer/src/task/dart.dart'; 23 import 'package:analyzer/src/task/dart.dart';
27 import 'package:analyzer/src/task/strong/checker.dart'; 24 import 'package:analyzer/src/task/strong/checker.dart';
28 import 'package:front_end/src/dependency_walker.dart'; 25 import 'package:front_end/src/dependency_walker.dart';
29 import 'package:front_end/src/scanner/reader.dart';
30 26
31 /** 27 /**
32 * Analyzer of Dart files. 28 * Analyzer of Dart files.
33 * 29 *
34 * Work in progress, not ready to be used. 30 * Work in progress, not ready to be used.
35 */ 31 */
36 class AnalyzerImpl { 32 class AnalyzerImpl {
37 final AnalysisOptions _analysisOptions; 33 final AnalysisOptions _analysisOptions;
38 final DeclaredVariables _declaredVariables; 34 final DeclaredVariables _declaredVariables;
39 final SourceFactory _sourceFactory; 35 final SourceFactory _sourceFactory;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 324 }
329 } 325 }
330 return null; 326 return null;
331 } 327 }
332 328
333 /** 329 /**
334 * Return a new parsed unresolved [CompilationUnit]. 330 * Return a new parsed unresolved [CompilationUnit].
335 */ 331 */
336 CompilationUnit _parse(FileState file) { 332 CompilationUnit _parse(FileState file) {
337 RecordingErrorListener errorListener = _getErrorListener(file); 333 RecordingErrorListener errorListener = _getErrorListener(file);
334 String content = file.content;
335 CompilationUnit unit = file.parse(errorListener);
338 336
339 String content = file.content; 337 LineInfo lineInfo = unit.lineInfo;
340
341 CharSequenceReader reader = new CharSequenceReader(content);
342 Scanner scanner = new Scanner(file.source, reader, errorListener);
343 scanner.scanGenericMethodComments = _analysisOptions.strongMode;
344 Token token = scanner.tokenize();
345 LineInfo lineInfo = new LineInfo(scanner.lineStarts);
346
347 _fileToLineInfo[file] = lineInfo; 338 _fileToLineInfo[file] = lineInfo;
348 _fileToIgnoreInfo[file] = IgnoreInfo.calculateIgnores(content, lineInfo); 339 _fileToIgnoreInfo[file] = IgnoreInfo.calculateIgnores(content, lineInfo);
349 340
350 Parser parser = new Parser(file.source, errorListener);
351 parser.parseGenericMethodComments = _analysisOptions.strongMode;
352 parser.enableUriInPartOf = _analysisOptions.enableUriInPartOf;
353 CompilationUnit unit = parser.parseCompilationUnit(token);
354 unit.lineInfo = lineInfo;
355 return unit; 341 return unit;
356 } 342 }
357 343
358 void _resolveDirectives(Map<FileState, CompilationUnit> units) { 344 void _resolveDirectives(Map<FileState, CompilationUnit> units) {
359 CompilationUnit definingCompilationUnit = units[_library]; 345 CompilationUnit definingCompilationUnit = units[_library];
360 346
361 var uriToElement = <Uri, CompilationUnitElement>{}; 347 var uriToElement = <Uri, CompilationUnitElement>{};
362 for (CompilationUnitElement partElement in _libraryElement.units) { 348 for (CompilationUnitElement partElement in _libraryElement.units) {
363 uriToElement[partElement.source.uri] = partElement; 349 uriToElement[partElement.source.uri] = partElement;
364 } 350 }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 709 }
724 710
725 /** 711 /**
726 * Either the name or the source associated with a part-of directive. 712 * Either the name or the source associated with a part-of directive.
727 */ 713 */
728 class _NameOrSource { 714 class _NameOrSource {
729 final String name; 715 final String name;
730 final Source source; 716 final Source source;
731 _NameOrSource(this.name, this.source); 717 _NameOrSource(this.name, this.source);
732 } 718 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698