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

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

Issue 2365553004: Convert subclasses of Enum (Closed)
Patch Set: Created 4 years, 3 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.generated.utilities_dart; 5 library analyzer.src.generated.utilities_dart;
6 6
7 import 'package:analyzer/dart/ast/ast.dart' show AnnotatedNode, Comment; 7 import 'package:analyzer/dart/ast/ast.dart' show AnnotatedNode, Comment;
8 import 'package:analyzer/dart/ast/token.dart' show Token; 8 import 'package:analyzer/dart/ast/token.dart' show Token;
9 import 'package:analyzer/exception/exception.dart'; 9 import 'package:analyzer/exception/exception.dart';
10 import 'package:analyzer/src/dart/element/element.dart' show ElementImpl; 10 import 'package:analyzer/src/dart/element/element.dart' show ElementImpl;
11 import 'package:analyzer/src/generated/java_core.dart';
12 import 'package:analyzer/src/generated/source.dart'; 11 import 'package:analyzer/src/generated/source.dart';
13 import 'package:analyzer/src/util/fast_uri.dart'; 12 import 'package:analyzer/src/util/fast_uri.dart';
14 13
15 /** 14 /**
16 * Resolve the [containedUri] against [baseUri] using Dart rules. 15 * Resolve the [containedUri] against [baseUri] using Dart rules.
17 * 16 *
18 * This function behaves similarly to [Uri.resolveUri], except that it properly 17 * This function behaves similarly to [Uri.resolveUri], except that it properly
19 * handles situations like the following: 18 * handles situations like the following:
20 * 19 *
21 * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart 20 * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 75
77 for (int i = 0; i < uri2Segments.length; ++i) { 76 for (int i = 0; i < uri2Segments.length; ++i) {
78 if (uri2Segments[i] != uri1Segments[i]) { 77 if (uri2Segments[i] != uri1Segments[i]) {
79 return false; 78 return false;
80 } 79 }
81 } 80 }
82 return true; 81 return true;
83 } 82 }
84 83
85 /** 84 /**
86 * The enumeration `ParameterKind` defines the different kinds of parameters. Th ere are two 85 * The kinds of a parameter. There are two basic kinds of parameters: required
87 * basic kinds of parameters: required and optional. Optional parameters are fur ther divided into 86 * and optional. Optional parameters are further divided into two kinds:
88 * two kinds: positional optional and named optional. 87 * positional optional and named optional.
89 */ 88 */
90 class ParameterKind extends Enum<ParameterKind> { 89 class ParameterKind implements Comparable<ParameterKind> {
91 static const ParameterKind REQUIRED = 90 static const ParameterKind REQUIRED =
92 const ParameterKind('REQUIRED', 0, false); 91 const ParameterKind('REQUIRED', 0, false);
93 92
94 static const ParameterKind POSITIONAL = 93 static const ParameterKind POSITIONAL =
95 const ParameterKind('POSITIONAL', 1, true); 94 const ParameterKind('POSITIONAL', 1, true);
96 95
97 static const ParameterKind NAMED = const ParameterKind('NAMED', 2, true); 96 static const ParameterKind NAMED = const ParameterKind('NAMED', 2, true);
98 97
99 static const List<ParameterKind> values = const [REQUIRED, POSITIONAL, NAMED]; 98 static const List<ParameterKind> values = const [REQUIRED, POSITIONAL, NAMED];
100 99
101 /** 100 /**
101 * The name of this parameter.
102 */
103 final String name;
104
105 /**
106 * The ordinal value of the parameter.
107 */
108 final int ordinal;
109
110 /**
102 * A flag indicating whether this is an optional parameter. 111 * A flag indicating whether this is an optional parameter.
103 */ 112 */
104 final bool isOptional; 113 final bool isOptional;
105 114
106 /** 115 /**
107 * Initialize a newly created kind with the given state. 116 * Initialize a newly created kind with the given state.
108 *
109 * @param isOptional `true` if this is an optional parameter
110 */ 117 */
111 const ParameterKind(String name, int ordinal, this.isOptional) 118 const ParameterKind(this.name, this.ordinal, this.isOptional);
112 : super(name, ordinal); 119
120 @override
121 int get hashCode => ordinal;
122
123 @override
124 int compareTo(ParameterKind other) => ordinal - other.ordinal;
125
126 @override
127 String toString() => name;
113 } 128 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/utilities_collection.dart ('k') | pkg/analyzer/test/enum_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698