StaticLint.jl

repository·master·Indexed 41 days ago

https://github.com/julia-vscode/staticlint.jl

A Julia package for static code analysis designed to support LanguageServer.jl by linking file trees, marking scopes, and resolving variable bindings. This project is deprecated and has been moved to JuliaWorkspaces.jl.

Tokens
697
Snippets
3
Records
5
Agent score
50%

What's inside StaticLint.jl

  1. How StaticLint performs static code analysis

    master

    StaticLint provides functionality similar to LanguageServer.jl by performing a single pass over a project's Syntax Tree (ST). The analysis process involves:

    1. Linking the file tree: Mapping the project structure.
    2. Scope marking: Identifying namespaces within the ST.
    3. Binding marking: Identifying variable bindings (functions, instances, etc.).
    4. Identifier linking: Connecting variable names to their relevant bindings.
    5. Error detection: Marking possible errors within the ST (which relies on the previous four steps).

    To perform a pass over a single EXPR (expression), you call a State object on the ST. This State requires an AbstractServer to determine how files are loaded and how packages are made available.

  2. Reference: AbstractServer interface

    master

    An AbstractServer is required to manage files within a project and provide access to installed packages. Any implementation of an AbstractServer must support the following functions:

    StaticLint.hasfile(server, path)::Bool
    StaticLint.getfile(server, path)::AbstractFile
    StaticLint.setfile(server, path, file)::AbstractFile
    StaticLint.canloadfile(server, path)::Bool
    StaticLint.loadfile(server, path)::AbstractFile
    StaticLint.getsymbolserver(server)::Dict{String,SymbolServer.ModuleStore}
  3. Reference: AbstractFile interface

    master

    An AbstractFile represents a file within the server's scope and must support the following methods:

    StaticLint.getpath(file)
    StaticLint.getroot(file)
    StaticLint.setroot(file, root)
    StaticLint.getcst(file)
    StaticLint.setcst(file, cst::CSTParser.EXPR)
    StaticLint.getserver(file)
    StaticLint.setserver(file, server::AbstractServer)
    StaticLint.semantic_pass(file, target = nothing(optional))