Skip to content

BSL Language Server

Actions Status Download Latest release GitHub Releases GitHub All Releases Quality Gate Maintainability Coverage Transifex Benchmark telegram

Language Server Protocol implementation for 1C (BSL) - 1C:Enterprise 8 and OneScript languages.

Perfomance measurement - SSL 3.1

Features

Each language-server capability comes with a short animated demo (see the full catalog):

  • Code completion — Context-aware suggestions as you type: global functions, object methods and properties (with type inference), types after the New operator, keywords and local variables.
  • Go to definition — Jump from a usage to the declaration of a procedure, function, variable or method. Works within a module and across configuration modules.
  • Go to implementations — For OneScript classes using the extends inheritance library: jump from an interface method (&Интерфейс) to the same-named methods in every implementing class (&Реализует).
  • Find references — Find all usages of a symbol across the project.
  • Quick documentation (hover) — Hovering over a symbol shows its signature, type and the description from doc comments.
  • Signature help — While typing a method call, shows the parameter list and highlights the active parameter.
  • Diagnostics — Highlights errors, potential issues and coding-standard violations inline and in the Problems panel.
  • Code actions / Quick fixes — Offers automatic fixes for diagnostics and refactorings via a shortcut at the problem location.
  • Formatting — Format the whole document, a selection, or on-the-fly while typing (indentation, keyword casing).
  • Rename — Safely rename a symbol together with all its usages.
  • Linked editing — Editing the declaration of a local symbol (variable, parameter) updates all of its occurrences in the module at once — without invoking rename.
  • Document symbols / Outline — A tree of the module's procedures, functions and regions — in the Outline view and quick navigation.
  • Workspace symbols — Quickly jump to any method or object across the whole project by name.
  • Document highlight — Placing the cursor on a symbol highlights all its occurrences in the current module.
  • Call hierarchy — Who calls a method and what it calls — as an expandable tree.
  • Type hierarchy — For OneScript classes using the extends inheritance library: a tree of supertypes and subtypes derived from the &Расширяет and &Реализует annotations.
  • Code folding — Collapse procedures, functions, regions and blocks for easier navigation.
  • Smart selection — Expand and shrink the selection step by step along syntactic boundaries.
  • Semantic highlighting — Accurate highlighting based on code analysis: distinguishes variables, parameters, methods and annotations.
  • Inlay hints — Inline hints embedded in the code — for example, parameter names at call sites.
  • Code lens — Informational lines above procedures: cognitive and cyclomatic complexity, test run and coverage.
  • Colors: preview and picker — Color preview for Новый Цвет(...) and WebЦвета.*. Clicking the swatch opens the picker — choosing a color updates the code. Web colors convert to/from the RGB constructor representation.
  • Document links (hyperlinks) — Clickable links right in the module text: См./See references in doc comments jump to the mentioned method or object; URLs in comments open in the browser; and optionally (off by default, documentLink.showDiagnosticDescription) the diagnosed range itself becomes a link to the diagnostic's documentation.

Additional capabilities (outside the demo catalog — command line and workspaces):

  • Run diagnostics engine from command line
  • Run formatter engine from command line
  • Multi-workspace support

Supported protocol operations

Workspace
Operation Support Comment
didChangeWorkspaceFolders yes Dynamic add/remove of workspace folders
didChangeConfiguration yes with restrictions see #1431
didChangeWatchedFiles yes
didCreateFiles yes Filters: **/*.bsl, **/*.os, folders
didRenameFiles yes Filters: **/*.bsl, **/*.os, folders
didDeleteFiles yes Filters: **/*.bsl, **/*.os, folders
symbol yes
executeCommand yes
diagnostic/refresh yes sent on configuration change
applyEdit no
willCreateFiles no
Text Synchronization
Operation Supported Comment
didOpen yes
didChange yes textDocumentSyncKind = Incremental
didClose yes
didSave yes
willSave no
willSaveWaitUntil no
Textdocument
Operation Support Commentary Is configured?
publishDiagnostics yes tagSupport = true
versionSupport = true
diagnostics
yes
diagnostic yes interFileDependencies = true
workspaceDiagnostics = false
no
completion yes resolveProvider = true
triggerCharacters = .
completionItem.labelDetailsSupport = true
Offers methods, functions and constructors with signatures, type members after a dot, local variables and keywords
completionItem/resolve yes Lazy documentation resolution (member/function description) when supported by the client
hover yes contentFormat = MarkupContent
signatureHelp yes triggerCharacters = (, ,
retriggerCharacters = ,
declaration no not applicable in 1C:Enterprise
definition yes linkSupport = true
typeDefinition no
implementation yes only for OneScript interfaces of the extends library (&Реализует)
references yes
documentHighlight yes Highlight related constructs: if/elsif/else/endif, try/except/endtry, loops, regions, brackets
documentSymbol yes hierarchicalDocumentSymbolSupport = true
codeAction yes codeActionKinds = ? (см. #1433)
isPreferredSupport = true
yes
codeAction/resolve no
codeLens yes resolveProvider = true yes
codeLens/resolve yes
codeLens/refresh yes
documentLink yes Showing hyperlinks to documentation on diagnostics.
tooltipSupport = true
resolveProvider = false
yes
documentLink/resolve no
documentColor yes
colorPresentation yes
formatting yes
rangeFormatting yes
onTypeFormatting yes firstTriggerCharacter = \n
moreTriggerCharacter = ;
rename yes
prepareRename yes
foldingRange yes
selectionRange yes
prepareCallHierarchy yes
callHierarchy/incomingCalls yes
callHierarchy/outgoingCalls yes
prepareTypeHierarchy yes only for OneScript classes using the extends library
typeHierarchy/supertypes yes only for OneScript classes using the extends library
typeHierarchy/subtypes yes only for OneScript classes using the extends library
semanticTokens/full yes multilineTokenSupport = true
semanticTokens/full/delta yes
semanticTokens/range yes
linkedEditingRange yes
moniker no
inlayHint yes resolveProvider = true yes
inlayHint/resolve yes
inlayHint/refresh yes

Run from command line

jar-files run through java -jar path/to/file.jar.

java -jar bsl-language-server.jar --help

BSL language server
Usage: bsl-language-server [-h] [-c=<path>] [COMMAND [ARGS]]
  -c, --configuration=<path>
               Path to language server configuration file
  -h, --help   Show this help message and exit
Commands:
  analyze, -a, --analyze      Run analysis and get diagnostic info
  format, -f, --format        Format files in source directory
  version, -v, --version      Print version
  lsp, --lsp                  LSP server mode (default)
  websocket, -w, --websocket  Websocket server mode

Starting BSL Language Server in standard mode will run the Language Server communicating via LSP. stdin and stdout are used for communication.

The -c (--configuration) flag specifies the path to a configuration file. If not provided, BSL Language Server automatically searches for .bsl-language-server.json first in the current working directory, then in the user's home directory. See Configuration file for details.

By default diagnostics texts are displayed in Russian. To switch the diagnostics text language you need to set parameter language in configuration file or raise an event workspace/didChangeConfiguration:

{
  "language": "en"
}

Run in websocket mode

By default, interaction with the server goes through standard input / output streams. But you can run BSL Language Server with a built-in web server and interact with it via websocket.

To do this, start the BSL Language Server with the --websocket or -w option:

Usage: bsl-language-server websocket [-h] [--app.websocket.lsp-path=<path>]
                                     [-c=<path>] [--server.port=<port>]
Websocket server mode
      --app.websocket.lsp-path=<path>
                             Path to LSP endpoint. Default is /lsp
  -c, --configuration=<path> Path to language server configuration file
  -h, --help                 Show this help message and exit
      --server.port=<port>   Port to listen. Default is 8025

Once started, BSL Language Server will be available at ws://localhost:8025/lsp.

To redefine the port to the LSP server, you must use the --server.port option and the port number. To redefine the path to the LSP server, you must use the --app.websocket.lsp-path option and a path starting with /.

An example of running BSL Language Server in websocket mode with port 8080:

java -jar bsl-language-server.jar --websocket --server.port=8080

For large projects, it is recommended to specify the -Xmx parameter, which is responsible for the RAM limit for the java process. The amount of allocated memory depends on the size of the analyzed codebase.

java -Xmx4g -jar bsl-language-server.jar ... other parameters

Run in analyzer mode

To run in analyzer mode use parameter --analyze (short -a).

Usage: bsl-language-server analyze [-hq] [-c=<path>] [-o=<path>] [-s=<path>]
                                   [-r=<keys>]...
Run analysis and get diagnostic info
  -c, --configuration=<path>
                           Path to language server configuration file
  -h, --help               Show this help message and exit
  -o, --outputDir=<path>   Output report directory
  -q, --silent             Silent mode
  -r, --reporter=<keys>    Reporter key (console, junit, json, tslint, generic)
  -s, --srcDir=<path>      Source directory
  -w, --workspaceDir=<path> 
                           Workspace directory

To set source code folder for analysis use parameter --srcDir (short -s) followed by the path (relative or absolute) to the source code folder. To generate an analysis report you need to specify one or more reporters. To specify reporter use parameter --reporter or -r, followed by reporter key. You may specify several reporters. The list of reporters see in section Reporters.

Command line example to run analysis:

java -jar bsl-language-server.jar --analyze --srcDir ./src/cf --reporter json

When run analysis for large code base it is recommended to set parameter {code0}-Xmx{/code0} to set maximum limit of memory being allocated to java process. The size of allocated memory depends on the size of code base for analysis.

java -Xmx4g -jar bsl-language-server.jar ... other parameters

Run in formatter mode

To run in formatter mode use parameter --format (short -f).

Usage: bsl-language-server format [-hq] [-s=<path>]
Format files in source directory
  -h, --help            Show this help message and exit
  -q, --silent          Silent mode
  -s, --src=<path>      Source directory or file

To set source code folder (or source file) for formatting use parameter --src (short -s) followed by the path (relative or absolute) to the source code folder (or file).

Command line example to run formatting:

java -jar bsl-language-server.jar --format --src ./src/cf

Configuration file

A detailed description of the configuration file is given on this page

Special thanks

Many thanks to all contributors to the project, to all who participated in the discussions, who helped with the testing.

You are awesome!

Thanks to companies supporting open source projects, and especially to those who supported us:


JetBrains

JetBrains is the creator of professional software for development. JetBrains has offered an open source license for his products, including IntelliJ IDEA Ultimate.

IntelliJ IDEA Ultimate is one of the best tools in its class.


Digilabs

Digilabs - authors of Alkir - a software package for monitoring the performance of systems based on 1C:Enterprise 8. Digilabs provides us with server facilities for continuous performance testing of the BSL Language Server.