Created
January 31, 2017 08:22
-
-
Save AdamBJ/1ea44cbd43136b47fdfb3acfed4326a8 to your computer and use it in GitHub Desktop.
Actual ouput
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
/*PLEASE DO NOT EDIT THIS CODE*/ | |
/*This code was generated using the UMPLE @UMPLE_VERSION@ modeling language!*/ | |
package example; | |
// line 3 "../test.ump" | |
public class Mentor | |
{ | |
//------------------------ | |
// MEMBER VARIABLES | |
//------------------------ | |
//------------------------ | |
// CONSTRUCTOR | |
//------------------------ | |
public Mentor() | |
{} | |
//------------------------ | |
// INTERFACE | |
//------------------------ | |
public void delete() | |
{} | |
// line 6 "../test.ump" | |
public static main(){ | |
} | |
} | |
public static class UmpleExceptionHandler implements Thread.UncaughtExceptionHandler | |
{ | |
public void uncaughtException(Thread t, Throwable e) | |
{ | |
translate(e); | |
if(e.getCause()!=null) | |
{ | |
translate(e.getCause()); | |
} | |
e.printStackTrace(); | |
} | |
public void translate(Throwable e) | |
{ | |
java.util.List<StackTraceElement> result = new java.util.ArrayList<StackTraceElement>(); | |
StackTraceElement[] elements = e.getStackTrace(); | |
try | |
{ | |
for(StackTraceElement element:elements) | |
{ | |
String className = element.getClassName(); | |
String methodName = element.getMethodName(); | |
boolean methodFound = false; | |
int index = className.lastIndexOf('.')+1; | |
try { | |
java.lang.reflect.Method query = this.getClass().getMethod(className.substring(index)+"_"+methodName,new Class[]{}); | |
UmpleSourceData sourceInformation = (UmpleSourceData)query.invoke(this,new Object[]{}); | |
for(int i=0;i<sourceInformation.size();++i) | |
{ | |
int distanceFromStart = element.getLineNumber()-sourceInformation.getJavaLine(i)-(("main".equals(methodName))?2:0); | |
if(distanceFromStart>=0&&distanceFromStart<=sourceInformation.getLength(i)) | |
{ | |
result.add(new StackTraceElement(element.getClassName(),element.getMethodName(),sourceInformation.getFileName(i),sourceInformation.getUmpleLine(i)+distanceFromStart)); | |
methodFound = true; | |
break; | |
} | |
} | |
} | |
catch (Exception e2){} | |
if(!methodFound) | |
{ | |
result.add(element); | |
} | |
} | |
} | |
catch (Exception e1) | |
{ | |
e1.printStackTrace(); | |
} | |
e.setStackTrace(result.toArray(new StackTraceElement[0])); | |
} | |
//The following methods Map Java lines back to their original Umple file / line | |
public UmpleSourceData Mentor_main(){ return new UmpleSourceData().setFileNames("test.ump").setUmpleLines(5).setJavaLines(28).setLengths(3);} | |
} | |
public static class UmpleSourceData | |
{ | |
String[] umpleFileNames; | |
Integer[] umpleLines; | |
Integer[] umpleJavaLines; | |
Integer[] umpleLengths; | |
public UmpleSourceData(){ | |
} | |
public String getFileName(int i){ | |
return umpleFileNames[i]; | |
} | |
public Integer getUmpleLine(int i){ | |
return umpleLines[i]; | |
} | |
public Integer getJavaLine(int i){ | |
return umpleJavaLines[i]; | |
} | |
public Integer getLength(int i){ | |
return umpleLengths[i]; | |
} | |
public UmpleSourceData setFileNames(String... filenames){ | |
umpleFileNames = filenames; | |
return this; | |
} | |
public UmpleSourceData setUmpleLines(Integer... umplelines){ | |
umpleLines = umplelines; | |
return this; | |
} | |
public UmpleSourceData setJavaLines(Integer... javalines){ | |
umpleJavaLines = javalines; | |
return this; | |
} | |
public UmpleSourceData setLengths(Integer... lengths){ | |
umpleLengths = lengths; | |
return this; | |
} | |
public int size(){ | |
return umpleFileNames.length; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment