Skip to content

Commit

Permalink
copied original Java files of the sync plugin from MPS
Browse files Browse the repository at this point in the history
As a separate commit so that we have a history of the changes that were
required after copying the files from MPS.
  • Loading branch information
slisson committed Dec 9, 2023
1 parent 811dfdc commit 882c632
Show file tree
Hide file tree
Showing 189 changed files with 44,430 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package de.slisson.mps.reflection.runtime;

/*Generated by MPS */

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.Method;

public class ReflectionUtil {
public static Object readField(Class cls, Object obj, String fieldName) {
try {
Field field = cls.getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(obj);
} catch (Exception ex) {
throw new RuntimeException("Cannot read field '" + fieldName + "' in class '" + cls + "' of object: " + obj, ex);
}
}
public static void writeField(Class cls, Object obj, String fieldName, Object value) {
try {
Field field = cls.getDeclaredField(fieldName);
field.setAccessible(true);
if (Modifier.isFinal(field.getModifiers())) {
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
int originalModifier = field.getModifiers();
modifiersField.setInt(field, originalModifier & ~(Modifier.FINAL));
}
field.set(obj, value);
} catch (Exception ex) {
throw new RuntimeException("Cannot write field '" + fieldName + "' in class '" + cls + "' of object: " + obj, ex);
}
}
public static Object callMethod(Class cls, Object obj, String methodName, Class[] argumentTypes, Object[] arguments) {
try {
Method method = cls.getDeclaredMethod(methodName, argumentTypes);
method.setAccessible(true);
return method.invoke(obj, arguments);
} catch (Exception ex) {
throw new RuntimeException("Cannot call method '" + methodName + "' in class '" + cls + "' of object: " + obj, ex);
}
}
public static void callVoidMethod(Class cls, Object obj, String methodName, Class[] argumentTypes, Object[] arguments) {
callMethod(cls, obj, methodName, argumentTypes, arguments);
}
public static Object callStaticMethod(Class cls, String methodName, Class[] argumentTypes, Object[] arguments) {
return callMethod(cls, null, methodName, argumentTypes, arguments);
}
public static void callStaticVoidMethod(Class cls, String methodName, Class[] argumentTypes, Object[] arguments) {
callStaticMethod(cls, methodName, argumentTypes, arguments);
}
public static Class getClass(String fqName) {
try {
return Class.forName(fqName);
} catch (ClassNotFoundException ex) {
throw new RuntimeException("", ex);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.modelix.common;

/*Generated by MPS */

import de.q60.mps.incremental.util.ContextValue;

public class AuthorOverride {
public static ContextValue<String> AUTHOR = new ContextValue<String>();
private static String instanceOwner = null;

public static void setInstanceOwner(String owner) {
instanceOwner = owner;
}

public static String apply(String author) {
String override = AUTHOR.getValue();
if ((override != null && override.length() > 0)) {
return override;
}
if ((author == null || author.length() == 0) && (instanceOwner != null && instanceOwner.length() > 0)) {
return instanceOwner;
}
return author;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.modelix.common;

/*Generated by MPS */


public class InstanceJwtToken {
public static String token = System.getenv("INITIAL_JWT_TOKEN");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.modelix.common;

/*Generated by MPS */


public class PropertyOrEnv {
public static String get(String name) {
String value = System.getProperty(name);
if ((value == null || value.length() == 0)) {
value = System.getenv(name);
}
if ((value == null || value.length() == 0) && name.contains(".")) {
String withoutDots = name.replace('.', '_');
value = System.getProperty(withoutDots);
if ((value == null || value.length() == 0)) {
value = System.getenv(withoutDots);
}
}
return value;
}

public static String getOrElse(String name, String defaultValue) {
String value = get(name);
return ((value != null && value.length() > 0) ? value : defaultValue);
}

public static boolean getOrElseBoolean(String name, boolean defaultValue) {
String value = get(name);
return ((value != null && value.length() > 0) ? Boolean.parseBoolean(value) : defaultValue);
}
}
90 changes: 90 additions & 0 deletions mps-legacy-sync-plugin/src/main/java/org/modelix/common/trace.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<debug-info version="2">
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1068580123155:jetbrains.mps.baseLanguage.structure.ExpressionStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1068580123159:jetbrains.mps.baseLanguage.structure.IfStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1068581242864:jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1068581242878:jetbrains.mps.baseLanguage.structure.ReturnStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1070462154015:jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1081236700938:jetbrains.mps.baseLanguage.structure.StaticMethodDeclaration" />
<root nodeRef="r:53d14de3-e820-4a3b-9328-a2833dcab0bd(org.modelix.common)/2921423254043408775">
<file name="InstanceJwtToken.java">
<node id="2921423254043408972" at="7,0,8,0" concept="4" trace="token" />
<unit id="2921423254043408775" at="6,0,9,0" name="org.modelix.common.InstanceJwtToken" />
</file>
</root>
<root nodeRef="r:53d14de3-e820-4a3b-9328-a2833dcab0bd(org.modelix.common)/4070572059246211635">
<file name="PropertyOrEnv.java">
<node id="4070572059246244580" at="7,41,8,44" concept="2" />
<node id="4070572059246254893" at="9,49,10,34" concept="0" />
<node id="4070572059246729789" at="12,71,13,50" concept="2" />
<node id="4070572059246725146" at="13,50,14,46" concept="0" />
<node id="4070572059246562454" at="15,51,16,43" concept="0" />
<node id="4070572059246259698" at="18,5,19,17" concept="3" />
<node id="6349202251076968563" at="22,68,23,29" concept="2" />
<node id="6349202251076971678" at="23,29,24,74" concept="3" />
<node id="8320180400982949126" at="27,77,28,29" concept="2" />
<node id="8320180400982949131" at="28,29,29,96" concept="3" />
<node id="4070572059246245784" at="8,44,11,5" concept="1" />
<node id="4070572059246718253" at="14,46,17,7" concept="1" />
<node id="6349202251076967925" at="22,0,26,0" concept="5" trace="getOrElse#(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;" />
<node id="8320180400982949124" at="27,0,31,0" concept="5" trace="getOrElseBoolean#(Ljava/lang/String;Z)Z" />
<node id="4070572059246555473" at="11,5,18,5" concept="1" />
<node id="4070572059246242659" at="7,0,21,0" concept="5" trace="get#(Ljava/lang/String;)Ljava/lang/String;" />
<scope id="4070572059246245786" at="9,49,10,34" />
<scope id="4070572059246718255" at="15,51,16,43" />
<scope id="6349202251076966837" at="22,68,24,74">
<var name="value" id="6349202251076968564" />
</scope>
<scope id="8320180400982949125" at="27,77,29,96">
<var name="value" id="8320180400982949127" />
</scope>
<scope id="6349202251076967925" at="22,0,26,0">
<var name="defaultValue" id="6349202251076967485" />
<var name="name" id="6349202251076967196" />
</scope>
<scope id="8320180400982949124" at="27,0,31,0">
<var name="defaultValue" id="8320180400982949140" />
<var name="name" id="8320180400982949138" />
</scope>
<scope id="4070572059246555475" at="12,71,17,7">
<var name="withoutDots" id="4070572059246729790" />
</scope>
<scope id="4070572059246241315" at="7,41,19,17">
<var name="value" id="4070572059246244581" />
</scope>
<scope id="4070572059246242659" at="7,0,21,0">
<var name="name" id="4070572059246241791" />
</scope>
<unit id="4070572059246211635" at="6,0,32,0" name="org.modelix.common.PropertyOrEnv" />
</file>
</root>
<root nodeRef="r:53d14de3-e820-4a3b-9328-a2833dcab0bd(org.modelix.common)/6676065291079107896">
<file name="AuthorOverride.java">
<node id="6676065291079109617" at="8,0,9,0" concept="4" trace="AUTHOR" />
<node id="4423366899059043251" at="9,0,10,0" concept="4" trace="instanceOwner" />
<node id="4423366899059048122" at="11,53,12,26" concept="0" />
<node id="6676065291079116689" at="15,45,16,40" concept="2" />
<node id="4423366899059042673" at="17,54,18,22" concept="3" />
<node id="4423366899059046533" at="20,108,21,27" concept="3" />
<node id="4423366899059046871" at="22,5,23,18" concept="3" />
<node id="4423366899059061483" at="11,0,14,0" concept="5" trace="setInstanceOwner#(Ljava/lang/String;)V" />
<node id="4423366899059040073" at="16,40,19,5" concept="1" />
<node id="4423366899059043073" at="19,5,22,5" concept="1" />
<node id="6676065291079124036" at="15,0,25,0" concept="5" trace="apply#(Ljava/lang/String;)Ljava/lang/String;" />
<scope id="4423366899059047544" at="11,53,12,26" />
<scope id="4423366899059040075" at="17,54,18,22" />
<scope id="4423366899059043075" at="20,108,21,27" />
<scope id="4423366899059061483" at="11,0,14,0">
<var name="owner" id="4423366899059047759" />
</scope>
<scope id="6676065291079111595" at="15,45,23,18">
<var name="override" id="6676065291079116690" />
</scope>
<scope id="6676065291079124036" at="15,0,25,0">
<var name="author" id="6676065291079111960" />
</scope>
<unit id="6676065291079107896" at="7,0,26,0" name="org.modelix.common.AuthorOverride" />
</file>
</root>
</debug-info>

Loading

0 comments on commit 882c632

Please sign in to comment.