Skip to content

Commit 905f265

Browse files
committedFeb 4, 2024
disable features for release
1 parent 5246eea commit 905f265

38 files changed

+2005
-3501
lines changed
 

‎README.md

+12-21
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,24 @@ following requests:
2929

3030
* Code Outline (`documentSymbols`)
3131

32+
* Error reporting (``)
3233

34+
* Code Actions
35+
* [ ] Check well-definedness (requires z3)
36+
* [ ] Normalise formula
37+
* [ ] ...
3338

34-
* Support for KeY files
39+
* Code Lenses
40+
* [ ] Prove refinment of contracts
41+
* [ ]
3542

36-
Syntax highlighting and snippets.
37-
38-
## Changelog
39-
40-
* **0.3.0** (upcoming-2022)
41-
- Changing to `SemanticTokenProvider` interface to highlight JML annotation texts inside Java files.
42-
There is no text mate grammar anymore.
43-
44-
- Language Server added on the basis of the [jmlparser
45-
project](https://github.com/wadoon/jmlparser).
46-
47-
- Simple support for KeY files
43+
* Snippets
4844

49-
Syntax highlighting and snippets.
45+
* Support for [KeY files](https://key-project.org/)
5046

51-
* **0.2.0** (04.04.2019)
52-
- Fixes by @csicar
53-
54-
* **0.1.0** (14.02.2019)
55-
- First release
47+
Syntax highlighting and snippets.
5648

57-
* **0.0.0** (unpublished)
58-
- Start with the `java` language definition of VS Code.
49+
5950

6051
## Authors
6152

‎example_workspace/Errors.java

+15
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,19 @@ public void bar(int x) {
2020
public final int x;
2121
/*@ assignable x; */
2222
public void bear() {}
23+
24+
25+
/*@
26+
public normal_behavior
27+
ensures true;
28+
{|
29+
also
30+
requires a<0;
31+
also
32+
requires a>0;
33+
also
34+
requires a==0;
35+
|}
36+
*/
37+
public void bbbbb() {}
2338
}

‎examples/project.key

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
\chooseContract
22

3+
\rules {
4+
\lemma
5+
eqTermCut {
6+
\find(t)
7+
\sameUpdateLevel
8+
"Assume #t = #s":
9+
\add(t = s ==>);
10+
"Assume #t != #s":
11+
\add(t != s ==>)
12+
};
13+
14+
15+
}
16+
317
\problem {
418
true -> \forall int x; x>2
519
}

‎lsp/.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lsp/.idea/gradle.xml

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lsp/.idea/kotlinc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lsp/.idea/misc.xml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lsp/.idea/vcs.xml

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lsp/build.gradle.kts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
plugins {
4-
kotlin("jvm") version "1.7.20"
4+
kotlin("jvm") version "2.0.0-Beta3"
55
id("com.github.johnrengelman.shadow") version "7.1.2"
66
id("application")
77
}
@@ -21,18 +21,21 @@ version = "1.0-SNAPSHOT"
2121

2222
repositories {
2323
mavenCentral()
24+
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
2425
}
2526

2627
dependencies {
2728
testImplementation(kotlin("test"))
2829
implementation("org.tinylog:tinylog-api-kotlin:2.5.0")
2930
implementation("org.tinylog:tinylog-api:2.5.0-M2.1")
3031
implementation("org.tinylog:tinylog-impl:2.5.0")
31-
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:0.15.0")
32+
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:0.21.2")
3233
implementation("com.github.ajalt.clikt:clikt:3.5.0")
3334

34-
implementation("io.github.wadoon:jmlparser-symbol-solver-core:3.24.7-SNAPSHOT")
35-
implementation("io.github.wadoon:jmlparser-jml-tools:3.24.7-SNAPSHOT")
35+
implementation("io.github.jmltoolkit:jmlparser-symbol-solver-core:3.25.8-SNAPSHOT")
36+
implementation("io.github.jmltoolkit:jmlparser-jml-tools:3.25.8-SNAPSHOT")
37+
38+
implementation("org.apache.groovy:groovy:4.0.6")
3639

3740
testImplementation("com.google.truth:truth:1.1.3")
3841
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
@@ -44,9 +47,9 @@ tasks.test {
4447
}
4548

4649
tasks.withType<KotlinCompile> {
47-
kotlinOptions.jvmTarget = "17"
50+
kotlinOptions.jvmTarget = "21"
4851
}
4952

5053
application {
51-
mainClassName="jml.lsp.Main"
54+
mainClass = "jml.lsp.Main"
5255
}

‎lsp/src/main/kotlin/jml/lsp/CatchSymbols.kt

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
package jml.lsp
22

3-
import com.github.javaparser.ast.*
3+
import com.github.javaparser.ast.CompilationUnit
4+
import com.github.javaparser.ast.Node
5+
import com.github.javaparser.ast.NodeList
46
import com.github.javaparser.ast.body.*
57
import com.github.javaparser.ast.expr.VariableDeclarationExpr
68
import com.github.javaparser.ast.jml.body.*
79
import com.github.javaparser.ast.jml.clauses.*
810
import com.github.javaparser.ast.modules.ModuleDeclaration
911
import com.github.javaparser.ast.visitor.GenericVisitorAdapter
10-
import org.eclipse.lsp4j.*
12+
import org.eclipse.lsp4j.DocumentSymbol
13+
import org.eclipse.lsp4j.SymbolKind
1114
import java.util.*
1215

16+
/**
17+
* Runs through an AST and gathers symbols within JML annotations.
18+
*
19+
* @author Alexander Weigl
20+
*/
1321
class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>() {
14-
override fun visit(n: CompilationUnit, arg: Unit?): MutableList<DocumentSymbol>? {
22+
override fun visit(n: CompilationUnit, arg: Unit?): MutableList<DocumentSymbol> {
1523
val children = acceptAll(n.types)
1624
return arrayListOf(
1725
DocumentSymbol(
@@ -33,7 +41,7 @@ class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>(
3341
)
3442
}
3543

36-
override fun visit(n: AnnotationMemberDeclaration, arg: Unit?): MutableList<DocumentSymbol>? {
44+
override fun visit(n: AnnotationMemberDeclaration, arg: Unit?): MutableList<DocumentSymbol> {
3745
return arrayListOf(
3846
DocumentSymbol(
3947
n.nameAsString,
@@ -95,7 +103,7 @@ class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>(
95103
)
96104
}
97105

98-
override fun visit(n: FieldDeclaration, arg: Unit?): MutableList<DocumentSymbol>? {
106+
override fun visit(n: FieldDeclaration, arg: Unit?): MutableList<DocumentSymbol> {
99107
return n.variables.map {
100108
DocumentSymbol(
101109
it.nameAsString,
@@ -105,7 +113,7 @@ class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>(
105113
}.toMutableList()
106114
}
107115

108-
override fun visit(n: MethodDeclaration, arg: Unit?): MutableList<DocumentSymbol>? {
116+
override fun visit(n: MethodDeclaration, arg: Unit?): MutableList<DocumentSymbol> {
109117
val children = acceptAllo(n.contracts)
110118
return arrayListOf(
111119
DocumentSymbol(
@@ -124,7 +132,7 @@ class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>(
124132
return super.visit(n, arg)
125133
}
126134

127-
override fun visit(n: ModuleDeclaration, arg: Unit?): MutableList<DocumentSymbol>? {
135+
override fun visit(n: ModuleDeclaration, arg: Unit?): MutableList<DocumentSymbol> {
128136
return arrayListOf(
129137
DocumentSymbol(
130138
n.nameAsString,
@@ -134,7 +142,7 @@ class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>(
134142
)
135143
}
136144

137-
override fun visit(n: JmlContract, arg: Unit?): MutableList<DocumentSymbol>? {
145+
override fun visit(n: JmlContract, arg: Unit?): MutableList<DocumentSymbol> {
138146
val children = acceptAll(n.subContracts) + acceptAll(n.clauses)
139147
return arrayListOf(
140148
DocumentSymbol(
@@ -145,12 +153,12 @@ class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>(
145153
)
146154
}
147155

148-
override fun visit(n: JmlRepresentsDeclaration?, arg: Unit?): MutableList<DocumentSymbol>? {
149-
return arrayListOf();//return super.visit(n, arg)
156+
override fun visit(n: JmlRepresentsDeclaration?, arg: Unit?): MutableList<DocumentSymbol> {
157+
return arrayListOf()//return super.visit(n, arg)
150158
}
151159

152160
override fun visit(n: JmlFieldDeclaration, arg: Unit?): MutableList<DocumentSymbol> {
153-
var decl = n.decl
161+
val decl = n.decl
154162
return decl.variables.map { v ->
155163
DocumentSymbol(
156164
v.nameAsString,
@@ -165,7 +173,7 @@ class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>(
165173
return arrayListOf() //super.visit(n, arg)
166174
}
167175

168-
override fun visit(n: JmlClassExprDeclaration, arg: Unit?): MutableList<DocumentSymbol>? {
176+
override fun visit(n: JmlClassExprDeclaration, arg: Unit?): MutableList<DocumentSymbol> {
169177
return arrayListOf(
170178
DocumentSymbol(
171179
n.name.map { it.asString() }.orElse("anon invariant"),

‎lsp/src/main/kotlin/jml/lsp/CodeActionCollector.kt

+15-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ package jml.lsp
22

33
import com.github.javaparser.ast.Node
44
import com.github.javaparser.ast.expr.Expression
5+
import com.github.javaparser.ast.jml.body.JmlClassExprDeclaration
56
import com.github.javaparser.ast.jml.clauses.JmlSignalsClause
67
import com.github.javaparser.ast.jml.clauses.JmlSimpleExprClause
78
import com.github.javaparser.ast.jml.expr.JmlQuantifiedExpr
89
import com.github.javaparser.ast.jml.expr.JmlQuantifiedExpr.JmlDefaultBinder
910
import com.github.javaparser.ast.jml.stmt.JmlExpressionStmt
10-
import jml.lsp.actions.WellDefinednessCheck
1111
import org.eclipse.lsp4j.CodeAction
1212
import org.eclipse.lsp4j.CodeActionContext
1313
import org.eclipse.lsp4j.Command
1414
import org.eclipse.lsp4j.jsonrpc.messages.Either
1515
import kotlin.jvm.optionals.getOrNull
1616

17+
/**
18+
* This visitor gathers actions, that can be executed on nodes within the given range.
19+
*/
1720
class CodeActionCollector(val context: CodeActionContext?, private val range: com.github.javaparser.Range) :
1821
ResultingVisitor<MutableList<Either<Command, CodeAction>>>() {
1922
override val result = arrayListOf<Either<Command, CodeAction>>()
@@ -36,14 +39,21 @@ class CodeActionCollector(val context: CodeActionContext?, private val range: co
3639
super.visit(n, arg)
3740
}
3841

42+
override fun visit(n: JmlClassExprDeclaration, arg: Unit?) {
43+
addWelldefinedCheck(n.invariant)
44+
super.visit(n, arg)
45+
}
46+
3947
private fun addWelldefinedCheck(n: Expression): Boolean {
40-
if (inRange(n))
41-
return add(WellDefinednessCheck.createCommand(n))
48+
/*if (inRange(n)) {
49+
return add(WellDefinednessCheck.createCodeAction(n))
50+
}*/
4251
return false
4352
}
4453

45-
@OptIn(ExperimentalStdlibApi::class)
46-
private fun inRange(n: Node): Boolean = n.range.getOrNull()?.contains(range) ?: false
54+
private fun inRange(n: Node): Boolean {
55+
return n.range.getOrNull()?.contains(range) ?: false
56+
}
4757

4858
override fun visit(n: JmlQuantifiedExpr, arg: Unit?) {
4959
if (n.binder == JmlDefaultBinder.FORALL || n.binder == JmlDefaultBinder.EXISTS) {

‎lsp/src/main/kotlin/jml/lsp/CodeLensCollector.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import jml.lsp.actions.VerifyAgainstParent
55
import org.eclipse.lsp4j.CodeLens
66
import org.eclipse.lsp4j.Command
77

8+
/**
9+
* Runs through the AST and collect code lens actions.
10+
*/
811
class CodeLensCollector : ResultingVisitor<MutableList<out CodeLens>>() {
912
override val result = arrayListOf<CodeLens>()
1013

1114
override fun visit(n: JmlContract, arg: Unit?) {
1215
if (n.type == JmlContract.Type.METHOD) {
13-
result.add(VerifyAgainstParent.createCodeLens(n))
16+
//result.add(VerifyAgainstParent.createCodeLens(n))
1417
}
1518
}
1619
}

0 commit comments

Comments
 (0)
Please sign in to comment.