Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Omit `--install` to print to stdout. Full per-shell install paths and notes:

## What CodeGraph Does (and Doesn't)

**Does:** deterministic code-structure extraction across 33 languages (TypeScript,
**Does:** deterministic code-structure extraction across 34 languages (TypeScript,
Python, Go, Rust, Java, C/C++, C#, Vue, Svelte, GDScript, and more — see
[`docs/languages.md`](docs/languages.md)), cross-file resolution (including
Godot project graphs), graph traversal, FTS5 search, whole-graph export with
Expand All @@ -454,9 +454,9 @@ beyond the fixed `LANGUAGES` set.

## Supported Languages

CodeGraph supports **33 languages** grouped by extraction depth. Quick overview:
CodeGraph supports **34 languages** grouped by extraction depth. Quick overview:

- **Tier 1 — Full symbol extraction (24):** TypeScript, TSX, JavaScript, JSX, ArkTS, Python, Go, Rust, Java, C, C++, C#, PHP, Ruby, Swift, Kotlin, Dart, Scala, Lua, Luau, Objective-C, R, GDScript, Pascal.
- **Tier 1 — Full symbol extraction (25):** TypeScript, TSX, JavaScript, JSX, ArkTS, Python, Go, Rust, Java, C, C++, C#, PHP, Ruby, Swift, Kotlin, Dart, Scala, Lua, Luau, Objective-C, R, Solidity, GDScript, Pascal.
- **Tier 2 — Embedded / template extraction (6):** Vue, Svelte, Astro, Razor/`.cshtml`, Liquid, XML/MyBatis mapper.
- **Tier 3 — File-level only (3):** YAML, Twig, Properties.

Expand Down
6 changes: 6 additions & 0 deletions crates/codegraph-bench/fixtures/solidity/IERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
}
49 changes: 49 additions & 0 deletions crates/codegraph-bench/fixtures/solidity/Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IERC20.sol";

error Unauthorized(address caller);

uint256 constant MAX_SUPPLY = 1000000;

contract Token is IERC20 {
uint256 public total;

event Transfer(address indexed from, uint256 value);

enum Status {
Active,
Closed
}

struct Holder {
address account;
uint256 balance;
}

modifier onlyOwner() {
_;
}

constructor() {
total = MAX_SUPPLY;
}

fallback() external {
}

receive() external payable {
}

function transfer(address to, uint256 value) public onlyOwner returns (bool) {
emit Transfer(to, value);
return true;
}
}

library Math {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
}
29 changes: 29 additions & 0 deletions crates/codegraph-bench/tests/equivalence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ fn arkts_db_is_self_equivalent_to_arkts_golden() {
assert_equivalent(&arkts_db(), &arkts_golden_dir()).unwrap();
}

#[test]
fn generated_golden_matches_committed_solidity_fixture() {
// Guards Solidity extraction (upstream #1170): the `.sol`->Solidity mapping,
// contract/library->Class + interface->Interface + struct->Struct +
// enum->Enum, synthetic constructor/fallback/receive method names,
// state-var/struct-member/event/error->Field, `is`-inheritance->Extends
// (resolver promotes to Implements), and emit/modifier-guard call edges.
let tempdir = TestDir::new("generated-golden-solidity");
write_golden(&solidity_db(), tempdir.path()).unwrap();

let expected = load_golden(&solidity_golden_dir()).unwrap();
let actual = load_golden(tempdir.path()).unwrap();

diff_canonical(&expected, &actual, None).unwrap();
}

#[test]
fn solidity_db_is_self_equivalent_to_solidity_golden() {
assert_equivalent(&solidity_db(), &solidity_golden_dir()).unwrap();
}

#[test]
fn tier1_node_drift_is_reported() {
let expected = load_golden(&mini_golden_dir()).unwrap();
Expand Down Expand Up @@ -237,6 +258,14 @@ fn arkts_golden_dir() -> PathBuf {
workspace_root().join("reference/golden/arkts")
}

fn solidity_db() -> PathBuf {
workspace_root().join("reference/golden/solidity/colby.db")
}

fn solidity_golden_dir() -> PathBuf {
workspace_root().join("reference/golden/solidity")
}

struct TestDir {
path: PathBuf,
}
Expand Down
9 changes: 7 additions & 2 deletions crates/codegraph-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub const EDGE_KIND_STRINGS: [&str; 12] = [
"decorates",
];

pub const LANGUAGE_STRINGS: [&str; 37] = [
pub const LANGUAGE_STRINGS: [&str; 38] = [
"typescript",
"javascript",
"tsx",
Expand Down Expand Up @@ -78,6 +78,7 @@ pub const LANGUAGE_STRINGS: [&str; 37] = [
"luau",
"objc",
"r",
"solidity",
"yaml",
"twig",
"xml",
Expand Down Expand Up @@ -323,6 +324,8 @@ pub enum Language {
ObjC,
#[serde(rename = "r")]
R,
#[serde(rename = "solidity")]
Solidity,
#[serde(rename = "yaml")]
Yaml,
#[serde(rename = "twig")]
Expand All @@ -344,7 +347,7 @@ pub enum Language {
}

impl Language {
pub const ALL: [Self; 37] = [
pub const ALL: [Self; 38] = [
Self::TypeScript,
Self::JavaScript,
Self::Tsx,
Expand Down Expand Up @@ -373,6 +376,7 @@ impl Language {
Self::Luau,
Self::ObjC,
Self::R,
Self::Solidity,
Self::Yaml,
Self::Twig,
Self::Xml,
Expand Down Expand Up @@ -414,6 +418,7 @@ impl Language {
Self::Luau => "luau",
Self::ObjC => "objc",
Self::R => "r",
Self::Solidity => "solidity",
Self::Yaml => "yaml",
Self::Twig => "twig",
Self::Xml => "xml",
Expand Down
1 change: 1 addition & 0 deletions crates/codegraph-extract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ tree-sitter-r = "1.2.0"
tree-sitter-ruby = "0.23.1"
tree-sitter-rust = "0.24.2"
tree-sitter-scala = "0.26.0"
tree-sitter-solidity = "1.2.13"
tree-sitter-swift = "0.7.3"
tree-sitter-typescript = "0.23.2"
tree-sitter-xml = "0.7.0"
Expand Down
8 changes: 7 additions & 1 deletion crates/codegraph-extract/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub fn builtin_language_for_ext(ext: &str) -> Option<Language> {
"luau" => Language::Luau,
"m" | "mm" => Language::ObjC,
"r" => Language::R,
"sol" => Language::Solidity,
"yml" | "yaml" => Language::Yaml,
"twig" => Language::Twig,
"xml" => Language::Xml,
Expand Down Expand Up @@ -870,14 +871,19 @@ mod tests {
assert_eq!(detect_language("s.metal"), Language::Cpp);
assert_eq!(detect_language("k.cu"), Language::Cpp);
assert_eq!(detect_language("k.cuh"), Language::Cpp);
assert_eq!(Language::ALL.len(), 37);
assert_eq!(Language::ALL.len(), 38);
}

#[test]
fn arkts_extension_maps_to_arkts() {
assert_eq!(detect_language("view.ets"), Language::ArkTs);
}

#[test]
fn sol_maps_to_solidity() {
assert_eq!(detect_language("Token.sol"), Language::Solidity);
}

#[test]
fn plain_ts_stays_typescript() {
assert_eq!(detect_language("m.ts"), Language::TypeScript);
Expand Down
3 changes: 3 additions & 0 deletions crates/codegraph-extract/src/lang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod r;
mod ruby;
mod rust;
mod scala;
mod solidity;
mod swift;
mod tsx;
mod typescript;
Expand Down Expand Up @@ -54,6 +55,7 @@ pub use r::R_SPEC;
pub use ruby::RUBY_SPEC;
pub use rust::RUST_SPEC;
pub use scala::SCALA_SPEC;
pub use solidity::SOLIDITY_SPEC;
pub use swift::SWIFT_SPEC;
pub use tsx::TSX_SPEC;
pub use typescript::TYPESCRIPT_SPEC;
Expand Down Expand Up @@ -83,6 +85,7 @@ pub fn spec_for_language(language: Language) -> Option<&'static dyn LanguageSpec
Language::Pascal => Some(&PASCAL_SPEC),
Language::ObjC => Some(&OBJC_SPEC),
Language::R => Some(&R_SPEC),
Language::Solidity => Some(&SOLIDITY_SPEC),
Language::Gdscript => Some(&GDSCRIPT_SPEC),
_ => None,
}
Expand Down
Loading
Loading