Skip to content

Commit 3ec53c2

Browse files
Merge pull request #10 from samtkit/semantic-validation
Semantic validation
2 parents d3770c2 + 6a30e90 commit 3ec53c2

File tree

29 files changed

+2148
-52
lines changed

29 files changed

+2148
-52
lines changed

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ jobs:
1717
with:
1818
distribution: temurin
1919
java-version: 17
20-
cache: gradle
20+
- name: Setup Gradle
21+
uses: gradle/gradle-build-action@v2
22+
2123
- name: Verify
22-
run: ./gradlew --no-daemon check koverMergedHtmlReport koverMergedVerify
23-
- name: Archive code coverage results
24-
uses: actions/upload-artifact@v3
25-
with:
26-
name: code-coverage-report
27-
path: build/reports/kover/merged/html/
24+
run: ./gradlew --no-daemon koverMergedVerify

.github/workflows/gradle-dependency-submission.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
with:
1616
distribution: temurin
1717
java-version: 17
18-
cache: gradle
18+
- name: Setup Gradle
19+
uses: gradle/gradle-build-action@v2
1920

2021
- name: Run snapshot action
2122
uses: mikepenz/gradle-dependency-submission@main

.github/workflows/qodana-scan.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ jobs:
1919
with:
2020
distribution: temurin
2121
java-version: 17
22-
cache: gradle
22+
- name: Setup Gradle
23+
uses: gradle/gradle-build-action@v2
2324

2425
- name: Build
2526
run: ./gradlew --no-daemon build -x test
2627

27-
- uses: JetBrains/qodana-action@v2022.3.4
28+
- uses: JetBrains/qodana-action@v2023.1.0
2829
with:
2930
pr-mode: false
3031
cache-default-branch-only: true

.github/workflows/security-scanning.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ jobs:
3939
with:
4040
distribution: temurin
4141
java-version: 17
42-
cache: gradle
42+
- name: Setup Gradle
43+
uses: gradle/gradle-build-action@v2
4344

4445
- name: Build
4546
run: ./gradlew --no-daemon build -x test

.idea/kotlinc.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
plugins {
2-
@Suppress("DSL_SCOPE_VIOLATION") // Fixed in Gradle 8.1, see https://github.com/gradle/gradle/issues/22797
32
alias(libs.plugins.kover)
43
}
54

buildSrc/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ plugins {
22
`kotlin-dsl`
33
}
44

5+
kotlin {
6+
jvmToolchain(17)
7+
}
8+
59
dependencies {
6-
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.8.10")
10+
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.8.21")
711
}
812

913
repositories {

cli/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
plugins {
22
application
33
id("samt-core.kotlin-conventions")
4-
@Suppress("DSL_SCOPE_VIOLATION") // Fixed in Gradle 8.1, see https://github.com/gradle/gradle/issues/22797
54
alias(libs.plugins.shadow)
65
}
76

@@ -11,6 +10,7 @@ dependencies {
1110
implementation(project(":common"))
1211
implementation(project(":lexer"))
1312
implementation(project(":parser"))
13+
implementation(project(":semantic"))
1414
}
1515

1616
application {

cli/src/main/kotlin/tools/samt/cli/ASTPrinter.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package tools.samt.cli
22

3-
import tools.samt.parser.*
4-
53
import com.github.ajalt.mordant.rendering.TextColors.*
6-
import com.github.ajalt.mordant.rendering.TextStyles.*
4+
import com.github.ajalt.mordant.rendering.TextStyles.bold
5+
import com.github.ajalt.mordant.rendering.TextStyles.underline
6+
import tools.samt.parser.*
77

88
object ASTPrinter {
99
fun dump(node: Node): String = buildString {
@@ -58,7 +58,7 @@ object ASTPrinter {
5858
}
5959

6060
private fun dumpInfo(node: Node): String? = when (node) {
61-
is FileNode -> gray(node.filePath)
61+
is FileNode -> gray(node.sourceFile.absolutePath)
6262
is RequestResponseOperationNode -> if (node.isAsync) red("async") else null
6363
is IdentifierNode -> yellow(node.name)
6464
is ImportBundleIdentifierNode -> yellow(node.name) + if (node.isWildcard) yellow(".*") else ""

cli/src/main/kotlin/tools/samt/cli/App.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.beust.jcommander.JCommander
55
import com.github.ajalt.mordant.terminal.Terminal
66
import tools.samt.common.DiagnosticController
77
import tools.samt.common.SourceFile
8+
import tools.samt.semantic.SemanticModelBuilder
89
import java.io.File
910

1011
fun main(args: Array<String>) {
@@ -85,8 +86,11 @@ fun main(args: Array<String>) {
8586
t.print(ASTPrinter.dump(it))
8687
}
8788
}
89+
90+
// build up the semantic model from the AST
91+
SemanticModelBuilder.build(fileNodes, controller)
8892
}
8993

9094
val currentTimestamp = System.currentTimeMillis()
9195
t.println(DiagnosticFormatter.format(diagnosticController, startTimestamp, currentTimestamp, terminalWidth = t.info.width))
92-
}
96+
}

0 commit comments

Comments
 (0)