luau-analyzer-sys 0.1.1

A high-performance, embedded Luau type-checking and analysis engine written in Rust. This crate provides bindings to the Luau analyzer, allowing you to integrate static analysis and code intelligence directly into your applications.
Documentation
  • Coverage
  • 0%
    0 out of 13 items documented0 out of 6 items with examples
  • Size
  • Source code size: 12.53 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 427.81 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 55s Average build duration of successful builds.
  • all releases: 55s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • luks-luau/luau-analyzer-sys
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • yanlvl99

luau-analyzer-sys

High-level ergonomic Rust bindings and low-level C++ FFI bindings for the native Luau static type analyzer and compiler frontend.

License: MIT Rust

Overview

luau-analyzer-sys provides a bridge between Rust and Luau's C++ static type checking engine (Luau::Frontend). It abstracts away internal type resolution scopes, AST traversal checks, and linting routines into a safe, easy-to-use Rust interface (NativeAnalyzer).

Key Features

  • Embedded Type Analysis: Perform zero-overhead static checking of Luau codebases directly from Rust.
  • Custom Definitions: Inject global environment mapping definitions dynamically via Luau .d.luau files.
  • Dependency Resolution: Fully recursive module path resolution via safe Rust closures.
  • Granular Diagnostics: Capture detailed warnings, errors, and lint output complete with source span offsets.
  • Deprecation Linting: Native static interception of deprecated functions (e.g. getfenv) mapped via dynamic line deduplication.

Usage

Add luau-analyzer-sys as a dependency in your Cargo.toml:

[dependencies]

luau-analyzer-sys = { path = "../luau-analyzer-sys" }

Example: Checking a Luau Module

use luau_analyzer_sys::NativeAnalyzer;

fn main() {
    let mut analyzer = NativeAnalyzer::new();

    // 1. Inject global type definitions
    analyzer.add_definitions(r#"
declare task: {
    spawn: (...any) -> thread
}
"#);

    // 2. Check source code using a recursive string-resolving closure
    let source = "task.spawn(function() print('Checking native type structures') end)";
    let diagnostics = analyzer.check("main.luau", |module_name| {
        if module_name == "main.luau" {
            Some(source.to_string())
        } else {
            None
        }
    });

    if diagnostics.is_empty() {
        println!("Type checking completed successfully with zero errors.");
    } else {
        for diag in diagnostics {
            let severity = if diag.severity == 0 { "error" } else { "warning" };
            println!("{}: {} at line {}:{}", severity, diag.message, diag.line + 1, diag.col + 1);
        }
    }
}

License

This project is licensed under the MIT License - see the LICENSE file for details.