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

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

Issue 1000873002: Deprecate utility method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/java_core.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) 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 engine.resolver; 5 library engine.resolver;
6 6
7 import "dart:math" as math; 7 import "dart:math" as math;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/generated/utilities_collection.dart'; 10 import 'package:analyzer/src/generated/utilities_collection.dart';
(...skipping 7470 matching lines...) Expand 10 before | Expand all | Expand 10 after
7481 buffer.write(StringUtilities.printListOfQuotedNames(indirectSources)); 7481 buffer.write(StringUtilities.printListOfQuotedNames(indirectSources));
7482 } else { 7482 } else {
7483 buffer.write(indirectSources[0]); 7483 buffer.write(indirectSources[0]);
7484 } 7484 }
7485 buffer.write(")"); 7485 buffer.write(")");
7486 } 7486 }
7487 return buffer.toString(); 7487 return buffer.toString();
7488 } 7488 }
7489 7489
7490 /** 7490 /**
7491 * Given a collection of elements that a single name could all be mapped to, r emove from the list 7491 * Given a collection of elements (captured by the [foundElement]) that the
7492 * all of the names defined in the SDK. Return the element(s) that remain. 7492 * [identifier] (with the given [name]) resolved to, remove from the list all
7493 * 7493 * of the names defined in the SDK and return the element(s) that remain.
7494 * @param identifier the identifier node to lookup element for, used to report correct kind of a
7495 * problem and associate problem with
7496 * @param name the name associated with the element
7497 * @param foundElement the element encapsulating the collection of elements
7498 * @return all of the elements that are not defined in the SDK
7499 */ 7494 */
7500 Element _removeSdkElements(Identifier identifier, String name, 7495 Element _removeSdkElements(Identifier identifier, String name,
7501 MultiplyDefinedElementImpl foundElement) { 7496 MultiplyDefinedElementImpl foundElement) {
7502 List<Element> conflictingMembers = foundElement.conflictingElements; 7497 List<Element> conflictingElements = foundElement.conflictingElements;
7503 int length = conflictingMembers.length; 7498 List<Element> nonSdkElements = new List<Element>();
7504 int to = 0;
7505 Element sdkElement = null; 7499 Element sdkElement = null;
7506 for (Element member in conflictingMembers) { 7500 for (Element member in conflictingElements) {
7507 if (member.library.isInSdk) { 7501 if (member.library.isInSdk) {
7508 sdkElement = member; 7502 sdkElement = member;
7509 } else { 7503 } else {
7510 conflictingMembers[to++] = member; 7504 nonSdkElements.add(member);
7511 } 7505 }
7512 } 7506 }
7513 if (sdkElement != null && to > 0) { 7507 if (sdkElement != null && nonSdkElements.length > 0) {
7514 String sdkLibName = _getLibraryName(sdkElement); 7508 String sdkLibName = _getLibraryName(sdkElement);
7515 String otherLibName = _getLibraryName(conflictingMembers[0]); 7509 String otherLibName = _getLibraryName(nonSdkElements[0]);
7516 errorListener.onError(new AnalysisError.con2(getSource(identifier), 7510 errorListener.onError(new AnalysisError.con2(getSource(identifier),
7517 identifier.offset, identifier.length, 7511 identifier.offset, identifier.length,
7518 StaticWarningCode.CONFLICTING_DART_IMPORT, [ 7512 StaticWarningCode.CONFLICTING_DART_IMPORT, [
7519 name, 7513 name,
7520 sdkLibName, 7514 sdkLibName,
7521 otherLibName 7515 otherLibName
7522 ])); 7516 ]));
7523 } 7517 }
7524 if (to == length) { 7518 if (nonSdkElements.length == conflictingElements.length) {
7525 // None of the members were removed 7519 // None of the members were removed
7526 return foundElement; 7520 return foundElement;
7527 } else if (to == 1) { 7521 } else if (nonSdkElements.length == 1) {
7528 // All but one member was removed 7522 // All but one member was removed
7529 return conflictingMembers[0]; 7523 return nonSdkElements[0];
7530 } else if (to == 0) { 7524 } else if (nonSdkElements.length == 0) {
7531 // All members were removed 7525 // All members were removed
7532 AnalysisEngine.instance.logger 7526 AnalysisEngine.instance.logger
7533 .logInformation("Multiply defined SDK element: $foundElement"); 7527 .logInformation("Multiply defined SDK element: $foundElement");
7534 return foundElement; 7528 return foundElement;
7535 } 7529 }
7536 List<Element> remaining = new List<Element>(to); 7530 return new MultiplyDefinedElementImpl(
7537 JavaSystem.arraycopy(conflictingMembers, 0, remaining, 0, to); 7531 _definingLibrary.context, nonSdkElements);
7538 return new MultiplyDefinedElementImpl(_definingLibrary.context, remaining);
7539 } 7532 }
7540 } 7533 }
7541 7534
7542 /** 7535 /**
7543 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent 7536 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent
7544 * libraries within a single context. 7537 * libraries within a single context.
7545 */ 7538 */
7546 class LibraryResolver { 7539 class LibraryResolver {
7547 /** 7540 /**
7548 * The analysis context in which the libraries are being analyzed. 7541 * The analysis context in which the libraries are being analyzed.
(...skipping 7851 matching lines...) Expand 10 before | Expand all | Expand 10 after
15400 * library. 15393 * library.
15401 */ 15394 */
15402 final HashSet<String> members = new HashSet<String>(); 15395 final HashSet<String> members = new HashSet<String>();
15403 15396
15404 /** 15397 /**
15405 * Names of resolved or unresolved class members that are read in the 15398 * Names of resolved or unresolved class members that are read in the
15406 * library. 15399 * library.
15407 */ 15400 */
15408 final HashSet<String> readMembers = new HashSet<String>(); 15401 final HashSet<String> readMembers = new HashSet<String>();
15409 } 15402 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/java_core.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698