getSuggestions method

Future<RuntimeSuggestionsResult> getSuggestions(
  1. String? code,
  2. int? offset,
  3. String? contextFile,
  4. int? contextOffset,
  5. List<RuntimeCompletionVariable>? variables, {
  6. List<RuntimeCompletionExpression>? expressions,
})

Request completion suggestions for the given runtime context.

It might take one or two requests of this type to get completion suggestions. The first request should have only "code", "offset", and "variables", but not "expressions". If there are sub-expressions that can have different runtime types, and are considered to be safe to evaluate at runtime (e.g. getters), so using their actual runtime types can improve completion results, the server will not include the "suggestions" field in the response, and instead will return the "expressions" field. The client will use debug API to get current runtime types for these sub-expressions and send another request, this time with "expressions". If there are no interesting sub-expressions to get runtime types for, or when the "expressions" field is provided by the client, the server will return "suggestions" in the response.

Implementation

Future<RuntimeSuggestionsResult> getSuggestions(
    String? code,
    int? offset,
    String? contextFile,
    int? contextOffset,
    List<RuntimeCompletionVariable>? variables,
    {List<RuntimeCompletionExpression>? expressions}) {
  final Map m = {
    'code': code,
    'offset': offset,
    'contextFile': contextFile,
    'contextOffset': contextOffset,
    'variables': variables
  };
  if (expressions != null) m['expressions'] = expressions;
  return _call('execution.getSuggestions', m)
      .then(RuntimeSuggestionsResult.parse);
}