22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5+ // The `MatchKind` enum names currently match the names of `SearchResultKind`
6+ // values, including case. This is asserted in `test/protocol_server_test.dart`,
7+ // but it's not clear whether it's actually important.
8+ // ignore_for_file: constant_identifier_names
9+
510import 'package:analyzer/dart/element/element.dart' ;
611import 'package:analyzer/source/source.dart' ;
712import 'package:analyzer/source/source_range.dart' ;
@@ -12,61 +17,47 @@ import 'package:analyzer/src/util/performance/operation_performance.dart';
1217
1318/// Instances of the enum [MatchKind] represent the kind of reference that was
1419/// found when a match represents a reference to an element.
15- class MatchKind {
20+ enum MatchKind {
1621 /// A declaration of an element.
17- static const MatchKind DECLARATION = MatchKind ( 'DECLARATION' );
22+ DECLARATION (),
1823
1924 /// A reference to an element in which it is being read.
20- static const MatchKind READ = MatchKind ( 'READ' );
25+ READ (),
2126
2227 /// A reference to an element in which it is being both read and written.
23- static const MatchKind READ_WRITE = MatchKind ( 'READ_WRITE' );
28+ READ_WRITE (),
2429
2530 /// A reference to an element in which it is being written.
26- static const MatchKind WRITE = MatchKind ( 'WRITE' );
31+ WRITE (),
2732
2833 /// A reference to an element in which it is being invoked.
29- static const MatchKind INVOCATION = MatchKind ( 'INVOCATION' );
34+ INVOCATION (),
3035
3136 /// An invocation of an enum constructor from an enum constant without
3237 /// arguments.
33- static const MatchKind INVOCATION_BY_ENUM_CONSTANT_WITHOUT_ARGUMENTS =
34- MatchKind ('INVOCATION_BY_ENUM_CONSTANT_WITHOUT_ARGUMENTS' );
38+ INVOCATION_BY_ENUM_CONSTANT_WITHOUT_ARGUMENTS (),
3539
3640 /// A reference to an element in which it is referenced.
37- static const MatchKind REFERENCE = MatchKind . reference ( 'REFERENCE' );
41+ REFERENCE (isReference : true ),
3842
3943 /// A tear-off reference to a constructor.
40- static const MatchKind REFERENCE_BY_CONSTRUCTOR_TEAR_OFF =
41- MatchKind .reference ('REFERENCE_BY_CONSTRUCTOR_TEAR_OFF' );
44+ REFERENCE_BY_CONSTRUCTOR_TEAR_OFF (isReference: true ),
4245
4346 /// A reference to an element in an extends clause.
44- static const MatchKind REFERENCE_IN_EXTENDS_CLAUSE = MatchKind .reference (
45- 'REFERENCE_IN_EXTENDS_CLAUSE' ,
46- );
47+ REFERENCE_IN_EXTENDS_CLAUSE (isReference: true ),
4748
4849 /// A reference to an element in an implements clause.
49- static const MatchKind REFERENCE_IN_IMPLEMENTS_CLAUSE = MatchKind .reference (
50- 'REFERENCE_IN_IMPLEMENTS_CLAUSE' ,
51- );
50+ REFERENCE_IN_IMPLEMENTS_CLAUSE (isReference: true ),
5251
5352 /// A reference to an element in a with clause.
54- static const MatchKind REFERENCE_IN_WITH_CLAUSE = MatchKind .reference (
55- 'REFERENCE_IN_WITH_CLAUSE' ,
56- );
53+ REFERENCE_IN_WITH_CLAUSE (isReference: true ),
5754
5855 /// A reference to an element in an on clause.
59- static const MatchKind REFERENCE_IN_ON_CLAUSE = MatchKind .reference (
60- 'REFERENCE_IN_ON_CLAUSE' ,
61- );
62-
63- final String name;
56+ REFERENCE_IN_ON_CLAUSE (isReference: true );
6457
6558 final bool isReference;
6659
67- const MatchKind (this .name) : isReference = false ;
68-
69- const MatchKind .reference (this .name) : isReference = true ;
60+ const MatchKind ({this .isReference = false });
7061
7162 @override
7263 String toString () => name;
0 commit comments