package org.aikodi.chameleon.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * A debugging class that stores the current stacktrace.
 * 
 * @author Marko van Dooren
 */
public class CreationStackTrace {

	private StackTraceElement[] _stackTrace;

	public List<StackTraceElement> trace() {
		return new ArrayList<StackTraceElement>(Arrays.asList(_stackTrace));
	}
	
	public CreationStackTrace() {
		try {
			throw new Exception();
		} catch (Exception e) {
			_stackTrace = e.getStackTrace();
		}
	}
	
}

@@ -247,16 +247,21 @@
 private 
+List%3C
 StackTra
@@ -273,10 +273,9 @@
 ment
-%5B%5D
+%3E
  _st
@@ -373,22 +373,8 @@
 nt%3E(
-Arrays.asList(
 _sta
@@ -381,17 +381,16 @@
 ckTrace)
-)
 ;%0A%09%7D%0A%09%0A%09
@@ -496,16 +496,30 @@
 Trace = 
+Arrays.asList(
 e.getSta
@@ -527,16 +527,17 @@
 kTrace()
+)
 ;%0A%09%09%7D%0A%09%7D
@@ -539,10 +539,198 @@
 %09%7D%0A%09%7D%0A%09%0A
+  public CreationStackTrace(int size) %7B%0A    try %7B%0A      throw new Exception();%0A    %7D catch (Exception e) %7B%0A      _stackTrace = Arrays.asList(e.getStackTrace()).subList(0, size);%0A    %7D%0A  %7D%0A
 %7D%0A

Allow taking a limited snapshot of the full trace