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

Side by Side Diff: pkg/analysis_server/lib/src/services/correction/namespace.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: 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 services.src.correction.namespace; 5 library services.src.correction.namespace;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/src/dart/resolver/scope.dart'; 9 import 'package:analyzer/src/dart/resolver/scope.dart';
10 10
(...skipping 19 matching lines...) Expand all
30 /** 30 /**
31 * Returns the export namespace of the given [LibraryElement]. 31 * Returns the export namespace of the given [LibraryElement].
32 */ 32 */
33 Map<String, Element> getExportNamespaceForLibrary(LibraryElement library) { 33 Map<String, Element> getExportNamespaceForLibrary(LibraryElement library) {
34 Namespace namespace = 34 Namespace namespace =
35 new NamespaceBuilder().createExportNamespaceForLibrary(library); 35 new NamespaceBuilder().createExportNamespaceForLibrary(library);
36 return namespace.definedNames; 36 return namespace.definedNames;
37 } 37 }
38 38
39 /** 39 /**
40 * Returns the [ImportElement] that is referenced by [prefixNode] with 40 * Return the [ImportElement] that is referenced by [prefixNode], or `null` if
41 * an [PrefixElement], maybe `null`. 41 * the node does not reference a prefix or if we cannot determine which import
42 * is being referenced.
42 */ 43 */
43 ImportElement getImportElement(SimpleIdentifier prefixNode) { 44 ImportElement getImportElement(SimpleIdentifier prefixNode) {
44 if (prefixNode.parent is ImportDirective) { 45 AstNode parent = prefixNode.parent;
45 ImportDirective importDirective = prefixNode.parent; 46 if (parent is ImportDirective) {
46 return importDirective.element; 47 return parent.element;
47 } 48 }
48 ImportElementInfo info = internal_getImportElementInfo(prefixNode); 49 ImportElementInfo info = internal_getImportElementInfo(prefixNode);
49 return info?.element; 50 return info?.element;
50 } 51 }
51 52
52 /** 53 /**
53 * Return the [ImportElement] that declared [prefix] and imports [element]. 54 * Return the [ImportElement] that declared [prefix] and imports [element].
54 * 55 *
55 * [libraryElement] - the [LibraryElement] where reference is. 56 * [libraryElement] - the [LibraryElement] where reference is.
56 * [prefix] - the import prefix, maybe `null`. 57 * [prefix] - the import prefix, maybe `null`.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 174 }
174 175
175 /** 176 /**
176 * Information about [ImportElement] and place where it is referenced using 177 * Information about [ImportElement] and place where it is referenced using
177 * [PrefixElement]. 178 * [PrefixElement].
178 */ 179 */
179 class ImportElementInfo { 180 class ImportElementInfo {
180 ImportElement element; 181 ImportElement element;
181 int periodEnd; 182 int periodEnd;
182 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698