Skip to content

Commit

Permalink
remove apache commons
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon committed Apr 22, 2024
1 parent 12b5777 commit 25d446d
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 143 deletions.
2 changes: 1 addition & 1 deletion qodana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ profile:
# paths:
# - <path/where/not/run/inspection>

projectJDK: 21 #(Applied in CI/CD pipeline)
projectJDK: "21" #(Applied in CI/CD pipeline)

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh
Expand Down
6 changes: 0 additions & 6 deletions stvs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@ dependencies {
implementation("com.google.code.gson:gson:2.10.1")
implementation 'de.tu-dresden.inf.lat.jsexp:jsexp:0.2.2'

implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.apache.commons:commons-lang3:3.14.0'
implementation 'commons-io:commons-io:2.16.1'

implementation 'org.fxmisc.cssfx:cssfx:11.2.2'
implementation(project(":fxutils"))



/* testImplementation "org.testfx:testfx-core:4.0.+"
testImplementation "org.testfx:testfx-junit:4.0.+"
testImplementation "org.mockito:mockito-core:2.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import edu.kit.iti.formal.stvs.model.config.History
import edu.kit.iti.formal.stvs.model.expressions.Type
import edu.kit.iti.formal.stvs.model.table.*
import edu.kit.iti.formal.stvs.model.verification.VerificationResult
import org.apache.commons.io.IOUtils
import org.xml.sax.InputSource
import org.xml.sax.SAXException
import java.io.*
Expand Down Expand Up @@ -243,12 +242,10 @@ object ImporterFacade {
fun importFile(
file: File, globalConfig: GlobalConfig, currentHistory: History,
importHybridSpecificationHandler: ImportHybridSpecificationHandler,
importStvsRootModelHandler: ImportStvsRootModelHandler, codeConsumer: ImportCodeHandler
importStvsRootModelHandler: ImportStvsRootModelHandler,
codeConsumer: ImportCodeHandler
) {
val writer = StringWriter()
val byteArray: ByteArray = IOUtils.toByteArray(FileInputStream(file))
IOUtils.copy(ByteArrayInputStream(byteArray), writer, "utf8")
val inputString = writer.toString()
val inputString = file.bufferedReader().readText()
val dbf = DocumentBuilderFactory.newInstance()
dbf.isNamespaceAware = true
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package edu.kit.iti.formal.stvs.logic.verification

import javafx.beans.property.*
import org.apache.commons.io.IOUtils
import tornadofx.getValue
import tornadofx.setValue
import java.io.IOException
Expand Down Expand Up @@ -50,17 +49,16 @@ class ProcessMonitor(process: Process?, timeout: Int) : Thread() {
*/
override fun run() {
isAborted = false
val process = this.process!!
try {
// wait for the process to finish
if (!process!!.waitFor(timeout.toLong(), TimeUnit.SECONDS)) {
process!!.destroy()
if (!process.waitFor(timeout.toLong(), TimeUnit.SECONDS)) {
process.destroy()
isAborted = true
}
if (process!!.exitValue() != 0) {
error = IOException(
"""Process ended with error ${process!!.exitValue()} and error output:
${IOUtils.toString(process!!.errorStream, "utf-8")}"""
)
if (process.exitValue() != 0) {
val errorOut = process.errorStream.reader().readText()
error = IOException("Process ended with error ${process.exitValue()} and error output: $errorOut")
}
processFinishedProperty.set(true)
} catch (e: InterruptedException) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package edu.kit.iti.formal.stvs.model.common

import org.apache.commons.lang3.StringEscapeUtils

/**
* A [FreeVariableProblem] that occurs when two free variables with the same name occur.
*
Expand All @@ -13,9 +11,9 @@ class DuplicateFreeVariableProblem
* method [DuplicateFreeVariableProblem.checkForDuplicates].
* @param freeVariableName the name of the duplicate variable
*/
private constructor(freeVariableName: String) : FreeVariableProblem(
"More than one free variable with name " + StringEscapeUtils.escapeJava(freeVariableName)
) {
private constructor(freeVariableName: String) :
FreeVariableProblem("More than one free variable with name $freeVariableName") {

override val problemName: String
get() = "duplicate variable name"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package edu.kit.iti.formal.stvs.model.common

import edu.kit.iti.formal.stvs.model.expressions.*
import edu.kit.iti.formal.stvs.model.expressions.parser.*
import org.apache.commons.lang3.StringEscapeUtils

/**
*
Expand Down Expand Up @@ -49,20 +48,14 @@ class InvalidFreeVariableProblem(errorMessage: String?) : FreeVariableProblem(er
if (VariableExpr.IDENTIFIER_PATTERN.matcher(varName).matches()) {
return varName
} else {
throw InvalidFreeVariableProblem(
"Variable has illegal characters in name: "
+ StringEscapeUtils.escapeJava(varName)
)
throw InvalidFreeVariableProblem("Variable has illegal characters in name: $varName")
}
}

@Throws(InvalidFreeVariableProblem::class)
private fun tryToGetValidType(freeVariable: FreeVariable, typesByName: Map<String, Type>): Type {
val foundType = typesByName[freeVariable.type]
?: throw InvalidFreeVariableProblem(
"Variable has unknown type: " + StringEscapeUtils
.escapeJava(freeVariable.type)
)
?: throw InvalidFreeVariableProblem("Variable has unknown type: ${freeVariable.type}")
return foundType
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package edu.kit.iti.formal.stvs.model.table

import org.apache.commons.lang3.StringEscapeUtils

/**
* Interface for classes that Provide commonly needed functionality for editing, like having a
* string property and being commentable.
Expand All @@ -14,8 +12,5 @@ interface CellOperationProvider : Commentable, StringEditable {
* (should only used for debugging purposes, i.e. in toString methods)
* @return a minimal string
*/
fun debuggingString(): String? {
return asString + (if (comment == null) ""
else " (comment: \"" + StringEscapeUtils.escapeJava(comment) + "\")")
}
fun debuggingString() = asString + (comment?.let { " (comment: \"$it\")" } ?: "")
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class ConstraintCell(stringRepresentation: String?) : CellOperationProvider {
comment = constraintCell.comment
}

override fun toString(): String {
return debuggingString()!!
}
override fun toString() = debuggingString()

override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import javafx.collections.FXCollections
import javafx.collections.ListChangeListener
import javafx.collections.ObservableList
import javafx.util.Callback
import org.apache.commons.lang3.StringEscapeUtils
import tornadofx.getValue
import tornadofx.setValue
import java.util.*
Expand Down Expand Up @@ -152,9 +151,7 @@ open class SpecificationTable<H : Named?, C, D>(
fun getColumnHeaderByName(columnHeaderName: String?): H {
return getOptionalColumnHeaderByName(columnHeaderName)
.orElseThrow {
NoSuchElementException(
"Column does not exist: " + StringEscapeUtils.escapeJava(columnHeaderName)
)
NoSuchElementException("Column does not exist: $columnHeaderName")
}
}

Expand Down Expand Up @@ -214,14 +211,10 @@ open class SpecificationTable<H : Named?, C, D>(
for (addedRow in added) {
// Check correctness of added row
require(addedRow!!.cells.size == columnHeaders.size) {
("Illegal width for row " + StringEscapeUtils.escapeJava(addedRow.toString())
+ ", expected width: " + columnHeaders.size)
"Illegal width for row $addedRow, expected width: ${columnHeaders.size}"
}
require(
addedRow.cells.keys.stream()
.allMatch { columnId: String? -> getOptionalColumnHeaderByName(columnId).isPresent }) {
("Added row contains unknown IoVariable: "
+ StringEscapeUtils.escapeJava(addedRow.toString()))
require(addedRow.cells.keys.all { getOptionalColumnHeaderByName(it).isPresent }) {
"Added row contains unknown IoVariable: $addedRow"
}
}
}
Expand All @@ -238,11 +231,8 @@ open class SpecificationTable<H : Named?, C, D>(
for (columnHeader in added) {
val columnId = columnHeader!!.name
getOptionalColumnHeaderByName(columnId).ifPresent { otherVariableWithSameName: H ->
require(
otherVariableWithSameName === columnHeader
) {
("Cannot add SpecIoVariable that collides with another SpecIoVariable: "
+ StringEscapeUtils.escapeJava(columnId))
require(otherVariableWithSameName === columnHeader) {
"Cannot add SpecIoVariable that collides with another SpecIoVariable: $columnId"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import javafx.beans.binding.Bindings
import javafx.beans.property.BooleanProperty
import javafx.beans.property.SimpleBooleanProperty
import javafx.beans.property.SimpleStringProperty
import javafx.beans.property.StringProperty
import javafx.beans.value.ObservableBooleanValue
import javafx.event.EventHandler
import javafx.scene.control.Alert.AlertType
Expand All @@ -16,29 +15,34 @@ import javafx.scene.image.Image
import javafx.stage.Modality
import javafx.stage.Stage
import javafx.stage.WindowEvent
import org.apache.commons.lang3.SystemUtils
import java.io.File
import tornadofx.getValue
import tornadofx.setValue
import java.nio.file.Path
import kotlin.io.path.Path

/**
* Created by leonk on 22.03.2017.
*/
class WelcomeWizard(private val config: GlobalConfig) : WizardManager() {
private val areAllPathsValid: ObservableBooleanValue
val javaPathProperty = SimpleStringProperty(ownJavaPath.toString())
var javaPath by javaPathProperty

val getetaPathProperty = SimpleStringProperty("")
val getetaPath by getetaPathProperty

init {
val javaPath: StringProperty = SimpleStringProperty(ownJavaPath)
val getetaPath: StringProperty = SimpleStringProperty("")
config.getetaCommandProperty
.bind(Bindings.concat(javaPath, " -jar ", getetaPath, " -c \${code} -t \${spec} -x"))
config.getetaCommandProperty.bind(
Bindings.concat(javaPath, " -jar ", getetaPath, " -c \${code} -t \${spec} -x"))

val java = WizardFilePathPage(
"Java",
"Choose the path to the java executable you would like to use to run the GeTeTa verification engine with.",
javaPath
javaPathProperty
)
val geteta = WizardFilePathPage(
"GeTeTa",
"Choose the path to the GeTeTa verification engine jar package.", getetaPath,
"Choose the path to the GeTeTa verification engine jar package.", getetaPathProperty,
"https://formal.iti.kit.edu/weigl/verifaps/geteta/"
)
val getetaCommandPage = WizardUneditableStringPage(
Expand Down Expand Up @@ -104,14 +108,13 @@ class WelcomeWizard(private val config: GlobalConfig) : WizardManager() {
return accu
}

private val ownJavaPath: String
private val ownJavaPath: Path
get() {
var extension = ""
if (SystemUtils.IS_OS_WINDOWS) {
if (System.getProperty("os.name").equals("win", ignoreCase = true)) {
extension = ".exe"
}
return (System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"
+ extension)
return Path(System.getProperty("java.home"), "bin", "java$extension")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import javafx.scene.control.Label
import javafx.scene.layout.HBox
import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid
import org.kordamp.ikonli.javafx.FontIcon
import tornadofx.getValue
import java.io.File

/**
* Created by leonk on 22.03.2017.
*/
class WizardFilePathPage(title: String, description: String?, filePath: StringProperty?) : WizardPage(title) {
class WizardFilePathPage(title: String, description: String, val filePathProperty: StringProperty) : WizardPage(title) {
val filePath by filePathProperty
private val filePathField = FileSelectionField()
private val valid: BooleanProperty = SimpleBooleanProperty()
private val notValidContainer = HBox(20.0)
Expand All @@ -32,11 +34,11 @@ class WizardFilePathPage(title: String, description: String?, filePath: StringPr
validator(filePathField.textField.textProperty())

children.addAll(Label(description), filePathField, notValidContainer)
filePathField.textField.textProperty().bindBidirectional(filePath)
filePathField.textField.textProperty().bindBidirectional(filePathProperty)
}

constructor(
title: String, description: String?, filePath: StringProperty?,
title: String, description: String, filePath: StringProperty,
downloadLink: String
) : this(title, description, filePath) {
children.addAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ class TimingDiagramCollectionController(
view.xaxis, selection, activatedProperty
)
})!!
val timingDiagramView = diagramAxisPair.left.view
val timingDiagramView = diagramAxisPair.first.view

if (concreteSpec!!.isCounterExample) {
timingDiagramView.styleClass.add("counterexample")
}
val externalYAxis = diagramAxisPair.right
val externalYAxis = diagramAxisPair.second
val verticalResizeContainerController =
VerticalResizeContainerController(timingDiagramView)

Expand Down
Loading

0 comments on commit 25d446d

Please sign in to comment.