Tree-sitter Analyzer Features

June 12, 2026 ยท View on GitHub

This document provides a comprehensive overview of the features and language support in Tree-sitter Analyzer.

Feature Overview

Feature CategoryKey CapabilitiesCore Benefits
๐Ÿค– Deep AI IntegrationMCP Protocol Support, SMART Workflow, Token Limitation BreakingNative support for Claude Desktop, Cursor, Roo Code
๐Ÿ” Powerful SearchIntelligent File Discovery, Precise Content Search, Two-Stage Searchfd + ripgrep based high-performance search
๐Ÿ“Š Intelligent AnalysisFast Structure Analysis, Precise Code Extraction, Complexity AnalysisEnterprise-grade parsing without full file reading

Enterprise Capabilities

Token Optimization

For AI assistants with token limits, Tree-sitter Analyzer provides multiple optimization strategies:

StrategyOptionToken Reduction
Count Onlycount_only=true~70%
Summary Onlysummary_only=true~80%
File Outputsuppress_output=true + output_file~95%
Group by Filegroup_by_file=true~60%
Total Onlytotal_only=true~90%

Security Features

  • Project Boundary Protection: Automatic security boundaries preventing access outside project
  • Path Traversal Prevention: Blocks ../ and symbolic link attacks
  • Input Validation: Sanitizes all user inputs
  • Error Sanitization: Removes sensitive information from error messages

Cross-Platform Support

PlatformStatusNotes
Windowsโœ… Full SupportPowerShell and CMD
macOSโœ… Full SupportNative and Homebrew
Linuxโœ… Full SupportAll major distributions

Supported Languages

Systems Programming Languages

C ๐Ÿ†•

Full Support - Complete C language analysis with C-specific features.

Feature CategorySupported ElementsNotes
FunctionsFunction definitionsParameters, return types
TypesStruct definitionsField names and types
Union definitionsField names and types
Enum definitionsEnumerator values
TypedefsType aliases
DeclarationsGlobal variablesStatic, const, extern
Function pointersComplex type support
Preprocessor#include directivesHeader file tracking
#define macrosMacro detection
Conditional compilation#ifdef/#ifndef

Formatter Terminology:

  • Uses C-specific terms: function, struct, union, enum, typedef
  • Scope: global, static, extern

C++ ๐Ÿ†•

Full Support - Complete C++ language analysis with C++-specific features.

Feature CategorySupported ElementsNotes
ClassesClass definitionsPublic/private/protected sections
FunctionsFunction declarationsConstructors, destructors
Operator overloadingCustom operators
Virtual functionsInheritance support
TypesStruct definitionsWith member functions
Enum/enum classC++11 scoped enums
TemplatesFunction templatesType parameters
Class templatesTemplate classes
NamespacesNamespace definitionsNested namespaces
DeclarationsUsing declarationsType aliases
Using namespaceNamespace imports
Modern C++Lambda expressionsCapture clauses
Smart pointersunique_ptr, shared_ptr

Formatter Terminology:

  • Uses C++-specific terms: class, struct, namespace, template
  • Visibility: public, protected, private

Go

Full Support - Complete Go language analysis with Go-specific features.

Feature CategorySupported ElementsNotes
PackagesPackage declarationsWith name and line number
FunctionsFunction declarationsParameters, return types, visibility
MethodsMethod declarationsReceiver type support
TypesStruct definitionsField names and types
Interface definitionsMethod signatures
Type aliasesType definitions
Declarationsconst declarationsConstants with types
var declarationsVariables with types
ConcurrencyGoroutine detectiongo statement patterns
Channel detectionChannel usage patterns

Formatter Terminology:

  • Uses Go-specific terms: package, func, struct, interface
  • Visibility: exported (capitalized) / unexported (lowercase)

Rust ๐Ÿ†•

Full Support - Complete Rust language analysis with Rust-specific features.

Feature CategorySupported ElementsNotes
ModulesModule declarations (mod)With visibility
FunctionsFunction declarations (fn)Parameters, return type, visibility
TypesStruct definitionsFields, visibility, derive macros
Enum definitionsVariants
Trait definitionsMethod signatures
Implementationsimpl blocksTrait implementations
Macrosmacro_rules!Macro definitions
Asyncasync functionsAsync pattern detection
LifetimesLifetime annotationsLifetime detection

Formatter Terminology:

  • Uses Rust-specific terms: mod, fn, struct, enum, trait, impl
  • Visibility: pub, pub(crate), private

JVM Languages

Kotlin ๐Ÿ†•

Full Support - Complete Kotlin language analysis with Kotlin-specific features.

Feature CategorySupported ElementsNotes
PackagesPackage declarations
Classesclass, data class, sealed classAll class types
object declarationsSingleton objects
interface definitions
FunctionsFunction declarationsExtension functions with receiver
suspend functionsCoroutine support
Propertiesval/var declarationsProperty distinction
AnnotationsAnnotation extractionWith parameters

Formatter Terminology:

  • Uses Kotlin-specific terms: class, data class, object, fun, val, var
  • Visibility: public, private, protected, internal

Java

Full Support - Enterprise-grade Java analysis.

Feature CategorySupported ElementsNotes
PackagesPackage declarations
ClassesClass, interface, enum, annotationAll types
MethodsMethod declarationsParameters, return types, annotations
FieldsField declarationsWith types and modifiers
Framework SupportSpring, JPAEnterprise patterns

Web Languages

JavaScript

Full Support - Modern JavaScript analysis.

Feature CategorySupported ElementsNotes
FunctionsFunction declarationsArrow functions, async/await
ClassesES6 classesMethods, properties
ModulesImport/exportES modules
FrameworksReact, Vue, AngularComponent detection

TypeScript

Full Support - TypeScript with advanced type analysis.

Feature CategorySupported ElementsNotes
TypesInterfaces, type aliases
DecoratorsDecorator extraction
JSX/TSXJSX supportReact components
Framework DetectionAutomatic detection

HTML

Full Support - DOM structure analysis.

Feature CategorySupported ElementsNotes
ElementsAll HTML elementsTag names, attributes
ClassificationElement categorizationStructure, media, form, etc.
HierarchyDOM tree structureParent-child relationships

CSS

Full Support - CSS rule analysis.

Feature CategorySupported ElementsNotes
SelectorsAll selector typesClass, ID, element, etc.
PropertiesProperty extractionWith values
ClassificationProperty categorizationLayout, typography, etc.

Data Languages

SQL

Enhanced Full Support - Database schema analysis.

Feature CategorySupported ElementsNotes
TablesTable definitionsColumns, constraints
ViewsView definitions
Stored ProceduresProcedure definitionsParameters
FunctionsFunction definitions
TriggersTrigger definitions
IndexesIndex definitions

YAML

Full Support - YAML configuration analysis.

Feature CategorySupported ElementsNotes
MappingsKey-value pairs
SequencesLists
ScalarsString, number, boolean, nullType identification
Anchors/AliasesReference detection&anchor / *alias
Multi-document--- separators

Markdown

Full Support - Document structure analysis.

Feature CategorySupported ElementsNotes
HeadingsATX and SetextLevels 1-6
Code blocksFenced and indentedLanguage detection
Links/ImagesAll link typesURLs, titles
TablesGFM tables
Task listsCheckbox items

Other Languages

Python

Full Support - Modern Python analysis.

Feature CategorySupported ElementsNotes
ClassesClass definitionsInheritance
FunctionsFunction definitionsType annotations
DecoratorsDecorator extraction

C#

Full Support - Modern C# analysis.

Feature CategorySupported ElementsNotes
TypesClass, interface, record, struct
PropertiesProperty definitionsGet/set accessors
Asyncasync/await patterns
AttributesAttribute extraction

PHP

Full Support - PHP 8+ support.

Feature CategorySupported ElementsNotes
TypesClass, interface, trait, enum
NamespacesNamespace declarations
AttributesPHP 8 attributes

Ruby

Full Support - Ruby and Rails analysis.

Feature CategorySupported ElementsNotes
Classes/ModulesClass, module definitionsMixins
MethodsInstance, class, singleton
BlocksBlock, Proc, Lambda

UML / Mermaid Diagrams

TSA exports Mermaid diagrams from indexed project intelligence via viz action=uml (MCP) or --uml (CLI). Six diagram types are shipped.

Diagram types

TypeWhat it rendersKey params
classInheritance graph โ€” classes, superclasses, subclassesfile_path, class_name, include_tests, --uml-no-external-bases
packageModule dependency graph grouped by directory depthpackage_depth (default: 2)
componentImport-level component dependenciesmax_edges
sequenceCall-path trace between two functionssource, target (both required)
activityPer-function control-flow graph (CFG) built from the ASTfunction_name (required), file_path, max_nodes
stateFSM approximation from enum definitions and match/switch statementsfile_path, max_nodes

activity and state re-parse the source file at query time (disk read + tree-sitter parse, typically < 50 ms). All other types read from the index.

Scoping parameters

ParamApplies toEffect
file_path / --uml-file-pathclass, activity, stateLimit to classes or functions in this file
class_name / --uml-class-nameclassShow the named class plus its immediate superclasses and subclasses
function_name / --uml-functionactivityRequired: function to graph (bare name or module.function)
include_tests / --uml-include-testsclass, package, componentInclude test-corpus classes (default: excluded)
max_nodes / --uml-max-nodesactivity, stateCap on CFG/FSM nodes (default: 50); truncated=true when exceeded

CLI examples

# Whole-project class diagram
uv run python -m tree_sitter_analyzer --uml class

# Class diagram for one file (excludes external base classes)
uv run python -m tree_sitter_analyzer --uml class \
  --uml-file-path tree_sitter_analyzer/mcp/tools/base_tool.py \
  --uml-no-external-bases

# Neighbourhood subgraph for one class
uv run python -m tree_sitter_analyzer --uml class \
  --uml-class-name BaseMCPTool

# Call-path sequence diagram
uv run python -m tree_sitter_analyzer --uml sequence \
  --uml-source execute --uml-target build_response

# Per-function CFG (activity diagram)
uv run python -m tree_sitter_analyzer --uml activity \
  --uml-function execute \
  --uml-file-path tree_sitter_analyzer/mcp/tools/uml_tool.py

# Enum/match FSM state diagram
uv run python -m tree_sitter_analyzer --uml state \
  --uml-file-path tree_sitter_analyzer/mcp/tools/uml_tool.py

# Package dependency map
uv run python -m tree_sitter_analyzer --uml package --uml-package-depth 2

MCP equivalent

{ "action": "uml", "diagram": "class", "file_path": "src/models.py" }
{ "action": "uml", "diagram": "activity", "function_name": "execute", "file_path": "src/tool.py" }
{ "action": "uml", "diagram": "sequence", "source": "handle_call", "target": "build_response" }

All diagrams require the AST index (index action=status to check; index action=auto mode=warm to build). activity and state additionally need file_path to locate the source.


Output Formats

All languages support the following output formats:

  • Full Table (--table full) - Comprehensive structured output
  • Compact Table (--table compact) - Abbreviated summary
  • CSV (--table csv) - Machine-readable format
  • JSON (--advanced --output-format json) - Structured data
  • Text (--advanced --output-format text) - Human-readable

Testing and Quality

Each language includes:

  • Unit Tests - Core functionality testing
  • Property-based Tests - Hypothesis-based invariant testing
  • Golden Master Tests - Regression testing with expected outputs

Adding New Languages

See New Language Support Checklist for guidance on adding support for additional languages.