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

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

Issue 2499693002: Fixes for URI and Object completions with the new driver. (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
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart ('k') | 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) 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 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/error/error.dart'; 10 import 'package:analyzer/error/error.dart';
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 correction: error.correction)) 507 correction: error.correction))
508 .toList()) 508 .toList())
509 .toBuffer(); 509 .toBuffer();
510 String key = _getResolvedUnitKey(libraryFile, file); 510 String key = _getResolvedUnitKey(libraryFile, file);
511 _byteStore.put(key, bytes); 511 _byteStore.put(key, bytes);
512 } 512 }
513 513
514 // Return the result, full or partial. 514 // Return the result, full or partial.
515 _logger.writeln('Computed new analysis result.'); 515 _logger.writeln('Computed new analysis result.');
516 return new AnalysisResult( 516 return new AnalysisResult(
517 _sourceFactory,
517 file.path, 518 file.path,
518 file.uri, 519 file.uri,
519 withUnit ? file.content : null, 520 withUnit ? file.content : null,
520 file.contentHash, 521 file.contentHash,
521 file.lineInfo, 522 file.lineInfo,
522 resolvedUnit, 523 resolvedUnit,
523 errors); 524 errors);
524 } finally { 525 } finally {
525 analysisContext.dispose(); 526 analysisContext.dispose();
526 } 527 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); 664 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes);
664 List<AnalysisError> errors = unit.errors 665 List<AnalysisError> errors = unit.errors
665 .map((error) => new AnalysisError.forValues( 666 .map((error) => new AnalysisError.forValues(
666 file.source, 667 file.source,
667 error.offset, 668 error.offset,
668 error.length, 669 error.length,
669 errorCodeByUniqueName(error.uniqueName), 670 errorCodeByUniqueName(error.uniqueName),
670 error.message, 671 error.message,
671 error.correction)) 672 error.correction))
672 .toList(); 673 .toList();
673 return new AnalysisResult(file.path, file.uri, null, file.contentHash, 674 return new AnalysisResult(_sourceFactory, file.path, file.uri, null,
674 file.lineInfo, null, errors); 675 file.contentHash, file.lineInfo, null, errors);
675 } 676 }
676 return null; 677 return null;
677 } 678 }
678 679
679 /** 680 /**
680 * Return the key to store fully resolved results for the [file] in the 681 * Return the key to store fully resolved results for the [file] in the
681 * [library] into the cache. Return `null` if the dependency signature is 682 * [library] into the cache. Return `null` if the dependency signature is
682 * not known yet. 683 * not known yet.
683 */ 684 */
684 String _getResolvedUnitKey(FileState library, FileState file) { 685 String _getResolvedUnitKey(FileState library, FileState file) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 * These results are self-consistent, i.e. [content], [contentHash], the 947 * These results are self-consistent, i.e. [content], [contentHash], the
947 * resolved [unit] correspond to each other. All referenced elements, even 948 * resolved [unit] correspond to each other. All referenced elements, even
948 * external ones, are also self-consistent. But none of the results is 949 * external ones, are also self-consistent. But none of the results is
949 * guaranteed to be consistent with the state of the files. 950 * guaranteed to be consistent with the state of the files.
950 * 951 *
951 * Every result is independent, and is not guaranteed to be consistent with 952 * Every result is independent, and is not guaranteed to be consistent with
952 * any previously returned result, even inside of the same library. 953 * any previously returned result, even inside of the same library.
953 */ 954 */
954 class AnalysisResult { 955 class AnalysisResult {
955 /** 956 /**
957 * The [SourceFactory] with which the file was analyzed.
958 */
959 final SourceFactory sourceFactory;
960
961 /**
956 * The path of the analysed file, absolute and normalized. 962 * The path of the analysed file, absolute and normalized.
957 */ 963 */
958 final String path; 964 final String path;
959 965
960 /** 966 /**
961 * The URI of the file that corresponded to the [path] in the used 967 * The URI of the file that corresponded to the [path] in the used
962 * [SourceFactory] at some point. Is it not guaranteed to be still consistent 968 * [SourceFactory] at some point. Is it not guaranteed to be still consistent
963 * to the [path], and provided as FYI. 969 * to the [path], and provided as FYI.
964 */ 970 */
965 final Uri uri; 971 final Uri uri;
(...skipping 16 matching lines...) Expand all
982 /** 988 /**
983 * The fully resolved compilation unit for the [content]. 989 * The fully resolved compilation unit for the [content].
984 */ 990 */
985 final CompilationUnit unit; 991 final CompilationUnit unit;
986 992
987 /** 993 /**
988 * The full list of computed analysis errors, both syntactic and semantic. 994 * The full list of computed analysis errors, both syntactic and semantic.
989 */ 995 */
990 final List<AnalysisError> errors; 996 final List<AnalysisError> errors;
991 997
992 AnalysisResult(this.path, this.uri, this.content, this.contentHash, 998 AnalysisResult(this.sourceFactory, this.path, this.uri, this.content,
993 this.lineInfo, this.unit, this.errors); 999 this.contentHash, this.lineInfo, this.unit, this.errors);
994 } 1000 }
995 1001
996 /** 1002 /**
997 * The result of parsing of a single file. 1003 * The result of parsing of a single file.
998 * 1004 *
999 * These results are self-consistent, i.e. [content], [contentHash], the 1005 * These results are self-consistent, i.e. [content], [contentHash], the
1000 * resolved [unit] correspond to each other. But none of the results is 1006 * resolved [unit] correspond to each other. But none of the results is
1001 * guaranteed to be consistent with the state of the files. 1007 * guaranteed to be consistent with the state of the files.
1002 */ 1008 */
1003 class ParseResult { 1009 class ParseResult {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 } 1176 }
1171 } 1177 }
1172 1178
1173 appendDependencies(file); 1179 appendDependencies(file);
1174 } 1180 }
1175 } 1181 }
1176 1182
1177 @override 1183 @override
1178 String toString() => uri.toString(); 1184 String toString() => uri.toString();
1179 } 1185 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698