-
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.
Merge pull request #4 from modelix/kotlin-conversion
Kotlin conversion
- Loading branch information
Showing
358 changed files
with
21,628 additions
and
20,855 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ on: | |
|
||
jobs: | ||
pre-commit: | ||
if: false | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
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
59 changes: 0 additions & 59 deletions
59
mps-legacy-sync-plugin/src/main/java/de/slisson/mps/reflection/runtime/ReflectionUtil.java
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
mps-legacy-sync-plugin/src/main/java/de/slisson/mps/reflection/runtime/ReflectionUtil.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package de.slisson.mps.reflection.runtime | ||
|
||
import java.lang.reflect.Field | ||
import java.lang.reflect.Modifier | ||
|
||
/*Generated by MPS */ | ||
object ReflectionUtil { | ||
fun readField(cls: Class<*>, obj: Any?, fieldName: String): Any { | ||
return try { | ||
val field = cls.getDeclaredField(fieldName) | ||
field.setAccessible(true) | ||
field[obj] | ||
} catch (ex: Exception) { | ||
throw RuntimeException("Cannot read field '$fieldName' in class '$cls' of object: $obj", ex) | ||
} | ||
} | ||
|
||
fun writeField(cls: Class<*>, obj: Any, fieldName: String, value: Any?) { | ||
try { | ||
val field = cls.getDeclaredField(fieldName) | ||
field.setAccessible(true) | ||
if (Modifier.isFinal(field.modifiers)) { | ||
val modifiersField = Field::class.java.getDeclaredField("modifiers") | ||
modifiersField.setAccessible(true) | ||
val originalModifier = field.modifiers | ||
modifiersField.setInt(field, originalModifier and Modifier.FINAL.inv()) | ||
} | ||
field[obj] = value | ||
} catch (ex: Exception) { | ||
throw RuntimeException("Cannot write field '$fieldName' in class '$cls' of object: $obj", ex) | ||
} | ||
} | ||
|
||
fun callMethod( | ||
cls: Class<*>, | ||
obj: Any?, | ||
methodName: String, | ||
argumentTypes: Array<Class<*>?>, | ||
arguments: Array<Any?>, | ||
): Any { | ||
return try { | ||
val method = cls.getDeclaredMethod(methodName, *argumentTypes) | ||
method.setAccessible(true) | ||
method.invoke(obj, *arguments) | ||
} catch (ex: Exception) { | ||
throw RuntimeException("Cannot call method '$methodName' in class '$cls' of object: $obj", ex) | ||
} | ||
} | ||
|
||
fun callVoidMethod( | ||
cls: Class<*>, | ||
obj: Any?, | ||
methodName: String, | ||
argumentTypes: Array<Class<*>?>, | ||
arguments: Array<Any?>, | ||
) { | ||
callMethod(cls, obj, methodName, argumentTypes, arguments) | ||
} | ||
|
||
fun callStaticMethod( | ||
cls: Class<*>, | ||
methodName: String, | ||
argumentTypes: Array<Class<*>?>, | ||
arguments: Array<Any?>, | ||
): Any { | ||
return callMethod(cls, null, methodName, argumentTypes, arguments) | ||
} | ||
|
||
fun callStaticVoidMethod( | ||
cls: Class<*>, | ||
methodName: String, | ||
argumentTypes: Array<Class<*>?>, | ||
arguments: Array<Any?>, | ||
) { | ||
callStaticMethod(cls, methodName, argumentTypes, arguments) | ||
} | ||
|
||
fun getClass(fqName: String?): Class<*> { | ||
return try { | ||
Class.forName(fqName) | ||
} catch (ex: ClassNotFoundException) { | ||
throw RuntimeException("", ex) | ||
} | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
mps-legacy-sync-plugin/src/main/java/org/modelix/common/AuthorOverride.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
mps-legacy-sync-plugin/src/main/java/org/modelix/common/AuthorOverride.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.modelix.common | ||
|
||
import org.modelix.kotlin.utils.ContextValue | ||
|
||
/*Generated by MPS */ | ||
object AuthorOverride { | ||
var AUTHOR: ContextValue<String> = ContextValue() | ||
private var instanceOwner: String? = null | ||
fun setInstanceOwner(owner: String?) { | ||
instanceOwner = owner | ||
} | ||
|
||
fun apply(author: String?): String? { | ||
val override: String? = AUTHOR.getValueOrNull() | ||
if ((override != null && override.length > 0)) { | ||
return override | ||
} | ||
if ((author == null || author.length == 0) && (instanceOwner != null && instanceOwner!!.length > 0)) { | ||
return instanceOwner | ||
} | ||
return author | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
mps-legacy-sync-plugin/src/main/java/org/modelix/common/InstanceJwtToken.java
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
mps-legacy-sync-plugin/src/main/java/org/modelix/common/InstanceJwtToken.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.modelix.common | ||
|
||
/*Generated by MPS */ | ||
object InstanceJwtToken { | ||
var token: String = System.getenv("INITIAL_JWT_TOKEN") | ||
} |
31 changes: 0 additions & 31 deletions
31
mps-legacy-sync-plugin/src/main/java/org/modelix/common/PropertyOrEnv.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
mps-legacy-sync-plugin/src/main/java/org/modelix/common/PropertyOrEnv.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.modelix.common | ||
|
||
/*Generated by MPS */ | ||
object PropertyOrEnv { | ||
operator fun get(name: String?): String? { | ||
var value: String? = System.getProperty(name) | ||
if ((value == null || value.length == 0)) { | ||
value = System.getenv(name) | ||
} | ||
if ((value == null || value.length == 0) && name!!.contains(".")) { | ||
val withoutDots: String = name.replace('.', '_') | ||
value = System.getProperty(withoutDots) | ||
if ((value == null || value.length == 0)) { | ||
value = System.getenv(withoutDots) | ||
} | ||
} | ||
return value | ||
} | ||
|
||
fun getOrElse(name: String?, defaultValue: String?): String { | ||
val value: String? = get(name) | ||
return (if ((value != null && value.length > 0)) value else (defaultValue)!!) | ||
} | ||
|
||
fun getOrElseBoolean(name: String?, defaultValue: Boolean): Boolean { | ||
val value: String? = get(name) | ||
return (if ((value != null && value.length > 0)) value.toBoolean() else defaultValue) | ||
} | ||
} |
Oops, something went wrong.