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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 1918923003: Remove unnecessary casts and general code clean-up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: clean-up Created 4 years, 7 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 analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 if (element is ConstructorElement) { 1711 if (element is ConstructorElement) {
1712 return element.enclosingElement.name == _DEPRECATED_CLASS_NAME; 1712 return element.enclosingElement.name == _DEPRECATED_CLASS_NAME;
1713 } else if (element is PropertyAccessorElement) { 1713 } else if (element is PropertyAccessorElement) {
1714 return element.name == _DEPRECATED_VARIABLE_NAME; 1714 return element.name == _DEPRECATED_VARIABLE_NAME;
1715 } 1715 }
1716 } 1716 }
1717 return false; 1717 return false;
1718 } 1718 }
1719 1719
1720 @override 1720 @override
1721 bool get isJS => element is ConstructorElement && 1721 bool get isJS =>
1722 element.enclosingElement.name == _JS_CLASS_NAME && 1722 element is ConstructorElement &&
1723 element.library?.name == _JS_LIB_NAME; 1723 element.enclosingElement.name == _JS_CLASS_NAME &&
1724 element.library?.name == _JS_LIB_NAME;
1724 1725
1725 @override 1726 @override
1726 bool get isMustCallSuper => 1727 bool get isMustCallSuper =>
1727 element is PropertyAccessorElement && 1728 element is PropertyAccessorElement &&
1728 element.name == _MUST_CALL_SUPER_VARIABLE_NAME && 1729 element.name == _MUST_CALL_SUPER_VARIABLE_NAME &&
1729 element.library?.name == _META_LIB_NAME; 1730 element.library?.name == _META_LIB_NAME;
1730 1731
1731 @override 1732 @override
1732 bool get isOverride => 1733 bool get isOverride =>
1733 element is PropertyAccessorElement && 1734 element is PropertyAccessorElement &&
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
3276 /** 3277 /**
3277 * Initialize a newly created library element in the given [context] to have 3278 * Initialize a newly created library element in the given [context] to have
3278 * the given [name]. 3279 * the given [name].
3279 */ 3280 */
3280 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) 3281 LibraryElementImpl.forNode(this.context, LibraryIdentifier name)
3281 : nameLength = name != null ? name.length : 0, 3282 : nameLength = name != null ? name.length : 0,
3282 super.forNode(name); 3283 super.forNode(name);
3283 3284
3284 @override 3285 @override
3285 int get codeLength { 3286 int get codeLength {
3286 if (_definingCompilationUnit is CompilationUnitElementImpl) { 3287 CompilationUnitElement unit = _definingCompilationUnit;
3287 return (_definingCompilationUnit as CompilationUnitElementImpl) 3288 if (unit is CompilationUnitElementImpl) {
3288 .codeLength; 3289 return unit.codeLength;
3289 } 3290 }
3290 return null; 3291 return null;
3291 } 3292 }
3292 3293
3293 @override 3294 @override
3294 int get codeOffset { 3295 int get codeOffset {
3295 if (_definingCompilationUnit is CompilationUnitElementImpl) { 3296 CompilationUnitElement unit = _definingCompilationUnit;
3296 return (_definingCompilationUnit as CompilationUnitElementImpl) 3297 if (unit is CompilationUnitElementImpl) {
3297 .codeOffset; 3298 return unit.codeOffset;
3298 } 3299 }
3299 return null; 3300 return null;
3300 } 3301 }
3301 3302
3302 @override 3303 @override
3303 CompilationUnitElement get definingCompilationUnit => 3304 CompilationUnitElement get definingCompilationUnit =>
3304 _definingCompilationUnit; 3305 _definingCompilationUnit;
3305 3306
3306 /** 3307 /**
3307 * Set the compilation unit that defines this library to the given compilation 3308 * Set the compilation unit that defines this library to the given compilation
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3677 // represents a new back edge. It would be sufficient to invalidate the 3678 // represents a new back edge. It would be sufficient to invalidate the
3678 // cycle information for all nodes that are between the target and the 3679 // cycle information for all nodes that are between the target and the
3679 // node in the topological order. For simplicity, we simply invalidate 3680 // node in the topological order. For simplicity, we simply invalidate
3680 // all nodes which are reachable from the the source node. 3681 // all nodes which are reachable from the the source node.
3681 // Note that in the invalidation phase, we do not cut off when we encounter 3682 // Note that in the invalidation phase, we do not cut off when we encounter
3682 // a node with no library cycle information, since we do not know whether 3683 // a node with no library cycle information, since we do not know whether
3683 // we are in the case where invalidation has already been performed, or we 3684 // we are in the case where invalidation has already been performed, or we
3684 // are in the case where library cycles have simply never been computed from 3685 // are in the case where library cycles have simply never been computed from
3685 // a newly reachable node. 3686 // a newly reachable node.
3686 Set<LibraryElementImpl> active = new HashSet(); 3687 Set<LibraryElementImpl> active = new HashSet();
3687 void invalidate(LibraryElement library) { 3688 void invalidate(LibraryElement element) {
3688 if (library is LibraryElementHandle) { 3689 LibraryElementImpl library =
3689 library = (library as LibraryElementHandle).actualElement; 3690 element is LibraryElementHandle ? element.actualElement : element;
3690 } 3691 if (active.add(library)) {
3691 LibraryElementImpl libraryImpl = library; 3692 if (library._libraryCycle != null) {
3692 if (active.add(libraryImpl)) { 3693 library._libraryCycle.forEach(invalidate);
3693 if (libraryImpl._libraryCycle != null) { 3694 library._libraryCycle = null;
3694 libraryImpl._libraryCycle.forEach(invalidate);
3695 libraryImpl._libraryCycle = null;
3696 } 3695 }
3697 library.exportedLibraries.forEach(invalidate); 3696 library.exportedLibraries.forEach(invalidate);
3698 library.importedLibraries.forEach(invalidate); 3697 library.importedLibraries.forEach(invalidate);
3699 } 3698 }
3700 } 3699 }
3701 invalidate(this); 3700 invalidate(this);
3702 } 3701 }
3703 3702
3704 @override 3703 @override
3705 bool isUpToDate(int timeStamp) { 3704 bool isUpToDate(int timeStamp) {
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
4693 super.appendTo(buffer); 4692 super.appendTo(buffer);
4694 } 4693 }
4695 4694
4696 @override 4695 @override
4697 AstNode computeNode() { 4696 AstNode computeNode() {
4698 if (isSynthetic) { 4697 if (isSynthetic) {
4699 return null; 4698 return null;
4700 } 4699 }
4701 if (enclosingElement is ClassElement) { 4700 if (enclosingElement is ClassElement) {
4702 return getNodeMatching((node) => node is MethodDeclaration); 4701 return getNodeMatching((node) => node is MethodDeclaration);
4703 } 4702 } else if (enclosingElement is CompilationUnitElement) {
4704 if (enclosingElement is CompilationUnitElement) {
4705 return getNodeMatching((node) => node is FunctionDeclaration); 4703 return getNodeMatching((node) => node is FunctionDeclaration);
4706 } 4704 }
4707 return null; 4705 return null;
4708 } 4706 }
4709 } 4707 }
4710 4708
4711 /** 4709 /**
4712 * A concrete implementation of a [PropertyInducingElement]. 4710 * A concrete implementation of a [PropertyInducingElement].
4713 */ 4711 */
4714 abstract class PropertyInducingElementImpl extends VariableElementImpl 4712 abstract class PropertyInducingElementImpl extends VariableElementImpl
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
5024 5022
5025 @override 5023 @override
5026 void visitElement(Element element) { 5024 void visitElement(Element element) {
5027 int offset = element.nameOffset; 5025 int offset = element.nameOffset;
5028 if (offset != -1) { 5026 if (offset != -1) {
5029 map[offset] = element; 5027 map[offset] = element;
5030 } 5028 }
5031 super.visitElement(element); 5029 super.visitElement(element);
5032 } 5030 }
5033 } 5031 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/constant/value.dart ('k') | pkg/analyzer/lib/src/dart/resolver/inheritance_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698