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

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

Issue 2226613004: Suppress follow-on errors when a file is imported with either a prefix or a show clause (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cache URI existence in a modifier' 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4150 return super.uriEnd; 4150 return super.uriEnd;
4151 } 4151 }
4152 4152
4153 @override 4153 @override
4154 void set uriEnd(int uriEnd) { 4154 void set uriEnd(int uriEnd) {
4155 assert(_unlinkedExportNonPublic == null); 4155 assert(_unlinkedExportNonPublic == null);
4156 super.uriEnd = uriEnd; 4156 super.uriEnd = uriEnd;
4157 } 4157 }
4158 4158
4159 @override 4159 @override
4160 bool get uriExists {
4161 if (_unlinkedExportNonPublic != null) {
4162 return true;
4163 }
4164 return hasModifier(Modifier.URI_EXISTS);
4165 }
4166
4167 /**
4168 * Set whether the file referenced by the import's URI exists to match the
4169 * given flag.
4170 */
4171 void set uriExists(bool exists) {
4172 assert(_unlinkedExportNonPublic == null);
4173 setModifier(Modifier.URI_EXISTS, exists);
4174 }
4175
4176 @override
4160 int get uriOffset { 4177 int get uriOffset {
4161 if (_unlinkedExportNonPublic != null) { 4178 if (_unlinkedExportNonPublic != null) {
4162 return _unlinkedExportNonPublic.uriOffset; 4179 return _unlinkedExportNonPublic.uriOffset;
4163 } 4180 }
4164 return super.uriOffset; 4181 return super.uriOffset;
4165 } 4182 }
4166 4183
4167 @override 4184 @override
4168 void set uriOffset(int uriOffset) { 4185 void set uriOffset(int uriOffset) {
4169 assert(_unlinkedExportNonPublic == null); 4186 assert(_unlinkedExportNonPublic == null);
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
5093 return super.uriEnd; 5110 return super.uriEnd;
5094 } 5111 }
5095 5112
5096 @override 5113 @override
5097 void set uriEnd(int uriEnd) { 5114 void set uriEnd(int uriEnd) {
5098 assert(_unlinkedImport == null); 5115 assert(_unlinkedImport == null);
5099 super.uriEnd = uriEnd; 5116 super.uriEnd = uriEnd;
5100 } 5117 }
5101 5118
5102 @override 5119 @override
5120 bool get uriExists {
5121 if (_unlinkedImport != null) {
5122 return true;
5123 }
5124 return hasModifier(Modifier.URI_EXISTS);
5125 }
5126
5127 /**
5128 * Set whether the file referenced by the import's URI exists to match the
5129 * given flag.
5130 */
5131 void set uriExists(bool exists) {
5132 assert(_unlinkedImport == null);
5133 setModifier(Modifier.URI_EXISTS, exists);
5134 }
5135
5136 @override
5103 int get uriOffset { 5137 int get uriOffset {
5104 if (_unlinkedImport != null) { 5138 if (_unlinkedImport != null) {
5105 if (_unlinkedImport.isImplicit) { 5139 if (_unlinkedImport.isImplicit) {
5106 return -1; 5140 return -1;
5107 } 5141 }
5108 return _unlinkedImport.uriOffset; 5142 return _unlinkedImport.uriOffset;
5109 } 5143 }
5110 return super.uriOffset; 5144 return super.uriOffset;
5111 } 5145 }
5112 5146
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
5661 // TODO(paulberry): this means that computing a library cycle will be 5695 // TODO(paulberry): this means that computing a library cycle will be
5662 // expensive for libraries resynthesized from summaries, since it will 5696 // expensive for libraries resynthesized from summaries, since it will
5663 // require fully resynthesizing all the libraries in the cycle as well 5697 // require fully resynthesizing all the libraries in the cycle as well
5664 // as any libraries they import or export. Try to find a better way. 5698 // as any libraries they import or export. Try to find a better way.
5665 if (lib is LibraryElementHandle) { 5699 if (lib is LibraryElementHandle) {
5666 return lib.actualElement; 5700 return lib.actualElement;
5667 } else { 5701 } else {
5668 return lib; 5702 return lib;
5669 } 5703 }
5670 } 5704 }
5705
5671 void recurse(LibraryElementImpl child) { 5706 void recurse(LibraryElementImpl child) {
5672 if (!indices.containsKey(child)) { 5707 if (!indices.containsKey(child)) {
5673 // We haven't visited this child yet, so recurse on the child, 5708 // We haven't visited this child yet, so recurse on the child,
5674 // returning the lowest numbered node reachable from the child. If 5709 // returning the lowest numbered node reachable from the child. If
5675 // the child can reach a root which is lower numbered than anything 5710 // the child can reach a root which is lower numbered than anything
5676 // we've reached so far, update the root. 5711 // we've reached so far, update the root.
5677 root = min(root, scc(child)); 5712 root = min(root, scc(child));
5678 } else if (active.contains(child)) { 5713 } else if (active.contains(child)) {
5679 // The child has been visited, but has not yet been placed into a 5714 // The child has been visited, but has not yet been placed into a
5680 // component. If the child is higher than anything we've seen so far 5715 // component. If the child is higher than anything we've seen so far
5681 // update the root appropriately. 5716 // update the root appropriately.
5682 root = min(root, indices[child]); 5717 root = min(root, indices[child]);
5683 } 5718 }
5684 } 5719 }
5720
5685 // Recurse on all of the children in the import/export graph, filtering 5721 // Recurse on all of the children in the import/export graph, filtering
5686 // out those for which library cycles have already been computed. 5722 // out those for which library cycles have already been computed.
5687 library.exportedLibraries 5723 library.exportedLibraries
5688 .map(getActualLibrary) 5724 .map(getActualLibrary)
5689 .where((l) => l._libraryCycle == null) 5725 .where((l) => l._libraryCycle == null)
5690 .forEach(recurse); 5726 .forEach(recurse);
5691 library.importedLibraries 5727 library.importedLibraries
5692 .map(getActualLibrary) 5728 .map(getActualLibrary)
5693 .where((l) => l._libraryCycle == null) 5729 .where((l) => l._libraryCycle == null)
5694 .forEach(recurse); 5730 .forEach(recurse);
5695 5731
5696 if (root == index) { 5732 if (root == index) {
5697 // This is the root of a strongly connected component. 5733 // This is the root of a strongly connected component.
5698 // Pop the elements, and share the component across all 5734 // Pop the elements, and share the component across all
5699 // of the elements. 5735 // of the elements.
5700 List<LibraryElement> component = <LibraryElement>[]; 5736 List<LibraryElement> component = <LibraryElement>[];
5701 LibraryElementImpl cur = null; 5737 LibraryElementImpl cur = null;
5702 do { 5738 do {
5703 cur = stack.removeLast(); 5739 cur = stack.removeLast();
5704 active.remove(cur); 5740 active.remove(cur);
5705 component.add(cur); 5741 component.add(cur);
5706 cur._libraryCycle = component; 5742 cur._libraryCycle = component;
5707 } while (cur != library); 5743 } while (cur != library);
5708 } 5744 }
5709 return root; 5745 return root;
5710 } 5746 }
5747
5711 scc(library); 5748 scc(library);
5712 return _libraryCycle; 5749 return _libraryCycle;
5713 } 5750 }
5714 5751
5715 @override 5752 @override
5716 FunctionElement get loadLibraryFunction { 5753 FunctionElement get loadLibraryFunction {
5717 assert(_loadLibraryFunction != null); 5754 assert(_loadLibraryFunction != null);
5718 return _loadLibraryFunction; 5755 return _loadLibraryFunction;
5719 } 5756 }
5720 5757
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
5900 element is LibraryElementHandle ? element.actualElement : element; 5937 element is LibraryElementHandle ? element.actualElement : element;
5901 if (active.add(library)) { 5938 if (active.add(library)) {
5902 if (library._libraryCycle != null) { 5939 if (library._libraryCycle != null) {
5903 library._libraryCycle.forEach(invalidate); 5940 library._libraryCycle.forEach(invalidate);
5904 library._libraryCycle = null; 5941 library._libraryCycle = null;
5905 } 5942 }
5906 library.exportedLibraries.forEach(invalidate); 5943 library.exportedLibraries.forEach(invalidate);
5907 library.importedLibraries.forEach(invalidate); 5944 library.importedLibraries.forEach(invalidate);
5908 } 5945 }
5909 } 5946 }
5947
5910 invalidate(this); 5948 invalidate(this);
5911 } 5949 }
5912 5950
5913 @override 5951 @override
5914 bool isUpToDate(int timeStamp) { 5952 bool isUpToDate(int timeStamp) {
5915 Set<LibraryElement> visitedLibraries = new Set(); 5953 Set<LibraryElement> visitedLibraries = new Set();
5916 return _safeIsUpToDate(this, timeStamp, visitedLibraries); 5954 return _safeIsUpToDate(this, timeStamp, visitedLibraries);
5917 } 5955 }
5918 5956
5919 /** 5957 /**
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
6388 static const Modifier STATIC = const Modifier('STATIC', 15); 6426 static const Modifier STATIC = const Modifier('STATIC', 15);
6389 6427
6390 /** 6428 /**
6391 * Indicates that the element does not appear in the source code but was 6429 * Indicates that the element does not appear in the source code but was
6392 * implicitly created. For example, if a class does not define any 6430 * implicitly created. For example, if a class does not define any
6393 * constructors, an implicit zero-argument constructor will be created and it 6431 * constructors, an implicit zero-argument constructor will be created and it
6394 * will be marked as being synthetic. 6432 * will be marked as being synthetic.
6395 */ 6433 */
6396 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 16); 6434 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 16);
6397 6435
6436 /**
6437 * A flag used for import and export elements that indicates whether the URI
6438 * in the corresponding directive referenced a file that exists.
6439 */
6440 static const Modifier URI_EXISTS = const Modifier('URI_EXISTS', 17);
6441
6398 static const List<Modifier> values = const [ 6442 static const List<Modifier> values = const [
6399 ABSTRACT, 6443 ABSTRACT,
6400 ASYNCHRONOUS, 6444 ASYNCHRONOUS,
6401 CONST, 6445 CONST,
6402 DEFERRED, 6446 DEFERRED,
6403 ENUM, 6447 ENUM,
6404 EXTERNAL, 6448 EXTERNAL,
6405 FACTORY, 6449 FACTORY,
6406 FINAL, 6450 FINAL,
6407 GENERATOR, 6451 GENERATOR,
6408 GETTER, 6452 GETTER,
6409 HAS_EXT_URI, 6453 HAS_EXT_URI,
6410 IMPLICIT_TYPE, 6454 IMPLICIT_TYPE,
6411 MIXIN_APPLICATION, 6455 MIXIN_APPLICATION,
6412 REFERENCES_SUPER, 6456 REFERENCES_SUPER,
6413 SETTER, 6457 SETTER,
6414 STATIC, 6458 STATIC,
6415 SYNTHETIC 6459 SYNTHETIC,
6460 URI_EXISTS
6416 ]; 6461 ];
6417 6462
6418 const Modifier(String name, int ordinal) : super(name, ordinal); 6463 const Modifier(String name, int ordinal) : super(name, ordinal);
6419 } 6464 }
6420 6465
6421 /** 6466 /**
6422 * A concrete implementation of a [MultiplyDefinedElement]. 6467 * A concrete implementation of a [MultiplyDefinedElement].
6423 */ 6468 */
6424 class MultiplyDefinedElementImpl implements MultiplyDefinedElement { 6469 class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
6425 /** 6470 /**
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
8475 8520
8476 @override 8521 @override
8477 void visitElement(Element element) { 8522 void visitElement(Element element) {
8478 int offset = element.nameOffset; 8523 int offset = element.nameOffset;
8479 if (offset != -1) { 8524 if (offset != -1) {
8480 map[offset] = element; 8525 map[offset] = element;
8481 } 8526 }
8482 super.visitElement(element); 8527 super.visitElement(element);
8483 } 8528 }
8484 } 8529 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698