Version 2.17.0-3.0.dev
Merge commit '2170c061b013096be0b306b026fe45cec5e53b01' into 'dev'
diff --git a/pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart b/pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart
index 5e3a9c5..ffba325 100644
--- a/pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart
+++ b/pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart
@@ -36,6 +36,7 @@
aliasedType: aliasedType,
parameters: elementParameters,
returnType: elementReturnType,
+ libraryUri: element.library?.source.uri.toString(),
);
}
diff --git a/pkg/analysis_server/lib/protocol/protocol_constants.dart b/pkg/analysis_server/lib/protocol/protocol_constants.dart
index ad20782..ade68e1 100644
--- a/pkg/analysis_server/lib/protocol/protocol_constants.dart
+++ b/pkg/analysis_server/lib/protocol/protocol_constants.dart
@@ -171,8 +171,6 @@
'subscriptions';
const String COMPLETION_RESPONSE_GET_SUGGESTIONS2_IS_INCOMPLETE =
'isIncomplete';
-const String COMPLETION_RESPONSE_GET_SUGGESTIONS2_LIBRARY_URIS_TO_IMPORT =
- 'libraryUrisToImport';
const String COMPLETION_RESPONSE_GET_SUGGESTIONS2_REPLACEMENT_LENGTH =
'replacementLength';
const String COMPLETION_RESPONSE_GET_SUGGESTIONS2_REPLACEMENT_OFFSET =
diff --git a/pkg/analysis_server/lib/protocol/protocol_generated.dart b/pkg/analysis_server/lib/protocol/protocol_generated.dart
index 19f187f..98395e9 100644
--- a/pkg/analysis_server/lib/protocol/protocol_generated.dart
+++ b/pkg/analysis_server/lib/protocol/protocol_generated.dart
@@ -4827,7 +4827,6 @@
/// "replacementOffset": int
/// "replacementLength": int
/// "suggestions": List<CompletionSuggestion>
-/// "libraryUrisToImport": List<String>
/// "isIncomplete": bool
/// }
///
@@ -4853,31 +4852,16 @@
/// (if isIncomplete was true).
///
/// This list contains suggestions from both imported, and not yet imported
- /// libraries. Items from not yet imported libraries will have
- /// libraryUriToImportIndex set, which is an index into the
- /// libraryUrisToImport in this response.
+ /// libraries. Items from not yet imported libraries will have isNotImported
+ /// set to true.
List<CompletionSuggestion> suggestions;
- /// The list of libraries with declarations that are not yet available in the
- /// file where completion was requested, most often because the library is
- /// not yet imported. The declarations still might be included into the
- /// suggestions, and the client should use getSuggestionDetails2 on selection
- /// to make the library available in the file.
- ///
- /// Each item is the URI of a library, such as package:foo/bar.dart or
- /// file:///home/me/workspace/foo/test/bar_test.dart.
- List<String> libraryUrisToImport;
-
/// True if the number of suggestions after filtering was greater than the
/// requested maxResults.
bool isIncomplete;
- CompletionGetSuggestions2Result(
- this.replacementOffset,
- this.replacementLength,
- this.suggestions,
- this.libraryUrisToImport,
- this.isIncomplete);
+ CompletionGetSuggestions2Result(this.replacementOffset,
+ this.replacementLength, this.suggestions, this.isIncomplete);
factory CompletionGetSuggestions2Result.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@@ -4907,15 +4891,6 @@
} else {
throw jsonDecoder.mismatch(jsonPath, 'suggestions');
}
- List<String> libraryUrisToImport;
- if (json.containsKey('libraryUrisToImport')) {
- libraryUrisToImport = jsonDecoder.decodeList(
- jsonPath + '.libraryUrisToImport',
- json['libraryUrisToImport'],
- jsonDecoder.decodeString);
- } else {
- throw jsonDecoder.mismatch(jsonPath, 'libraryUrisToImport');
- }
bool isIncomplete;
if (json.containsKey('isIncomplete')) {
isIncomplete = jsonDecoder.decodeBool(
@@ -4923,8 +4898,8 @@
} else {
throw jsonDecoder.mismatch(jsonPath, 'isIncomplete');
}
- return CompletionGetSuggestions2Result(replacementOffset,
- replacementLength, suggestions, libraryUrisToImport, isIncomplete);
+ return CompletionGetSuggestions2Result(
+ replacementOffset, replacementLength, suggestions, isIncomplete);
} else {
throw jsonDecoder.mismatch(
jsonPath, 'completion.getSuggestions2 result', json);
@@ -4946,7 +4921,6 @@
result['suggestions'] = suggestions
.map((CompletionSuggestion value) => value.toJson())
.toList();
- result['libraryUrisToImport'] = libraryUrisToImport;
result['isIncomplete'] = isIncomplete;
return result;
}
@@ -4966,8 +4940,6 @@
replacementLength == other.replacementLength &&
listEqual(suggestions, other.suggestions,
(CompletionSuggestion a, CompletionSuggestion b) => a == b) &&
- listEqual(libraryUrisToImport, other.libraryUrisToImport,
- (String a, String b) => a == b) &&
isIncomplete == other.isIncomplete;
}
return false;
@@ -4978,7 +4950,6 @@
replacementOffset,
replacementLength,
suggestions,
- libraryUrisToImport,
isIncomplete,
);
}
diff --git a/pkg/analysis_server/lib/src/domain_completion.dart b/pkg/analysis_server/lib/src/domain_completion.dart
index 71fad87..45ccc9b 100644
--- a/pkg/analysis_server/lib/src/domain_completion.dart
+++ b/pkg/analysis_server/lib/src/domain_completion.dart
@@ -288,7 +288,6 @@
suggestions.replacementOffset,
suggestions.replacementLength,
suggestions.suggestions,
- [],
false,
).toResponse(request.id),
);
@@ -297,7 +296,7 @@
if (!file_paths.isDart(pathContext, file)) {
server.sendResponse(
- CompletionGetSuggestions2Result(offset, 0, [], [], false)
+ CompletionGetSuggestions2Result(offset, 0, [], false)
.toResponse(request.id),
);
return;
@@ -372,7 +371,6 @@
completionRequest.replacementOffset,
completionRequest.replacementLength,
[],
- [],
true,
).toResponse(request.id),
);
@@ -390,19 +388,12 @@
var lengthRestricted = suggestions.take(params.maxResults).toList();
completionPerformance.suggestionCount = lengthRestricted.length;
- // Update `libraryUriToImportIndex` for not yet imported.
- // Gather referenced unique libraries to import.
- var librariesToImport = <Uri, int>{};
+ // Update `isNotImported` for not yet imported.
for (var i = 0; i < lengthRestricted.length; i++) {
var suggestion = lengthRestricted[i];
- var libraryToImport = notImportedSuggestions.map[suggestion];
- if (libraryToImport != null) {
- var index = librariesToImport.putIfAbsent(
- libraryToImport,
- () => librariesToImport.length,
- );
+ if (notImportedSuggestions.set.contains(suggestion)) {
lengthRestricted[i] = suggestion.copyWith(
- libraryUriToImportIndex: CopyWithValue(index),
+ isNotImported: CopyWithValue(true),
);
}
}
@@ -416,7 +407,6 @@
completionRequest.replacementOffset,
completionRequest.replacementLength,
lengthRestricted,
- librariesToImport.keys.map((e) => '$e').toList(),
isIncomplete,
).toResponse(request.id),
);
diff --git a/pkg/analysis_server/lib/src/server/debounce_requests.dart b/pkg/analysis_server/lib/src/server/debounce_requests.dart
index 4ee01d6..35845fc 100644
--- a/pkg/analysis_server/lib/src/server/debounce_requests.dart
+++ b/pkg/analysis_server/lib/src/server/debounce_requests.dart
@@ -68,7 +68,7 @@
var params = CompletionGetSuggestions2Params.fromRequest(request);
var offset = params.offset;
channel.sendResponse(
- CompletionGetSuggestions2Result(offset, 0, [], [], true)
+ CompletionGetSuggestions2Result(offset, 0, [], true)
.toResponse(request.id),
);
continue;
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
index 4932c25..b2ef7d6d 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:collection';
-
import 'package:analysis_server/src/protocol_server.dart';
import 'package:analysis_server/src/provisional/completion/completion_core.dart';
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
@@ -505,7 +503,7 @@
/// Information provided by [NotImportedContributor] in addition to suggestions.
class NotImportedSuggestions {
- final Map<protocol.CompletionSuggestion, Uri> map = HashMap.identity();
+ final Set<protocol.CompletionSuggestion> set = Set.identity();
/// This flag is set to `true` if the contributor decided to stop before it
/// processed all available libraries, e.g. we ran out of budget.
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart
index 4046262..50197a2 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart
@@ -64,7 +64,7 @@
builder.laterReplacesEarlier = false;
builder.suggestionAdded = (suggestion) {
- additionalData.map[suggestion] = file.uri;
+ additionalData.set.add(suggestion);
};
if (request.includeIdentifiers) {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index b4c063c..3ec8bec 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
@@ -1353,7 +1353,7 @@
extension CompletionSuggestionExtension on CompletionSuggestion {
CompletionSuggestion copyWith({
- CopyWithValue<int?>? libraryUriToImportIndex,
+ CopyWithValue<bool?>? isNotImported,
}) {
return protocol.CompletionSuggestion(
kind,
@@ -1379,9 +1379,7 @@
hasNamedParameters: hasNamedParameters,
parameterName: parameterName,
parameterType: parameterType,
- libraryUriToImportIndex: libraryUriToImportIndex.orElse(
- this.libraryUriToImportIndex,
- ),
+ isNotImported: isNotImported.orElse(this.isNotImported),
);
}
}
diff --git a/pkg/analysis_server/test/domain_completion_test.dart b/pkg/analysis_server/test/domain_completion_test.dart
index 0597706..9a4c5a3 100644
--- a/pkg/analysis_server/test/domain_completion_test.dart
+++ b/pkg/analysis_server/test/domain_completion_test.dart
@@ -1620,7 +1620,6 @@
replacementOffset: result.replacementOffset,
replacementLength: result.replacementLength,
isIncomplete: result.isIncomplete,
- librariesToImport: result.libraryUrisToImport,
suggestions: result.suggestions,
);
}
@@ -2536,27 +2535,6 @@
}
}
-class CompletionGetSuggestions2ResponseValidator {
- final int completionOffset;
- final CompletionGetSuggestions2Result result;
-
- CompletionGetSuggestions2ResponseValidator(
- this.completionOffset,
- this.result,
- );
-
- CompletionResponseForTesting get asResponse {
- return CompletionResponseForTesting(
- requestOffset: completionOffset,
- replacementOffset: result.replacementOffset,
- replacementLength: result.replacementLength,
- isIncomplete: result.isIncomplete,
- librariesToImport: result.libraryUrisToImport,
- suggestions: result.suggestions,
- );
- }
-}
-
class PubPackageAnalysisServerTest with ResourceProviderMixin {
late final MockServerChannel serverChannel;
late final AnalysisServer server;
@@ -2686,7 +2664,6 @@
replacementOffset: result.replacementOffset,
replacementLength: result.replacementLength,
isIncomplete: result.isIncomplete,
- librariesToImport: result.libraryUrisToImport,
suggestions: result.suggestions,
);
}
diff --git a/pkg/analysis_server/test/integration/support/integration_test_methods.dart b/pkg/analysis_server/test/integration/support/integration_test_methods.dart
index 23a7a61..c12b23d 100644
--- a/pkg/analysis_server/test/integration/support/integration_test_methods.dart
+++ b/pkg/analysis_server/test/integration/support/integration_test_methods.dart
@@ -1021,19 +1021,7 @@
///
/// This list contains suggestions from both imported, and not yet imported
/// libraries. Items from not yet imported libraries will have
- /// libraryUriToImportIndex set, which is an index into the
- /// libraryUrisToImport in this response.
- ///
- /// libraryUrisToImport: List<String>
- ///
- /// The list of libraries with declarations that are not yet available in
- /// the file where completion was requested, most often because the library
- /// is not yet imported. The declarations still might be included into the
- /// suggestions, and the client should use getSuggestionDetails2 on
- /// selection to make the library available in the file.
- ///
- /// Each item is the URI of a library, such as package:foo/bar.dart or
- /// file:///home/me/workspace/foo/test/bar_test.dart.
+ /// isNotImported set to true.
///
/// isIncomplete: bool
///
@@ -1148,7 +1136,7 @@
}
/// Clients must make this request when the user has selected a completion
- /// suggestion with the libraryUriToImportIndex field set. The server will
+ /// suggestion with the isNotImported field set to true. The server will
/// respond with the text to insert, as well as any SourceChange that needs
/// to be applied in case the completion requires an additional import to be
/// added. The text to insert might be different from the original suggestion
diff --git a/pkg/analysis_server/test/integration/support/protocol_matchers.dart b/pkg/analysis_server/test/integration/support/protocol_matchers.dart
index 4f35ccd..4b5a4ce 100644
--- a/pkg/analysis_server/test/integration/support/protocol_matchers.dart
+++ b/pkg/analysis_server/test/integration/support/protocol_matchers.dart
@@ -305,7 +305,7 @@
'hasNamedParameters': isBool,
'parameterName': isString,
'parameterType': isString,
- 'libraryUriToImportIndex': isInt
+ 'isNotImported': isBool
}));
/// CompletionSuggestionKind
@@ -384,7 +384,8 @@
'parameters': isString,
'returnType': isString,
'typeParameters': isString,
- 'aliasedType': isString
+ 'aliasedType': isString,
+ 'libraryUri': isString
}));
/// ElementDeclaration
@@ -2163,7 +2164,6 @@
/// "replacementOffset": int
/// "replacementLength": int
/// "suggestions": List<CompletionSuggestion>
-/// "libraryUrisToImport": List<String>
/// "isIncomplete": bool
/// }
final Matcher isCompletionGetSuggestions2Result =
@@ -2171,7 +2171,6 @@
'replacementOffset': isInt,
'replacementLength': isInt,
'suggestions': isListOf(isCompletionSuggestion),
- 'libraryUrisToImport': isListOf(isString),
'isIncomplete': isBool
}));
diff --git a/pkg/analysis_server/test/search/type_hierarchy_test.dart b/pkg/analysis_server/test/search/type_hierarchy_test.dart
index e0fef5d..60d734d 100644
--- a/pkg/analysis_server/test/search/type_hierarchy_test.dart
+++ b/pkg/analysis_server/test/search/type_hierarchy_test.dart
@@ -62,7 +62,8 @@
'kind': 'CLASS',
'name': 'B',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -74,7 +75,8 @@
'kind': 'CLASS',
'name': 'A',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -114,7 +116,8 @@
'kind': 'CLASS',
'name': 'AAA',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -126,7 +129,8 @@
'kind': 'CLASS',
'name': 'Object',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'interfaces': [],
'mixins': [],
@@ -137,7 +141,8 @@
'kind': 'CLASS',
'name': 'BBB',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -149,7 +154,8 @@
'kind': 'CLASS',
'name': 'CCC',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -203,7 +209,8 @@
'kind': 'CLASS',
'name': 'A',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -215,7 +222,8 @@
'kind': 'CLASS',
'name': 'Object',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'interfaces': [],
'mixins': [],
@@ -226,7 +234,8 @@
'kind': 'CLASS',
'name': 'B',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -238,7 +247,8 @@
'kind': 'CLASS',
'name': 'C',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 2,
'interfaces': [],
@@ -264,7 +274,8 @@
'kind': 'CLASS',
'name': 'B',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -276,7 +287,8 @@
'kind': 'CLASS',
'name': 'A',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 2,
'interfaces': [],
@@ -288,7 +300,8 @@
'kind': 'CLASS',
'name': 'Object',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'interfaces': [],
'mixins': [],
@@ -299,7 +312,8 @@
'kind': 'CLASS',
'name': 'C',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -325,7 +339,8 @@
'kind': 'CLASS',
'name': 'C',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -337,7 +352,8 @@
'kind': 'CLASS',
'name': 'B',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 2,
'interfaces': [],
@@ -349,7 +365,8 @@
'kind': 'CLASS',
'name': 'A',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 3,
'interfaces': [],
@@ -361,7 +378,8 @@
'kind': 'CLASS',
'name': 'Object',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'interfaces': [],
'mixins': [],
@@ -386,7 +404,8 @@
'kind': 'CLASS',
'name': 'T',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [2, 3],
@@ -398,7 +417,8 @@
'kind': 'CLASS',
'name': 'Object',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'interfaces': [],
'mixins': [],
@@ -409,7 +429,8 @@
'kind': 'CLASS',
'name': 'MA',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -421,7 +442,8 @@
'kind': 'CLASS',
'name': 'MB',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -448,7 +470,8 @@
'kind': 'CLASS',
'name': 'A',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -460,7 +483,8 @@
'kind': 'CLASS',
'name': 'Object',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'interfaces': [],
'mixins': [],
@@ -471,7 +495,8 @@
'kind': 'CLASS',
'name': 'B',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -483,7 +508,8 @@
'kind': 'CLASS',
'name': 'C',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -495,7 +521,8 @@
'kind': 'CLASS',
'name': 'D',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -507,7 +534,8 @@
'kind': 'CLASS',
'name': 'E',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 0,
'interfaces': [],
@@ -519,7 +547,8 @@
'kind': 'CLASS',
'name': 'F',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 4,
'interfaces': [],
@@ -531,7 +560,8 @@
'kind': 'CLASS',
'name': 'G',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 4,
'interfaces': [],
@@ -557,7 +587,8 @@
'kind': 'CLASS',
'name': 'T',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -569,7 +600,8 @@
'kind': 'CLASS',
'name': 'Object',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'interfaces': [],
'mixins': [],
@@ -580,7 +612,8 @@
'kind': 'CLASS',
'name': 'MA',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -592,7 +625,8 @@
'kind': 'CLASS',
'name': 'MB',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [],
@@ -1132,7 +1166,8 @@
'kind': 'CLASS',
'name': 'C',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 1,
'interfaces': [3],
@@ -1144,7 +1179,8 @@
'kind': 'CLASS',
'name': 'A',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 2,
'interfaces': [],
@@ -1156,7 +1192,8 @@
'kind': 'CLASS',
'name': 'Object',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'interfaces': [],
'mixins': [],
@@ -1167,7 +1204,8 @@
'kind': 'CLASS',
'name': 'B',
'location': anything,
- 'flags': 0
+ 'flags': 0,
+ 'libraryUri': anything
},
'superclass': 2,
'interfaces': [],
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_check.dart b/pkg/analysis_server/test/services/completion/dart/completion_check.dart
index 3e6c785..f963f06 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_check.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_check.dart
@@ -4,13 +4,14 @@
import 'package:analysis_server/src/protocol_server.dart';
import 'package:analyzer_utilities/check/check.dart';
+import 'package:collection/collection.dart';
+import 'package:meta/meta.dart';
class CompletionResponseForTesting {
final int requestOffset;
final int replacementOffset;
final int replacementLength;
final bool isIncomplete;
- final List<String> librariesToImport;
final List<CompletionSuggestion> suggestions;
CompletionResponseForTesting({
@@ -18,7 +19,6 @@
required this.replacementOffset,
required this.replacementLength,
required this.isIncomplete,
- required this.librariesToImport,
required this.suggestions,
});
@@ -31,7 +31,6 @@
replacementOffset: parameters.replacementOffset,
replacementLength: parameters.replacementLength,
isIncomplete: false,
- librariesToImport: const [],
suggestions: parameters.results,
);
}
@@ -70,7 +69,12 @@
CheckTarget<List<String>> get librariesToImport {
return nest(
- value.librariesToImport,
+ value.suggestions
+ .where((e) => e.isNotImported == true)
+ .map((e) => e.element?.libraryUri)
+ .whereNotNull()
+ .toSet()
+ .toList(),
(selected) => 'has librariesToImport ${valueStr(selected)}',
);
}
@@ -211,6 +215,14 @@
element.isNotNull.kind.isMethod;
}
+ @useResult
+ CheckTarget<bool?> get isNotImported {
+ return nest(
+ value.suggestion.isNotImported,
+ (selected) => 'has isNotImported ${valueStr(selected)}',
+ );
+ }
+
void get isParameter {
kind.isIdentifier;
element.isNotNull.kind.isParameter;
@@ -234,9 +246,10 @@
}
CheckTarget<String?> get libraryUriToImport {
- var index = value.suggestion.libraryUriToImportIndex;
return nest(
- index != null ? value.response.librariesToImport[index] : null,
+ value.suggestion.isNotImported == true
+ ? value.suggestion.element?.libraryUri
+ : null,
(selected) => 'has libraryUriToImport ${valueStr(selected)}',
);
}
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
index bcf730f..f721cc8 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
@@ -583,7 +583,6 @@
replacementOffset: replacementOffset,
replacementLength: replacementLength,
isIncomplete: false,
- librariesToImport: const [],
suggestions: suggestions,
);
}
diff --git a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java
index c5a5ed2..3d8e563 100644
--- a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java
+++ b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java
@@ -405,11 +405,10 @@
* {@code completion.getSuggestionDetails2}
*
* Clients must make this request when the user has selected a completion suggestion with the
- * libraryUriToImportIndex field set. The server will respond with the text to insert, as well as
- * any SourceChange that needs to be applied in case the completion requires an additional import
- * to be added. The text to insert might be different from the original suggestion to include an
- * import prefix if the library will be imported with a prefix to avoid shadowing conflicts in the
- * file.
+ * isNotImported field set to true. The server will respond with the text to insert, as well as any
+ * SourceChange that needs to be applied in case the completion requires an additional import to be
+ * added. The text to insert might be different from the original suggestion to include an import
+ * prefix if the library will be imported with a prefix to avoid shadowing conflicts in the file.
*
* @param file The path of the file into which this completion is being inserted.
* @param offset The offset in the file where the completion will be inserted.
diff --git a/pkg/analysis_server/tool/spec/generated/java/types/CompletionSuggestion.java b/pkg/analysis_server/tool/spec/generated/java/types/CompletionSuggestion.java
index bf8d912..f73aa41 100644
--- a/pkg/analysis_server/tool/spec/generated/java/types/CompletionSuggestion.java
+++ b/pkg/analysis_server/tool/spec/generated/java/types/CompletionSuggestion.java
@@ -176,18 +176,16 @@
private final String parameterType;
/**
- * The index in the list of libraries that could be imported to make this suggestion accessible in
- * the file where completion was requested. The server provides this list of libraries together
- * with suggestions, so that information about the library can be shared for multiple suggestions.
- * This field is omitted if the library is already imported, so that the suggestion can be inserted
- * as is, or if getSuggestions was used rather than getSuggestions2.
+ * True if the suggestion is for an element from a not yet imported library. This field is omitted
+ * if the element is declared locally, or is from library is already imported, so that the
+ * suggestion can be inserted as is, or if getSuggestions was used rather than getSuggestions2.
*/
- private final Integer libraryUriToImportIndex;
+ private final Boolean isNotImported;
/**
* Constructor for {@link CompletionSuggestion}.
*/
- public CompletionSuggestion(String kind, int relevance, String completion, String displayText, Integer replacementOffset, Integer replacementLength, int selectionOffset, int selectionLength, boolean isDeprecated, boolean isPotential, String docSummary, String docComplete, String declaringType, String defaultArgumentListString, int[] defaultArgumentListTextRanges, Element element, String returnType, List<String> parameterNames, List<String> parameterTypes, Integer requiredParameterCount, Boolean hasNamedParameters, String parameterName, String parameterType, Integer libraryUriToImportIndex) {
+ public CompletionSuggestion(String kind, int relevance, String completion, String displayText, Integer replacementOffset, Integer replacementLength, int selectionOffset, int selectionLength, boolean isDeprecated, boolean isPotential, String docSummary, String docComplete, String declaringType, String defaultArgumentListString, int[] defaultArgumentListTextRanges, Element element, String returnType, List<String> parameterNames, List<String> parameterTypes, Integer requiredParameterCount, Boolean hasNamedParameters, String parameterName, String parameterType, Boolean isNotImported) {
this.kind = kind;
this.relevance = relevance;
this.completion = completion;
@@ -211,7 +209,7 @@
this.hasNamedParameters = hasNamedParameters;
this.parameterName = parameterName;
this.parameterType = parameterType;
- this.libraryUriToImportIndex = libraryUriToImportIndex;
+ this.isNotImported = isNotImported;
}
@Override
@@ -242,7 +240,7 @@
ObjectUtilities.equals(other.hasNamedParameters, hasNamedParameters) &&
ObjectUtilities.equals(other.parameterName, parameterName) &&
ObjectUtilities.equals(other.parameterType, parameterType) &&
- ObjectUtilities.equals(other.libraryUriToImportIndex, libraryUriToImportIndex);
+ ObjectUtilities.equals(other.isNotImported, isNotImported);
}
return false;
}
@@ -271,8 +269,8 @@
Boolean hasNamedParameters = jsonObject.get("hasNamedParameters") == null ? null : jsonObject.get("hasNamedParameters").getAsBoolean();
String parameterName = jsonObject.get("parameterName") == null ? null : jsonObject.get("parameterName").getAsString();
String parameterType = jsonObject.get("parameterType") == null ? null : jsonObject.get("parameterType").getAsString();
- Integer libraryUriToImportIndex = jsonObject.get("libraryUriToImportIndex") == null ? null : jsonObject.get("libraryUriToImportIndex").getAsInt();
- return new CompletionSuggestion(kind, relevance, completion, displayText, replacementOffset, replacementLength, selectionOffset, selectionLength, isDeprecated, isPotential, docSummary, docComplete, declaringType, defaultArgumentListString, defaultArgumentListTextRanges, element, returnType, parameterNames, parameterTypes, requiredParameterCount, hasNamedParameters, parameterName, parameterType, libraryUriToImportIndex);
+ Boolean isNotImported = jsonObject.get("isNotImported") == null ? null : jsonObject.get("isNotImported").getAsBoolean();
+ return new CompletionSuggestion(kind, relevance, completion, displayText, replacementOffset, replacementLength, selectionOffset, selectionLength, isDeprecated, isPotential, docSummary, docComplete, declaringType, defaultArgumentListString, defaultArgumentListTextRanges, element, returnType, parameterNames, parameterTypes, requiredParameterCount, hasNamedParameters, parameterName, parameterType, isNotImported);
}
public static List<CompletionSuggestion> fromJsonArray(JsonArray jsonArray) {
@@ -369,6 +367,15 @@
}
/**
+ * True if the suggestion is for an element from a not yet imported library. This field is omitted
+ * if the element is declared locally, or is from library is already imported, so that the
+ * suggestion can be inserted as is, or if getSuggestions was used rather than getSuggestions2.
+ */
+ public Boolean getIsNotImported() {
+ return isNotImported;
+ }
+
+ /**
* True if the element is not known to be valid for the target. This happens if the type of the
* target is dynamic.
*/
@@ -384,17 +391,6 @@
}
/**
- * The index in the list of libraries that could be imported to make this suggestion accessible in
- * the file where completion was requested. The server provides this list of libraries together
- * with suggestions, so that information about the library can be shared for multiple suggestions.
- * This field is omitted if the library is already imported, so that the suggestion can be inserted
- * as is, or if getSuggestions was used rather than getSuggestions2.
- */
- public Integer getLibraryUriToImportIndex() {
- return libraryUriToImportIndex;
- }
-
- /**
* The name of the optional parameter being suggested. This field is omitted if the suggestion is
* not the addition of an optional argument within an argument list.
*/
@@ -509,7 +505,7 @@
builder.append(hasNamedParameters);
builder.append(parameterName);
builder.append(parameterType);
- builder.append(libraryUriToImportIndex);
+ builder.append(isNotImported);
return builder.toHashCode();
}
@@ -582,8 +578,8 @@
if (parameterType != null) {
jsonObject.addProperty("parameterType", parameterType);
}
- if (libraryUriToImportIndex != null) {
- jsonObject.addProperty("libraryUriToImportIndex", libraryUriToImportIndex);
+ if (isNotImported != null) {
+ jsonObject.addProperty("isNotImported", isNotImported);
}
return jsonObject;
}
@@ -638,8 +634,8 @@
builder.append(parameterName + ", ");
builder.append("parameterType=");
builder.append(parameterType + ", ");
- builder.append("libraryUriToImportIndex=");
- builder.append(libraryUriToImportIndex);
+ builder.append("isNotImported=");
+ builder.append(isNotImported);
builder.append("]");
return builder.toString();
}
diff --git a/pkg/analysis_server/tool/spec/generated/java/types/Element.java b/pkg/analysis_server/tool/spec/generated/java/types/Element.java
index 690f101..0648fc7 100644
--- a/pkg/analysis_server/tool/spec/generated/java/types/Element.java
+++ b/pkg/analysis_server/tool/spec/generated/java/types/Element.java
@@ -101,9 +101,15 @@
private final String aliasedType;
/**
+ * If the element belongs to a library, the URI of the library. Otherwise, this field will not be
+ * defined.
+ */
+ private final String libraryUri;
+
+ /**
* Constructor for {@link Element}.
*/
- public Element(String kind, String name, Location location, int flags, String parameters, String returnType, String typeParameters, String aliasedType) {
+ public Element(String kind, String name, Location location, int flags, String parameters, String returnType, String typeParameters, String aliasedType, String libraryUri) {
this.kind = kind;
this.name = name;
this.location = location;
@@ -112,6 +118,7 @@
this.returnType = returnType;
this.typeParameters = typeParameters;
this.aliasedType = aliasedType;
+ this.libraryUri = libraryUri;
}
@Override
@@ -126,7 +133,8 @@
ObjectUtilities.equals(other.parameters, parameters) &&
ObjectUtilities.equals(other.returnType, returnType) &&
ObjectUtilities.equals(other.typeParameters, typeParameters) &&
- ObjectUtilities.equals(other.aliasedType, aliasedType);
+ ObjectUtilities.equals(other.aliasedType, aliasedType) &&
+ ObjectUtilities.equals(other.libraryUri, libraryUri);
}
return false;
}
@@ -140,7 +148,8 @@
String returnType = jsonObject.get("returnType") == null ? null : jsonObject.get("returnType").getAsString();
String typeParameters = jsonObject.get("typeParameters") == null ? null : jsonObject.get("typeParameters").getAsString();
String aliasedType = jsonObject.get("aliasedType") == null ? null : jsonObject.get("aliasedType").getAsString();
- return new Element(kind, name, location, flags, parameters, returnType, typeParameters, aliasedType);
+ String libraryUri = jsonObject.get("libraryUri") == null ? null : jsonObject.get("libraryUri").getAsString();
+ return new Element(kind, name, location, flags, parameters, returnType, typeParameters, aliasedType, libraryUri);
}
public static List<Element> fromJsonArray(JsonArray jsonArray) {
@@ -185,6 +194,14 @@
}
/**
+ * If the element belongs to a library, the URI of the library. Otherwise, this field will not be
+ * defined.
+ */
+ public String getLibraryUri() {
+ return libraryUri;
+ }
+
+ /**
* The location of the name in the declaration of the element.
*/
public Location getLocation() {
@@ -235,6 +252,7 @@
builder.append(returnType);
builder.append(typeParameters);
builder.append(aliasedType);
+ builder.append(libraryUri);
return builder.toHashCode();
}
@@ -282,6 +300,9 @@
if (aliasedType != null) {
jsonObject.addProperty("aliasedType", aliasedType);
}
+ if (libraryUri != null) {
+ jsonObject.addProperty("libraryUri", libraryUri);
+ }
return jsonObject;
}
@@ -304,7 +325,9 @@
builder.append("typeParameters=");
builder.append(typeParameters + ", ");
builder.append("aliasedType=");
- builder.append(aliasedType);
+ builder.append(aliasedType + ", ");
+ builder.append("libraryUri=");
+ builder.append(libraryUri);
builder.append("]");
return builder.toString();
}
diff --git a/pkg/analysis_server/tool/spec/spec_input.html b/pkg/analysis_server/tool/spec/spec_input.html
index 76d97d58..3c5c0ad 100644
--- a/pkg/analysis_server/tool/spec/spec_input.html
+++ b/pkg/analysis_server/tool/spec/spec_input.html
@@ -1570,25 +1570,7 @@
<p>
This list contains suggestions from both imported, and not yet
imported libraries. Items from not yet imported libraries will
- have <tt>libraryUriToImportIndex</tt> set, which is an index into
- the <tt>libraryUrisToImport</tt> in this response.
- </p>
- </field>
- <field name="libraryUrisToImport">
- <list>
- <ref>String</ref>
- </list>
- <p>
- The list of libraries with declarations that are not yet available
- in the file where completion was requested, most often because
- the library is not yet imported. The declarations still might be
- included into the <tt>suggestions</tt>, and the client should use
- <tt>getSuggestionDetails2</tt> on selection to make the library
- available in the file.
- </p>
- <p>
- Each item is the URI of a library, such as <tt>package:foo/bar.dart</tt>
- or <tt>file:///home/me/workspace/foo/test/bar_test.dart</tt>.
+ have <tt>isNotImported</tt> set to <tt>true</tt>.
</p>
</field>
<field name="isIncomplete">
@@ -1699,7 +1681,7 @@
<request method="getSuggestionDetails2" experimental="true">
<p>
Clients must make this request when the user has selected a completion
- suggestion with the <tt>libraryUriToImportIndex</tt> field set.
+ suggestion with the <tt>isNotImported</tt> field set to <tt>true</tt>.
The server will respond with the text to insert, as well as any
<tt>SourceChange</tt> that needs to be applied in case the completion
requires an additional import to be added. The text to insert might be
diff --git a/pkg/analysis_server_client/lib/src/protocol/protocol_common.dart b/pkg/analysis_server_client/lib/src/protocol/protocol_common.dart
index b2d7548..2223244 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_common.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_common.dart
@@ -612,14 +612,11 @@
/// if the parameterName field is omitted.
String? parameterType;
- /// The index in the list of libraries that could be imported to make this
- /// suggestion accessible in the file where completion was requested. The
- /// server provides this list of libraries together with suggestions, so that
- /// information about the library can be shared for multiple suggestions.
- /// This field is omitted if the library is already imported, so that the
- /// suggestion can be inserted as is, or if getSuggestions was used rather
- /// than getSuggestions2.
- int? libraryUriToImportIndex;
+ /// True if the suggestion is for an element from a not yet imported library.
+ /// This field is omitted if the element is declared locally, or is from
+ /// library is already imported, so that the suggestion can be inserted as
+ /// is, or if getSuggestions was used rather than getSuggestions2.
+ bool? isNotImported;
CompletionSuggestion(
this.kind,
@@ -645,7 +642,7 @@
this.hasNamedParameters,
this.parameterName,
this.parameterType,
- this.libraryUriToImportIndex});
+ this.isNotImported});
factory CompletionSuggestion.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@@ -784,11 +781,10 @@
parameterType = jsonDecoder.decodeString(
jsonPath + '.parameterType', json['parameterType']);
}
- int? libraryUriToImportIndex;
- if (json.containsKey('libraryUriToImportIndex')) {
- libraryUriToImportIndex = jsonDecoder.decodeInt(
- jsonPath + '.libraryUriToImportIndex',
- json['libraryUriToImportIndex']);
+ bool? isNotImported;
+ if (json.containsKey('isNotImported')) {
+ isNotImported = jsonDecoder.decodeBool(
+ jsonPath + '.isNotImported', json['isNotImported']);
}
return CompletionSuggestion(kind, relevance, completion, selectionOffset,
selectionLength, isDeprecated, isPotential,
@@ -808,7 +804,7 @@
hasNamedParameters: hasNamedParameters,
parameterName: parameterName,
parameterType: parameterType,
- libraryUriToImportIndex: libraryUriToImportIndex);
+ isNotImported: isNotImported);
} else {
throw jsonDecoder.mismatch(jsonPath, 'CompletionSuggestion', json);
}
@@ -888,9 +884,9 @@
if (parameterType != null) {
result['parameterType'] = parameterType;
}
- var libraryUriToImportIndex = this.libraryUriToImportIndex;
- if (libraryUriToImportIndex != null) {
- result['libraryUriToImportIndex'] = libraryUriToImportIndex;
+ var isNotImported = this.isNotImported;
+ if (isNotImported != null) {
+ result['isNotImported'] = isNotImported;
}
return result;
}
@@ -927,7 +923,7 @@
hasNamedParameters == other.hasNamedParameters &&
parameterName == other.parameterName &&
parameterType == other.parameterType &&
- libraryUriToImportIndex == other.libraryUriToImportIndex;
+ isNotImported == other.isNotImported;
}
return false;
}
@@ -957,7 +953,7 @@
hasNamedParameters,
parameterName,
parameterType,
- libraryUriToImportIndex,
+ isNotImported,
]);
}
@@ -1238,12 +1234,17 @@
/// this field will not be defined.
String? aliasedType;
+ /// If the element belongs to a library, the URI of the library. Otherwise,
+ /// this field will not be defined.
+ String? libraryUri;
+
Element(this.kind, this.name, this.flags,
{this.location,
this.parameters,
this.returnType,
this.typeParameters,
- this.aliasedType});
+ this.aliasedType,
+ this.libraryUri});
factory Element.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@@ -1293,12 +1294,18 @@
aliasedType = jsonDecoder.decodeString(
jsonPath + '.aliasedType', json['aliasedType']);
}
+ String? libraryUri;
+ if (json.containsKey('libraryUri')) {
+ libraryUri = jsonDecoder.decodeString(
+ jsonPath + '.libraryUri', json['libraryUri']);
+ }
return Element(kind, name, flags,
location: location,
parameters: parameters,
returnType: returnType,
typeParameters: typeParameters,
- aliasedType: aliasedType);
+ aliasedType: aliasedType,
+ libraryUri: libraryUri);
} else {
throw jsonDecoder.mismatch(jsonPath, 'Element', json);
}
@@ -1337,6 +1344,10 @@
if (aliasedType != null) {
result['aliasedType'] = aliasedType;
}
+ var libraryUri = this.libraryUri;
+ if (libraryUri != null) {
+ result['libraryUri'] = libraryUri;
+ }
return result;
}
@@ -1353,7 +1364,8 @@
parameters == other.parameters &&
returnType == other.returnType &&
typeParameters == other.typeParameters &&
- aliasedType == other.aliasedType;
+ aliasedType == other.aliasedType &&
+ libraryUri == other.libraryUri;
}
return false;
}
@@ -1368,6 +1380,7 @@
returnType,
typeParameters,
aliasedType,
+ libraryUri,
);
}
diff --git a/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart b/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart
index ad20782..ade68e1 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart
@@ -171,8 +171,6 @@
'subscriptions';
const String COMPLETION_RESPONSE_GET_SUGGESTIONS2_IS_INCOMPLETE =
'isIncomplete';
-const String COMPLETION_RESPONSE_GET_SUGGESTIONS2_LIBRARY_URIS_TO_IMPORT =
- 'libraryUrisToImport';
const String COMPLETION_RESPONSE_GET_SUGGESTIONS2_REPLACEMENT_LENGTH =
'replacementLength';
const String COMPLETION_RESPONSE_GET_SUGGESTIONS2_REPLACEMENT_OFFSET =
diff --git a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
index d24faa1..413c551 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
@@ -4827,7 +4827,6 @@
/// "replacementOffset": int
/// "replacementLength": int
/// "suggestions": List<CompletionSuggestion>
-/// "libraryUrisToImport": List<String>
/// "isIncomplete": bool
/// }
///
@@ -4853,31 +4852,16 @@
/// (if isIncomplete was true).
///
/// This list contains suggestions from both imported, and not yet imported
- /// libraries. Items from not yet imported libraries will have
- /// libraryUriToImportIndex set, which is an index into the
- /// libraryUrisToImport in this response.
+ /// libraries. Items from not yet imported libraries will have isNotImported
+ /// set to true.
List<CompletionSuggestion> suggestions;
- /// The list of libraries with declarations that are not yet available in the
- /// file where completion was requested, most often because the library is
- /// not yet imported. The declarations still might be included into the
- /// suggestions, and the client should use getSuggestionDetails2 on selection
- /// to make the library available in the file.
- ///
- /// Each item is the URI of a library, such as package:foo/bar.dart or
- /// file:///home/me/workspace/foo/test/bar_test.dart.
- List<String> libraryUrisToImport;
-
/// True if the number of suggestions after filtering was greater than the
/// requested maxResults.
bool isIncomplete;
- CompletionGetSuggestions2Result(
- this.replacementOffset,
- this.replacementLength,
- this.suggestions,
- this.libraryUrisToImport,
- this.isIncomplete);
+ CompletionGetSuggestions2Result(this.replacementOffset,
+ this.replacementLength, this.suggestions, this.isIncomplete);
factory CompletionGetSuggestions2Result.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@@ -4907,15 +4891,6 @@
} else {
throw jsonDecoder.mismatch(jsonPath, 'suggestions');
}
- List<String> libraryUrisToImport;
- if (json.containsKey('libraryUrisToImport')) {
- libraryUrisToImport = jsonDecoder.decodeList(
- jsonPath + '.libraryUrisToImport',
- json['libraryUrisToImport'],
- jsonDecoder.decodeString);
- } else {
- throw jsonDecoder.mismatch(jsonPath, 'libraryUrisToImport');
- }
bool isIncomplete;
if (json.containsKey('isIncomplete')) {
isIncomplete = jsonDecoder.decodeBool(
@@ -4923,8 +4898,8 @@
} else {
throw jsonDecoder.mismatch(jsonPath, 'isIncomplete');
}
- return CompletionGetSuggestions2Result(replacementOffset,
- replacementLength, suggestions, libraryUrisToImport, isIncomplete);
+ return CompletionGetSuggestions2Result(
+ replacementOffset, replacementLength, suggestions, isIncomplete);
} else {
throw jsonDecoder.mismatch(
jsonPath, 'completion.getSuggestions2 result', json);
@@ -4946,7 +4921,6 @@
result['suggestions'] = suggestions
.map((CompletionSuggestion value) => value.toJson())
.toList();
- result['libraryUrisToImport'] = libraryUrisToImport;
result['isIncomplete'] = isIncomplete;
return result;
}
@@ -4966,8 +4940,6 @@
replacementLength == other.replacementLength &&
listEqual(suggestions, other.suggestions,
(CompletionSuggestion a, CompletionSuggestion b) => a == b) &&
- listEqual(libraryUrisToImport, other.libraryUrisToImport,
- (String a, String b) => a == b) &&
isIncomplete == other.isIncomplete;
}
return false;
@@ -4978,7 +4950,6 @@
replacementOffset,
replacementLength,
suggestions,
- libraryUrisToImport,
isIncomplete,
);
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index a63cff8..66200d1 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -82,7 +82,7 @@
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
class AnalysisDriver implements AnalysisDriverGeneric {
/// The version of data format, should be incremented on every format change.
- static const int DATA_VERSION = 194;
+ static const int DATA_VERSION = 196;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index d666d5c..1b45e50 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -21,7 +21,6 @@
import 'package:analyzer/src/dart/ast/token.dart';
import 'package:analyzer/src/dart/constant/compute.dart';
import 'package:analyzer/src/dart/constant/evaluation.dart';
-import 'package:analyzer/src/dart/constant/value.dart';
import 'package:analyzer/src/dart/element/display_string_builder.dart';
import 'package:analyzer/src/dart/element/member.dart';
import 'package:analyzer/src/dart/element/nullability_eliminator.dart';
@@ -1255,153 +1254,6 @@
}
}
-/// A field element representing an enum constant.
-class ConstFieldElementImpl_EnumValue extends ConstFieldElementImpl_ofEnum {
- final int _index;
-
- ConstFieldElementImpl_EnumValue(
- EnumElementImpl enumElement, String name, this._index)
- : super(enumElement, name);
-
- @override
- Expression? get constantInitializer => null;
-
- @override
- EvaluationResultImpl? get evaluationResult {
- if (_evaluationResult == null) {
- Map<String, DartObjectImpl> fieldMap = <String, DartObjectImpl>{
- 'index': DartObjectImpl(
- library.typeSystem,
- library.typeProvider.intType,
- IntState(_index),
- ),
- // TODO(brianwilkerson) There shouldn't be a field with the same name as
- // the constant, but we can't remove it until a version of dartdoc that
- // doesn't depend on it has been published and pulled into the SDK. The
- // map entry below should be removed when
- // https://github.com/dart-lang/dartdoc/issues/2318 has been resolved.
- name: DartObjectImpl(
- library.typeSystem,
- library.typeProvider.intType,
- IntState(_index),
- ),
- };
- DartObjectImpl value = DartObjectImpl(
- library.typeSystem,
- type,
- GenericState(fieldMap),
- );
- _evaluationResult = EvaluationResultImpl(value);
- }
- return _evaluationResult;
- }
-
- @override
- bool get hasInitializer => false;
-
- @override
- bool get isEnumConstant => true;
-
- @override
- Element get nonSynthetic => this;
-
- @override
- InterfaceType get type =>
- ElementTypeProvider.current.getFieldType(this) as InterfaceType;
-
- @override
- InterfaceType get typeInternal => _enum.thisType;
-}
-
-/// The synthetic `values` field of an enum.
-class ConstFieldElementImpl_EnumValues extends ConstFieldElementImpl_ofEnum {
- ConstFieldElementImpl_EnumValues(EnumElementImpl enumElement)
- : super(enumElement, 'values') {
- isSynthetic = true;
- }
-
- @override
- EvaluationResultImpl get evaluationResult {
- if (_evaluationResult == null) {
- var constantValues = <DartObjectImpl>[];
- for (FieldElement field in _enum.fields) {
- if (field is ConstFieldElementImpl_EnumValue) {
- constantValues.add(field.evaluationResult!.value!);
- }
- }
- _evaluationResult = EvaluationResultImpl(
- DartObjectImpl(
- library.typeSystem,
- type,
- ListState(constantValues),
- ),
- );
- }
- return _evaluationResult!;
- }
-
- @override
- String get name => 'values';
-
- @override
- InterfaceType get type =>
- ElementTypeProvider.current.getFieldType(this) as InterfaceType;
-
- @override
- InterfaceType get typeInternal {
- if (_type == null) {
- return _type = library.typeProvider.listType(_enum.thisType);
- }
- return _type as InterfaceType;
- }
-}
-
-/// An abstract constant field of an enum.
-abstract class ConstFieldElementImpl_ofEnum extends ConstFieldElementImpl {
- final EnumElementImpl _enum;
-
- ConstFieldElementImpl_ofEnum(this._enum, String name) : super(name, -1) {
- enclosingElement = _enum;
- }
-
- @override
- set evaluationResult(_) {
- assert(false);
- }
-
- @override
- bool get isConst => true;
-
- @override
- set isConst(bool isConst) {
- assert(false);
- }
-
- @override
- bool get isConstantEvaluated => true;
-
- @override
- set isFinal(bool isFinal) {
- assert(false);
- }
-
- @override
- bool get isStatic => true;
-
- @override
- set isStatic(bool isStatic) {
- assert(false);
- }
-
- @override
- Element get nonSynthetic => _enum;
-
- @override
- set type(DartType type) {
- assert(false);
- }
-}
-
/// A [LocalVariableElement] for a local 'const' variable that has an
/// initializer.
class ConstLocalVariableElementImpl extends LocalVariableElementImpl
@@ -1474,8 +1326,8 @@
}
@override
- ClassElementImpl get enclosingElement =>
- super.enclosingElement as ClassElementImpl;
+ AbstractClassElementImpl get enclosingElement =>
+ super.enclosingElement as AbstractClassElementImpl;
@override
bool get isConst {
@@ -2818,6 +2670,7 @@
/// An [AbstractClassElementImpl] which is an enum.
class EnumElementImpl extends AbstractClassElementImpl {
ElementLinkedData? linkedData;
+ List<ConstructorElement> _constructors = _Sentinel.constructorElement;
/// Initialize a newly created class element to have the given [name] at the
/// given [offset] in the file that contains the declaration of this element.
@@ -2843,11 +2696,14 @@
@override
List<ConstructorElement> get constructors {
- // The equivalent code for enums in the spec shows a single constructor,
- // but that constructor is not callable (since it is a compile-time error
- // to subclass, mix-in, implement, or explicitly instantiate an enum).
- // So we represent this as having no constructors.
- return const <ConstructorElement>[];
+ return _constructors;
+ }
+
+ set constructors(List<ConstructorElement> constructors) {
+ for (var constructor in constructors) {
+ (constructor as ConstructorElementImpl).enclosingElement = this;
+ }
+ _constructors = constructors;
}
@override
@@ -3360,7 +3216,13 @@
}
@override
- bool get isEnumConstant => false;
+ bool get isEnumConstant {
+ return hasModifier(Modifier.ENUM_CONSTANT);
+ }
+
+ set isEnumConstant(bool isEnumConstant) {
+ setModifier(Modifier.ENUM_CONSTANT, isEnumConstant);
+ }
@override
bool get isExternal {
@@ -4423,58 +4285,61 @@
/// Indicates that a class element was defined by an enum declaration.
static const Modifier ENUM = Modifier('ENUM', 6);
+ /// Indicates that the element is an enum constant field.
+ static const Modifier ENUM_CONSTANT = Modifier('ENUM_CONSTANT', 7);
+
/// Indicates that a class element was defined by an enum declaration.
- static const Modifier EXTERNAL = Modifier('EXTERNAL', 7);
+ static const Modifier EXTERNAL = Modifier('EXTERNAL', 8);
/// Indicates that the modifier 'factory' was applied to the element.
- static const Modifier FACTORY = Modifier('FACTORY', 8);
+ static const Modifier FACTORY = Modifier('FACTORY', 9);
/// Indicates that the modifier 'final' was applied to the element.
- static const Modifier FINAL = Modifier('FINAL', 9);
+ static const Modifier FINAL = Modifier('FINAL', 10);
/// Indicates that an executable element has a body marked as being a
/// generator.
- static const Modifier GENERATOR = Modifier('GENERATOR', 10);
+ static const Modifier GENERATOR = Modifier('GENERATOR', 11);
/// Indicates that the pseudo-modifier 'get' was applied to the element.
- static const Modifier GETTER = Modifier('GETTER', 11);
+ static const Modifier GETTER = Modifier('GETTER', 12);
/// A flag used for libraries indicating that the variable has an explicit
/// initializer.
- static const Modifier HAS_INITIALIZER = Modifier('HAS_INITIALIZER', 12);
+ static const Modifier HAS_INITIALIZER = Modifier('HAS_INITIALIZER', 13);
/// A flag used for fields and top-level variables that have implicit type,
/// and specify when the type has been inferred.
- static const Modifier HAS_TYPE_INFERRED = Modifier('HAS_TYPE_INFERRED', 13);
+ static const Modifier HAS_TYPE_INFERRED = Modifier('HAS_TYPE_INFERRED', 14);
/// A flag used for libraries indicating that the defining compilation unit
/// has a `part of` directive, meaning that this unit should be a part,
/// but is used as a library.
static const Modifier HAS_PART_OF_DIRECTIVE =
- Modifier('HAS_PART_OF_DIRECTIVE', 14);
+ Modifier('HAS_PART_OF_DIRECTIVE', 15);
/// Indicates that the associated element did not have an explicit type
/// associated with it. If the element is an [ExecutableElement], then the
/// type being referred to is the return type.
- static const Modifier IMPLICIT_TYPE = Modifier('IMPLICIT_TYPE', 15);
+ static const Modifier IMPLICIT_TYPE = Modifier('IMPLICIT_TYPE', 16);
/// Indicates that modifier 'lazy' was applied to the element.
- static const Modifier LATE = Modifier('LATE', 16);
+ static const Modifier LATE = Modifier('LATE', 17);
/// Indicates that a class is a mixin application.
- static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 17);
+ static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 18);
/// Indicates that the pseudo-modifier 'set' was applied to the element.
- static const Modifier SETTER = Modifier('SETTER', 18);
+ static const Modifier SETTER = Modifier('SETTER', 19);
/// Indicates that the modifier 'static' was applied to the element.
- static const Modifier STATIC = Modifier('STATIC', 19);
+ static const Modifier STATIC = Modifier('STATIC', 20);
/// Indicates that the element does not appear in the source code but was
/// implicitly created. For example, if a class does not define any
/// constructors, an implicit zero-argument constructor will be created and it
/// will be marked as being synthetic.
- static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 20);
+ static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 21);
static const List<Modifier> values = [
ABSTRACT,
@@ -4484,6 +4349,7 @@
DART_CORE_OBJECT,
DEFERRED,
ENUM,
+ ENUM_CONSTANT,
EXTERNAL,
FACTORY,
FINAL,
@@ -5424,6 +5290,11 @@
return !isFinal;
}
+ void bindReference(Reference reference) {
+ this.reference = reference;
+ reference.element = this;
+ }
+
void createImplicitAccessors(Reference enclosingRef, String name) {
getter = PropertyAccessorElementImpl_ImplicitGetter(
this,
diff --git a/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart b/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
index f6a8e6a..0652729 100644
--- a/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
@@ -175,7 +175,9 @@
/// TODO(scheglov) Remove after https://github.com/dart-lang/sdk/issues/31925
void _clearConstantEvaluationResults() {
for (var constant in _libraryConstants) {
- if (constant is ConstFieldElementImpl_ofEnum) continue;
+ if (constant is ConstFieldElementImpl && constant.isEnumConstant) {
+ continue;
+ }
if (constant is ConstVariableElement) {
constant.evaluationResult = null;
}
diff --git a/pkg/analyzer/lib/src/summary2/bundle_reader.dart b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
index 14aa0a2..ab6cf0e 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
@@ -281,16 +281,13 @@
var indexField = element.getField('index') as FieldElementImpl;
indexField.type = typeProvider.intType;
+ var valuesField = element.getField('values') as ConstFieldElementImpl;
+ valuesField.constantInitializer = reader._readRequiredNode() as Expression;
+ valuesField.type = typeProvider.listType(element.thisType);
+
var toStringMethod = element.getMethod('toString') as MethodElementImpl;
toStringMethod.returnType = typeProvider.stringType;
- for (var constant in element.constants) {
- constant as FieldElementImpl;
- constant.metadata = reader._readAnnotationList(
- unitElement: element.enclosingElement,
- );
- }
-
applyConstantOffsets?.perform();
}
}
@@ -568,7 +565,7 @@
List<ConstructorElementImpl> _readConstructors(
CompilationUnitElementImpl unitElement,
- ClassElementImpl classElement,
+ AbstractClassElementImpl classElement,
Reference classReference,
) {
var containerRef = classReference.getChild('@constructor');
@@ -609,53 +606,46 @@
);
element.setLinkedData(reference, linkedData);
+ var accessors = <PropertyAccessorElement>[];
var fields = <FieldElement>[];
- var getters = <PropertyAccessorElement>[];
// Build the 'index' field.
{
- var field = FieldElementImpl('index', -1)
- ..enclosingElement = element
- ..isSynthetic = true
- ..isFinal = true;
- fields.add(field);
- getters.add(
- PropertyAccessorElementImpl_ImplicitGetter(field,
- reference: reference.getChild('@getter').getChild('index'))
- ..enclosingElement = element,
+ var indexField = ConstFieldElementImpl('index', -1)
+ ..isFinal = true
+ ..isSynthetic = true;
+ indexField.bindReference(
+ reference.getChild('@field').getChild('index'),
);
+ indexField.createImplicitAccessors(reference, 'index');
+ fields.add(indexField);
+ accessors.add(indexField.getter!);
}
+ _readFields(unitElement, element, reference, accessors, fields);
+ _readPropertyAccessors(
+ unitElement, element, reference, accessors, fields, '@field');
+
// Build the 'values' field.
{
- var field = ConstFieldElementImpl_EnumValues(element);
+ var field = ConstFieldElementImpl('values', -1)
+ ..isConst = true
+ ..isStatic = true
+ ..isSynthetic = true;
fields.add(field);
- getters.add(
+ accessors.add(
PropertyAccessorElementImpl_ImplicitGetter(field,
reference: reference.getChild('@getter').getChild('values'))
..enclosingElement = element,
);
}
- // Build fields for all enum constants.
- var containerRef = reference.getChild('@constant');
- var constantCount = _reader.readUInt30();
- for (var i = 0; i < constantCount; i++) {
- var constantName = _reader.readStringReference();
- var field = ConstFieldElementImpl_EnumValue(element, constantName, i);
- var constantRef = containerRef.getChild(constantName);
- field.reference = constantRef;
- constantRef.element = field;
- fields.add(field);
- getters.add(
- PropertyAccessorElementImpl_ImplicitGetter(field,
- reference: reference.getChild('@getter').getChild(constantName))
- ..enclosingElement = element,
- );
- }
-
element.fields = fields;
- element.accessors = getters;
+ element.accessors = accessors;
+
+ element.constructors = _readConstructors(unitElement, element, reference);
+ // element.methods = _readMethods(unitElement, element, reference);
+
element.createToStringMethodElement();
return element;
diff --git a/pkg/analyzer/lib/src/summary2/bundle_writer.dart b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
index 946fd6e6..240ec16 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
@@ -174,12 +174,19 @@
_sink._writeStringReference(element.name);
_resolutionSink._writeAnnotationList(element.metadata);
- var constants =
- element.fields.whereType<ConstFieldElementImpl_EnumValue>().toList();
- _writeList<FieldElement>(constants, (field) {
- _sink._writeStringReference(field.name);
- _resolutionSink._writeAnnotationList(field.metadata);
- });
+ var valuesField = element.getField('values') as ConstFieldElementImpl;
+ _resolutionSink._writeNode(valuesField.constantInitializer!);
+
+ _writeList(
+ element.fields.where((e) => !e.isSynthetic).toList(),
+ _writeFieldElement,
+ );
+ _writeList(
+ element.accessors.where((e) => !e.isSynthetic).toList(),
+ _writePropertyAccessorElement,
+ );
+ _writeList(element.constructors, _writeConstructorElement);
+ // _writeList(element.methods, _writeMethodElement);
}
void _writeExportElement(ExportElement element) {
diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart
index f0d5965..ea24e67 100644
--- a/pkg/analyzer/lib/src/summary2/element_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/element_builder.dart
@@ -3,12 +3,16 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/ast_factory.dart';
+import 'package:analyzer/src/dart/ast/token.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
+import 'package:analyzer/src/summary2/ast_binary_tokens.dart';
import 'package:analyzer/src/summary2/library_builder.dart';
import 'package:analyzer/src/summary2/link.dart';
import 'package:analyzer/src/summary2/reference.dart';
@@ -1138,37 +1142,59 @@
var getters = <PropertyAccessorElementImpl>[];
// Build the 'index' field.
+ FieldElementImpl indexField;
{
- var field = FieldElementImpl('index', -1)
+ var field = ConstFieldElementImpl('index', -1)
..enclosingElement = element
..isSynthetic = true
..isFinal = true
..type = libraryElement.typeProvider.intType;
+ field.bindReference(
+ reference.getChild('@field').getChild('index'),
+ );
+ indexField = field;
fields.add(field);
getters.add(PropertyAccessorElementImpl_ImplicitGetter(field,
reference: reference.getChild('@getter').getChild('index'))
..enclosingElement = element);
}
- // Build the 'values' field.
- {
- var field = ConstFieldElementImpl_EnumValues(element);
- fields.add(field);
- getters.add(PropertyAccessorElementImpl_ImplicitGetter(field,
- reference: reference.getChild('@getter').getChild('values'))
- ..enclosingElement = element);
- }
+ var constructorReference =
+ reference.getChild('@constructor').getChild('_');
+ var constructor = ConstructorElementImpl('_', -1)
+ ..isConst = true
+ ..isSynthetic = true
+ ..parameters = [
+ FieldFormalParameterElementImpl(
+ name: 'index',
+ nameOffset: -1,
+ parameterKind: ParameterKind.REQUIRED,
+ )
+ ..field = indexField
+ ..type = libraryElement.typeProvider.intType,
+ ParameterElementImpl(
+ name: 'name',
+ nameOffset: -1,
+ parameterKind: ParameterKind.REQUIRED,
+ )..type = libraryElement.typeProvider.stringType,
+ ]
+ ..reference = constructorReference;
+ constructorReference.element = constructor;
+ element.constructors = [constructor];
// Build fields for all enum constants.
- var containerRef = reference.getChild('@constant');
+ var containerRef = reference.getChild('@field');
var constants = node.constants;
+ var valuesElements = <Expression>[];
for (var i = 0; i < constants.length; ++i) {
var constant = constants[i];
var name = constant.name.name;
var reference = containerRef.getChild(name);
- var field = ConstFieldElementImpl_EnumValue(element, name, i);
- // TODO(scheglov) test it
- field.nameOffset = constant.name.offset;
+ var field = ConstFieldElementImpl(name, constant.name.offset)
+ ..isConst = true
+ ..isEnumConstant = true
+ ..isStatic = true
+ ..type = element.thisType;
_setCodeRange(field, constant);
_setDocumentation(field, constant);
field.reference = reference;
@@ -1176,9 +1202,63 @@
unitElement as CompilationUnitElementImpl,
constant.metadata,
);
+ field.constantInitializer = astFactory.instanceCreationExpression(
+ null,
+ astFactory.constructorName(
+ astFactory.namedType(
+ name: astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, element.name, -1),
+ )..staticElement = element,
+ )..type = element.thisType,
+ null,
+ null,
+ )..staticElement = constructor,
+ astFactory.argumentList(
+ Tokens.openParenthesis(),
+ [
+ astFactory.integerLiteral(
+ StringToken(TokenType.STRING, '$i', 0),
+ i,
+ )..staticType = libraryElement.typeProvider.intType,
+ astFactory.simpleStringLiteral(
+ StringToken(TokenType.STRING, "'$name'", 0),
+ name,
+ )..staticType = libraryElement.typeProvider.stringType,
+ ],
+ Tokens.closeParenthesis(),
+ ),
+ )..staticType = element.thisType;
field.createImplicitAccessors(containerRef.parent!, name);
fields.add(field);
getters.add(field.getter as PropertyAccessorElementImpl);
+ valuesElements.add(
+ astFactory.simpleIdentifier(
+ StringToken(TokenType.STRING, name, -1),
+ )
+ ..staticElement = field.getter
+ ..staticType = element.thisType,
+ );
+ }
+
+ // Build the 'values' field.
+ {
+ var type = libraryElement.typeProvider.listType(element.thisType);
+ var field = ConstFieldElementImpl('values', -1)
+ ..isConst = true
+ ..isStatic = true
+ ..isSynthetic = true
+ ..type = type;
+ field.constantInitializer = astFactory.listLiteral(
+ null,
+ null,
+ Tokens.openSquareBracket(),
+ valuesElements,
+ Tokens.closeSquareBracket(),
+ )..staticType = type;
+ fields.add(field);
+ getters.add(PropertyAccessorElementImpl_ImplicitGetter(field,
+ reference: reference.getChild('@getter').getChild('values'))
+ ..enclosingElement = element);
}
element.fields = fields;
diff --git a/pkg/analyzer/lib/src/summary2/element_flags.dart b/pkg/analyzer/lib/src/summary2/element_flags.dart
index 806aab7..0d38935 100644
--- a/pkg/analyzer/lib/src/summary2/element_flags.dart
+++ b/pkg/analyzer/lib/src/summary2/element_flags.dart
@@ -58,10 +58,11 @@
static const int _isAbstract = 1 << 3;
static const int _isConst = 1 << 4;
static const int _isCovariant = 1 << 5;
- static const int _isExternal = 1 << 6;
- static const int _isFinal = 1 << 7;
- static const int _isLate = 1 << 8;
- static const int _isStatic = 1 << 9;
+ static const int _isEnumConstant = 1 << 6;
+ static const int _isExternal = 1 << 7;
+ static const int _isFinal = 1 << 8;
+ static const int _isLate = 1 << 9;
+ static const int _isStatic = 1 << 10;
static void read(SummaryDataReader reader, FieldElementImpl element) {
var byte = reader.readUInt30();
@@ -71,6 +72,7 @@
element.isAbstract = (byte & _isAbstract) != 0;
element.isConst = (byte & _isConst) != 0;
element.isCovariant = (byte & _isCovariant) != 0;
+ element.isEnumConstant = (byte & _isEnumConstant) != 0;
element.isExternal = (byte & _isExternal) != 0;
element.isFinal = (byte & _isFinal) != 0;
element.isLate = (byte & _isLate) != 0;
@@ -85,6 +87,7 @@
result |= element.isAbstract ? _isAbstract : 0;
result |= element.isConst ? _isConst : 0;
result |= element.isCovariant ? _isCovariant : 0;
+ result |= element.isEnumConstant ? _isEnumConstant : 0;
result |= element.isExternal ? _isExternal : 0;
result |= element.isFinal ? _isFinal : 0;
result |= element.isLate ? _isLate : 0;
diff --git a/pkg/analyzer/test/src/dart/resolution/enum_test.dart b/pkg/analyzer/test/src/dart/resolution/enum_test.dart
index 7a52582..5b0bc4c 100644
--- a/pkg/analyzer/test/src/dart/resolution/enum_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/enum_test.dart
@@ -27,18 +27,6 @@
assertType(v.type, 'List<Enum>');
}
- test_isConstantEvaluated() async {
- await assertNoErrorsInCode(r'''
-enum E {
- aaa, bbb
-}
-''');
-
- expect(findElement.field('aaa').isConstantEvaluated, isTrue);
- expect(findElement.field('bbb').isConstantEvaluated, isTrue);
- expect(findElement.field('values').isConstantEvaluated, isTrue);
- }
-
test_isEnumConstant() async {
await assertNoErrorsInCode(r'''
enum E {
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 16b9b82..5b4aab2 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -318,11 +318,7 @@
_writeElements('fields', e.fields, _writePropertyInducingElement);
var constructors = e.constructors;
- if (e.isEnum) {
- expect(constructors, isEmpty);
- } else {
- expect(constructors, isNotEmpty);
- }
+ expect(constructors, isNotEmpty);
_writeElements('constructors', constructors, _writeConstructorElement);
_writeElements('accessors', e.accessors, _writePropertyAccessorElement);
@@ -776,6 +772,7 @@
_writeIf(e.isLate, 'late ');
_writeIf(e.isFinal, 'final ');
_writeIf(e.isConst, 'const ');
+ _writeIf(e is FieldElementImpl && e.isEnumConstant, 'enumConstant ');
_writeName(e);
});
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 984f6c7..358fed5 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -8302,31 +8302,121 @@
fields
synthetic final index @-1
type: int
- synthetic static const values @-1
- type: List<E>
- static const aaa @11
+ static const enumConstant aaa @11
codeOffset: 11
codeLength: 3
type: E
- static const bbb @16
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'aaa' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant bbb @16
codeOffset: 16
codeLength: 3
type: E
- static const ccc @21
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'bbb' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant ccc @21
codeOffset: 21
codeLength: 3
type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'ccc' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ synthetic static const values @-1
+ type: List<E>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::aaa
+ staticType: E
+ token: aaa @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::bbb
+ staticType: E
+ token: bbb @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::ccc
+ staticType: E
+ token: ccc @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ codeOffset: null
+ codeLength: null
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
+ codeOffset: null
+ codeLength: null
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get aaa @-1
returnType: E
synthetic static get bbb @-1
returnType: E
synthetic static get ccc @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -13477,25 +13567,111 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant a @33
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant b @36
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant c @39
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'c' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const a @33
- type: E
- static const b @36
- type: E
- static const c @39
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::c
+ staticType: E
+ token: c @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
synthetic static get b @-1
returnType: E
synthetic static get c @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -15695,25 +15871,111 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant a @8
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant b @11
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant c @14
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'c' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const a @8
- type: E
- static const b @11
- type: E
- static const c @14
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::c
+ staticType: E
+ token: c @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
synthetic static get b @-1
returnType: E
synthetic static get c @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -15748,17 +16010,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant a @8
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const a @8
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -16718,21 +17018,83 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant a @8
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant b @11
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const a @8
- type: E
- static const b @11
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
synthetic static get b @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -16741,25 +17103,111 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant c @22
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'c' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant d @25
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'd' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant e @28
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'e' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const c @22
- type: E
- static const d @25
- type: E
- static const e @28
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::c
+ staticType: E
+ token: c @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::d
+ staticType: E
+ token: d @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::e
+ staticType: E
+ token: e @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get c @-1
returnType: E
synthetic static get d @-1
returnType: E
synthetic static get e @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -16998,17 +17446,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v @69
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v @69
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -17034,23 +17520,85 @@
fields
synthetic final index @-1
type: int
- synthetic static const values @-1
- type: List<E>
- static const a @32
+ static const enumConstant a @32
documentationComment: /**\n * aaa\n */
type: E
- static const b @47
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant b @47
documentationComment: /// bbb
type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ synthetic static const values @-1
+ type: List<E>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
synthetic static get b @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -17081,9 +17629,7 @@
fields
synthetic final index @-1
type: int
- synthetic static const values @-1
- type: List<E>
- static const a @46
+ static const enumConstant a @46
documentationComment: /**\n * aaa\n */
metadata
Annotation
@@ -17094,7 +17640,27 @@
staticType: null
token: annotation @33
type: E
- static const b @75
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant b @75
documentationComment: /// bbb
metadata
Annotation
@@ -17105,15 +17671,59 @@
staticType: null
token: annotation @62
type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ synthetic static const values @-1
+ type: List<E>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
synthetic static get b @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -17141,21 +17751,83 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v1 @9
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v1' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant v2 @13
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v2' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v1 @9
- type: E
- static const v2 @13
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v1
+ staticType: E
+ token: v1 @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v2
+ staticType: E
+ token: v2 @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v1 @-1
returnType: E
synthetic static get v2 @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -17173,17 +17845,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v1 @10
+ type: E1
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v1' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E1::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E1
+ staticType: null
+ token: E1 @-1
+ type: E1
+ staticType: E1
synthetic static const values @-1
type: List<E1>
- static const v1 @10
- type: E1
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E1::@getter::v1
+ staticType: E1
+ token: v1 @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E1>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E1::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E1>
synthetic static get v1 @-1
returnType: E1
+ synthetic static get values @-1
+ returnType: List<E1>
methods
synthetic toString @-1
returnType: String
@@ -17192,17 +17902,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v2 @25
+ type: E2
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v2' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E2::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E2
+ staticType: null
+ token: E2 @-1
+ type: E2
+ staticType: E2
synthetic static const values @-1
type: List<E2>
- static const v2 @25
- type: E2
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E2::@getter::v2
+ staticType: E2
+ token: v2 @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E2>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E2::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E2>
synthetic static get v2 @-1
returnType: E2
+ synthetic static get values @-1
+ returnType: List<E2>
methods
synthetic toString @-1
returnType: String
@@ -17278,25 +18026,111 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant a @8
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant b @11
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant c @14
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'c' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const a @8
- type: E
- static const b @11
- type: E
- static const c @14
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::c
+ staticType: E
+ token: c @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
synthetic static get b @-1
returnType: E
synthetic static get c @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -24137,9 +24971,7 @@
fields
synthetic final index @-1
type: int
- synthetic static const values @-1
- type: List<E>
- static const v @26
+ static const enumConstant v @26
metadata
Annotation
atSign: @ @23
@@ -24149,13 +24981,53 @@
staticType: null
token: a @24
type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ synthetic static const values @-1
+ type: List<E>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -24208,9 +25080,7 @@
fields
synthetic final index @-1
type: int
- synthetic static const values @-1
- type: List<E>
- static const a @78
+ static const enumConstant a @78
metadata
Annotation
arguments: ArgumentList
@@ -24227,9 +25097,49 @@
staticType: null
token: A @71
type: E
- static const b @83
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant b @83
type: E
- static const c @96
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant c @96
metadata
Annotation
arguments: ArgumentList
@@ -24246,17 +25156,65 @@
staticType: null
token: A @89
type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'c' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ synthetic static const values @-1
+ type: List<E>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::c
+ staticType: E
+ token: c @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
synthetic static get b @-1
returnType: E
synthetic static get c @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -24282,17 +25240,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v @26
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v @26
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -25781,9 +26777,7 @@
fields
synthetic final index @-1
type: int
- synthetic static const values @-1
- type: List<E>
- static const e1 @37
+ static const enumConstant e1 @37
metadata
Annotation
atSign: @ @32
@@ -25793,9 +26787,49 @@
staticType: null
token: foo @33
type: E
- static const e2 @43
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'e1' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant e2 @43
type: E
- static const e3 @54
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'e2' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant e3 @54
metadata
Annotation
atSign: @ @49
@@ -25805,17 +26839,65 @@
staticType: null
token: foo @50
type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'e3' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ synthetic static const values @-1
+ type: List<E>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::e1
+ staticType: E
+ token: e1 @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::e2
+ staticType: E
+ token: e2 @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::e3
+ staticType: E
+ token: e3 @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get e1 @-1
returnType: E
synthetic static get e2 @-1
returnType: E
synthetic static get e3 @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -27025,25 +28107,111 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant a @8
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant b @11
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ static const enumConstant c @14
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 2 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'c' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const a @8
- type: E
- static const b @11
- type: E
- static const c @14
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::c
+ staticType: E
+ token: c @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get a @-1
returnType: E
synthetic static get b @-1
returnType: E
synthetic static get c @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -28337,28 +29505,93 @@
synthetic final index @-1
type: int
nonSynthetic: self::@enum::E
+ static const enumConstant a @11
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'a' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ nonSynthetic: self::@enum::E::@field::a
+ static const enumConstant b @14
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 1 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'b' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
+ nonSynthetic: self::@enum::E::@field::b
synthetic static const values @-1
type: List<E>
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::a
+ staticType: E
+ token: a @-1
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::b
+ staticType: E
+ token: b @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
nonSynthetic: self::@enum::E
- static const a @11
- type: E
- nonSynthetic: self::@enum::E::@constant::a
- static const b @14
- type: E
- nonSynthetic: self::@enum::E::@constant::b
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ nonSynthetic: index@-1
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
+ nonSynthetic: name@-1
+ nonSynthetic: self::@enum::E
accessors
synthetic get index @-1
returnType: int
nonSynthetic: self::@enum::E
+ synthetic static get a @-1
+ returnType: E
+ nonSynthetic: self::@enum::E::@field::a
+ synthetic static get b @-1
+ returnType: E
+ nonSynthetic: self::@enum::E::@field::b
synthetic static get values @-1
returnType: List<E>
nonSynthetic: self::@enum::E
- synthetic static get a @-1
- returnType: E
- nonSynthetic: self::@enum::E::@constant::a
- synthetic static get b @-1
- returnType: E
- nonSynthetic: self::@enum::E::@constant::b
methods
synthetic toString @-1
returnType: String
@@ -30311,17 +31544,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v @20
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v @20
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -30418,17 +31689,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v @31
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v @31
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -30459,17 +31768,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v @46
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v @46
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -30537,17 +31884,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v @31
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v @31
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -30613,17 +31998,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v @31
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v @31
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
@@ -30757,17 +32180,55 @@
fields
synthetic final index @-1
type: int
+ static const enumConstant v @9
+ type: E
+ constantInitializer
+ InstanceCreationExpression
+ argumentList: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 0 @0
+ staticType: int
+ SimpleStringLiteral
+ literal: 'v' @0
+ leftParenthesis: ( @0
+ rightParenthesis: ) @0
+ constructorName: ConstructorName
+ staticElement: self::@enum::E::@constructor::_
+ type: NamedType
+ name: SimpleIdentifier
+ staticElement: self::@enum::E
+ staticType: null
+ token: E @-1
+ type: E
+ staticType: E
synthetic static const values @-1
type: List<E>
- static const v @9
- type: E
+ constantInitializer
+ ListLiteral
+ elements
+ SimpleIdentifier
+ staticElement: self::@enum::E::@getter::v
+ staticType: E
+ token: v @-1
+ leftBracket: [ @0
+ rightBracket: ] @0
+ staticType: List<E>
+ constructors
+ synthetic const _ @-1
+ parameters
+ requiredPositional final this.index @-1
+ type: int
+ field: self::@enum::E::@field::index
+ requiredPositional name @-1
+ type: String
accessors
synthetic get index @-1
returnType: int
- synthetic static get values @-1
- returnType: List<E>
synthetic static get v @-1
returnType: E
+ synthetic static get values @-1
+ returnType: List<E>
methods
synthetic toString @-1
returnType: String
diff --git a/pkg/analyzer_plugin/lib/protocol/protocol_common.dart b/pkg/analyzer_plugin/lib/protocol/protocol_common.dart
index 434f6bf..dd7d2a2 100644
--- a/pkg/analyzer_plugin/lib/protocol/protocol_common.dart
+++ b/pkg/analyzer_plugin/lib/protocol/protocol_common.dart
@@ -612,14 +612,11 @@
/// if the parameterName field is omitted.
String? parameterType;
- /// The index in the list of libraries that could be imported to make this
- /// suggestion accessible in the file where completion was requested. The
- /// server provides this list of libraries together with suggestions, so that
- /// information about the library can be shared for multiple suggestions.
- /// This field is omitted if the library is already imported, so that the
- /// suggestion can be inserted as is, or if getSuggestions was used rather
- /// than getSuggestions2.
- int? libraryUriToImportIndex;
+ /// True if the suggestion is for an element from a not yet imported library.
+ /// This field is omitted if the element is declared locally, or is from
+ /// library is already imported, so that the suggestion can be inserted as
+ /// is, or if getSuggestions was used rather than getSuggestions2.
+ bool? isNotImported;
CompletionSuggestion(
this.kind,
@@ -645,7 +642,7 @@
this.hasNamedParameters,
this.parameterName,
this.parameterType,
- this.libraryUriToImportIndex});
+ this.isNotImported});
factory CompletionSuggestion.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@@ -784,11 +781,10 @@
parameterType = jsonDecoder.decodeString(
jsonPath + '.parameterType', json['parameterType']);
}
- int? libraryUriToImportIndex;
- if (json.containsKey('libraryUriToImportIndex')) {
- libraryUriToImportIndex = jsonDecoder.decodeInt(
- jsonPath + '.libraryUriToImportIndex',
- json['libraryUriToImportIndex']);
+ bool? isNotImported;
+ if (json.containsKey('isNotImported')) {
+ isNotImported = jsonDecoder.decodeBool(
+ jsonPath + '.isNotImported', json['isNotImported']);
}
return CompletionSuggestion(kind, relevance, completion, selectionOffset,
selectionLength, isDeprecated, isPotential,
@@ -808,7 +804,7 @@
hasNamedParameters: hasNamedParameters,
parameterName: parameterName,
parameterType: parameterType,
- libraryUriToImportIndex: libraryUriToImportIndex);
+ isNotImported: isNotImported);
} else {
throw jsonDecoder.mismatch(jsonPath, 'CompletionSuggestion', json);
}
@@ -888,9 +884,9 @@
if (parameterType != null) {
result['parameterType'] = parameterType;
}
- var libraryUriToImportIndex = this.libraryUriToImportIndex;
- if (libraryUriToImportIndex != null) {
- result['libraryUriToImportIndex'] = libraryUriToImportIndex;
+ var isNotImported = this.isNotImported;
+ if (isNotImported != null) {
+ result['isNotImported'] = isNotImported;
}
return result;
}
@@ -927,7 +923,7 @@
hasNamedParameters == other.hasNamedParameters &&
parameterName == other.parameterName &&
parameterType == other.parameterType &&
- libraryUriToImportIndex == other.libraryUriToImportIndex;
+ isNotImported == other.isNotImported;
}
return false;
}
@@ -957,7 +953,7 @@
hasNamedParameters,
parameterName,
parameterType,
- libraryUriToImportIndex,
+ isNotImported,
]);
}
@@ -1238,12 +1234,17 @@
/// this field will not be defined.
String? aliasedType;
+ /// If the element belongs to a library, the URI of the library. Otherwise,
+ /// this field will not be defined.
+ String? libraryUri;
+
Element(this.kind, this.name, this.flags,
{this.location,
this.parameters,
this.returnType,
this.typeParameters,
- this.aliasedType});
+ this.aliasedType,
+ this.libraryUri});
factory Element.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@@ -1293,12 +1294,18 @@
aliasedType = jsonDecoder.decodeString(
jsonPath + '.aliasedType', json['aliasedType']);
}
+ String? libraryUri;
+ if (json.containsKey('libraryUri')) {
+ libraryUri = jsonDecoder.decodeString(
+ jsonPath + '.libraryUri', json['libraryUri']);
+ }
return Element(kind, name, flags,
location: location,
parameters: parameters,
returnType: returnType,
typeParameters: typeParameters,
- aliasedType: aliasedType);
+ aliasedType: aliasedType,
+ libraryUri: libraryUri);
} else {
throw jsonDecoder.mismatch(jsonPath, 'Element', json);
}
@@ -1337,6 +1344,10 @@
if (aliasedType != null) {
result['aliasedType'] = aliasedType;
}
+ var libraryUri = this.libraryUri;
+ if (libraryUri != null) {
+ result['libraryUri'] = libraryUri;
+ }
return result;
}
@@ -1353,7 +1364,8 @@
parameters == other.parameters &&
returnType == other.returnType &&
typeParameters == other.typeParameters &&
- aliasedType == other.aliasedType;
+ aliasedType == other.aliasedType &&
+ libraryUri == other.libraryUri;
}
return false;
}
@@ -1368,6 +1380,7 @@
returnType,
typeParameters,
aliasedType,
+ libraryUri,
);
}
diff --git a/pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart b/pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
index f49f000..164ea38 100644
--- a/pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
+++ b/pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
@@ -165,7 +165,7 @@
'hasNamedParameters': isBool,
'parameterName': isString,
'parameterType': isString,
- 'libraryUriToImportIndex': isInt
+ 'isNotImported': isBool
}));
/// CompletionSuggestionKind
@@ -237,7 +237,8 @@
'parameters': isString,
'returnType': isString,
'typeParameters': isString,
- 'aliasedType': isString
+ 'aliasedType': isString,
+ 'libraryUri': isString
}));
/// ElementKind
diff --git a/pkg/analyzer_plugin/tool/spec/common_types_spec.html b/pkg/analyzer_plugin/tool/spec/common_types_spec.html
index 00b5663..ce3a5e9 100644
--- a/pkg/analyzer_plugin/tool/spec/common_types_spec.html
+++ b/pkg/analyzer_plugin/tool/spec/common_types_spec.html
@@ -380,16 +380,14 @@
omitted if the parameterName field is omitted.
</p>
</field>
- <field name="libraryUriToImportIndex" experimental="true" optional="true">
- <ref>int</ref>
+ <field name="isNotImported" optional="true" experimental="true">
+ <ref>bool</ref>
<p>
- The index in the list of libraries that could be imported to make
- this suggestion accessible in the file where completion was requested.
- The server provides this list of libraries together with suggestions,
- so that information about the library can be shared for multiple
- suggestions. This field is omitted if the library is already
- imported, so that the suggestion can be inserted as is, or if
- <tt>getSuggestions</tt> was used rather than <tt>getSuggestions2</tt>.
+ True if the suggestion is for an element from a not yet imported
+ library. This field is omitted if the element is declared locally,
+ or is from library is already imported, so that the suggestion can
+ be inserted as is, or if <tt>getSuggestions</tt> was used rather
+ than <tt>getSuggestions2</tt>.
</p>
</field>
</object>
@@ -565,6 +563,13 @@
Otherwise this field will not be defined.
</p>
</field>
+ <field name="libraryUri" optional="true" experimental="true">
+ <ref>String</ref>
+ <p>
+ If the element belongs to a library, the URI of the library.
+ Otherwise, this field will not be defined.
+ </p>
+ </field>
</object>
</type>
<type name="ElementKind">
diff --git a/pkg/dds/lib/src/dap/adapters/dart.dart b/pkg/dds/lib/src/dap/adapters/dart.dart
index 48957f1..5e1cda7 100644
--- a/pkg/dds/lib/src/dap/adapters/dart.dart
+++ b/pkg/dds/lib/src/dap/adapters/dart.dart
@@ -382,6 +382,22 @@
/// VM Service disconnects.
bool isTerminating = false;
+ /// Removes any breakpoints or pause behaviour and resumes any paused
+ /// isolates.
+ ///
+ /// This is useful when detaching from a process that was attached to, where
+ /// the user would not expect the script to continue to pause on breakpoints
+ /// the had set while attached.
+ Future<void> preventBreakingAndResume() async {
+ // Remove anything that may cause us to pause again.
+ await Future.wait([
+ _isolateManager.clearAllBreakpoints(),
+ _isolateManager.setExceptionPauseMode('None'),
+ ]);
+ // Once those have completed, it's safe to resume anything paused.
+ await _isolateManager.resumeAll();
+ }
+
DartDebugAdapter(
ByteStreamServerChannel channel, {
this.ipv6 = false,
diff --git a/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart b/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
index 1ec25dd..928f94a 100644
--- a/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
+++ b/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
@@ -67,6 +67,9 @@
/// Called by [disconnectRequest] to request that we forcefully shut down the
/// app being run (or in the case of an attach, disconnect).
Future<void> disconnectImpl() async {
+ if (isAttach) {
+ await preventBreakingAndResume();
+ }
terminatePids(ProcessSignal.sigkill);
}
@@ -248,6 +251,9 @@
/// Called by [terminateRequest] to request that we gracefully shut down the
/// app being run (or in the case of an attach, disconnect).
Future<void> terminateImpl() async {
+ if (isAttach) {
+ await preventBreakingAndResume();
+ }
terminatePids(ProcessSignal.sigterm);
await _process?.exitCode;
}
diff --git a/pkg/dds/lib/src/dap/isolate_manager.dart b/pkg/dds/lib/src/dap/isolate_manager.dart
index 9fb0adf..b3fac35 100644
--- a/pkg/dds/lib/src/dap/isolate_manager.dart
+++ b/pkg/dds/lib/src/dap/isolate_manager.dart
@@ -283,6 +283,18 @@
.map((thread) => _sendBreakpoints(thread, uri: uri)));
}
+ /// Clears all breakpoints.
+ Future<void> clearAllBreakpoints() async {
+ // Clear all breakpoints for each URI. Do not remove the items from the map
+ // as that will stop them being tracked/sent by the call below.
+ _clientBreakpointsByUri.updateAll((key, value) => []);
+
+ // Send the breakpoints to all existing threads.
+ await Future.wait(
+ _threadsByThreadId.values.map((thread) => _sendBreakpoints(thread)),
+ );
+ }
+
/// Records exception pause mode as one of 'None', 'Unhandled' or 'All'. All
/// existing isolates will be updated to reflect the new setting.
Future<void> setExceptionPauseMode(String mode) async {
@@ -560,6 +572,14 @@
}
}
+ /// Resumes any paused isolates.
+ Future<void> resumeAll() async {
+ final pausedThreads = threads.where((thread) => thread.paused).toList();
+ await Future.wait(
+ pausedThreads.map((thread) => resumeThread(thread.threadId)),
+ );
+ }
+
/// Calls reloadSources for the given isolate.
Future<void> _reloadSources(vm.IsolateRef isolateRef) async {
final service = _adapter.vmService;
diff --git a/pkg/dds/test/dap/integration/debug_attach_test.dart b/pkg/dds/test/dap/integration/debug_attach_test.dart
index 3df0fc9..810a15f 100644
--- a/pkg/dds/test/dap/integration/debug_attach_test.dart
+++ b/pkg/dds/test/dap/integration/debug_attach_test.dart
@@ -116,6 +116,45 @@
'Exited.',
]);
});
+
+ test('removes breakpoints/pause and resumes on detach', () async {
+ final testFile = dap.createTestFile(simpleBreakpointAndThrowProgram);
+
+ final proc = await startDartProcessPaused(
+ testFile.path,
+ [],
+ cwd: dap.testAppDir.path,
+ );
+ final vmServiceUri = await waitForStdoutVmServiceBanner(proc);
+
+ // Attach to the paused script without resuming and wait for the startup
+ // pause event.
+ await Future.wait([
+ dap.client.expectStop('entry'),
+ dap.client.start(
+ launch: () => dap.client.attach(
+ vmServiceUri: vmServiceUri.toString(),
+ autoResume: false,
+ cwd: dap.testAppDir.path,
+ ),
+ ),
+ ]);
+
+ // Set a breakpoint that we expect not to be hit, as detach should disable
+ // it and resume.
+ final breakpointLine = lineWith(testFile, breakpointMarker);
+ await dap.client.setBreakpoint(testFile, breakpointLine);
+
+ // Detach using terminateRequest. Despite the name, terminateRequest is
+ // the request for a graceful detach (and disconnectRequest is the
+ // forceful shutdown).
+ await dap.client.terminate();
+
+ // Expect the process terminates (and hasn't got stuck on the breakpoint
+ // or exception).
+ await proc.exitCode;
+ });
+
// These tests can be slow due to starting up the external server process.
}, timeout: Timeout.none);
}
diff --git a/pkg/dds/test/dap/integration/test_client.dart b/pkg/dds/test/dap/integration/test_client.dart
index d960bec..ec3c7c0 100644
--- a/pkg/dds/test/dap/integration/test_client.dart
+++ b/pkg/dds/test/dap/integration/test_client.dart
@@ -104,7 +104,7 @@
// When attaching, the paused VM will not be automatically unpaused, but
// instead send a Stopped(reason: 'entry') event. Respond to this by
- // resuming.
+ // resuming (if requested).
final resumeFuture = autoResume
? expectStop('entry').then((event) => continue_(event.threadId!))
: null;
@@ -499,18 +499,23 @@
await Future.wait([
initialize(),
- sendRequest(
- SetBreakpointsArguments(
- source: Source(path: file.path),
- breakpoints: [SourceBreakpoint(line: line, condition: condition)],
- ),
- ),
+ setBreakpoint(file, line, condition: condition),
launch?.call() ?? this.launch(entryFile.path, cwd: cwd, args: args),
], eagerError: true);
return stop;
}
+ /// Sets a breakpoint at [line] in [file].
+ Future<void> setBreakpoint(File file, int line, {String? condition}) async {
+ await sendRequest(
+ SetBreakpointsArguments(
+ source: Source(path: file.path),
+ breakpoints: [SourceBreakpoint(line: line, condition: condition)],
+ ),
+ );
+ }
+
/// Sets the exception pause mode to [pauseMode] and expects to pause after
/// running the script.
///
diff --git a/pkg/dds/test/dap/integration/test_scripts.dart b/pkg/dds/test/dap/integration/test_scripts.dart
index 59bc718..429018b 100644
--- a/pkg/dds/test/dap/integration/test_scripts.dart
+++ b/pkg/dds/test/dap/integration/test_scripts.dart
@@ -109,6 +109,16 @@
}
''';
+/// A simple Dart script that has a breakpoint and an exception used for
+/// testing whether breakpoints and exceptions are being paused on (for example
+/// during detach where they should not).
+const simpleBreakpointAndThrowProgram = '''
+ void main(List<String> args) async {
+ print('Hello!'); $breakpointMarker
+ throw 'error';
+ }
+''';
+
/// A simple Dart script that throws an error and catches it in user code.
const simpleCaughtErrorProgram = r'''
void main(List<String> args) async {
diff --git a/pkg/front_end/test/tool/reload.dart b/pkg/front_end/test/tool/reload.dart
index 887ed3b..15142ec 100644
--- a/pkg/front_end/test/tool/reload.dart
+++ b/pkg/front_end/test/tool/reload.dart
@@ -55,14 +55,26 @@
/// Retrieves the ID of the main isolate using the service protocol.
Future<String> _computeMainId() async {
- var vm = await rpc.sendRequest('getVM');
+ var completer = new Completer<String>();
+ rpc.registerMethod('streamNotify', (response) {
+ if (response['streamId'] == 'Isolate') return;
+ var event = response['event'];
+ if (event['kind'] != 'IsolateStart') return;
+ var isolate = event['isolate'];
+ completer.complete(isolate['id']);
+ });
+ await rpc.sendRequest('streamListen', {'streamId': 'Isolate'});
+ var vm = await rpc.sendRequest('getVM', {});
var isolates = vm['isolates'];
for (var isolate in isolates) {
if (isolate['name'].contains(r'$main')) {
return isolate['id'];
}
}
- return isolates.first['id'];
+ for (var isolate in isolates) {
+ return isolate['id'];
+ }
+ return completer.future;
}
/// Send a request to the VM to reload sources from [entryUri].
diff --git a/pkg/vm/test/incremental_compiler_test.dart b/pkg/vm/test/incremental_compiler_test.dart
index 62a66f4..056d540 100644
--- a/pkg/vm/test/incremental_compiler_test.dart
+++ b/pkg/vm/test/incremental_compiler_test.dart
@@ -1688,6 +1688,15 @@
/// Retrieves the ID of the main isolate using the service protocol.
Future<String> _computeMainId() async {
+ var completer = new Completer<String>();
+ rpc.registerMethod('streamNotify', (response) {
+ if (response['streamId'] == 'Isolate') return;
+ var event = response['event'];
+ if (event['kind'] != 'IsolateStart') return;
+ var isolate = event['isolate'];
+ completer.complete(isolate['id']);
+ });
+ await rpc.sendRequest('streamListen', {'streamId': 'Isolate'});
var vm = await rpc.sendRequest('getVM', {});
var isolates = vm['isolates'];
for (var isolate in isolates) {
@@ -1695,7 +1704,10 @@
return isolate['id'];
}
}
- return isolates.first['id'];
+ for (var isolate in isolates) {
+ return isolate['id'];
+ }
+ return completer.future;
}
/// Send a request to the VM to reload sources from [entryUri].
diff --git a/runtime/lib/vmservice.cc b/runtime/lib/vmservice.cc
index 1f0744a..b99a955 100644
--- a/runtime/lib/vmservice.cc
+++ b/runtime/lib/vmservice.cc
@@ -35,6 +35,7 @@
virtual void VisitIsolate(Isolate* isolate) {
isolate_ports_.Add(isolate->main_port());
isolate_names_.Add(&String::Handle(zone_, String::New(isolate->name())));
+ isolate->set_is_service_registered(true);
}
void RegisterIsolates() {
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index 1048e4e..7510e4f 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -1347,6 +1347,13 @@
UpdateIsolateFlagsBit<IsKernelIsolateBit>(value);
}
+ bool is_service_registered() const {
+ return LoadIsolateFlagsBit<IsServiceRegisteredBit>();
+ }
+ void set_is_service_registered(bool value) {
+ UpdateIsolateFlagsBit<IsServiceRegisteredBit>(value);
+ }
+
const DispatchTable* dispatch_table() const {
return group()->dispatch_table();
}
@@ -1540,7 +1547,8 @@
V(HasAttemptedStepping) \
V(ShouldPausePostServiceRequest) \
V(CopyParentCode) \
- V(IsSystemIsolate)
+ V(IsSystemIsolate) \
+ V(IsServiceRegistered)
// Isolate specific flags.
enum FlagBits {
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index f1f721b..19c98fd 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -796,6 +796,30 @@
uword* fp_;
};
+// The layout of C stack frames.
+#if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) || \
+ defined(HOST_ARCH_ARM) || defined(HOST_ARCH_ARM64)
+// +-------------+
+// | saved IP/LR |
+// +-------------+
+// | saved FP | <- FP
+// +-------------+
+static constexpr intptr_t kHostSavedCallerPcSlotFromFp = 1;
+static constexpr intptr_t kHostSavedCallerFpSlotFromFp = 0;
+#elif defined(HOST_ARCH_RISCV32) || defined(HOST_ARCH_RISCV64)
+// +-------------+
+// | | <- FP
+// +-------------+
+// | saved RA |
+// +-------------+
+// | saved FP |
+// +-------------+
+static constexpr intptr_t kHostSavedCallerPcSlotFromFp = -1;
+static constexpr intptr_t kHostSavedCallerFpSlotFromFp = -2;
+#else
+#error What architecture?
+#endif
+
// If the VM is compiled without frame pointers (which is the default on
// recent GCC versions with optimizing enabled) the stack walking code may
// fail.
@@ -893,7 +917,7 @@
private:
uword* CallerPC(uword* fp) const {
ASSERT(fp != NULL);
- uword* caller_pc_ptr = fp + kSavedCallerPcSlotFromFp;
+ uword* caller_pc_ptr = fp + kHostSavedCallerPcSlotFromFp;
// This may actually be uninitialized, by design (see class comment above).
MSAN_UNPOISON(caller_pc_ptr, kWordSize);
ASAN_UNPOISON(caller_pc_ptr, kWordSize);
@@ -902,7 +926,7 @@
uword* CallerFP(uword* fp) const {
ASSERT(fp != NULL);
- uword* caller_fp_ptr = fp + kSavedCallerFpSlotFromFp;
+ uword* caller_fp_ptr = fp + kHostSavedCallerFpSlotFromFp;
// This may actually be uninitialized, by design (see class comment above).
MSAN_UNPOISON(caller_fp_ptr, kWordSize);
ASAN_UNPOISON(caller_fp_ptr, kWordSize);
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 9787cea..3cb390d 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -4895,7 +4895,7 @@
virtual ~ServiceIsolateVisitor() {}
void VisitIsolate(Isolate* isolate) {
- if (!IsSystemIsolate(isolate)) {
+ if (!IsSystemIsolate(isolate) && isolate->is_service_registered()) {
jsarr_->AddValue(isolate);
}
}
diff --git a/runtime/vm/service_isolate.cc b/runtime/vm/service_isolate.cc
index 95add31..f2a1286 100644
--- a/runtime/vm/service_isolate.cc
+++ b/runtime/vm/service_isolate.cc
@@ -229,9 +229,11 @@
" registered.\n",
name.ToCString(), Dart_GetMainPortId());
}
- return PortMap::PostMessage(WriteMessage(
+ bool result = PortMap::PostMessage(WriteMessage(
/* can_send_any_object */ false, /* same_group */ false, list, port_,
Message::kNormalPriority));
+ isolate->set_is_service_registered(true);
+ return result;
}
bool ServiceIsolate::SendIsolateShutdownMessage() {
diff --git a/tools/VERSION b/tools/VERSION
index 28c95b7..7e3b57f 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 2
+PRERELEASE 3
PRERELEASE_PATCH 0
\ No newline at end of file