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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1854003003: Fixes for import/export directive resolution and tasks graph. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | pkg/analyzer/tool/task_dependency_graph/tasks.dot » ('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) 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.generated.resolver; 5 library analyzer.src.generated.resolver;
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 2834 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 * has the given [source]. Throw an [ElementMismatchException] if an element 2845 * has the given [source]. Throw an [ElementMismatchException] if an element
2846 * corresponding to the identifier cannot be found. 2846 * corresponding to the identifier cannot be found.
2847 */ 2847 */
2848 ExportElement _findExport( 2848 ExportElement _findExport(
2849 ExportDirective node, List<ExportElement> exports, Source source) { 2849 ExportDirective node, List<ExportElement> exports, Source source) {
2850 if (source == null || !_enclosingUnit.context.exists(source)) { 2850 if (source == null || !_enclosingUnit.context.exists(source)) {
2851 return null; 2851 return null;
2852 } 2852 }
2853 for (ExportElement export in exports) { 2853 for (ExportElement export in exports) {
2854 if (export.exportedLibrary.source == source) { 2854 if (export.exportedLibrary.source == source) {
2855 // Must have the same offset.
2856 if (export.nameOffset != node.offset) {
2857 continue;
2858 }
2859 // In general we should also match combinators.
2860 // But currently we invalidate element model on any directive change.
2861 // So, either the combinators are the same, or we build new elements.
2855 return export; 2862 return export;
2856 } 2863 }
2857 } 2864 }
2858 _mismatch("Could not find export element for '$source'", node); 2865 _mismatch("Could not find export element for '$source'", node);
2859 return null; // Never reached 2866 return null; // Never reached
2860 } 2867 }
2861 2868
2862 /** 2869 /**
2863 * Return the import element from the given list of [imports] whose library 2870 * Return the import element from the given list of [imports] whose library
2864 * has the given [source]. Throw an [ElementMismatchException] if an element 2871 * has the given [source]. Throw an [ElementMismatchException] if an element
2865 * corresponding to the [source] cannot be found. 2872 * corresponding to the [source] cannot be found.
2866 */ 2873 */
2867 ImportElement _findImport( 2874 ImportElement _findImport(
2868 ImportDirective node, List<ImportElement> imports, Source source) { 2875 ImportDirective node, List<ImportElement> imports, Source source) {
2869 if (source == null || !_enclosingUnit.context.exists(source)) { 2876 if (source == null || !_enclosingUnit.context.exists(source)) {
2870 return null; 2877 return null;
2871 } 2878 }
2872 SimpleIdentifier prefix = node.prefix; 2879 SimpleIdentifier prefix = node.prefix;
2873 bool foundSource = false; 2880 bool foundSource = false;
2874 for (ImportElement element in imports) { 2881 for (ImportElement element in imports) {
2875 if (element.importedLibrary.source == source) { 2882 if (element.importedLibrary.source == source) {
2876 foundSource = true; 2883 foundSource = true;
2877 PrefixElement prefixElement = element.prefix; 2884 // Must have the same offset.
2878 if (prefix == null) { 2885 if (element.nameOffset != node.offset) {
2879 if (prefixElement == null) { 2886 continue;
2880 return element;
2881 }
2882 } else {
2883 if (prefixElement != null &&
2884 prefix.name == prefixElement.displayName) {
2885 return element;
2886 }
2887 } 2887 }
2888 // Must have the same prefix.
2889 if (element.prefix?.displayName != prefix?.name) {
2890 continue;
2891 }
2892 // In general we should also match combinators.
2893 // But currently we invalidate element model on any directive change.
2894 // So, either the combinators are the same, or we build new elements.
2895 return element;
2888 } 2896 }
2889 } 2897 }
2890 if (foundSource) { 2898 if (foundSource) {
2891 if (prefix == null) { 2899 if (prefix == null) {
2892 _mismatch( 2900 _mismatch(
2893 "Could not find import element for '$source' with no prefix", node); 2901 "Could not find import element for '$source' with no prefix", node);
2894 } 2902 }
2895 _mismatch( 2903 _mismatch(
2896 "Could not find import element for '$source' with prefix ${prefix.name }", 2904 "Could not find import element for '$source' with prefix ${prefix.name }",
2897 node); 2905 node);
(...skipping 10071 matching lines...) Expand 10 before | Expand all | Expand 10 after
12969 nonFields.add(node); 12977 nonFields.add(node);
12970 return null; 12978 return null;
12971 } 12979 }
12972 12980
12973 @override 12981 @override
12974 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 12982 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
12975 12983
12976 @override 12984 @override
12977 Object visitWithClause(WithClause node) => null; 12985 Object visitWithClause(WithClause node) => null;
12978 } 12986 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/tool/task_dependency_graph/tasks.dot » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698