diff --git a/pkg/analysis_server/lib/protocol/protocol_constants.dart b/pkg/analysis_server/lib/protocol/protocol_constants.dart index e061b39bf76..d9cad4b60d2 100644 --- a/pkg/analysis_server/lib/protocol/protocol_constants.dart +++ b/pkg/analysis_server/lib/protocol/protocol_constants.dart @@ -236,6 +236,8 @@ const String SEARCH_REQUEST_FIND_TOP_LEVEL_DECLARATIONS = const String SEARCH_REQUEST_FIND_TOP_LEVEL_DECLARATIONS_PATTERN = 'pattern'; const String SEARCH_REQUEST_GET_ELEMENT_DECLARATIONS = 'search.getElementDeclarations'; +const String SEARCH_REQUEST_GET_ELEMENT_DECLARATIONS_MAX_RESULTS = 'maxResults'; +const String SEARCH_REQUEST_GET_ELEMENT_DECLARATIONS_PATTERN = 'pattern'; const String SEARCH_REQUEST_GET_TYPE_HIERARCHY = 'search.getTypeHierarchy'; const String SEARCH_REQUEST_GET_TYPE_HIERARCHY_FILE = 'file'; const String SEARCH_REQUEST_GET_TYPE_HIERARCHY_OFFSET = 'offset'; diff --git a/pkg/analysis_server/lib/protocol/protocol_generated.dart b/pkg/analysis_server/lib/protocol/protocol_generated.dart index 3c54e206cb0..8ab87f56972 100644 --- a/pkg/analysis_server/lib/protocol/protocol_generated.dart +++ b/pkg/analysis_server/lib/protocol/protocol_generated.dart @@ -15301,28 +15301,114 @@ class SearchFindTopLevelDeclarationsResult implements ResponseResult { /** * search.getElementDeclarations params * + * { + * "pattern": optional String + * "maxResults": optional int + * } + * * Clients may not extend, implement or mix-in this class. */ class SearchGetElementDeclarationsParams implements RequestParams { + String _pattern; + + int _maxResults; + + /** + * The regular expression used to match the names of declarations. If this + * field is missing, return all declarations. + */ + String get pattern => _pattern; + + /** + * The regular expression used to match the names of declarations. If this + * field is missing, return all declarations. + */ + void set pattern(String value) { + this._pattern = value; + } + + /** + * The maximum number of declarations to return. If this field is missing, + * return all matching declarations. + */ + int get maxResults => _maxResults; + + /** + * The maximum number of declarations to return. If this field is missing, + * return all matching declarations. + */ + void set maxResults(int value) { + this._maxResults = value; + } + + SearchGetElementDeclarationsParams({String pattern, int maxResults}) { + this.pattern = pattern; + this.maxResults = maxResults; + } + + factory SearchGetElementDeclarationsParams.fromJson( + JsonDecoder jsonDecoder, String jsonPath, Object json) { + if (json == null) { + json = {}; + } + if (json is Map) { + String pattern; + if (json.containsKey("pattern")) { + pattern = + jsonDecoder.decodeString(jsonPath + ".pattern", json["pattern"]); + } + int maxResults; + if (json.containsKey("maxResults")) { + maxResults = + jsonDecoder.decodeInt(jsonPath + ".maxResults", json["maxResults"]); + } + return new SearchGetElementDeclarationsParams( + pattern: pattern, maxResults: maxResults); + } else { + throw jsonDecoder.mismatch( + jsonPath, "search.getElementDeclarations params", json); + } + } + + factory SearchGetElementDeclarationsParams.fromRequest(Request request) { + return new SearchGetElementDeclarationsParams.fromJson( + new RequestDecoder(request), "params", request.params); + } + @override - Map toJson() => {}; + Map toJson() { + Map result = {}; + if (pattern != null) { + result["pattern"] = pattern; + } + if (maxResults != null) { + result["maxResults"] = maxResults; + } + return result; + } @override Request toRequest(String id) { - return new Request(id, "search.getElementDeclarations", null); + return new Request(id, "search.getElementDeclarations", toJson()); } + @override + String toString() => JSON.encode(toJson()); + @override bool operator ==(other) { if (other is SearchGetElementDeclarationsParams) { - return true; + return pattern == other.pattern && maxResults == other.maxResults; } return false; } @override int get hashCode { - return 653510116; + int hash = 0; + hash = JenkinsSmiHash.combine(hash, pattern.hashCode); + hash = JenkinsSmiHash.combine(hash, maxResults.hashCode); + return JenkinsSmiHash.finish(hash); } } 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 35eca2f1261..ab48dde0763 100644 --- a/pkg/analysis_server/test/integration/support/integration_test_methods.dart +++ b/pkg/analysis_server/test/integration/support/integration_test_methods.dart @@ -1199,6 +1199,18 @@ abstract class IntegrationTestMixin { /** * Return top-level and class member declarations. * + * Parameters + * + * pattern: String (optional) + * + * The regular expression used to match the names of declarations. If this + * field is missing, return all declarations. + * + * maxResults: int (optional) + * + * The maximum number of declarations to return. If this field is missing, + * return all matching declarations. + * * Returns * * declarations: List @@ -1209,9 +1221,12 @@ abstract class IntegrationTestMixin { * * The list of the paths of files with declarations. */ - Future - sendSearchGetElementDeclarations() async { - var result = await server.send("search.getElementDeclarations", null); + Future sendSearchGetElementDeclarations( + {String pattern, int maxResults}) async { + var params = new SearchGetElementDeclarationsParams( + pattern: pattern, maxResults: maxResults) + .toJson(); + var result = await server.send("search.getElementDeclarations", params); ResponseDecoder decoder = new ResponseDecoder(null); return new SearchGetElementDeclarationsResult.fromJson( decoder, 'result', result); diff --git a/pkg/analysis_server/test/integration/support/protocol_matchers.dart b/pkg/analysis_server/test/integration/support/protocol_matchers.dart index 38017870ccc..973f9a56eb5 100644 --- a/pkg/analysis_server/test/integration/support/protocol_matchers.dart +++ b/pkg/analysis_server/test/integration/support/protocol_matchers.dart @@ -2665,8 +2665,15 @@ final Matcher isSearchFindTopLevelDeclarationsResult = new LazyMatcher(() => /** * search.getElementDeclarations params + * + * { + * "pattern": optional String + * "maxResults": optional int + * } */ -final Matcher isSearchGetElementDeclarationsParams = isNull; +final Matcher isSearchGetElementDeclarationsParams = new LazyMatcher(() => + new MatchesJsonObject("search.getElementDeclarations params", null, + optionalFields: {"pattern": isString, "maxResults": isInt})); /** * search.getElementDeclarations result diff --git a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java index 1c3bc3bd1de..f1f240163d0 100644 --- a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java +++ b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java @@ -733,8 +733,13 @@ public interface AnalysisServer { * {@code search.getElementDeclarations} * * Return top-level and class member declarations. + * + * @param pattern The regular expression used to match the names of declarations. If this field is + * missing, return all declarations. + * @param maxResults The maximum number of declarations to return. If this field is missing, return + * all matching declarations. */ - public void search_getElementDeclarations(GetElementDeclarationsConsumer consumer); + public void search_getElementDeclarations(String pattern, int maxResults, GetElementDeclarationsConsumer consumer); /** * {@code search.getTypeHierarchy} diff --git a/pkg/analysis_server/tool/spec/spec_input.html b/pkg/analysis_server/tool/spec/spec_input.html index 652818680cb..b979640c6ba 100644 --- a/pkg/analysis_server/tool/spec/spec_input.html +++ b/pkg/analysis_server/tool/spec/spec_input.html @@ -1578,6 +1578,22 @@

Return top-level and class member declarations.

+ + + String +

+ The regular expression used to match the names of declarations. + If this field is missing, return all declarations. +

+
+ + int +

+ The maximum number of declarations to return. + If this field is missing, return all matching declarations. +

+
+