-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
3,175 additions
and
1,612 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...kotlin/jml2java/Jml2JavaTranslatorTest.kt → ...oolkit/jml2java/Jml2JavaTranslatorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a/src/test/kotlin/jml2java/PatternTest.kt → ...github/jmltoolkit/jml2java/PatternTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import com.github.jmlparser.TestWithJavaParser; | ||
import org.junit.jupiter.api.Assumptions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import io.github.jmltoolkit.lint.JmlLintingConfig | ||
import io.github.jmltoolkit.lint.JmlLintingFacade | ||
import io.github.jmltoolkit.utils.TestWithJavaParser | ||
import org.junit.jupiter.api.Assumptions | ||
import org.junit.jupiter.api.Test | ||
|
||
/** | ||
* @author Alexander Weigl | ||
* @version 1 (14.10.22) | ||
*/ | ||
class LinterTest extends TestWithJavaParser { | ||
internal class LinterTest : TestWithJavaParser() { | ||
@Test | ||
void everythingWrong() { | ||
var result = parser.parse(getClass().getResourceAsStream("EverythingWrong.java")); | ||
Assumptions.assumeTrue(result.isSuccessful()); | ||
var actual = | ||
new JmlLintingFacade(new JmlLintingConfig()).lint(Collections.singletonList(result.getResult().get())); | ||
fun everythingWrong() { | ||
val result = parser.parse(javaClass.getResourceAsStream("EverythingWrong.java")) | ||
Assumptions.assumeTrue(result.isSuccessful) | ||
val actual = JmlLintingFacade(JmlLintingConfig()).lint(listOf(result.result.get())) | ||
|
||
for (LintProblem lintProblem : actual) { | ||
System.out.println(lintProblem); | ||
for (lintProblem in actual) { | ||
println(lintProblem) | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
plugins { | ||
id("standard-kotlin") | ||
id("com.github.johnrengelman.shadow") version "7.1.2" | ||
id("application") | ||
} | ||
|
||
version = "1.0-SNAPSHOT" | ||
|
||
dependencies { | ||
api(libs.jmlcore) | ||
api(libs.jmlsymbol) | ||
|
||
testImplementation(kotlin("test")) | ||
|
||
implementation(project(":utils")) | ||
implementation(project(":smt")) | ||
implementation(project(":wd")) | ||
implementation(project(":stat")) | ||
implementation(project(":redux")) | ||
implementation(project(":lint")) | ||
implementation(project(":jml2java")) | ||
|
||
implementation("org.tinylog:tinylog-api-kotlin:2.5.0") | ||
implementation("org.tinylog:tinylog-api:2.5.0-M2.1") | ||
implementation("org.tinylog:tinylog-impl:2.5.0") | ||
|
||
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:0.21.2") | ||
|
||
implementation("com.github.ajalt.clikt:clikt:4.2.2") | ||
|
||
//implementation("org.apache.groovy:groovy:4.0.6") | ||
} | ||
|
||
application { | ||
mainClass = "jml.lsp.Main" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
rootProject.name = "jml-lsp" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
package jml.lsp | ||
|
||
import com.github.javaparser.ast.CompilationUnit | ||
import com.github.javaparser.ast.Node | ||
import com.github.javaparser.ast.NodeList | ||
import com.github.javaparser.ast.body.* | ||
import com.github.javaparser.ast.expr.VariableDeclarationExpr | ||
import com.github.javaparser.ast.jml.body.* | ||
import com.github.javaparser.ast.jml.clauses.* | ||
import com.github.javaparser.ast.modules.ModuleDeclaration | ||
import com.github.javaparser.ast.visitor.GenericVisitorAdapter | ||
import org.eclipse.lsp4j.DocumentSymbol | ||
import org.eclipse.lsp4j.SymbolKind | ||
import java.util.* | ||
|
||
/** | ||
* Runs through an AST and gathers symbols within JML annotations. | ||
* | ||
* @author Alexander Weigl | ||
*/ | ||
class CatchSymbols : GenericVisitorAdapter<MutableList<DocumentSymbol>?, Unit?>() { | ||
override fun visit(n: CompilationUnit, arg: Unit?): MutableList<DocumentSymbol> { | ||
val children = acceptAll(n.types) | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.storage.get().fileName, | ||
SymbolKind.File, | ||
n.asRange, n.primaryType.map { it.name.asRange }.orElse(n.asRange), "", children | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: AnnotationDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
val children = acceptAll(n.members) | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.nameAsString, | ||
SymbolKind.Interface, | ||
n.asRange, n.name.asRange, "", children | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: AnnotationMemberDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.nameAsString, | ||
SymbolKind.Field, | ||
n.asRange, n.name.asRange, "" | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: ClassOrInterfaceDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
val children = acceptAll(n.members) | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.nameAsString, | ||
if (n.isInterface) SymbolKind.Interface else SymbolKind.Class, | ||
n.asRange, n.name.asRange, "", children | ||
) | ||
) | ||
} | ||
|
||
private fun acceptAll(members: NodeList<*>?): MutableList<DocumentSymbol> { | ||
if (members == null) return arrayListOf() | ||
return members.flatMap { it.accept(this, null) ?: arrayListOf() }.toMutableList() | ||
} | ||
|
||
private fun <T : Node> acceptAllo(members: Optional<NodeList<T>>?): MutableList<DocumentSymbol> = | ||
acceptAll(members?.orElse(null)) | ||
|
||
override fun visit(n: ConstructorDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
val children = acceptAllo(n.contracts) | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.nameAsString, | ||
SymbolKind.Constructor, | ||
n.asRange, n.name.asRange, "", children | ||
) | ||
) | ||
} | ||
|
||
|
||
override fun visit(n: EnumConstantDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.nameAsString, | ||
SymbolKind.EnumMember, | ||
n.asRange, n.name.asRange, | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: EnumDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
val children = acceptAll(n.members) | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.nameAsString, | ||
SymbolKind.Enum, | ||
n.asRange, n.name.asRange, "", children | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: FieldDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
return n.variables.map { | ||
DocumentSymbol( | ||
it.nameAsString, | ||
SymbolKind.Field, | ||
it.asRange, it.name.asRange, it.typeAsString, arrayListOf() | ||
) | ||
}.toMutableList() | ||
} | ||
|
||
override fun visit(n: MethodDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
val children = acceptAllo(n.contracts) | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.nameAsString, | ||
SymbolKind.Method, | ||
n.asRange, n.name.asRange, "", children | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: JmlMethodDeclaration, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return n.methodDeclaration.accept(this, arg) | ||
} | ||
|
||
override fun visit(n: VariableDeclarationExpr?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: ModuleDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.nameAsString, | ||
SymbolKind.Module, | ||
n.asRange, n.name.asRange, "", arrayListOf() | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: JmlContract, arg: Unit?): MutableList<DocumentSymbol> { | ||
val children = acceptAll(n.subContracts) + acceptAll(n.clauses) | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.name.map { it.asString() }.orElse(n.behavior.asString()), | ||
SymbolKind.Key, | ||
n.asRange, n.asRange, "${n.jmlTags}", children | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: JmlRepresentsDeclaration?, arg: Unit?): MutableList<DocumentSymbol> { | ||
return arrayListOf()//return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlFieldDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
val decl = n.decl | ||
return decl.variables.map { v -> | ||
DocumentSymbol( | ||
v.nameAsString, | ||
SymbolKind.Property, | ||
n.asRange, n.asRange, "Jml model method: activated with ${n.jmlTags}", listOf() | ||
) | ||
}.toMutableList() | ||
|
||
} | ||
|
||
override fun visit(n: JmlClassAccessibleDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
return arrayListOf() //super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlClassExprDeclaration, arg: Unit?): MutableList<DocumentSymbol> { | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.name.map { it.asString() }.orElse("anon invariant"), | ||
SymbolKind.Property, | ||
n.asRange, n.asRange, "Jml class invariant", listOf() | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: JmlSimpleExprClause, arg: Unit?): MutableList<DocumentSymbol> { | ||
return arrayListOf( | ||
DocumentSymbol( | ||
n.name.map { "$it : ${n.kind}" }.orElse("Clause ${n.kind}"), | ||
SymbolKind.EnumMember, | ||
n.asRange, n.asRange, "Jml clause", listOf() | ||
) | ||
) | ||
} | ||
|
||
override fun visit(n: JmlSignalsClause?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlSignalsOnlyClause?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlCallableClause?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlCapturesClause?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlForallClause?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlClauseIf?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlOldClause?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
|
||
override fun visit(n: JmlMultiExprClause?, arg: Unit?): MutableList<DocumentSymbol>? { | ||
return super.visit(n, arg) | ||
} | ||
} |
Oops, something went wrong.