Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USVM-based type inference #279

Merged
merged 122 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
dbc3000
Improve resolution of callees
Lipen Aug 16, 2024
c4a3e15
Fix test
Lipen Aug 19, 2024
8379510
Fix complex expr (cast) in assignment
Lipen Aug 19, 2024
c9fe6cb
Add some samples for type inference
Lipen Aug 20, 2024
188018c
Unify resource loading
Lipen Aug 20, 2024
e3c1292
Lazy callees
Lipen Aug 21, 2024
79b2fae
Fix new array element type
Lipen Aug 28, 2024
78c049d
Add enclosingFile property
Lipen Aug 28, 2024
ea7e05b
Implement basic method lookup
rudolf101 Sep 4, 2024
de07c72
Improve callees resolve
Lipen Sep 10, 2024
1dd3003
Add sample with scoped local
Lipen Sep 10, 2024
cda4f41
mark first block as visited
MForest7 Sep 13, 2024
a767a86
Fix literal type
rudolf101 Sep 18, 2024
eaf3869
For unknown class signature, do not blindly go into outer constructor…
Lipen Sep 18, 2024
fc8e804
Fix convert for literal type
Lipen Sep 19, 2024
eee07ff
Yet another take on callees resolver
Lipen Sep 20, 2024
dda8bd7
Exclude recursive callee in neighbor lookup
Lipen Sep 20, 2024
f110aa4
Use sequence
Lipen Sep 20, 2024
0a40ef1
Cleanup
Lipen Sep 20, 2024
9e9e03f
Add extra check for current method signature
Lipen Sep 20, 2024
15bc338
Add ad-hoc constructor resolution
Lipen Sep 20, 2024
8fda1e1
Chane unknown value to string
rudolf101 Sep 20, 2024
6cc1dc2
Fix unknown call expr
rudolf101 Sep 23, 2024
c3b7595
Fix path for local project
Lipen Sep 23, 2024
6202d2c
Cleanup
Lipen Sep 23, 2024
8023bd6
Update model for AA/neo/2024-09-23
Lipen Sep 23, 2024
4c291b0
Revert typeParameters in FieldDto to support deserializing outdated DTOs
Lipen Sep 23, 2024
f9667fb
Add PtrCallExpr, fix unknown values/stmts
Lipen Sep 23, 2024
753fd9b
Improve EtsFile loaders, add comments
Lipen Sep 23, 2024
2e3bf99
Add test for loading the project
Lipen Sep 23, 2024
fc53c3b
Add comment for literal type
Lipen Sep 25, 2024
bf7d6df
Add script for setting up local projects
Lipen Sep 25, 2024
c32f8af
Fix gitignore for samples
Lipen Sep 25, 2024
9470018
Improve utility functions
Lipen Sep 25, 2024
b509a0a
Ignore repos
Lipen Sep 25, 2024
6d66661
Prepare AudioPicker project
Lipen Sep 25, 2024
2e4737a
Improve script for preparing projects, add EtsScene loader
Lipen Sep 25, 2024
7c6e610
Extract common code for project dir preparation
Lipen Sep 25, 2024
b89d197
Add getResourcePathOrNull
Lipen Sep 25, 2024
bab94af
Use dynamic tests for loading local projects
Lipen Sep 25, 2024
88af61d
Add DSL for dynamic tests
Lipen Sep 25, 2024
5d82cdf
More modules and projects
Lipen Sep 26, 2024
53a17fa
Move test utils to fixtures
Lipen Sep 26, 2024
2bfcf62
Reorder logging
Lipen Sep 26, 2024
384fdba
Use node
Lipen Sep 26, 2024
7356b46
Add force mode
Lipen Sep 26, 2024
165c05d
Fix exit code
Lipen Sep 26, 2024
7383f96
Add force mode (`-f` flag) for overriding existing dirs
Lipen Sep 26, 2024
0106e07
Make ts-node FASTER
Lipen Sep 26, 2024
8810018
Comment the check for outdated JS script
Lipen Sep 26, 2024
aded534
Space
Lipen Sep 26, 2024
8759d4f
Add SettingsData project
Lipen Sep 26, 2024
b959cf2
Use cd instead of pushd
Lipen Sep 27, 2024
8d1e880
Add script for cloning/updating all repos with projects
Lipen Sep 27, 2024
7bb77c6
Cleanup
Lipen Sep 27, 2024
3dd92de
Fix messages
Lipen Sep 27, 2024
eba04ad
Type inference hacks and improvements
CaelmBleidd Sep 27, 2024
484f7bd
Cleanup
Lipen Sep 27, 2024
2277a3e
Move Maybe to jacodb-core
Lipen Sep 27, 2024
a85cbd0
Speed up Ets IFDS by 5917%
Lipen Sep 27, 2024
baab36b
New callees resolver
Lipen Sep 27, 2024
c239668
Fix imports
Lipen Sep 27, 2024
5a970bc
Cleanup dot-view extension for JcGraph
Lipen Sep 30, 2024
dcd037e
Cleanup dot-view extension for EtsCfg
Lipen Sep 30, 2024
67a2f9a
Fix messages
Lipen Sep 30, 2024
a81887b
Change default for viewCatchConnections to true in EtsCfg.view
Lipen Sep 30, 2024
99b2741
Move graph settings
Lipen Sep 30, 2024
4f4af9a
Support "incorrect" IfStmt without 2 successors in dot-view
Lipen Sep 30, 2024
2b777c0
Fix ArrayTypeDto::toString
Lipen Oct 2, 2024
00f4dfc
Add GenericTypeDto
Lipen Oct 2, 2024
460b628
Add EtsGenericType
Lipen Oct 2, 2024
2fa0a76
Handle locals
Lipen Oct 2, 2024
56052a3
Update ArkAnalyzer branch
Lipen Oct 2, 2024
90e81fd
Enable arkanalyzer's type inference
CaelmBleidd Oct 4, 2024
54484ad
Add more open-source projects
Lipen Oct 9, 2024
48af899
Convert to lists to avoid re-iterating sequences
Lipen Oct 9, 2024
94fd103
Add PrimitiveLiteralDto
Lipen Oct 11, 2024
2af482e
Run ArkAnalyzer's type inference on projects
Lipen Oct 11, 2024
44bdca2
First entry points support
CaelmBleidd Oct 25, 2024
3f6f73f
Update AA branch in CI
Lipen Oct 28, 2024
30ca455
Add `loadEntrypoint` argument for EtsIR loader
Lipen Oct 28, 2024
6bad23d
Use getResourcePath
Lipen Oct 28, 2024
eb27cab
Use AA's type inference once by default
Lipen Oct 28, 2024
a2667f8
Make file signature non-null
Lipen Oct 30, 2024
7ce9f3e
Handle decorators, modifiers, type parameters, etc
Lipen Oct 31, 2024
1b7b702
Add constants
Lipen Nov 6, 2024
30941c9
Bump AA on CI
Lipen Nov 6, 2024
2f8b10b
Add more "unknown" constants
Lipen Nov 6, 2024
416523c
Print classes and methods
Lipen Nov 6, 2024
8f2054f
Refine signatures
Lipen Nov 6, 2024
dacf419
Extract implemented interfaces from DTO
Lipen Nov 6, 2024
11c00ff
Infer types in generateTestResource
Lipen Nov 6, 2024
341a110
Add generics for ClassType, FunctionType, UnclearRefType
Lipen Nov 6, 2024
1b0e13b
add resolver stats
MForest7 Nov 14, 2024
4d665ef
Query the callees only for call statements
Lipen Nov 21, 2024
d293c33
Merge branch 'neo'
Lipen Nov 21, 2024
0771293
Add kotlin-logging dep for testFixtures
Lipen Nov 21, 2024
91c7779
Fix isNullable import
Lipen Nov 21, 2024
5939b32
Ignore .kotlin folder
Lipen Nov 21, 2024
f9daac5
Fix tests for FieldInitializers
Lipen Nov 21, 2024
ac2abfb
Migrate to Develocity for Gradle build scans
Lipen Nov 21, 2024
ba85528
Publish build scans on demand
Lipen Nov 21, 2024
58c68f4
Update Gradle wrapper to 6.11
Lipen Nov 21, 2024
aa1b8a8
Remove context receivers on classes
Lipen Nov 21, 2024
f0a304f
Update AA version on CI
Lipen Nov 21, 2024
a517ef7
Update model: type parameters, AliasType, AnnotationType
Lipen Nov 22, 2024
78ac19f
Use `-t 1` in prepare_projects script
Lipen Nov 22, 2024
d65094b
Traverse all namespaces recursively to get ALL classes
Lipen Nov 28, 2024
bb8ed47
Revert context receivers for Traits
Lipen Nov 29, 2024
edfa893
Bump Kotlin to 2.1.0
Lipen Nov 29, 2024
5786147
Add EtsAliasType and support its se-/de-serialization
Lipen Nov 29, 2024
1167b35
Make percent Double
Lipen Nov 29, 2024
597ce9c
Remove unnecessary file signature comparison
Lipen Nov 29, 2024
ed66348
Add missing brackets to if-statement
Lipen Nov 29, 2024
8631e6f
Add trailing comma
Lipen Nov 29, 2024
7952a37
Bump AA
Lipen Dec 4, 2024
4e9bf44
Inline traits
Lipen Dec 6, 2024
0e446b2
Merge branch 'neo'
Lipen Dec 9, 2024
a351bf4
Move Maybe to jacodb-ets
Lipen Dec 9, 2024
473c864
Separate sdk files from the project ones in EtsScene
CaelmBleidd Dec 25, 2024
9396eaa
Remove statistics in callee resolver
CaelmBleidd Dec 25, 2024
f7ee59b
Fix failed complication
CaelmBleidd Dec 25, 2024
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 .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
DEST_DIR="arkanalyzer"
MAX_RETRIES=10
RETRY_DELAY=3 # Delay between retries in seconds
BRANCH="neo/2024-08-16"
BRANCH="neo/2024-12-04"

for ((i=1; i<=MAX_RETRIES; i++)); do
git clone --depth=1 --branch $BRANCH $REPO_URL $DEST_DIR && break
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.idea/
.gradle/
build/
.kotlin/
idea-community
*.db
/generated/
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
39 changes: 31 additions & 8 deletions jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,32 @@
import java.nio.file.Files
import java.nio.file.Path

fun JcGraph.view(dotCmd: String, viewerCmd: String, viewCatchConnections: Boolean = false) {
Util.sh(arrayOf(viewerCmd, "file://${toFile(dotCmd, viewCatchConnections)}"))
private const val DEFAULT_DOT_CMD = "dot"

fun JcGraph.view(

Check warning on line 63 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L63

Added line #L63 was not covered by tests
viewerCmd: String = if (System.getProperty("os.name").lowercase().contains("windows")) "start" else "xdg-open",
dotCmd: String = DEFAULT_DOT_CMD,
viewCatchConnections: Boolean = false,

Check warning on line 66 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L65-L66

Added lines #L65 - L66 were not covered by tests
) {
val path = toFile(null, dotCmd, viewCatchConnections)
Util.sh(arrayOf(viewerCmd, "file://$path"))

Check warning on line 69 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L68-L69

Added lines #L68 - L69 were not covered by tests
}

fun JcGraph.toFile(dotCmd: String, viewCatchConnections: Boolean = false, file: File? = null): Path {
fun JcGraph.toFile(
file: File? = null,
dotCmd: String = DEFAULT_DOT_CMD,
viewCatchConnections: Boolean = false,

Check warning on line 75 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L72-L75

Added lines #L72 - L75 were not covered by tests
): Path {
Graph.setDefaultCmd(dotCmd)

val graph = Graph("jcGraph")

val nodes = mutableMapOf<JcInst, Node>()
for ((index, inst) in instructions.withIndex()) {
val label = inst.toString().replace("\"", "\\\"")

Check warning on line 83 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L83

Added line #L83 was not covered by tests
val node = Node("$index")
.setShape(Shape.box)
.setLabel(inst.toString().replace("\"", "\\\""))
.setLabel(label)

Check warning on line 86 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L86

Added line #L86 was not covered by tests
.setFontSize(12.0)
nodes[inst] = node
graph.addNode(node)
Expand Down Expand Up @@ -140,20 +152,31 @@
return resultingFile
}

fun JcBlockGraph.view(dotCmd: String, viewerCmd: String) {
Util.sh(arrayOf(viewerCmd, "file://${toFile(dotCmd)}"))
fun JcBlockGraph.view(

Check warning on line 155 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L155

Added line #L155 was not covered by tests
viewerCmd: String,
dotCmd: String = DEFAULT_DOT_CMD,

Check warning on line 157 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L157

Added line #L157 was not covered by tests
) {
val path = toFile(null, dotCmd = dotCmd)
Util.sh(arrayOf(viewerCmd, "file://$path"))

Check warning on line 160 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L159-L160

Added lines #L159 - L160 were not covered by tests
}

fun JcBlockGraph.toFile(dotCmd: String, file: File? = null): Path {
fun JcBlockGraph.toFile(
file: File? = null,
dotCmd: String = DEFAULT_DOT_CMD,

Check warning on line 165 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L163-L165

Added lines #L163 - L165 were not covered by tests
): Path {
Graph.setDefaultCmd(dotCmd)

val graph = Graph("jcGraph")

val nodes = mutableMapOf<JcBasicBlock, Node>()
for ((index, block) in instructions.withIndex()) {
val label = instructions(block)
.joinToString("") { "$it\\l" }
.replace("\"", "\\\"")
.replace("\n", "\\n")

Check warning on line 176 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L173-L176

Added lines #L173 - L176 were not covered by tests
val node = Node("$index")
.setShape(Shape.box)
.setLabel(instructions(block).joinToString("") { "$it\\l" }.replace("\"", "\\\"").replace("\n", "\\n"))
.setLabel(label)

Check warning on line 179 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/GraphExt.kt#L179

Added line #L179 was not covered by tests
.setFontSize(12.0)
nodes[block] = node
graph.addNode(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class IRSvgGenerator(private val folder: File) : Closeable {
val fileName = "${it.enclosingClass.simpleName}-$fixedName-$index.svg"
val graph = it.flowGraph()
JcGraphChecker(it, graph).check()
graph.toFile("dot", false, file = File(folder, "graph-$fileName"))
graph.blockGraph().toFile("dot", file = File(folder, "block-graph-$fileName"))
graph.toFile(File(folder, "graph-$fileName"))
graph.blockGraph().toFile(File(folder, "block-graph-$fileName"))
}
}

Expand Down
5 changes: 5 additions & 0 deletions jacodb-ets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import java.io.FileNotFoundException

plugins {
kotlin("plugin.serialization")
`java-test-fixtures`
}

dependencies {
Expand All @@ -15,6 +16,9 @@ dependencies {

testImplementation(kotlin("test"))
testImplementation(Libs.mockk)

testFixturesImplementation(Libs.kotlin_logging)
testFixturesImplementation(Libs.junit_jupiter_api)
}

// Example usage:
Expand Down Expand Up @@ -67,6 +71,7 @@ tasks.register("generateTestResources") {
"--multi",
inputDir.relativeTo(resources).path,
outputDir.relativeTo(resources).path,
"-t",
)
println("Running: '${cmd.joinToString(" ")}'")
val process = ProcessBuilder(cmd).directory(resources).start()
Expand Down
37 changes: 37 additions & 0 deletions jacodb-ets/src/main/kotlin/org/jacodb/ets/base/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2022 UnitTestBot contributors (utbot.org)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jacodb.ets.base

const val CONSTRUCTOR_NAME = "constructor"

const val DEFAULT_ARK_CLASS_NAME = "%dflt"
const val DEFAULT_ARK_METHOD_NAME = "%dflt"

const val UNKNOWN_PROJECT_NAME = "%unk"
const val UNKNOWN_FILE_NAME = "%unk"
const val UNKNOWN_NAMESPACE_NAME = "%unk"
const val UNKNOWN_CLASS_NAME = "" // TODO: consult AA/src/core/common/Const.ts
const val UNKNOWN_FIELD_NAME = "" // TODO: consult AA/src/core/common/Const.ts
const val UNKNOWN_METHOD_NAME = "" // TODO: consult AA/src/core/common/Const.ts

const val INSTANCE_INIT_METHOD_NAME = "%instInit"
const val STATIC_INIT_METHOD_NAME = "%statInit"

const val ANONYMOUS_CLASS_PREFIX = "%AC"
const val ANONYMOUS_METHOD_PREFIX = "%AM"

const val TEMP_LOCAL_PREFIX = "%"
16 changes: 16 additions & 0 deletions jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
// Call
fun visit(expr: EtsInstanceCallExpr): R
fun visit(expr: EtsStaticCallExpr): R
fun visit(expr: EtsPtrCallExpr): R

// Other
fun visit(expr: EtsCommaExpr): R
Expand Down Expand Up @@ -133,6 +134,7 @@

override fun visit(expr: EtsInstanceCallExpr): R = defaultVisit(expr)
override fun visit(expr: EtsStaticCallExpr): R = defaultVisit(expr)
override fun visit(expr: EtsPtrCallExpr): R = defaultVisit(expr)

Check warning on line 137 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt#L137

Added line #L137 was not covered by tests

override fun visit(expr: EtsCommaExpr): R = defaultVisit(expr)
override fun visit(expr: EtsTernaryExpr): R = defaultVisit(expr)
Expand Down Expand Up @@ -790,6 +792,20 @@
}
}

data class EtsPtrCallExpr(
val ptr: EtsLocal,
override val method: EtsMethodSignature,
override val args: List<EtsValue>,

Check warning on line 798 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt#L795-L798

Added lines #L795 - L798 were not covered by tests
) : EtsCallExpr {
override fun toString(): String {
return "${ptr}.${method.name}(${args.joinToString()})"

Check warning on line 801 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt#L801

Added line #L801 was not covered by tests
}

override fun <R> accept(visitor: EtsExpr.Visitor<R>): R {
return visitor.visit(this)

Check warning on line 805 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsExpr.kt#L805

Added line #L805 was not covered by tests
}
}

data class EtsCommaExpr(
override val left: EtsEntity,
override val right: EtsEntity,
Expand Down
104 changes: 100 additions & 4 deletions jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import org.jacodb.api.common.CommonType
import org.jacodb.api.common.CommonTypeName
import org.jacodb.ets.model.EtsClassSignature
import org.jacodb.ets.model.EtsLocalSignature
import org.jacodb.ets.model.EtsMethodSignature
import org.jacodb.ets.model.EtsNamespaceSignature

interface EtsType : CommonType, CommonTypeName {
override val typeName: String
Expand All @@ -45,6 +47,10 @@
fun visit(type: EtsArrayType): R
fun visit(type: EtsArrayObjectType): R
fun visit(type: EtsUnclearRefType): R
fun visit(type: EtsGenericType): R
fun visit(type: EtsAliasType): R
fun visit(type: EtsAnnotationNamespaceType): R
fun visit(type: EtsAnnotationTypeQueryType): R

interface Default<R> : Visitor<R> {
override fun visit(type: EtsAnyType): R = defaultVisit(type)
Expand All @@ -64,6 +70,10 @@
override fun visit(type: EtsArrayType): R = defaultVisit(type)
override fun visit(type: EtsArrayObjectType): R = defaultVisit(type)
override fun visit(type: EtsUnclearRefType): R = defaultVisit(type)
override fun visit(type: EtsGenericType): R = defaultVisit(type)
override fun visit(type: EtsAliasType): R = defaultVisit(type)
override fun visit(type: EtsAnnotationNamespaceType): R = defaultVisit(type)
override fun visit(type: EtsAnnotationTypeQueryType): R = defaultVisit(type)

Check warning on line 76 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L73-L76

Added lines #L73 - L76 were not covered by tests

fun defaultVisit(type: EtsType): R
}
Expand Down Expand Up @@ -215,10 +225,16 @@
interface EtsRefType : EtsType

data class EtsClassType(
val classSignature: EtsClassSignature,
val signature: EtsClassSignature,
val typeParameters: List<EtsType> = emptyList(),
) : EtsRefType {
override val typeName: String
get() = classSignature.name
get() = if (typeParameters.isNotEmpty()) {
val generics = typeParameters.joinToString()
"${signature.name}<$generics>"

Check warning on line 234 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L233-L234

Added lines #L233 - L234 were not covered by tests
} else {
signature.name
}

override fun toString(): String = typeName

Expand All @@ -229,9 +245,15 @@

data class EtsFunctionType(
val method: EtsMethodSignature,
val typeParameters: List<EtsType> = emptyList(),
) : EtsRefType {
override val typeName: String
get() = method.name
get() = if (typeParameters.isNotEmpty()) {
val generics = typeParameters.joinToString()
"${method.name}<$generics>"

Check warning on line 253 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L252-L253

Added lines #L252 - L253 were not covered by tests
} else {
method.name
}

Check warning on line 256 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L255-L256

Added lines #L255 - L256 were not covered by tests

override fun toString(): String = typeName

Expand Down Expand Up @@ -268,11 +290,85 @@
}

data class EtsUnclearRefType(
override val typeName: String,
val name: String,
val typeParameters: List<EtsType> = emptyList(),

Check warning on line 294 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L293-L294

Added lines #L293 - L294 were not covered by tests
) : EtsRefType {
override val typeName: String
get() = if (typeParameters.isNotEmpty()) {
val generics = typeParameters.joinToString()
"$name<$generics>"

Check warning on line 299 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L298-L299

Added lines #L298 - L299 were not covered by tests
} else {
name
}

Check warning on line 302 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L301-L302

Added lines #L301 - L302 were not covered by tests

override fun toString(): String = typeName

override fun <R> accept(visitor: EtsType.Visitor<R>): R {
return visitor.visit(this)
}
}

data class EtsGenericType(
val name: String,
val defaultType: EtsType? = null,
val constraint: EtsType? = null,
) : EtsRefType {

Check warning on line 315 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L315

Added line #L315 was not covered by tests
override val typeName: String
get() = name

Check warning on line 317 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L317

Added line #L317 was not covered by tests

override fun toString(): String {
return name + (constraint?.let { " extends $it" } ?: "") + (defaultType?.let { " = $it" } ?: "")
}

override fun <R> accept(visitor: EtsType.Visitor<R>): R {
return visitor.visit(this)

Check warning on line 324 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L324

Added line #L324 was not covered by tests
}
}

data class EtsAliasType(
val name: String,
val originalType: EtsType,
val signature: EtsLocalSignature,

Check warning on line 331 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L328-L331

Added lines #L328 - L331 were not covered by tests
) : EtsType {
override val typeName: String
get() = name

Check warning on line 334 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L334

Added line #L334 was not covered by tests

override fun toString(): String {
return "$name = $originalType"

Check warning on line 337 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L337

Added line #L337 was not covered by tests
}

override fun <R> accept(visitor: EtsType.Visitor<R>): R {
return visitor.visit(this)

Check warning on line 341 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L341

Added line #L341 was not covered by tests
}
}

data class EtsAnnotationNamespaceType(
val originType: String,
val namespaceSignature: EtsNamespaceSignature,

Check warning on line 347 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L345-L347

Added lines #L345 - L347 were not covered by tests
) : EtsType {
override val typeName: String
get() = originType

Check warning on line 350 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L350

Added line #L350 was not covered by tests

override fun toString(): String {
return originType

Check warning on line 353 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L353

Added line #L353 was not covered by tests
}

override fun <R> accept(visitor: EtsType.Visitor<R>): R {
return visitor.visit(this)

Check warning on line 357 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L357

Added line #L357 was not covered by tests
}
}

data class EtsAnnotationTypeQueryType(
val originType: String,

Check warning on line 362 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L361-L362

Added lines #L361 - L362 were not covered by tests
) : EtsType {
override val typeName: String
get() = originType

Check warning on line 365 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L365

Added line #L365 was not covered by tests

override fun toString(): String {
return originType

Check warning on line 368 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L368

Added line #L368 was not covered by tests
}

override fun <R> accept(visitor: EtsType.Visitor<R>): R {
return visitor.visit(this)

Check warning on line 372 in jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-ets/src/main/kotlin/org/jacodb/ets/base/EtsType.kt#L372

Added line #L372 was not covered by tests
}
}
Loading
Loading