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

Side by Side Diff: lib/src/utils.dart

Issue 1401273002: Move DDC to analyzer-based checker (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebase Created 5 years, 2 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 | « lib/src/server/server.dart ('k') | lib/strong_mode.dart » ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Holds a couple utility functions used at various places in the system. 5 /// Holds a couple utility functions used at various places in the system.
6 library dev_compiler.src.utils; 6 library dev_compiler.src.utils;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 /// inDeclarationContext, this method returns true if [node] is used in an 373 /// inDeclarationContext, this method returns true if [node] is used in an
374 /// invocation context such as a MethodInvocation. 374 /// invocation context such as a MethodInvocation.
375 bool inInvocationContext(SimpleIdentifier node) { 375 bool inInvocationContext(SimpleIdentifier node) {
376 var parent = node.parent; 376 var parent = node.parent;
377 return parent is MethodInvocation && parent.methodName == node; 377 return parent is MethodInvocation && parent.methodName == node;
378 } 378 }
379 379
380 // TODO(vsm): Move this onto the appropriate class. Ideally, we'd attach 380 // TODO(vsm): Move this onto the appropriate class. Ideally, we'd attach
381 // it to TypeProvider. 381 // it to TypeProvider.
382 382
383 final _objectMap = new Expando('providerToObjectMap');
384 Map<String, DartType> getObjectMemberMap(TypeProvider typeProvider) {
385 var map = _objectMap[typeProvider] as Map<String, DartType>;
386 if (map == null) {
387 map = <String, DartType>{};
388 _objectMap[typeProvider] = map;
389 var objectType = typeProvider.objectType;
390 var element = objectType.element;
391 // Only record methods (including getters) with no parameters. As parameter s are contravariant wrt
392 // type, using Object's version may be too strict.
393 // Add instance methods.
394 element.methods.where((method) => !method.isStatic).forEach((method) {
395 map[method.name] = method.type;
396 });
397 // Add getters.
398 element.accessors
399 .where((member) => !member.isStatic && member.isGetter)
400 .forEach((member) {
401 map[member.name] = member.type.returnType;
402 });
403 }
404 return map;
405 }
406
407 /// Searches all supertype, in order of most derived members, to see if any 383 /// Searches all supertype, in order of most derived members, to see if any
408 /// [match] a condition. If so, returns the first match, otherwise returns null. 384 /// [match] a condition. If so, returns the first match, otherwise returns null.
409 InterfaceType findSupertype(InterfaceType type, bool match(InterfaceType t)) { 385 InterfaceType findSupertype(InterfaceType type, bool match(InterfaceType t)) {
410 for (var m in type.mixins.reversed) { 386 for (var m in type.mixins.reversed) {
411 if (match(m)) return m; 387 if (match(m)) return m;
412 } 388 }
413 var s = type.superclass; 389 var s = type.superclass;
414 if (s == null) return null; 390 if (s == null) return null;
415 391
416 if (match(s)) return type; 392 if (match(s)) return type;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 425 }
450 } 426 }
451 427
452 bool isInlineJS(Element e) => e is FunctionElement && 428 bool isInlineJS(Element e) => e is FunctionElement &&
453 e.library.source.uri.toString() == 'dart:_foreign_helper' && 429 e.library.source.uri.toString() == 'dart:_foreign_helper' &&
454 e.name == 'JS'; 430 e.name == 'JS';
455 431
456 bool isDartMathMinMax(Element e) => e is FunctionElement && 432 bool isDartMathMinMax(Element e) => e is FunctionElement &&
457 e.library.source.uri.toString() == 'dart:math' && 433 e.library.source.uri.toString() == 'dart:math' &&
458 (e.name == 'min' || e.name == 'max'); 434 (e.name == 'min' || e.name == 'max');
OLDNEW
« no previous file with comments | « lib/src/server/server.dart ('k') | lib/strong_mode.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698