dart_language_server 0.1.14

  • Readme
  • Changelog
  • Installing
  • 47

Pub Package Build Status Build status

Dart Language Server #

Wraps the dart analysis server and adapts its default protocol to the language server protocol.

Features #

This server supports:

  • Diagnostic notifications
  • Completion suggestions
  • Jump to definition
  • List references
  • List implementations
  • Hover information
  • Document reference highlights
  • Document outlines
  • Workspace symbol search
  • Quick Fixes / Code Actions
  • Symbol Rename

Installing #

pub global activate dart_language_server

If you have the pub bin directory in your path (you should be warned during the previous command if not) the server can be run as dart_language_server.

Integration with an editor depends on the details of the editor. All communication with this server is through stdin/stdout.

0.1.14 #

  • Set the executeCommandProvider capability.
  • Fix bug searching for a package root when receiving a didOpen for a document in a directory that doesn't exist.

0.1.13+2 #

  • Correct documentHighlightsProviers capability documentHighlightProvider.

0.1.13+1 #

  • Fix some static warnings for dev SDK.

0.1.13 #

  • Rename --force_trace_level argument to --force-trace-level. Keep the old name as a fallback.
  • Add support for sending edits directly with CodeAction literals.
  • Use the 2.0 stable SDK.

0.1.12+2 #

  • Yet another Dart 2 runtime fix: Correct type of List<SymbolInformation> for documentSymbols call.

0.1.12+1 #

  • More Dart 2 runtime fixes:
    • Fix a null boolean when loading an empty hover.
    • Fix the reified type of the List<TextEdit> for applying workspace edits.

0.1.12 #

  • Fix more Dart 2 runtime types for collections deserialized from json.
  • Use Windows style newlines in the analyzer wirelog on Windows platform.
  • Add support for using MarkupContent for hover.

0.1.11+6 #

  • Fix compatibility with Dart 2.
  • Write uncaught exceptions to stderr instead of a temp file.

0.1.11+5 #

  • Bug fix for mishandled edits which could cause offset calculations to become inaccurate.

0.1.11+4 #

  • Bug fix for converting positions in files with windows line endings.

0.1.11+3 #

  • Bug fixes for windows file paths:
    • Use toFilePath() to convert from URI which uses correct separators.
    • Use Directory.systemTemp to use a correct temp directory.
    • Use platform path separators when checking for apparent workspace roots.

0.1.11+2 #

  • Bug Fix: Set implementationProvider and workspaceSymbolProvider to true in server capabilities since these requests are now supported.

0.1.11+1 #

  • Bug Fix: Don't error when textDocument/implementation is called with a position that is not a symbol that can be implemented.

0.1.11 #

  • Add support for textDocument/implementation.

0.1.10 #

  • Add support for workspace/symbol.

0.1.9+4 #

  • Bug Fix: Send null rather than false for codeLensProvider and documentOnTypeFormattingProvider.

0.1.9+3 #

  • Bug Fix: Send a SaveOptions rather than a boolean for ServerCapabilities.textDocumentSync.save

0.1.9+2 #

  • Bug fixes:
    • Reduce the possibilities for Overlays to get out of sync - start requests in order and don't put a timeout on the operations that impact file overlays.
    • Increase timeouts for other operations.
    • Flush logs on each message.
    • Improve performance of textDocument/documentHighlight. Use Occurrences subscription which is per-file rather than references request which is across the entire workspace.

0.1.9+1 #

  • Use the latest package:async.

0.1.9 #

  • Add 'Sort Members' to available code actions.

0.1.8 #

  • Add support for textDocument/documentSymbol.

0.1.7 #

  • Add textDocument/documentHighlights.
  • Bug Fix: Calling textDocument/references on non-identifiers won't freeze up all operations for that document.
  • Add a 500ms time for operations that lock per-file.

0.1.6 #

  • Chunk writes to stdout.

0.1.5+2 #

  • Tolerate keys explicitly set to null instead of omitted.

0.1.5+1 #

  • Bug Fix: Remove usage of new Function type syntax so to restore compatibility with the stable SDK.

0.1.5 #

  • Only treat pubspec.yaml and BUILD files as indications of a package root.
  • Only send empty diagnostics for a file if it is clearing previous diagnostics.

0.1.4 #

  • Stop adding rootUri as an analysis root. When there are nested directories that 'look like' a package this can be very large (like with the SDK repo) and given the other tweaks to how didOpen analysis roots are handled this shouldn't be as useful anymore.

0.1.3 #

  • Add fixes to available code actions.
  • Add support for textDocument/rename.
  • Run requests for the same file serially rather than allowing them to interleave. Fixes some cases where bad overlays can stick around.
  • Add 'Organize imports' to every code actions list.
  • Never offer "Convert into block documentation comment"
  • Add dart/getServerPort extension method.
  • Strip trailing comma from completions since there is no cursor moving support.

0.1.2 #

  • Only add rootUri as an analysis root when it or a parent seems to be a package directory.
  • Add support for code actions.

0.1.1 #

  • Bug Fix: Restore analyzer wire log.
  • Set the client rootUri as an analysis root. Resolves some cases where opening a file in a subdirectory can fail to find symbols from directories higher up.
  • Bug Fix: Set priority files by path rather than URI.
  • Add ability to pass arguments to the analysis server.

0.1.0 #

  • Add support for TextDocumentSyncKind.Incremental.
  • Only send changed diagnostics.

0.0.16 #

  • Reduce memory usage by caching file line lengths instead of complete content.
  • Always reread files that the editor doesn't have open rather than cache their line lengths.
  • Bug Fix: URI decode file paths.

0.0.15 #

  • Report 'Hint' type analysis as a 'Hint' rather than 'Info' diagnostic.
  • Use package:analysis_server_lib.

0.0.14 #

  • Add element description to hover message.

0.0.13+1 #

  • Bug Fix: Report support for hover during initialization.

0.0.13 #

  • Add textDocument/hover - finds the dartdoc string for an element.

0.0.12 #

  • Include definition in list of element references.

0.0.11 #

  • Bug Fix: Conform to spec for headers - use a space after the colon.

0.0.10 #

  • Improved CompletionItemKind for completion suggestions.

0.0.9 #

  • Bug fix: Allow the process to exit when the server is done.

0.0.8 #

  • Add more information in completion item detail field. Add full doc comment to documentation field.
  • Bug fix: Avoid duplicates in reference list when the same file shows up in multiple analysis roots.
  • Only write logs when 'verbose' or 'message' trace level is used.

0.0.7 #

  • Add logging of uncaught asynchronous error logs to a hardcoded path in /tmp
  • Bug Fix: Support forwarding diagnostics for files that haven't already been opened in the editor
  • Add support for textDocument/references call.

0.0.6 #

  • Fix a bug for clients which do not send a trace parameter to initialize call

0.0.5 #

  • Fix an error with sdk 1.22 where lineMode cannot be set on stdin when it is a pipe
  • Separate logs by client. Log names are prefixed with client's directory and pid
  • Fix a buf causing a stack trace when attempting to jump to a token with no definition
  • Ignore updates to old file versions

0.0.4 #

  • Add the initialize method for better spec compliance

0.0.3 #

  • Add support for GoToDefinition

0.0.2 #

  • Add (almost entirely untested) support for completion suggestions.
  • Correct Range translation for diagnostics which span lines.

0.0.1 #

  • Initial experimental version. Starts up the sdk analysis server and forwards file state messages and errors. Can be used to show file diagnostics in an editor.

Use this package as an executable

1. Install it

You can install the package from the command line:

$ pub global activate dart_language_server

2. Use it

The package has the following executables:

$ dart_language_server

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dart_language_server: ^0.1.14

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dart_language_server/dart_language_server.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 17, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-1 points)

7 out of 7 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/protocol/language_server/messages.dart. (-25 points)

Analysis of lib/src/protocol/language_server/messages.dart reported 262 hints, including:

line 6 col 15: Unnecessary new keyword.

line 8 col 12: Unnecessary new keyword.

line 12 col 7: Unnecessary new keyword.

line 14 col 17: Unnecessary new keyword.

line 55 col 15: Unnecessary new keyword.

Fix lib/src/shim.dart. (-1.49 points)

Analysis of lib/src/shim.dart reported 3 hints:

line 436 col 9: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 439 col 9: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 474 col 25: Unnecessary new keyword.

Fix lib/src/logging/wirelog.dart. (-0.50 points)

Analysis of lib/src/logging/wirelog.dart reported 1 hint:

line 19 col 7: 'tap' is deprecated and shouldn't be used. Use the extension instead.

Fix lib/src/utils/guid.dart. (-0.50 points)

Analysis of lib/src/utils/guid.dart reported 1 hint:

line 10 col 16: DO use curly braces for all flow control structures.

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (stream_channel, stream_transform).

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dart_language_server.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
analysis_server_lib ^0.1.2+1 0.1.9
args ^1.0.0 1.5.2
async ^2.0.0 2.4.0
json_rpc_2 ^2.0.3 2.1.0
logging ^0.11.3 0.11.4
meta ^1.1.0 1.1.8
path ^1.4.1 1.6.4
pool ^1.3.0 1.4.0
stream_channel ^1.5.0 1.7.0 2.0.0
stream_transform ^0.0.3 0.0.20 1.1.0
Transitive dependencies
collection 1.14.12
stack_trace 1.9.3
Dev dependencies
build_runner ^1.0.0
message_builder ^0.1.3
test ^1.0.0