Skip to content

Editor support

brass lsp implements the Language Server Protocol over stdin/stdout: full-document sync, diagnostics on open/change/save (the whole program is checked with open buffers taking the place of their files; checking the compiler itself takes about 0.15s), textDocument/formatting via brass fmt, textDocument/documentSymbol, hover and go-to-definition. For the last two the program is compiled with recording on: each local, parameter, field, function or method call and type name notes where it is defined and a one-line description (origin: Point, fn len2(p: &Point) -> i64). Positions are converted to UTF-16 columns as the protocol requires.

Find-references and rename use the same records: everything defined at the same place as the name under the cursor (which may be the definition itself) is one symbol, across all files of the program. A path like Shape.Circle is edited only in its last name, and a shorthand field Point { x } is spelled out (Point { px: x } or Point { x: start }) so it keeps its meaning. Names in standard modules cannot be renamed. Completion after . checks the line with the . cut off and offers the fields and methods of the value before it; elsewhere it offers keywords and the words in the file.

--time on any command reports how long each phase took: reading and parsing, declaring and resolving types, checking traits and generic bodies, checking and generating function bodies, assembling C, and the C compiler.