Skip to content

[K9VULN-12932] Add Dart support#903

Merged
jasonforal merged 1 commit intomainfrom
jf/K9VULN-12932
Apr 29, 2026
Merged

[K9VULN-12932] Add Dart support#903
jasonforal merged 1 commit intomainfrom
jf/K9VULN-12932

Conversation

@jasonforal
Copy link
Copy Markdown
Collaborator

@jasonforal jasonforal commented Apr 29, 2026

What this PR does

Adds support for Dart

Notes

We're using UserNobody14's grammar at https://github.com/UserNobody14/tree-sitter-dart. This repo has committed the generated parser.c and scanner.c files, but it generated them targeting ABI 15 (#define LANGUAGE_VERSION 15 in parser.c).

Our current version of tree-sitter only supports up to ABI 14, so the repo was forked and grammar (re)generated for ABI 14 (See: muh-nee/tree-sitter-dart#1).

The above context is documented with code comments in build.rs:

// Fork of https://github.com/UserNobody14/tree-sitter-dart
repository: "https://github.com/muh-nee/tree-sitter-dart".to_string(),
build_dir: "src".into(),
// ABI 14 version of upstream 0fc19c3a57b1109802af41d2b8f60d8835c5da3a
commit_hash: "dfad3d21e451c9406bee9c44e4ffcd6d7fb44bb7".to_string(),

Copilot AI review requested due to automatic review settings April 29, 2026 18:12
@jasonforal jasonforal requested a review from a team as a code owner April 29, 2026 18:12
@jasonforal jasonforal requested review from colemaring and removed request for a team April 29, 2026 18:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Dart language support to the static analysis kernel by wiring in a tree-sitter Dart grammar, recognizing Dart generated files, and ensuring Dart files are detected/parsed across CLI + analysis components.

Changes:

  • Add Language::Dart to the core language model and CLI file-extension mapping.
  • Integrate the Dart tree-sitter grammar via build.rs, and route Dart through tree-sitter parsing + a basic parsing test.
  • Add Dart generated-file header detection + tests, and include Dart in inline-suppression comment handling.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/static-analysis-kernel/src/model/common.rs Adds Dart to Language, display formatting, and language listing.
crates/static-analysis-kernel/src/analysis/tree_sitter.rs Adds Dart tree-sitter language binding and a parse sanity test.
crates/static-analysis-kernel/src/analysis/generated_content.rs Adds Dart generated-file header detection and tests.
crates/static-analysis-kernel/src/analysis/analyze.rs Treats Dart as //-comment language for inline suppression scanning.
crates/static-analysis-kernel/build.rs Vendors/compiles a forked tree-sitter-dart pinned to an ABI-14-compatible commit.
crates/cli/src/file_utils.rs Maps .dart extension to Language::Dart.
Comments suppressed due to low confidence (1)

crates/static-analysis-kernel/src/model/common.rs:76

  • ALL_LANGUAGES is used by the server /languages endpoint to report supported languages, but it currently omits Language::Elixir even though Elixir is supported elsewhere (e.g., tree-sitter integration). This means Elixir won't be advertised as supported. Add Language::Elixir to ALL_LANGUAGES (or rename/scope this list if it is intentionally not meant to include all supported languages).
#[allow(dead_code)]
pub static ALL_LANGUAGES: &[Language] = &[
    Language::Csharp,
    Language::Dart,
    Language::Dockerfile,
    Language::Go,
    Language::Java,
    Language::JavaScript,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: -1.00%
Overall Coverage: 84.94% (-0.27%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ea20ab2 | Docs | Datadog PR Page | Give us feedback!

@jasonforal jasonforal merged commit 8fef617 into main Apr 29, 2026
94 checks passed
@jasonforal jasonforal deleted the jf/K9VULN-12932 branch April 29, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants