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

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

Issue 2468223003: Include LineInfo into AnalysisResult to allow reporting errors with lines/columns. (Closed)
Patch Set: Created 4 years, 1 month 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 _byteStore.put(key, bytes); 461 _byteStore.put(key, bytes);
462 } 462 }
463 463
464 // Return the result, full or partial. 464 // Return the result, full or partial.
465 _logger.writeln('Computed new analysis result.'); 465 _logger.writeln('Computed new analysis result.');
466 return new AnalysisResult( 466 return new AnalysisResult(
467 file.path, 467 file.path,
468 file.uri, 468 file.uri,
469 withUnit ? file.content : null, 469 withUnit ? file.content : null,
470 file.contentHash, 470 file.contentHash,
471 file.lineInfo,
471 resolvedUnit, 472 resolvedUnit,
472 errors); 473 errors);
473 } finally { 474 } finally {
474 analysisContext.dispose(); 475 analysisContext.dispose();
475 } 476 }
476 }); 477 });
477 } 478 }
478 479
479 AnalysisContext _createAnalysisContext(_LibraryContext libraryContext) { 480 AnalysisContext _createAnalysisContext(_LibraryContext libraryContext) {
480 AnalysisContextImpl analysisContext = 481 AnalysisContextImpl analysisContext =
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); 606 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes);
606 List<AnalysisError> errors = unit.errors 607 List<AnalysisError> errors = unit.errors
607 .map((error) => new AnalysisError.forValues( 608 .map((error) => new AnalysisError.forValues(
608 file.source, 609 file.source,
609 error.offset, 610 error.offset,
610 error.length, 611 error.length,
611 ErrorCode.byUniqueName(error.uniqueName), 612 ErrorCode.byUniqueName(error.uniqueName),
612 error.message, 613 error.message,
613 error.correction)) 614 error.correction))
614 .toList(); 615 .toList();
615 return new AnalysisResult( 616 return new AnalysisResult(file.path, file.uri, null, file.contentHash,
616 file.path, file.uri, null, file.contentHash, null, errors); 617 file.lineInfo, null, errors);
617 } 618 }
618 return null; 619 return null;
619 } 620 }
620 621
621 /** 622 /**
622 * Return the key to store fully resolved results for the [file] into the 623 * Return the key to store fully resolved results for the [file] into the
623 * cache. Return `null` if the dependency signature is not known yet. 624 * cache. Return `null` if the dependency signature is not known yet.
624 */ 625 */
625 String _getResolvedUnitKey(FileState file) { 626 String _getResolvedUnitKey(FileState file) {
626 String dependencyHash = _dependencySignatureMap[file.uri]; 627 String dependencyHash = _dependencySignatureMap[file.uri];
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 * The content of the file that was scanned, parsed and resolved. 723 * The content of the file that was scanned, parsed and resolved.
723 */ 724 */
724 final String content; 725 final String content;
725 726
726 /** 727 /**
727 * The MD5 hash of the [content]. 728 * The MD5 hash of the [content].
728 */ 729 */
729 final String contentHash; 730 final String contentHash;
730 731
731 /** 732 /**
733 * Information about lines in the [content].
734 */
735 final LineInfo lineInfo;
736
737 /**
732 * The fully resolved compilation unit for the [content]. 738 * The fully resolved compilation unit for the [content].
733 */ 739 */
734 final CompilationUnit unit; 740 final CompilationUnit unit;
735 741
736 /** 742 /**
737 * The full list of computed analysis errors, both syntactic and semantic. 743 * The full list of computed analysis errors, both syntactic and semantic.
738 */ 744 */
739 final List<AnalysisError> errors; 745 final List<AnalysisError> errors;
740 746
741 AnalysisResult(this.path, this.uri, this.content, this.contentHash, this.unit, 747 AnalysisResult(this.path, this.uri, this.content, this.contentHash,
742 this.errors); 748 this.lineInfo, this.unit, this.errors);
743 } 749 }
744 750
745 /** 751 /**
746 * The status of [AnalysisDriver] 752 * The status of [AnalysisDriver]
747 */ 753 */
748 class AnalysisStatus { 754 class AnalysisStatus {
749 static const IDLE = const AnalysisStatus._(false); 755 static const IDLE = const AnalysisStatus._(false);
750 static const ANALYZING = const AnalysisStatus._(true); 756 static const ANALYZING = const AnalysisStatus._(true);
751 757
752 final bool _analyzing; 758 final bool _analyzing;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 /** 928 /**
923 * Complete the [signal] future if it is not completed yet. It is safe to 929 * Complete the [signal] future if it is not completed yet. It is safe to
924 * call this method multiple times, but the [signal] will complete only once. 930 * call this method multiple times, but the [signal] will complete only once.
925 */ 931 */
926 void notify() { 932 void notify() {
927 if (!_completer.isCompleted) { 933 if (!_completer.isCompleted) {
928 _completer.complete(null); 934 _completer.complete(null);
929 } 935 }
930 } 936 }
931 } 937 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/computer/new_notifications.dart ('k') | pkg/analyzer/lib/src/dart/analysis/file_state.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698