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

Side by Side Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 2232863004: Create new error message for missing generated files (Closed) Base URL: https://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
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | 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) 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 library analyzer.src.task.dart; 5 library analyzer.src.task.dart;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 6425 matching lines...) Expand 10 before | Expand all | Expand 10 after
6436 if (modificationTime >= 0) { 6436 if (modificationTime >= 0) {
6437 return; 6437 return;
6438 } 6438 }
6439 } else { 6439 } else {
6440 // Don't report errors already reported by ParseDartTask.resolveDirective 6440 // Don't report errors already reported by ParseDartTask.resolveDirective
6441 if (directive.validate() != null) { 6441 if (directive.validate() != null) {
6442 return; 6442 return;
6443 } 6443 }
6444 } 6444 }
6445 StringLiteral uriLiteral = directive.uri; 6445 StringLiteral uriLiteral = directive.uri;
6446 errorReporter.reportErrorForNode(CompileTimeErrorCode.URI_DOES_NOT_EXIST, 6446 CompileTimeErrorCode errorCode = CompileTimeErrorCode.URI_DOES_NOT_EXIST;
6447 uriLiteral, [directive.uriContent]); 6447 if (_isGenerated(source)) {
6448 errorCode = CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED;
6449 }
6450 errorReporter
6451 .reportErrorForNode(errorCode, uriLiteral, [directive.uriContent]);
6448 } 6452 }
6449 6453
6450 /** 6454 /**
6455 * Return `true` if the given [source] refers to a file that is assumed to be
6456 * generated.
6457 */
6458 bool _isGenerated(Source source) {
6459 if (source == null) {
6460 return false;
6461 }
6462 // TODO(brianwilkerson) Generalize this mechanism.
6463 List<String> suffixes = <String>[
scheglov 2016/08/10 19:12:15 const const
Brian Wilkerson 2016/08/10 19:42:02 Done
6464 '.g.dart',
6465 '.pb.dart',
6466 '.pbenum.dart',
6467 '.pbserver.dart',
6468 '.pbjson.dart',
6469 '.template.dart'
6470 ];
6471 String fullName = source.fullName;
6472 for (String suffix in suffixes) {
6473 if (fullName.endsWith(suffix)) {
6474 return true;
6475 }
6476 }
6477 return false;
6478 }
6479
6480 /**
6451 * Return a map from the names of the inputs of this kind of task to the task 6481 * Return a map from the names of the inputs of this kind of task to the task
6452 * input descriptors describing those inputs for a task with the 6482 * input descriptors describing those inputs for a task with the
6453 * given [target]. 6483 * given [target].
6454 */ 6484 */
6455 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 6485 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
6456 LibrarySpecificUnit unit = target; 6486 LibrarySpecificUnit unit = target;
6457 return <String, TaskInput>{ 6487 return <String, TaskInput>{
6458 'thisLibraryClosureIsReady': READY_RESOLVED_UNIT.of(unit.library), 6488 'thisLibraryClosureIsReady': READY_RESOLVED_UNIT.of(unit.library),
6459 UNIT_INPUT: RESOLVED_UNIT.of(unit), 6489 UNIT_INPUT: RESOLVED_UNIT.of(unit),
6460 REFERENCED_SOURCE_MODIFICATION_TIME_MAP_INPUT: 6490 REFERENCED_SOURCE_MODIFICATION_TIME_MAP_INPUT:
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
6583 6613
6584 @override 6614 @override
6585 bool moveNext() { 6615 bool moveNext() {
6586 if (_newSources.isEmpty) { 6616 if (_newSources.isEmpty) {
6587 return false; 6617 return false;
6588 } 6618 }
6589 currentTarget = _newSources.removeLast(); 6619 currentTarget = _newSources.removeLast();
6590 return true; 6620 return true;
6591 } 6621 }
6592 } 6622 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698