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

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

Issue 2365553004: Convert subclasses of Enum (Closed)
Patch Set: Created 4 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 | « pkg/analyzer/lib/error/error.dart ('k') | pkg/analyzer/lib/src/generated/engine.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) 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';
11 import 'package:analyzer/dart/ast/token.dart'; 11 import 'package:analyzer/dart/ast/token.dart';
12 import 'package:analyzer/dart/constant/value.dart'; 12 import 'package:analyzer/dart/constant/value.dart';
13 import 'package:analyzer/dart/element/element.dart'; 13 import 'package:analyzer/dart/element/element.dart';
14 import 'package:analyzer/dart/element/type.dart'; 14 import 'package:analyzer/dart/element/type.dart';
15 import 'package:analyzer/dart/element/visitor.dart'; 15 import 'package:analyzer/dart/element/visitor.dart';
16 import 'package:analyzer/src/dart/ast/utilities.dart'; 16 import 'package:analyzer/src/dart/ast/utilities.dart';
17 import 'package:analyzer/src/dart/constant/value.dart'; 17 import 'package:analyzer/src/dart/constant/value.dart';
18 import 'package:analyzer/src/dart/element/handle.dart'; 18 import 'package:analyzer/src/dart/element/handle.dart';
19 import 'package:analyzer/src/dart/element/type.dart'; 19 import 'package:analyzer/src/dart/element/type.dart';
20 import 'package:analyzer/src/error/codes.dart' show CompileTimeErrorCode; 20 import 'package:analyzer/src/error/codes.dart' show CompileTimeErrorCode;
21 import 'package:analyzer/src/generated/constant.dart' show EvaluationResultImpl; 21 import 'package:analyzer/src/generated/constant.dart' show EvaluationResultImpl;
22 import 'package:analyzer/src/generated/engine.dart' 22 import 'package:analyzer/src/generated/engine.dart'
23 show AnalysisContext, AnalysisEngine; 23 show AnalysisContext, AnalysisEngine;
24 import 'package:analyzer/src/generated/java_core.dart';
25 import 'package:analyzer/src/generated/java_engine.dart'; 24 import 'package:analyzer/src/generated/java_engine.dart';
26 import 'package:analyzer/src/generated/resolver.dart'; 25 import 'package:analyzer/src/generated/resolver.dart';
27 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 26 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
28 import 'package:analyzer/src/generated/source.dart'; 27 import 'package:analyzer/src/generated/source.dart';
29 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 28 import 'package:analyzer/src/generated/testing/ast_factory.dart';
30 import 'package:analyzer/src/generated/utilities_collection.dart'; 29 import 'package:analyzer/src/generated/utilities_collection.dart';
31 import 'package:analyzer/src/generated/utilities_dart.dart'; 30 import 'package:analyzer/src/generated/utilities_dart.dart';
32 import 'package:analyzer/src/generated/utilities_general.dart'; 31 import 'package:analyzer/src/generated/utilities_general.dart';
33 import 'package:analyzer/src/summary/idl.dart'; 32 import 'package:analyzer/src/summary/idl.dart';
34 import 'package:analyzer/src/task/dart.dart'; 33 import 'package:analyzer/src/task/dart.dart';
(...skipping 3032 matching lines...) Expand 10 before | Expand all | Expand 10 after
3067 if (node == null) { 3066 if (node == null) {
3068 return null; 3067 return null;
3069 } 3068 }
3070 return node.getAncestor(predicate); 3069 return node.getAncestor(predicate);
3071 } 3070 }
3072 3071
3073 /** 3072 /**
3074 * Return `true` if this element has the given [modifier] associated with it. 3073 * Return `true` if this element has the given [modifier] associated with it.
3075 */ 3074 */
3076 bool hasModifier(Modifier modifier) => 3075 bool hasModifier(Modifier modifier) =>
3077 BooleanArray.getEnum(_modifiers, modifier); 3076 BooleanArray.get(_modifiers, modifier.ordinal);
3078 3077
3079 @override 3078 @override
3080 bool isAccessibleIn(LibraryElement library) { 3079 bool isAccessibleIn(LibraryElement library) {
3081 if (Identifier.isPrivateName(name)) { 3080 if (Identifier.isPrivateName(name)) {
3082 return library == this.library; 3081 return library == this.library;
3083 } 3082 }
3084 return true; 3083 return true;
3085 } 3084 }
3086 3085
3087 /** 3086 /**
(...skipping 14 matching lines...) Expand all
3102 assert(!isResynthesized); 3101 assert(!isResynthesized);
3103 _codeOffset = offset; 3102 _codeOffset = offset;
3104 _codeLength = length; 3103 _codeLength = length;
3105 } 3104 }
3106 3105
3107 /** 3106 /**
3108 * Set whether the given [modifier] is associated with this element to 3107 * Set whether the given [modifier] is associated with this element to
3109 * correspond to the given [value]. 3108 * correspond to the given [value].
3110 */ 3109 */
3111 void setModifier(Modifier modifier, bool value) { 3110 void setModifier(Modifier modifier, bool value) {
3112 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); 3111 _modifiers = BooleanArray.set(_modifiers, modifier.ordinal, value);
3113 } 3112 }
3114 3113
3115 @override 3114 @override
3116 String toString() { 3115 String toString() {
3117 StringBuffer buffer = new StringBuffer(); 3116 StringBuffer buffer = new StringBuffer();
3118 appendTo(buffer); 3117 appendTo(buffer);
3119 return buffer.toString(); 3118 return buffer.toString();
3120 } 3119 }
3121 3120
3122 @override 3121 @override
(...skipping 3049 matching lines...) Expand 10 before | Expand all | Expand 10 after
6172 buffer.write(displayName); 6171 buffer.write(displayName);
6173 super.appendTo(buffer); 6172 super.appendTo(buffer);
6174 } 6173 }
6175 6174
6176 @override 6175 @override
6177 MethodDeclaration computeNode() => 6176 MethodDeclaration computeNode() =>
6178 getNodeMatching((node) => node is MethodDeclaration); 6177 getNodeMatching((node) => node is MethodDeclaration);
6179 } 6178 }
6180 6179
6181 /** 6180 /**
6182 * The enumeration `Modifier` defines constants for all of the modifiers defined 6181 * The constants for all of the modifiers defined by the Dart language and for a
6183 * by the Dart language and for a few additional flags that are useful. 6182 * few additional flags that are useful.
6184 * 6183 *
6185 * Clients may not extend, implement or mix-in this class. 6184 * Clients may not extend, implement or mix-in this class.
6186 */ 6185 */
6187 class Modifier extends Enum<Modifier> { 6186 class Modifier implements Comparable<Modifier> {
6188 /** 6187 /**
6189 * Indicates that the modifier 'abstract' was applied to the element. 6188 * Indicates that the modifier 'abstract' was applied to the element.
6190 */ 6189 */
6191 static const Modifier ABSTRACT = const Modifier('ABSTRACT', 0); 6190 static const Modifier ABSTRACT = const Modifier('ABSTRACT', 0);
6192 6191
6193 /** 6192 /**
6194 * Indicates that an executable element has a body marked as being 6193 * Indicates that an executable element has a body marked as being
6195 * asynchronous. 6194 * asynchronous.
6196 */ 6195 */
6197 static const Modifier ASYNCHRONOUS = const Modifier('ASYNCHRONOUS', 1); 6196 static const Modifier ASYNCHRONOUS = const Modifier('ASYNCHRONOUS', 1);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
6294 GETTER, 6293 GETTER,
6295 HAS_EXT_URI, 6294 HAS_EXT_URI,
6296 IMPLICIT_TYPE, 6295 IMPLICIT_TYPE,
6297 MIXIN_APPLICATION, 6296 MIXIN_APPLICATION,
6298 REFERENCES_SUPER, 6297 REFERENCES_SUPER,
6299 SETTER, 6298 SETTER,
6300 STATIC, 6299 STATIC,
6301 SYNTHETIC 6300 SYNTHETIC
6302 ]; 6301 ];
6303 6302
6304 const Modifier(String name, int ordinal) : super(name, ordinal); 6303 /**
6304 * The name of this modifier.
6305 */
6306 final String name;
6307
6308 /**
6309 * The ordinal value of the modifier.
6310 */
6311 final int ordinal;
6312
6313 const Modifier(this.name, this.ordinal);
6314
6315 @override
6316 int get hashCode => ordinal;
6317
6318 @override
6319 int compareTo(Modifier other) => ordinal - other.ordinal;
6320
6321 @override
6322 String toString() => name;
6305 } 6323 }
6306 6324
6307 /** 6325 /**
6308 * A concrete implementation of a [MultiplyDefinedElement]. 6326 * A concrete implementation of a [MultiplyDefinedElement].
6309 */ 6327 */
6310 class MultiplyDefinedElementImpl implements MultiplyDefinedElement { 6328 class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
6311 /** 6329 /**
6312 * The unique integer identifier of this element. 6330 * The unique integer identifier of this element.
6313 */ 6331 */
6314 final int id = ElementImpl._NEXT_ID++; 6332 final int id = ElementImpl._NEXT_ID++;
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after
8415 8433
8416 @override 8434 @override
8417 void visitElement(Element element) { 8435 void visitElement(Element element) {
8418 int offset = element.nameOffset; 8436 int offset = element.nameOffset;
8419 if (offset != -1) { 8437 if (offset != -1) {
8420 map[offset] = element; 8438 map[offset] = element;
8421 } 8439 }
8422 super.visitElement(element); 8440 super.visitElement(element);
8423 } 8441 }
8424 } 8442 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/error/error.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698