tree-sitter-scala

repository·master·Indexed 41 days ago

https://github.com/tree-sitter/tree-sitter-scala

A Tree-sitter grammar implementation for the Scala programming language, supporting both Scala 2 and Scala 3 syntax. Version 0.26.2 provides incremental parsing, syntax highlighting, and code navigation, including Node.js bindings and node type information.

Tokens
371
Snippets
1
Records
3
Agent score
2%

What's inside tree-sitter-scala

  1. Use tree-sitter-scala for Scala parsing

    master
    The tree-sitter-scala repository provides a Tree-sitter grammar for the Scala programming language. It is designed to support both Scala 2 and Scala 3 syntax, enabling incremental parsing, syntax highlighting, and code navigation for Scala codebases within any editor or tool that supports Tree-sitter.
  2. Use the tree-sitter-scala Node.js bindings

    master

    The tree-sitter-scala package provides Node.js bindings for the Scala grammar. It can be required directly in your Node.js or Bun environments. The module exports the compiled grammar object, which is compatible with the standard tree-sitter library API. Additionally, it provides nodeTypeInfo which contains metadata about the Scala node types defined in the grammar.

    const Parser = require('tree-sitter');
    const Scala = require('tree-sitter-scala');
    
    const parser = new Parser();
    parser.setLanguage(Scala);
    
    // Access node type metadata if needed
    const nodeTypes = Scala.nodeTypeInfo;
  3. Access Scala node type information

    master
    The tree-sitter-scala bindings export a nodeTypeInfo property. This property contains a JSON object mapping node types to their specific metadata (such as names and structure) as defined in the Scala grammar's src/node-types.json. This is useful for tools that need to understand the grammar's structure without parsing code.