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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:11-jdk-jammy
FROM eclipse-temurin:17-jdk-jammy
WORKDIR /workspace
# Optional: install tools you like
RUN apt-get update && apt-get install -y bash git && rm -rf /var/lib/apt/lists/*
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ Each line has a `kind` field:

SQL file analysis uses a hybrid JSqlParser + ANTLR approach to support multiple dialects (PostgreSQL, MySQL, T-SQL, PL/SQL) without configuration.

For complete documentation on SQL support, see **[SQL_ANALYSIS.md](SQL_ANALYSIS.md)**.
For complete documentation on SQL support, see **[SQL_ANALYSIS.md](docs/SQL_ANALYSIS.md)**.

## Architecture

See **[ARCHITECTURE.md](ARCHITECTURE.md)** for details on core components and design decisions.
See **[ARCHITECTURE.md](docs/ARCHITECTURE.md)** for details on core components and design decisions.

## Contributing

See **[CONTRIBUTING.md](CONTRIBUTING.md)** for guidelines on adding new languages and analyzer conventions.
See **[CONTRIBUTING.md](docs/CONTRIBUTING.md)** for guidelines on adding new languages and analyzer conventions.

## Requirements

Expand All @@ -184,12 +184,12 @@ This project uses Tree-sitter and its language grammars, which are licensed unde
- **C#**: Events not handled; see test samples for details
- **Java**: Local/anonymous classes not extracted as separate types
- **Python**: Type aliases using `TypeAlias` annotation are captured with `kind: "type_alias"`. PEP 695 style (`type X = ...`) is not yet supported by the tree-sitter-python grammar
- **SQL**: See [SQL_ANALYSIS.md](SQL_ANALYSIS.md)
- **SQL**: See [SQL_ANALYSIS.md](docs/SQL_ANALYSIS.md)

## Testing

```bash
./gradlew test
```

See [CONTRIBUTING.md](CONTRIBUTING.md) for testing workflow and conventions.
See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for testing workflow and conventions.
72 changes: 54 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.gradleup.shadow' version '9.3.1'
id 'antlr'
}

java {
toolchain { languageVersion = JavaLanguageVersion.of(11) }
toolchain { languageVersion = JavaLanguageVersion.of(17) }
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

group = 'org.dxworks'
version = '1.0-SNAPSHOT'

repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
mavenLocal()
}

dependencies {
// Core binding (bundles natives for Win/Linux/macOS)
implementation 'io.github.bonede:tree-sitter:0.25.3'
implementation 'io.github.bonede:tree-sitter:0.26.3'

// Language grammars
implementation 'io.github.bonede:tree-sitter-java:0.23.4'
Expand All @@ -34,17 +34,18 @@ dependencies {
implementation 'io.github.bonede:tree-sitter-ruby:0.23.1'
implementation 'io.github.bonede:tree-sitter-rust:0.23.1'

implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.21.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.21.0'
implementation 'com.github.jsqlparser:jsqlparser:5.3'
implementation 'org.antlr:antlr4-runtime:4.13.1'
antlr 'org.antlr:antlr4:4.13.1'
implementation 'org.antlr:antlr4-runtime:4.13.2'
antlr 'org.antlr:antlr4:4.13.2'
// DXWorks ignore library (loads .ignore patterns)
implementation 'org.dxworks:dx-ignore:1.1.0-SNAPSHOT'
implementation 'org.dxworks.utils:dx-ignore:1.1.0'

// Testing
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testImplementation 'com.approvaltests:approvaltests:22.3.3'
testImplementation 'org.junit.jupiter:junit-jupiter:6.0.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:6.0.2'
testImplementation 'com.approvaltests:approvaltests:26.6.0'
}

application {
Expand All @@ -53,18 +54,43 @@ application {

import org.gradle.api.plugins.antlr.AntlrTask

// Configure ANTLR generation for all grammars in src/main/antlr
tasks.withType(AntlrTask).configureEach {
// Generate visitor interfaces and set a shared Java package for generated sources
task generateSqlGrammarSource(type: AntlrTask) {
source = fileTree(dir: 'src/main/antlr', include: 'sql/**/*.g4')
outputDirectory = file('build/generated-src/antlr/sql')
arguments.clear()
arguments += ['-visitor',
'-package', 'org.dxworks.codeframe.analyzer.sql.generated',
// Make sure grammar imports like `import PlSqlLexer;` can be resolved
// when the grammars live under src/main/antlr/plsql
'-lib', 'src/main/antlr']
}

task generateCobolGrammarSource(type: AntlrTask) {
source = fileTree(dir: 'src/main/antlr', include: 'cobol/**/*.g4')
outputDirectory = file('build/generated-src/antlr/cobol')
arguments.clear()
arguments += ['-visitor',
'-package', 'org.dxworks.codeframe.analyzer.cobol.generated',
'-lib', 'src/main/antlr']
}

tasks.named('generateGrammarSource') {
enabled = false
}

task generateAllGrammarSource {
dependsOn generateSqlGrammarSource, generateCobolGrammarSource
}

sourceSets {
main {
java {
srcDir 'build/generated-src/antlr/sql'
srcDir 'build/generated-src/antlr/cobol'
}
}
}

tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' }
tasks.named('compileJava') { dependsOn generateAllGrammarSource }

// Produce a single, self-contained JAR named exactly 'codeframe.jar'
tasks.named('shadowJar') {
Expand All @@ -80,4 +106,14 @@ tasks.named('build') {
// Configure all Test tasks to use JUnit Platform and run in parallel
tasks.withType(Test).configureEach {
useJUnitPlatform()
dependsOn 'generateAllGrammarSource'

testLogging {
events 'skipped', 'failed'
exceptionFormat 'full'
showExceptions true
showCauses true
showStackTraces true
showStandardStreams = false
}
}
9 changes: 9 additions & 0 deletions docs/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Project Scope
See the [README](README.md) for overall project scope

# Design guidline
- Use at little Regex as possible
- Do not add complexity only for backward compatibility unless the user explicitly asks for it.
- Do not hack your way to a solution. Understand the problem and find a proper solution. Many times, a better understanding of the grammar or the tree will help you find a better solution.
- For parser/analyzer behavior, follow the global **Extraction Contract (All Parsers)** in [CONTRIBUTING.md](CONTRIBUTING.md).
- I'm running on Windows, but I can't run the app locally, so I work with docker. If you suggest comamnds, specify them using Unix syntax, but don't offer to run them. Just tell me the command. I will run it and give you the output.
File renamed without changes.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md → docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

Follow these conventions to ensure consistency across all analyzers.

### Extraction Contract (All Parsers)

- Extract facts only. Do not infer capabilities or intent.
- Keep output deterministic.
- Do not write files as side effects.
- On parse errors, return partial results when possible.
- Keep analyzers simple and fast; enrichment belongs to post-processing tools.

### Using TreeSitterHelper

`TreeSitterHelper` provides shared utilities that all analyzers should use:
Expand Down
File renamed without changes.
Loading