import java.util.Vector;
import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
+import net.sourceforge.phpdt.internal.debug.core.PHPDebugCorePlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugEvent;
public void setFile(String file) {
this.file = file;
+
+ final String COMPILED_EVAL = "eval()'d code";
+ final String COMPILED_LAMBDA = "runtime-created function";
+
+ int i = 0;
+ if (file.endsWith(COMPILED_EVAL)) {
+ i = file.length() - COMPILED_EVAL.length();
+ } else if (file.endsWith(COMPILED_LAMBDA)) {
+ i = file.length() - COMPILED_LAMBDA.length();
+ }
+ if (i > 0) {
+ // assume COMPILED_STRING_DESCRIPTION_FORMAT
+ // "filename(linenumber) : string"
+ int j = i;
+ while (--i > 0) {
+ switch (file.charAt(i)) {
+ case ')':
+ j = i;
+ break;
+ case '(':
+ this.file = file.substring(0, i);
+ try {
+ lineNumber = Integer.parseInt(file.substring(i + 1, j));
+ } catch (NumberFormatException e) {
+ PHPDebugCorePlugin.log(e);
+ }
+ return;
+ }
+ }
+ }
}
public int getModNo() {
* @return
* <ul>
* <li> -1 if the index of this stackframe is less.
- * <li> 0 if the index of both stackfream is equal (should no happen).
- * <li> 1 if the index of this stackfram is greater.
+ * <li> 0 if the index of both stackframes are equal (should no happen).
+ * <li> 1 if the index of this stackframe is greater.
* </ul>
*/
public int compareTo(Object obj) {
- //if (index < ((PHPStackFrame) obj).getIndex()) {
- // return -1;
- //} else if (index > ((PHPStackFrame) obj).getIndex()) {
- // return 1;
- //}
-
- //return 0;
- return Integer.signum(index - ((PHPStackFrame) obj).getIndex());
+ if (!(obj instanceof PHPStackFrame)) {
+ throw new IllegalArgumentException("A PHPStackFrame can only be compared with another PHPStackFrame");
+ }
+ int frameIndex = ((PHPStackFrame) obj).getIndex();
+ if (index < frameIndex) {
+ return -1;
+ } else if (index > frameIndex) {
+ return 1;
+ }
+ return 0;
}
}