# Analysis Server Plugin API Specification

# Version 1.0.0-alpha.0

This document contains a specification of the API used by the analysis server to communicate with analysis server plugins. Changes to the API will be accompanied by an update to the protocol version number according to the principles of semantic versioning (semver.org).

## Overview

TBD

## plugin domain

The plugin domain contains API's related to the execution of a plugin.

TODO: Provide notifications by which plugins can report instrumentation and/or DartSilo data.

TODO: Add a notification to the server protocol to inform the client of problems related to the execution of plugins.

### Requests

plugin.versionCheck

      request: {
        "id": String
        "method": "plugin.versionCheck"
        "params": {
          "byteStorePath": FilePath
          "sdkPath": FilePath
          "version": String
        }
      }

      response: {
        "id": String
        "error": optional RequestError
        "result": {
          "isCompatible": bool
          "name": String
          "version": String
          "contactInfo": optional String
          "interestingFiles": List<String>
        }
      }

  Used to request that the plugin perform a version check to confirm that it works with the version of the analysis server that is executing it.

  #### parameters:

  byteStorePath: FilePath

    The path to the directory containing the on-disk byte store that is to be used by any analysis drivers that are created.

  sdkPath: FilePath

    The path to the directory containing the SDK that is to be used by any analysis drivers that are created.

  version: String

    The version number of the plugin spec supported by the analysis server that is executing the plugin.

  #### returns:

  isCompatible: bool

    A flag indicating whether the plugin supports the same version of the plugin spec as the analysis server. If the value is `false`, then the plugin is expected to shutdown after returning the response.

  name: String

    The name of the plugin. This value is only used when the server needs to identify the plugin, either to the user or for debugging purposes.

  version: String

    The version of the plugin. This value is only used when the server needs to identify the plugin, either to the user or for debugging purposes.

  contactInfo: String (optional)

    Information that the user can use to use to contact the maintainers of the plugin when there is a problem.

  interestingFiles: List<String>

    The glob patterns of the files for which the plugin will provide information. This value is ignored if the `isCompatible` field is `false`. Otherwise, it will be used to identify the files for which the plugin should be notified of changes.

plugin.shutdown

      request: {
        "id": String
        "method": "plugin.shutdown"
      }

      response: {
        "id": String
        "error": optional RequestError
      }

  Used to request that the plugin exit. The server will not send any other requests after this request. The plugin should not send any responses or notifications after sending the response to this request.

### Notifications

plugin.error

      notification: {
        "event": "plugin.error"
        "params": {
          "isFatal": bool
          "message": String
          "stackTrace": String
        }
      }

  Used to report that an unexpected error has occurred while executing the plugin. This notification is not used for problems with specific requests (which should be returned as part of the response) but is used for exceptions that occur while performing other tasks, such as analysis or preparing notifications.

  #### parameters:

  isFatal: bool

    A flag indicating whether the error is a fatal error, meaning that the plugin will shutdown automatically after sending this notification. If `true`, the server will not expect any other responses or notifications from the plugin.

  message: String

    The error message indicating what kind of error was encountered.

  stackTrace: String

    The stack trace associated with the generation of the error, used for debugging the plugin.

plugin.status

      notification: {
        "event": "plugin.status"
        "params": {
          "analysis": optional AnalysisStatus
        }
      }

  Reports the current status of the plugin. Parameters are omitted if there has been no change in the status represented by that parameter.

  Only used for "new" analyzer plugins. Legacy plugins should not use this type.

  #### parameters:

  analysis: AnalysisStatus (optional)

    The current status of analysis (whether analysis is being performed).

## analysis domain

The analysis domain contains API's related to the analysis of files.

### Requests

analysis.getNavigation

      request: {
        "id": String
        "method": "analysis.getNavigation"
        "params": {
          "file": FilePath
          "offset": int
          "length": int
        }
      }

      response: {
        "id": String
        "error": optional RequestError
        "result": {
          "files": List<FilePath>
          "targets": List<NavigationTarget>
          "regions": List<NavigationRegion>
        }
      }

  Return the navigation information associated with the given region of the given file. If the navigation information for the given file has not yet been computed, or the most recently computed navigation information for the given file is out of date, then the response for this request will be delayed until it has been computed. If the content of the file changes after this request was received but before a response could be sent, then an error of type `CONTENT_MODIFIED` will be generated.

  If a navigation region overlaps (but extends either before or after) the given region of the file it will be included in the result. This means that it is theoretically possible to get the same navigation region in response to multiple requests. Clients can avoid this by always choosing a region that starts at the beginning of a line and ends at the end of a (possibly different) line in the file.

  #### parameters:

  file: FilePath

    The file in which navigation information is being requested.

  offset: int

    The offset of the region for which navigation information is being requested.

  length: int

    The length of the region for which navigation information is being requested.

  #### returns:

  files: List<FilePath>

    A list of the paths of files that are referenced by the navigation targets.

  targets: List<NavigationTarget>

    A list of the navigation targets that are referenced by the navigation regions.

  regions: List<NavigationRegion>

    A list of the navigation regions within the requested region of the file.

analysis.handleWatchEvents

      request: {
        "id": String
        "method": "analysis.handleWatchEvents"
        "params": {
          "events": List<WatchEvent>
        }
      }

      response: {
        "id": String
        "error": optional RequestError
      }

  Used to inform the plugin of changes to files in the file system. Only events associated with files that match the `interestingFiles` glob patterns will be forwarded to the plugin.

  #### parameters:

  events: List<WatchEvent>

    The watch events that the plugin should handle.

analysis.setContextRoots

      request: {
        "id": String
        "method": "analysis.setContextRoots"
        "params": {
          "roots": List<ContextRoot>
        }
      }

      response: {
        "id": String
        "error": optional RequestError
      }

  Set the list of context roots that should be analyzed.

  #### parameters:

  roots: List<ContextRoot>

    A list of the context roots that should be analyzed.

analysis.setPriorityFiles

      request: {
        "id": String
        "method": "analysis.setPriorityFiles"
        "params": {
          "files": List<FilePath>
        }
      }

      response: {
        "id": String
        "error": optional RequestError
      }

  Used to set the priority files to the files in the given list. A priority file is a file that should be given priority when scheduling which analysis work to do first. The list typically contains those files that are visible to the user and those for which analysis results will have the biggest impact on the user experience. The order of the files within the list is significant: the first file will be given higher priority than the second, the second higher priority than the third, and so on.

  #### parameters:

  files: List<FilePath>

    The files that are to be a priority for analysis.

analysis.setSubscriptions

      request: {
        "id": String
        "method": "analysis.setSubscriptions"
        "params": {
          "subscriptions": Map<AnalysisService, List<FilePath>>
        }
      }

      response: {
        "id": String
        "error": optional RequestError
      }

  Used to subscribe for services that are specific to individual files. All previous subscriptions should be replaced by the current set of subscriptions. If a given service is not included as a key in the map then no files should be subscribed to the service, exactly as if the service had been included in the map with an explicit empty list of files.

  #### parameters:

  subscriptions: Map<AnalysisService, List<FilePath>>

    A table mapping services to a list of the files being subscribed to the service.

analysis.updateContent

      request: {
        "id": String
        "method": "analysis.updateContent"
        "params": {
          "files": Map<FilePath, AddContentOverlay | ChangeContentOverlay | RemoveContentOverlay>
        }
      }

      response: {
        "id": String
        "error": optional RequestError
      }

  Used to update the content of one or more files. Files that were previously updated but not included in this update remain unchanged. This effectively represents an overlay of the filesystem. The files whose content is overridden are therefore seen by the plugin as being files with the given content, even if the files do not exist on the filesystem or if the file path represents the path to a directory on the filesystem.

  #### parameters:

  files: Map<FilePath, AddContentOverlay | ChangeContentOverlay | RemoveContentOverlay>

    A table mapping the files whose content has changed to a description of the content change.

### Notifications

analysis.errors

      notification: {
        "event": "analysis.errors"
        "params": {
          "file": FilePath
          "errors": List<AnalysisError>
        }
      }

  Used to report the errors associated with a given file. The set of errors included in the notification is always a complete list that supersedes any previously reported errors.

  #### parameters:

  file: FilePath

    The file containing the errors.

  errors: List<AnalysisError>

    The errors contained in the file.

analysis.folding

      notification: {
        "event": "analysis.folding"
        "params": {
          "file": FilePath
          "regions": List<FoldingRegion>
        }
      }

  Used to report the folding regions associated with a given file. Folding regions can be nested, but cannot be overlapping. Nesting occurs when a foldable element, such as a method, is nested inside another foldable element such as a class.

  Folding regions that overlap a folding region computed by the server, or by one of the other plugins that are currently running, might be dropped by the server in order to present a consistent view to the client.

  This notification should only be sent if the server has subscribed to it by including the value `"FOLDING"` in the list of services passed in an analysis.setSubscriptions request.

  #### parameters:

  file: FilePath

    The file containing the folding regions.

  regions: List<FoldingRegion>

    The folding regions contained in the file.

analysis.highlights

      notification: {
        "event": "analysis.highlights"
        "params": {
          "file": FilePath
          "regions": List<HighlightRegion>
        }
      }

  Used to report the highlight regions associated with a given file. Each highlight region represents a particular syntactic or semantic meaning associated with some range. Note that the highlight regions that are returned can overlap other highlight regions if there is more than one meaning associated with a particular region.

  This notification should only be sent if the server has subscribed to it by including the value `"HIGHLIGHTS"` in the list of services passed in an analysis.setSubscriptions request.

  #### parameters:

  file: FilePath

    The file containing the highlight regions.

  regions: List<HighlightRegion>

    The highlight regions contained in the file.

analysis.navigation

      notification: {
        "event": "analysis.navigation"
        "params": {
          "file": FilePath
          "regions": List<NavigationRegion>
          "targets": List<NavigationTarget>
          "files": List<FilePath>
        }
      }

  Used to report the navigation regions associated with a given file. Each navigation region represents a list of targets associated with some range. The lists will usually contain a single target, but can contain more in the case of a part that is included in multiple libraries or in Dart code that is compiled against multiple versions of a package. Note that the navigation regions that are returned should not overlap other navigation regions.

  Navigation regions that overlap a navigation region computed by the server, or by one of the other plugins that are currently running, might be dropped or modified by the server in order to present a consistent view to the client.

  This notification should only be sent if the server has subscribed to it by including the value `"NAVIGATION"` in the list of services passed in an analysis.setSubscriptions request.

  #### parameters:

  file: FilePath

    The file containing the navigation regions.

  regions: List<NavigationRegion>

    The navigation regions contained in the file.

  targets: List<NavigationTarget>

    The navigation targets referenced in the file. They are referenced by NavigationRegions by their index in this array.

  files: List<FilePath>

    The files containing navigation targets referenced in the file. They are referenced by NavigationTargets by their index in this array.

analysis.occurrences

      notification: {
        "event": "analysis.occurrences"
        "params": {
          "file": FilePath
          "occurrences": List<Occurrences>
        }
      }

  Used to report the occurrences of references to elements within a single file. None of the occurrence regions should overlap.

  Occurrence regions that overlap an occurrence region computed by the server, or by one of the other plugins that are currently running, might be dropped or modified by the server in order to present a consistent view to the client.

  This notification should only be sent if the server has subscribed to it by including the value `"OCCURRENCES"` in the list of services passed in an analysis.setSubscriptions request.

  #### parameters:

  file: FilePath

    The file in which the references occur.

  occurrences: List<Occurrences>

    The occurrences of references to elements within the file.

analysis.outline

      notification: {
        "event": "analysis.outline"
        "params": {
          "file": FilePath
          "outline": List<Outline>
        }
      }

  Used to report the outline fragments associated with a single file.

  The outline fragments will be merged with any outline produced by the server and with any fragments produced by other plugins. If the server cannot create a coherent outline, some fragments might be dropped.

  This notification should only be sent if the server has subscribed to it by including the value `"OUTLINE"` in the list of services passed in an analysis.setSubscriptions request.

  #### parameters:

  file: FilePath

    The file with which the outline is associated.

  outline: List<Outline>

    The outline fragments associated with the file.

## completion domain

Deprecated - no longer supported.

The code completion domain contains API's related to getting code completion suggestions.

### Requests

completion.getSuggestions

      request: {
        "id": String
        "method": "completion.getSuggestions"
        "params": {
          "file": FilePath
          "offset": int
        }
      }

      response: {
        "id": String
        "error": optional RequestError
        "result": {
          "replacementOffset": int
          "replacementLength": int
          "results": List<CompletionSuggestion>
        }
      }

  Deprecated - no longer supported.

  Used to request that completion suggestions for the given offset in the given file be returned.

  #### parameters:

  file: FilePath

    The file containing the point at which suggestions are to be made.

  offset: int

    The offset within the file at which suggestions are to be made.

  #### returns:

  replacementOffset: int

    The offset of the start of the text to be replaced. This will be different than the offset used to request the completion suggestions if there was a portion of an identifier before the original offset. In particular, the replacementOffset will be the offset of the beginning of said identifier.

  replacementLength: int

    The length of the text to be replaced if the remainder of the identifier containing the cursor is to be replaced when the suggestion is applied (that is, the number of characters in the existing identifier).

  results: List<CompletionSuggestion>

    The completion suggestions being reported. The notification contains all possible completions at the requested cursor position, even those that do not match the characters the user has already typed. This allows the client to respond to further keystrokes from the user without having to make additional requests.

## edit domain

The edit domain contains API's related to edits that can be applied to the code.

### Requests

edit.getAssists

      request: {
        "id": String
        "method": "edit.getAssists"
        "params": {
          "file": FilePath
          "offset": int
          "length": int
        }
      }

      response: {
        "id": String
        "error": optional RequestError
        "result": {
          "assists": List<PrioritizedSourceChange>
        }
      }

  Used to request the set of assists that are available at the given location. An assist is distinguished from a refactoring primarily by the fact that it affects a single file and does not require user input in order to be performed.

  #### parameters:

  file: FilePath

    The file containing the code for which assists are being requested.

  offset: int

    The offset of the code for which assists are being requested.

  length: int

    The length of the code for which assists are being requested.

  #### returns:

  assists: List<PrioritizedSourceChange>

    The assists that are available at the given location.

edit.getFixes

      request: {
        "id": String
        "method": "edit.getFixes"
        "params": {
          "file": FilePath
          "offset": int
        }
      }

      response: {
        "id": String
        "error": optional RequestError
        "result": {
          "fixes": List<AnalysisErrorFixes>
        }
      }

  Used to request the set of fixes that are available for the errors at a given offset in a given file.

  #### parameters:

  file: FilePath

    The file containing the errors for which fixes are being requested.

  offset: int

    The offset used to select the errors for which fixes will be returned.

  #### returns:

  fixes: List<AnalysisErrorFixes>

    The fixes that are available for the errors at the given offset.

## Types

This section contains descriptions of the data types referenced in the API's of the various domains.

AddContentOverlay: object

  A directive to begin overlaying the contents of a file. The supplied content will be used for analysis in place of the file contents in the filesystem.

  If this directive is used on a file that already has a file content overlay, the old overlay is discarded and replaced with the new one.

  type = "add"
  content: String

    The new content of the file.

AnalysisError: object

  An indication of an error, warning, or hint that was produced by the analysis.

  severity: AnalysisErrorSeverity

    The severity of the error.

  type: AnalysisErrorType

    The type of the error.

  location: Location

    The location associated with the error.

  message: String

    The message to be displayed for this error. The message should indicate what is wrong with the code and why it is wrong.

  correction: String (optional)

    The correction message to be displayed for this error. The correction message should indicate how the user can fix the error. The field is omitted if there is no correction message associated with the error code.

  code: String

    The name, as a string, of the error code associated with this error.

  url: String (optional)

    The URL of a page containing documentation associated with this error.

  contextMessages: List<DiagnosticMessage> (optional)

    Additional messages associated with this diagnostic that provide context to help the user understand the diagnostic.

  hasFix: bool (optional)

    A hint to indicate to interested clients that this error has an associated fix (or fixes). The absence of this field implies there are not known to be fixes. Note that since the operation to calculate whether fixes apply needs to be performant it is possible that complicated tests will be skipped and a false negative returned. For this reason, this attribute should be treated as a "hint". Despite the possibility of false negatives, no false positives should be returned. If a client sees this flag set they can proceed with the confidence that there are in fact associated fixes.

AnalysisErrorFixes: object

  A list of fixes associated with a specific error

  error: AnalysisError

    The error with which the fixes are associated.

  fixes: List<PrioritizedSourceChange>

    The fixes associated with the error.

AnalysisErrorSeverity: String

  An enumeration of the possible severities of analysis errors.

  INFO
  WARNING
  ERROR
AnalysisErrorType: String

  An enumeration of the possible types of analysis errors.

  CHECKED_MODE_COMPILE_TIME_ERROR
  COMPILE_TIME_ERROR
  HINT
  LINT
  STATIC_TYPE_WARNING
  STATIC_WARNING
  SYNTACTIC_ERROR
  TODO
AnalysisService: String

  An enumeration of the services provided by the analysis domain that are related to a specific list of files.

  FOLDING
  HIGHLIGHTS
  NAVIGATION
  OCCURRENCES
  OUTLINE
AnalysisStatus: object

  An indication of the current state of analysis.

  Only used for "new" analyzer plugins. Legacy plugins should not use this type.

  isAnalyzing: bool

    True if analysis is currently being performed.

ChangeContentOverlay: object

  A directive to modify an existing file content overlay. One or more ranges of text are deleted from the old file content overlay and replaced with new text.

  The edits are applied in the order in which they occur in the list. This means that the offset of each edit must be correct under the assumption that all previous edits have been applied.

  It is an error to use this overlay on a file that does not yet have a file content overlay or that has had its overlay removed via RemoveContentOverlay.

  If any of the edits cannot be applied due to its offset or length being out of range, an `INVALID_OVERLAY_CHANGE` error will be reported.

  type = "change"
  edits: List<SourceEdit>

    The edits to be applied to the file.

CompletionSuggestion: object

  A suggestion for how to complete partially entered text. Many of the fields are optional, depending on the kind of element being suggested.

  kind: CompletionSuggestionKind

    The kind of element being suggested.

  relevance: int

    The relevance of this completion suggestion where a higher number indicates a higher relevance.

  completion: String

    The identifier to be inserted if the suggestion is selected. If the suggestion is for a method or function, the client might want to additionally insert a template for the parameters. The information required in order to do so is contained in other fields.

  displayText: String (optional)

    Text to be displayed in, for example, a completion pop-up. This field is only defined if the displayed text should be different than the completion. Otherwise it is omitted.

  replacementOffset: int (optional)

    The offset of the start of the text to be replaced. If supplied, this should be used in preference to the offset provided on the containing completion results. This value may be provided independently of replacementLength (for example if only one differs from the completion result value).

  replacementLength: int (optional)

    The length of the text to be replaced. If supplied, this should be used in preference to the offset provided on the containing completion results. This value may be provided independently of replacementOffset (for example if only one differs from the completion result value).

  selectionOffset: int

    The offset, relative to the beginning of the completion, of where the selection should be placed after insertion.

  selectionLength: int

    The number of characters that should be selected after insertion.

  isDeprecated: bool

    True if the suggested element is deprecated.

  isPotential: bool

    True if the element is not known to be valid for the target. This happens if the type of the target is dynamic.

  docSummary: String (optional)

    An abbreviated version of the Dartdoc associated with the element being suggested. This field is omitted if there is no Dartdoc associated with the element.

  docComplete: String (optional)

    The Dartdoc associated with the element being suggested. This field is omitted if there is no Dartdoc associated with the element.

  declaringType: String (optional)

    The class that declares the element being suggested. This field is omitted if the suggested element is not a member of a class.

  defaultArgumentListString: String (optional)

    A default String for use in generating argument list source contents on the client side.

  defaultArgumentListTextRanges: List<int> (optional)

    Pairs of offsets and lengths describing 'defaultArgumentListString' text ranges suitable for use by clients to set up linked edits of default argument source contents. For example, given an argument list string 'x, y', the corresponding text range [0, 1, 3, 1], indicates two text ranges of length 1, starting at offsets 0 and 3. Clients can use these ranges to treat the 'x' and 'y' values specially for linked edits.

  element: Element (optional)

    Information about the element reference being suggested.

  returnType: String (optional)

    The return type of the getter, function or method or the type of the field being suggested. This field is omitted if the suggested element is not a getter, function or method.

  parameterNames: List<String> (optional)

    The names of the parameters of the function or method being suggested. This field is omitted if the suggested element is not a setter, function or method.

  parameterTypes: List<String> (optional)

    The types of the parameters of the function or method being suggested. This field is omitted if the parameterNames field is omitted.

  requiredParameterCount: int (optional)

    The number of required parameters for the function or method being suggested. This field is omitted if the parameterNames field is omitted.

  hasNamedParameters: bool (optional)

    True if the function or method being suggested has at least one named parameter. This field is omitted if the parameterNames field is omitted.

  parameterName: String (optional)

    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.

  parameterType: String (optional)

    The type of the options parameter being suggested. This field is omitted if the parameterName field is omitted.

  libraryUri: String (optional)

    This field is omitted if `getSuggestions` was used rather than `getSuggestions2`.

    This field is omitted if this suggestion corresponds to a locally declared element.

    If this suggestion corresponds to an already imported element, then this field is the URI of a library that provides this element, not the URI of the library where the element is declared.

    If this suggestion corresponds to an element from a not yet imported library, this field is the URI of a library that could be imported to make this suggestion accessible in the file where completion was requested, such as `package:foo/bar.dart` or `file:///home/me/workspace/foo/test/bar_test.dart`.

  isNotImported: bool (optional)

    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`.

CompletionSuggestionKind: String

  An enumeration of the kinds of elements that can be included in a completion suggestion.

  ARGUMENT_LIST

    A list of arguments for the method or function that is being invoked. For this suggestion kind, the completion field is a textual representation of the invocation and the parameterNames, parameterTypes, and requiredParameterCount attributes are defined.

  IMPORT
  IDENTIFIER

    The element identifier should be inserted at the completion location. For example "someMethod" in `import 'myLib.dart' show someMethod;`. For suggestions of this kind, the element attribute is defined and the completion field is the element's identifier.

  INVOCATION

    The element is being invoked at the completion location. For example, 'someMethod' in `x.someMethod();`. For suggestions of this kind, the element attribute is defined and the completion field is the element's identifier.

  KEYWORD

    A keyword is being suggested. For suggestions of this kind, the completion is the keyword.

  NAMED_ARGUMENT

    A named argument for the current call site is being suggested. For suggestions of this kind, the completion is the named argument identifier including a trailing ':' and a space.

  OPTIONAL_ARGUMENT
  OVERRIDE

    An overriding implementation of a class member is being suggested.

  PARAMETER
  PACKAGE_NAME

    The name of a pub package is being suggested.

ContextRoot: object

  A description of an analysis context.

  root: FilePath

    The absolute path of the root directory containing the files to be analyzed.

  exclude: List<FilePath>

    A list of the absolute paths of files and directories within the root directory that should not be analyzed.

  optionsFile: FilePath (optional)

    The absolute path of the analysis options file that should be used to control the analysis of the files in the context.

DiagnosticMessage: object

  A message associated with a diagnostic.

  For example, if the diagnostic is reporting that a variable has been referenced before it was declared, it might have a diagnostic message that indicates where the variable is declared.

  message: String

    The message to be displayed to the user.

  location: Location

    The location associated with or referenced by the message. Clients should provide the ability to navigate to the location.

Element: object

  Information about an element (something that can be declared in code).

  kind: ElementKind

    The kind of the element.

  name: String

    The name of the element. This is typically used as the label in the outline.

  location: Location (optional)

    The location of the name in the declaration of the element.

  flags: int

    A bit-map containing the following flags:

    - 0x01 - set if the element is explicitly or implicitly abstract
    - 0x02 - set if the element was declared to be 'const'
    - 0x04 - set if the element was declared to be 'final'
    - 0x08 - set if the element is a static member of a class or is a top-level function or field
    - 0x10 - set if the element is private
    - 0x20 - set if the element is deprecated
  parameters: String (optional)

    The parameter list for the element. If the element is not a method or function this field will not be defined. If the element doesn't have parameters (e.g. getter), this field will not be defined. If the element has zero parameters, this field will have a value of "()".

  returnType: String (optional)

    The return type of the element. If the element is not a method or function this field will not be defined. If the element does not have a declared return type, this field will contain an empty string.

  typeParameters: String (optional)

    The type parameter list for the element. If the element doesn't have type parameters, this field will not be defined.

  aliasedType: String (optional)

    If the element is a type alias, this field is the aliased type. Otherwise this field will not be defined.

ElementKind: String

  An enumeration of the kinds of elements.

  CLASS
  CLASS_TYPE_ALIAS
  COMPILATION_UNIT
  CONSTRUCTOR
  CONSTRUCTOR_INVOCATION
  ENUM
  ENUM_CONSTANT
  EXTENSION
  EXTENSION_TYPE
  FIELD
  FILE
  FUNCTION
  FUNCTION_INVOCATION
  FUNCTION_TYPE_ALIAS
  GETTER
  LABEL
  LIBRARY
  LOCAL_VARIABLE
  METHOD
  MIXIN
  PARAMETER
  PREFIX
  SETTER
  TOP_LEVEL_VARIABLE
  TYPE_ALIAS
  TYPE_PARAMETER
  UNIT_TEST_GROUP
  UNIT_TEST_TEST
  UNKNOWN
FilePath: String

  The absolute, normalized path of a file.

  If the format of a file path in a request is not valid, e.g. the path is not absolute or is not normalized, then an error of type `INVALID_FILE_PATH_FORMAT` will be generated.

FoldingKind: String

  An enumeration of the kinds of folding regions.

  ANNOTATIONS
  BLOCK
  CLASS_BODY
  COMMENT
  DIRECTIVES
  DOCUMENTATION_COMMENT
  FILE_HEADER
  FUNCTION_BODY
  INVOCATION
  LITERAL
  PARAMETERS
FoldingRegion: object

  A description of a region that can be folded.

  kind: FoldingKind

    The kind of the region.

  offset: int

    The offset of the region to be folded.

  length: int

    The length of the region to be folded.

HighlightRegion: object

  A description of a region that could have special highlighting associated with it.

  type: HighlightRegionType

    The type of highlight associated with the region.

  offset: int

    The offset of the region to be highlighted.

  length: int

    The length of the region to be highlighted.

HighlightRegionType: String

  An enumeration of the kinds of highlighting that can be applied to files.

  ANNOTATION
  BUILT_IN
  CLASS
  COMMENT_BLOCK
  COMMENT_DOCUMENTATION
  COMMENT_END_OF_LINE
  CONSTRUCTOR
  CONSTRUCTOR_TEAR_OFF
  DIRECTIVE
  DYNAMIC_TYPE

    Deprecated - no longer sent.

  DYNAMIC_LOCAL_VARIABLE_DECLARATION
  DYNAMIC_LOCAL_VARIABLE_REFERENCE
  DYNAMIC_PARAMETER_DECLARATION
  DYNAMIC_PARAMETER_REFERENCE
  ENUM
  ENUM_CONSTANT
  EXTENSION
  EXTENSION_TYPE
  FIELD

    Deprecated - no longer sent.

  FIELD_STATIC

    Deprecated - no longer sent.

  FUNCTION

    Deprecated - no longer sent.

  FUNCTION_DECLARATION

    Deprecated - no longer sent.

  FUNCTION_TYPE_ALIAS
  GETTER_DECLARATION

    Deprecated - no longer sent.

  IDENTIFIER_DEFAULT
  IMPORT_PREFIX
  INSTANCE_FIELD_DECLARATION
  INSTANCE_FIELD_REFERENCE
  INSTANCE_GETTER_DECLARATION
  INSTANCE_GETTER_REFERENCE
  INSTANCE_METHOD_DECLARATION
  INSTANCE_METHOD_REFERENCE
  INSTANCE_METHOD_TEAR_OFF
  INSTANCE_SETTER_DECLARATION
  INSTANCE_SETTER_REFERENCE
  INVALID_STRING_ESCAPE
  KEYWORD
  LABEL
  LIBRARY_NAME
  LITERAL_BOOLEAN
  LITERAL_DOUBLE
  LITERAL_INTEGER
  LITERAL_LIST
  LITERAL_MAP
  LITERAL_RECORD
  LITERAL_STRING
  LOCAL_FUNCTION_DECLARATION
  LOCAL_FUNCTION_REFERENCE
  LOCAL_FUNCTION_TEAR_OFF
  LOCAL_VARIABLE

    Deprecated - no longer sent.

  LOCAL_VARIABLE_DECLARATION
  LOCAL_VARIABLE_REFERENCE
  METHOD

    Deprecated - no longer sent.

  METHOD_DECLARATION

    Deprecated - no longer sent.

  METHOD_DECLARATION_STATIC

    Deprecated - no longer sent.

  METHOD_STATIC

    Deprecated - no longer sent.

  MIXIN
  PARAMETER

    Deprecated - no longer sent.

  SETTER_DECLARATION

    Deprecated - no longer sent.

  TOP_LEVEL_VARIABLE

    Deprecated - no longer sent.

  PARAMETER_DECLARATION
  PARAMETER_REFERENCE
  STATIC_FIELD_DECLARATION
  STATIC_GETTER_DECLARATION
  STATIC_GETTER_REFERENCE
  STATIC_METHOD_DECLARATION
  STATIC_METHOD_REFERENCE
  STATIC_METHOD_TEAR_OFF
  STATIC_SETTER_DECLARATION
  STATIC_SETTER_REFERENCE
  TOP_LEVEL_FUNCTION_DECLARATION
  TOP_LEVEL_FUNCTION_REFERENCE
  TOP_LEVEL_FUNCTION_TEAR_OFF
  TOP_LEVEL_GETTER_DECLARATION
  TOP_LEVEL_GETTER_REFERENCE
  TOP_LEVEL_SETTER_DECLARATION
  TOP_LEVEL_SETTER_REFERENCE
  TOP_LEVEL_VARIABLE_DECLARATION
  TYPE_ALIAS
  TYPE_NAME_DYNAMIC
  TYPE_PARAMETER
  UNRESOLVED_INSTANCE_MEMBER_REFERENCE
  VALID_STRING_ESCAPE
LinkedEditGroup: object

  A collection of positions that should be linked (edited simultaneously) for the purposes of updating code after a source change. For example, if a set of edits introduced a new variable name, the group would contain all of the positions of the variable name so that if the client wanted to let the user edit the variable name after the operation, all occurrences of the name could be edited simultaneously.

  Edit groups may have a length of 0 and function as tabstops where there is no default text, for example, an edit that inserts an `if` statement might provide an empty group between parens where a condition should be typed. For this reason, it's also valid for a group to contain only a single position that is not linked to others.

  positions: List<Position>

    The positions of the regions (after applying the relevant edits) that should be edited simultaneously.

  length: int

    The length of the regions that should be edited simultaneously.

  suggestions: List<LinkedEditSuggestion>

    Pre-computed suggestions for what every region might want to be changed to.

LinkedEditSuggestion: object

  A suggestion of a value that could be used to replace all of the linked edit regions in a LinkedEditGroup.

  value: String

    The value that could be used to replace all of the linked edit regions.

  kind: LinkedEditSuggestionKind

    The kind of value being proposed.

LinkedEditSuggestionKind: String

  An enumeration of the kind of values that can be suggested for a linked edit.

  METHOD
  PARAMETER
  TYPE
  VARIABLE
Location: object

  A location (character range) within a file.

  file: FilePath

    The file containing the range.

  offset: int

    The offset of the range.

  length: int

    The length of the range.

  startLine: int

    The one-based index of the line containing the first character of the range.

  startColumn: int

    The one-based index of the column containing the first character of the range.

  endLine: int (optional)

    The one-based index of the line containing the character immediately following the range.

  endColumn: int (optional)

    The one-based index of the column containing the character immediately following the range.

NavigationRegion: object

  A description of a region from which the user can navigate to the declaration of an element.

  offset: int

    The offset of the region from which the user can navigate.

  length: int

    The length of the region from which the user can navigate.

  targets: List<int>

    The indexes of the targets (in the enclosing navigation response) to which the given region is bound. By opening the target, clients can implement one form of navigation. This list cannot be empty.

NavigationTarget: object

  A description of a target to which the user can navigate.

  kind: ElementKind

    The kind of the element.

  fileIndex: int

    The index of the file (in the enclosing navigation response) to navigate to.

  offset: int

    The offset of the name of the target to which the user can navigate.

  length: int

    The length of the name of the target to which the user can navigate.

  startLine: int

    The one-based index of the line containing the first character of the name of the target.

  startColumn: int

    The one-based index of the column containing the first character of the name of the target.

  codeOffset: int (optional)

    The offset of the target code to which the user can navigate.

  codeLength: int (optional)

    The length of the target code to which the user can navigate.

Occurrences: object

  A description of the references to a single element within a single file.

  element: Element

    The element that was referenced.

  offsets: List<int>

    The offsets of the name of the referenced element within the file.

  length: int

    The length of the name of the referenced element.

Outline: object

  An node in the outline structure of a file.

  element: Element

    A description of the element represented by this node.

  offset: int

    The offset of the first character of the element. This is different than the offset in the Element, which is the offset of the name of the element. It can be used, for example, to map locations in the file back to an outline.

  length: int

    The length of the element.

  codeOffset: int

    The offset of the first character of the element code, which is neither documentation, nor annotation.

  codeLength: int

    The length of the element code.

  children: List<Outline> (optional)

    The children of the node. The field will be omitted if the node has no children. Children are sorted by offset.

Position: object

  A position within a file.

  file: FilePath

    The file containing the position.

  offset: int

    The offset of the position.

PrioritizedSourceChange: object

  A source change that has a priority associated with it.

  priority: int

    The priority of the change. The value is expected to be non-negative, and zero (0) is the lowest priority.

  change: SourceChange

    The change with which the relevance is associated.

RefactoringKind: String

  An enumeration of the kinds of refactorings that can be created.

  CONVERT_GETTER_TO_METHOD
  CONVERT_METHOD_TO_GETTER
  EXTRACT_LOCAL_VARIABLE
  EXTRACT_METHOD
  EXTRACT_WIDGET
  INLINE_LOCAL_VARIABLE
  INLINE_METHOD
  MOVE_FILE
  RENAME
RefactoringMethodParameter: object

  A description of a parameter in a method refactoring.

  id: String (optional)

    The unique identifier of the parameter. Clients may omit this field for the parameters they want to add.

  kind: RefactoringMethodParameterKind

    The kind of the parameter.

  type: String

    The type that should be given to the parameter, or the return type of the parameter's function type.

  name: String

    The name that should be given to the parameter.

  parameters: String (optional)

    The parameter list of the parameter's function type. If the parameter is not of a function type, this field will not be defined. If the function type has zero parameters, this field will have a value of '()'.

RefactoringMethodParameterKind: String

  An enumeration of the kinds of parameters.

  REQUIRED
  POSITIONAL
  NAMED
RefactoringProblem: object

  A description of a problem related to a refactoring.

  severity: RefactoringProblemSeverity

    The severity of the problem being represented.

  message: String

    A human-readable description of the problem being represented.

  location: Location (optional)

    The location of the problem being represented. This field is omitted unless there is a specific location associated with the problem (such as a location where an element being renamed will be shadowed).

RefactoringProblemSeverity: String

  An enumeration of the severities of problems that can be returned by the refactoring requests.

  INFO

    A minor code problem. No example, because it is not used yet.

  WARNING

    A minor code problem. For example names of local variables should be camel case and start with a lower case letter. Staring the name of a variable with an upper case is OK from the language point of view, but it is nice to warn the user.

  ERROR

    The refactoring technically can be performed, but there is a logical problem. For example the name of a local variable being extracted conflicts with another name in the scope, or duplicate parameter names in the method being extracted, or a conflict between a parameter name and a local variable, etc. In some cases the location of the problem is also provided, so the IDE can show user the location and the problem, and let the user decide whether they want to perform the refactoring. For example the name conflict might be expected, and the user wants to fix it afterwards.

  FATAL

    A fatal error, which prevents performing the refactoring. For example the name of a local variable being extracted is not a valid identifier, or selection is not a valid expression.

RemoveContentOverlay: object

  A directive to remove an existing file content overlay. After processing this directive, the file contents will once again be read from the file system.

  If this directive is used on a file that doesn't currently have a content overlay, it has no effect.

  type = "remove"
RequestError: object

  An indication of a problem with the execution of the server, typically in response to a request.

  code: RequestErrorCode

    A code that uniquely identifies the error that occurred.

  message: String

    A short description of the error.

  stackTrace: String (optional)

    The stack trace associated with processing the request, used for debugging the plugin.

RequestErrorCode: String

  An enumeration of the types of errors that can occur in the execution of the plugin.

  INVALID_OVERLAY_CHANGE

    An "analysis.updateContent" request contained a ChangeContentOverlay object that can't be applied. This can happen for two reasons:

    - there was no preceding AddContentOverlay and hence no content to which the edits could be applied, or
    - one or more of the specified edits have an offset or length that is out of range.
  INVALID_PARAMETER

    One of the method parameters was invalid.

  PLUGIN_ERROR

    An internal error occurred in the plugin while attempting to respond to a request. Also see the plugin.error notification for errors that occur outside of handling a request.

  UNKNOWN_REQUEST

    A request was received that the plugin does not recognize, or cannot handle in its current configuration.

SourceChange: object

  A description of a set of edits that implement a single conceptual change.

  message: String

    A human-readable description of the change to be applied.

    If this change includes multiple edits made for different reasons (such as during a bulk fix operation), the individual items in `edits` may contain more specific descriptions.

  edits: List<SourceFileEdit>

    A list of the edits used to effect the change, grouped by file.

  linkedEditGroups: List<LinkedEditGroup>

    A list of the linked editing groups used to customize the changes that were made.

  selection: Position (optional)

    The position that should be selected after the edits have been applied.

  selectionLength: int (optional)

    The length of the selection (starting at Position) that should be selected after the edits have been applied.

  id: String (optional)

    The optional identifier of the change kind. The identifier remains stable even if the message changes, or is parameterized.

SourceEdit: object

  A description of a single change to a single file.

  offset: int

    The offset of the region to be modified.

  length: int

    The length of the region to be modified.

  replacement: String

    The code that is to replace the specified region in the original code.

  id: String (optional)

    An identifier that uniquely identifies this source edit from other edits in the same response. This field is omitted unless a containing structure needs to be able to identify the edit for some reason.

    For example, some refactoring operations can produce edits that might not be appropriate (referred to as potential edits). Such edits will have an id so that they can be referenced. Edits in the same response that do not need to be referenced will not have an id.

  description: String (optional)

    A human readable description of the change made by this edit.

    This description should be short and suitable to use as a heading with changes grouped by it. For example, a change made as part of a quick-fix may use the message "Replace final with var", allowing multiple changes and multiple applications of the fix to be grouped together.

    This value may be more specific than any value in an enclosing `SourceChange.message` which could contain edits made for different reasons (such as during a bulk fix operation).

SourceFileEdit: object

  A description of a set of changes to a single file.

  file: FilePath

    The file containing the code to be modified.

  fileStamp: long

    The modification stamp of the file at the moment when the change was created, in milliseconds since the "Unix epoch". Will be -1 if the file did not exist and should be created. The client may use this field to make sure that the file was not changed since then, so it is safe to apply the change.

  edits: List<SourceEdit>

    A list of the edits used to effect the change.

WatchEvent: object

  A watch event sent by the server when the file system has been modified.

  type: WatchEventType

    The type of change represented by this event.

  path: FilePath

    The absolute path of the file or directory that changed.

WatchEventType: String

  An indication of the type of change associated with a watch event.

  ADD

    An indication that the file or directory was added.

  MODIFY

    An indication that the file was modified.

  REMOVE

    An indication that the file or directory was removed.

## Refactorings

This section contains additional information for each kind of refactoring. In addition to a brief description of the refactoring, there is a specification of the feedback that is provided when a refactoring is requested using the edit.getRefactoring request (designed to improve the UX) and the options that may be provided to edit.getRefactoring.

CONVERT_GETTER_TO_METHOD

  Convert a getter into a method by removing the keyword get and adding an empty parameter list.

  It is an error if the range contains anything other than all or part of the name of a single getter.

  #### Feedback:

  none

  #### Options:

  none

CONVERT_METHOD_TO_GETTER

  Convert a method into a getter by adding the keyword get and removing the parameter list.

  It is an error if the range contains anything other than all or part of the name of a single method or if the method has a non-empty parameter list.

  #### Feedback:

  none

  #### Options:

  none

EXTRACT_LOCAL_VARIABLE

  Create a local variable initialized by the expression that covers the specified selection.

  It is an error if the selection range is not covered by a complete expression.

  #### Feedback:

  coveringExpressionOffsets: List<int> (optional)

    The offsets of the expressions that cover the specified selection, from the down most to the up most.

  coveringExpressionLengths: List<int> (optional)

    The lengths of the expressions that cover the specified selection, from the down most to the up most.

  names: List<String>

    The proposed names for the local variable.

  offsets: List<int>

    The offsets of the expressions that would be replaced by a reference to the variable.

  lengths: List<int>

    The lengths of the expressions that would be replaced by a reference to the variable. The lengths correspond to the offsets. In other words, for a given expression, if the offset of that expression is offsets[i], then the length of that expression is lengths[i].

  #### Options:

  name: String

    The name that the local variable should be given.

  extractAll: bool

    True if all occurrences of the expression within the scope in which the variable will be defined should be replaced by a reference to the local variable. The expression used to initiate the refactoring will always be replaced.

EXTRACT_METHOD

  Create a method whose body is the specified expression or list of statements, possibly augmented with a return statement.

  It is an error if the range contains anything other than a complete expression (no partial expressions are allowed) or a complete sequence of statements.

  #### Feedback:

  offset: int

    The offset to the beginning of the expression or statements that will be extracted.

  length: int

    The length of the expression or statements that will be extracted.

  returnType: String

    The proposed return type for the method. If the returned element does not have a declared return type, this field will contain an empty string.

  names: List<String>

    The proposed names for the method.

  canCreateGetter: bool

    True if a getter could be created rather than a method.

  parameters: List<RefactoringMethodParameter>

    The proposed parameters for the method.

  offsets: List<int>

    The offsets of the expressions or statements that would be replaced by an invocation of the method.

  lengths: List<int>

    The lengths of the expressions or statements that would be replaced by an invocation of the method. The lengths correspond to the offsets. In other words, for a given expression (or block of statements), if the offset of that expression is offsets[i], then the length of that expression is lengths[i].

  #### Options:

  returnType: String

    The return type that should be defined for the method.

  createGetter: bool

    True if a getter should be created rather than a method. It is an error if this field is true and the list of parameters is non-empty.

  name: String

    The name that the method should be given.

  parameters: List<RefactoringMethodParameter>

    The parameters that should be defined for the method.

    It is an error if a REQUIRED or NAMED parameter follows a POSITIONAL parameter. It is an error if a REQUIRED or POSITIONAL parameter follows a NAMED parameter.

    - To change the order and/or update proposed parameters, add parameters with the same identifiers as proposed.
    - To add new parameters, omit their identifier.
    - To remove some parameters, omit them in this list.
  extractAll: bool

    True if all occurrences of the expression or statements should be replaced by an invocation of the method. The expression or statements used to initiate the refactoring will always be replaced.

INLINE_LOCAL_VARIABLE

  Inline the initializer expression of a local variable in place of any references to that variable.

  It is an error if the range contains anything other than all or part of the name of a single local variable.

  #### Feedback:

  name: String

    The name of the variable being inlined.

  occurrences: int

    The number of times the variable occurs.

  #### Options:

  none

INLINE_METHOD

  Inline a method in place of one or all references to that method.

  It is an error if the range contains anything other than all or part of the name of a single method.

  #### Feedback:

  className: String (optional)

    The name of the class enclosing the method being inlined. If not a class member is being inlined, this field will be absent.

  methodName: String

    The name of the method (or function) being inlined.

  isDeclaration: bool

    True if the declaration of the method is selected and all references should be inlined.

  #### Options:

  deleteSource: bool

    True if the method being inlined should be removed. It is an error if this field is true and inlineAll is false.

  inlineAll: bool

    True if all invocations of the method should be inlined, or false if only the invocation site used to create this refactoring should be inlined.

MOVE_FILE

  Move the given file and update all of the references to that file and from it. The move operation is supported in general case - for renaming a file in the same folder, moving it to a different folder or both.

  The refactoring must be activated before an actual file moving operation is performed.

  The "offset" and "length" fields from the request are ignored, but the file specified in the request specifies the file to be moved.

  #### Feedback:

  none

  #### Options:

  newFile: FilePath

    The new file path to which the given file is being moved.

RENAME

  Rename a given element and all of the references to that element.

  It is an error if the range contains anything other than all or part of the name of a single function (including methods, getters and setters), variable (including fields, parameters and local variables), class or function type.

  #### Feedback:

  offset: int

    The offset to the beginning of the name selected to be renamed.

  length: int

    The length of the name selected to be renamed.

  elementKindName: String

    The human-readable description of the kind of element being renamed (such as “class” or “function type alias”).

  oldName: String

    The old name of the element before the refactoring.

  #### Options:

  newName: String

    The name that the element should have after the refactoring.

## Index

### Domains

#### plugin (↑)

##### Requests

- versionCheck
- shutdown

##### Notifications

- error
- status

#### analysis (↑)

##### Requests

- getNavigation
- handleWatchEvents
- setContextRoots
- setPriorityFiles
- setSubscriptions
- updateContent

##### Notifications

- errors
- folding
- highlights
- navigation
- occurrences
- outline

#### completion (↑)

##### Requests

- getSuggestions

#### edit (↑)

##### Requests

- getAssists
- getFixes

### Types (↑)

- AddContentOverlay
- AnalysisError
- AnalysisErrorFixes
- AnalysisErrorSeverity
- AnalysisErrorType
- AnalysisService
- AnalysisStatus
- ChangeContentOverlay
- CompletionSuggestion
- CompletionSuggestionKind
- ContextRoot
- DiagnosticMessage
- Element
- ElementKind
- FilePath
- FoldingKind
- FoldingRegion
- HighlightRegion
- HighlightRegionType
- LinkedEditGroup
- LinkedEditSuggestion
- LinkedEditSuggestionKind
- Location
- NavigationRegion
- NavigationTarget
- Occurrences
- Outline
- Position
- PrioritizedSourceChange
- RefactoringKind
- RefactoringMethodParameter
- RefactoringMethodParameterKind
- RefactoringProblem
- RefactoringProblemSeverity
- RemoveContentOverlay
- RequestError
- RequestErrorCode
- SourceChange
- SourceEdit
- SourceFileEdit
- WatchEvent
- WatchEventType

### Refactorings (↑)

- CONVERT_GETTER_TO_METHOD
- CONVERT_METHOD_TO_GETTER
- EXTRACT_LOCAL_VARIABLE
- EXTRACT_METHOD
- INLINE_LOCAL_VARIABLE
- INLINE_METHOD
- MOVE_FILE
- RENAME