01: package org.drools.eclipse.launching;
02:
03: import org.drools.eclipse.DRLInfo.FunctionInfo;
04: import org.drools.eclipse.DRLInfo.RuleInfo;
05: import org.drools.eclipse.debug.core.DroolsDebugTarget;
06: import org.drools.eclipse.debug.core.MVELStackFrame;
07: import org.eclipse.core.runtime.CoreException;
08: import org.eclipse.debug.core.model.IDebugTarget;
09: import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
10: import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
11:
12: class MVELSourceLookupParticipant extends JavaSourceLookupParticipant {
13: public void dispose() {
14: //do nothing
15: }
16:
17: public Object[] findSourceElements(Object object)
18: throws CoreException {
19: if (object instanceof MVELStackFrame) {
20: MVELStackFrame frame = (MVELStackFrame) object;
21:
22: int lineNumber = frame.getBreakpointLineNumber();
23: String mvelName = frame.getMVELName();
24:
25: IDebugTarget target = frame.getDebugTarget();
26: if (target instanceof DroolsDebugTarget) {
27: DroolsDebugTarget droolsTarget = (DroolsDebugTarget) target;
28: Object bpoint = droolsTarget.getDroolsBreakpoint(
29: mvelName, lineNumber);
30: return new Object[] { bpoint };
31: }
32: }
33: return null;
34: }
35:
36: public String getSourceName(Object object) throws CoreException {
37: if (object instanceof MVELStackFrame) {
38: MVELStackFrame frame = (MVELStackFrame) object;
39: RuleInfo ruleInfo = frame.getExecutingRuleInfo();
40: if (ruleInfo != null) {
41: String sourcePath = ruleInfo.getSourcePathName();
42: return sourcePath;
43: }
44: FunctionInfo functionInfo = frame
45: .getExecutingFunctionInfo();
46: if (functionInfo != null) {
47: return functionInfo.getSourcePathName();
48: }
49: }
50: return super .getSourceName(object);
51: }
52:
53: public void init(ISourceLookupDirector director) {
54: //do nothing
55: }
56:
57: public void sourceContainersChanged(ISourceLookupDirector director) {
58: //do nothing
59: }
60: }
|