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

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

Issue 680913002: Remove JavaIterator and MapEntry (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.constant; 8 library engine.constant;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 unit.accept(_constantFinder); 371 unit.accept(_constantFinder);
372 } 372 }
373 373
374 /** 374 /**
375 * Compute values for all of the constants in the compilation units that were added. 375 * Compute values for all of the constants in the compilation units that were added.
376 */ 376 */
377 void computeValues() { 377 void computeValues() {
378 _variableDeclarationMap = _constantFinder.variableMap; 378 _variableDeclarationMap = _constantFinder.variableMap;
379 constructorDeclarationMap = _constantFinder.constructorMap; 379 constructorDeclarationMap = _constantFinder.constructorMap;
380 _constructorInvocations = _constantFinder.constructorInvocations; 380 _constructorInvocations = _constantFinder.constructorInvocations;
381 for (MapEntry<VariableElement, VariableDeclaration> entry in getMapEntrySet( _variableDeclarationMap)) { 381 _variableDeclarationMap.values.forEach((VariableDeclaration declaration) {
382 VariableDeclaration declaration = entry.getValue();
383 ReferenceFinder referenceFinder = new ReferenceFinder(declaration, referen ceGraph, _variableDeclarationMap, constructorDeclarationMap); 382 ReferenceFinder referenceFinder = new ReferenceFinder(declaration, referen ceGraph, _variableDeclarationMap, constructorDeclarationMap);
384 referenceGraph.addNode(declaration); 383 referenceGraph.addNode(declaration);
385 declaration.initializer.accept(referenceFinder); 384 declaration.initializer.accept(referenceFinder);
386 } 385 });
387 for (MapEntry<ConstructorElement, ConstructorDeclaration> entry in getMapEnt rySet(constructorDeclarationMap)) { 386 constructorDeclarationMap.forEach((ConstructorElement element, ConstructorDe claration declaration) {
388 ConstructorDeclaration declaration = entry.getValue();
389 ReferenceFinder referenceFinder = new ReferenceFinder(declaration, referen ceGraph, _variableDeclarationMap, constructorDeclarationMap); 387 ReferenceFinder referenceFinder = new ReferenceFinder(declaration, referen ceGraph, _variableDeclarationMap, constructorDeclarationMap);
390 referenceGraph.addNode(declaration); 388 referenceGraph.addNode(declaration);
391 bool superInvocationFound = false; 389 bool superInvocationFound = false;
392 NodeList<ConstructorInitializer> initializers = declaration.initializers; 390 NodeList<ConstructorInitializer> initializers = declaration.initializers;
393 for (ConstructorInitializer initializer in initializers) { 391 for (ConstructorInitializer initializer in initializers) {
394 if (initializer is SuperConstructorInvocation) { 392 if (initializer is SuperConstructorInvocation) {
395 superInvocationFound = true; 393 superInvocationFound = true;
396 } 394 }
397 initializer.accept(referenceFinder); 395 initializer.accept(referenceFinder);
398 } 396 }
399 if (!superInvocationFound) { 397 if (!superInvocationFound) {
400 // No explicit superconstructor invocation found, so we need to manually insert 398 // No explicit superconstructor invocation found, so we need to manually insert
401 // a reference to the implicit superconstructor. 399 // a reference to the implicit superconstructor.
402 InterfaceType superclass = (entry.getKey().returnType as InterfaceType). superclass; 400 InterfaceType superclass = (element.returnType as InterfaceType).supercl ass;
403 if (superclass != null && !superclass.isObject) { 401 if (superclass != null && !superclass.isObject) {
404 ConstructorElement unnamedConstructor = superclass.element.unnamedCons tructor; 402 ConstructorElement unnamedConstructor = superclass.element.unnamedCons tructor;
405 ConstructorDeclaration superConstructorDeclaration = findConstructorDe claration(unnamedConstructor); 403 ConstructorDeclaration superConstructorDeclaration = findConstructorDe claration(unnamedConstructor);
406 if (superConstructorDeclaration != null) { 404 if (superConstructorDeclaration != null) {
407 referenceGraph.addEdge(declaration, superConstructorDeclaration); 405 referenceGraph.addEdge(declaration, superConstructorDeclaration);
408 } 406 }
409 } 407 }
410 } 408 }
411 for (FormalParameter parameter in declaration.parameters.parameters) { 409 for (FormalParameter parameter in declaration.parameters.parameters) {
412 referenceGraph.addNode(parameter); 410 referenceGraph.addNode(parameter);
413 referenceGraph.addEdge(declaration, parameter); 411 referenceGraph.addEdge(declaration, parameter);
414 if (parameter is DefaultFormalParameter) { 412 if (parameter is DefaultFormalParameter) {
415 Expression defaultValue = parameter.defaultValue; 413 Expression defaultValue = parameter.defaultValue;
416 if (defaultValue != null) { 414 if (defaultValue != null) {
417 ReferenceFinder parameterReferenceFinder = new ReferenceFinder(param eter, referenceGraph, _variableDeclarationMap, constructorDeclarationMap); 415 ReferenceFinder parameterReferenceFinder = new ReferenceFinder(param eter, referenceGraph, _variableDeclarationMap, constructorDeclarationMap);
418 defaultValue.accept(parameterReferenceFinder); 416 defaultValue.accept(parameterReferenceFinder);
419 } 417 }
420 } 418 }
421 } 419 }
422 } 420 });
423 for (InstanceCreationExpression expression in _constructorInvocations) { 421 for (InstanceCreationExpression expression in _constructorInvocations) {
424 referenceGraph.addNode(expression); 422 referenceGraph.addNode(expression);
425 ConstructorElement constructor = expression.staticElement; 423 ConstructorElement constructor = expression.staticElement;
426 if (constructor == null) { 424 if (constructor == null) {
427 continue; 425 continue;
428 } 426 }
429 constructor = _followConstantRedirectionChain(constructor); 427 constructor = _followConstantRedirectionChain(constructor);
430 ConstructorDeclaration declaration = findConstructorDeclaration(constructo r); 428 ConstructorDeclaration declaration = findConstructorDeclaration(constructo r);
431 // An instance creation expression depends both on the constructor and the arguments passed 429 // An instance creation expression depends both on the constructor and the arguments passed
432 // to it. 430 // to it.
(...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after
4181 if (object is! MapState) { 4179 if (object is! MapState) {
4182 return false; 4180 return false;
4183 } 4181 }
4184 HashMap<DartObjectImpl, DartObjectImpl> otherElements = (object as MapState) ._entries; 4182 HashMap<DartObjectImpl, DartObjectImpl> otherElements = (object as MapState) ._entries;
4185 int count = _entries.length; 4183 int count = _entries.length;
4186 if (otherElements.length != count) { 4184 if (otherElements.length != count) {
4187 return false; 4185 return false;
4188 } else if (count == 0) { 4186 } else if (count == 0) {
4189 return true; 4187 return true;
4190 } 4188 }
4191 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri es)) { 4189 for (DartObjectImpl key in _entries.keys) {
4192 DartObjectImpl key = entry.getKey(); 4190 DartObjectImpl value = _entries[key];
4193 DartObjectImpl value = entry.getValue();
4194 DartObjectImpl otherValue = otherElements[key]; 4191 DartObjectImpl otherValue = otherElements[key];
4195 if (value != otherValue) { 4192 if (value != otherValue) {
4196 return false; 4193 return false;
4197 } 4194 }
4198 } 4195 }
4199 return true; 4196 return true;
4200 } 4197 }
4201 4198
4202 @override 4199 @override
4203 String get typeName => "Map"; 4200 String get typeName => "Map";
4204 4201
4205 @override 4202 @override
4206 Map<Object, Object> get value { 4203 Map<Object, Object> get value {
4207 HashMap<Object, Object> result = new HashMap<Object, Object>(); 4204 HashMap<Object, Object> result = new HashMap<Object, Object>();
4208 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri es)) { 4205 for (DartObjectImpl key in _entries.keys) {
4209 DartObjectImpl key = entry.getKey(); 4206 DartObjectImpl value = _entries[key];
4210 DartObjectImpl value = entry.getValue();
4211 if (!key.hasExactValue || !value.hasExactValue) { 4207 if (!key.hasExactValue || !value.hasExactValue) {
4212 return null; 4208 return null;
4213 } 4209 }
4214 result[key.value] = value.value; 4210 result[key.value] = value.value;
4215 } 4211 }
4216 return result; 4212 return result;
4217 } 4213 }
4218 4214
4219 @override 4215 @override
4220 bool get hasExactValue { 4216 bool get hasExactValue {
4221 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri es)) { 4217 for (DartObjectImpl key in _entries.keys) {
4222 if (!entry.getKey().hasExactValue || !entry.getValue().hasExactValue) { 4218 if (!key.hasExactValue || !_entries[key].hasExactValue) {
4223 return false; 4219 return false;
4224 } 4220 }
4225 } 4221 }
4226 return true; 4222 return true;
4227 } 4223 }
4228 4224
4229 @override 4225 @override
4230 int get hashCode { 4226 int get hashCode {
4231 int value = 0; 4227 int value = 0;
4232 for (DartObjectImpl key in _entries.keys.toSet()) { 4228 for (DartObjectImpl key in _entries.keys.toSet()) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 4690
4695 @override 4691 @override
4696 String get typeName => "Type"; 4692 String get typeName => "Type";
4697 4693
4698 @override 4694 @override
4699 int get hashCode => _element == null ? 0 : _element.hashCode; 4695 int get hashCode => _element == null ? 0 : _element.hashCode;
4700 4696
4701 @override 4697 @override
4702 String toString() => _element == null ? "-unknown-" : _element.name; 4698 String toString() => _element == null ? "-unknown-" : _element.name;
4703 } 4699 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | pkg/analyzer/lib/src/generated/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698