1 11 package org.eclipse.ant.internal.ui.debug.model; 12 13 import org.eclipse.ant.internal.ui.AntUtil; 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.core.runtime.Path; 16 import org.eclipse.debug.core.DebugException; 17 import org.eclipse.debug.core.model.IRegisterGroup; 18 import org.eclipse.debug.core.model.IStackFrame; 19 import org.eclipse.debug.core.model.IThread; 20 import org.eclipse.debug.core.model.IVariable; 21 22 25 public class AntStackFrame extends AntDebugElement implements IStackFrame { 26 27 private AntThread fThread; 28 private String fName; 29 private int fLineNumber; 30 private String fFilePath; 31 private int fId; 32 private String fFullPath; 33 34 40 public AntStackFrame(AntThread thread, int id, String name, String fullPath, int lineNumber) { 41 super((AntDebugTarget) thread.getDebugTarget()); 42 fId = id; 43 fThread = thread; 44 fLineNumber= lineNumber; 45 fName= name; 46 setFilePath(fullPath); 47 } 48 49 protected void setId(int id) { 50 fId= id; 51 } 52 53 56 public IThread getThread() { 57 return fThread; 58 } 59 60 63 public IVariable[] getVariables() throws DebugException { 64 return fThread.getVariables(); 65 } 66 67 70 public boolean hasVariables() { 71 return isSuspended(); 72 } 73 74 77 public int getLineNumber() { 78 return fLineNumber; 79 } 80 81 protected void setLineNumber(int lineNumber) { 82 fLineNumber= lineNumber; 83 } 84 85 protected void setFilePath(String fullPath) { 86 fFullPath= fullPath; 87 IFile file= AntUtil.getFileForLocation(fullPath, null); 88 if (file != null) { 89 fFilePath= file.getProjectRelativePath().toString(); 90 } else { 91 fFilePath= new Path(fullPath).lastSegment(); 92 } 93 } 94 95 public String getFilePath() { 96 return fFullPath; 97 } 98 99 102 public int getCharStart() { 103 return -1; 104 } 105 106 109 public int getCharEnd() { 110 return -1; 111 } 112 113 116 public String getName() { 117 return fName; 118 } 119 120 protected void setName(String name) { 121 fName= name; 122 } 123 124 127 public IRegisterGroup[] getRegisterGroups() { 128 return null; 129 } 130 131 134 public boolean hasRegisterGroups() { 135 return false; 136 } 137 138 141 public boolean canStepInto() { 142 return getThread().canStepInto(); 143 } 144 145 148 public boolean canStepOver() { 149 return getThread().canStepOver(); 150 } 151 152 155 public boolean canStepReturn() { 156 return getThread().canStepReturn(); 157 } 158 159 162 public boolean isStepping() { 163 return getThread().isStepping(); 164 } 165 166 169 public void stepInto() throws DebugException { 170 getThread().stepInto(); 171 } 172 173 176 public void stepOver() throws DebugException { 177 getThread().stepOver(); 178 } 179 180 183 public void stepReturn() throws DebugException { 184 getThread().stepReturn(); 185 } 186 187 190 public boolean canResume() { 191 return getThread().canResume(); 192 } 193 194 197 public boolean canSuspend() { 198 return getThread().canSuspend(); 199 } 200 201 204 public boolean isSuspended() { 205 return getThread().isSuspended(); 206 } 207 208 211 public void resume() throws DebugException { 212 getThread().resume(); 213 } 214 215 218 public void suspend() throws DebugException { 219 getThread().suspend(); 220 } 221 222 225 public boolean canTerminate() { 226 return getThread().canTerminate(); 227 } 228 229 232 public boolean isTerminated() { 233 return getThread().isTerminated(); 234 } 235 236 239 public void terminate() throws DebugException { 240 getThread().terminate(); 241 } 242 243 250 public String getSourceName() { 251 return fFilePath; 252 } 253 254 257 public boolean equals(Object obj) { 258 if (obj instanceof AntStackFrame) { 259 AntStackFrame sf = (AntStackFrame)obj; 260 if (getSourceName() != null) { 261 return getSourceName().equals(sf.getSourceName()) && 262 sf.getLineNumber() == getLineNumber() && 263 sf.fId == fId; 264 } 265 return sf.fId == fId; 266 } 267 return false; 268 } 269 270 273 public int hashCode() { 274 if (getSourceName() == null) { 275 return fId; 276 } 277 return getSourceName().hashCode() + fId; 278 } 279 280 285 protected int getIdentifier() { 286 return fId; 287 } 288 289 296 public AntProperty findProperty(String propertyName) { 297 try { 298 IVariable[] groups= getVariables(); 299 for (int i = 0; i < groups.length; i++) { 300 AntProperties propertiesGrouping = (AntProperties) groups[i]; 301 AntPropertiesValue value= (AntPropertiesValue) propertiesGrouping.getValue(); 302 IVariable[] properties= value.getVariables(); 303 for (int j = 0; j < properties.length; j++) { 304 AntProperty property = (AntProperty) properties[j]; 305 if (property.getName().equals(propertyName)) { 306 return property; 307 } 308 } 309 } 310 } catch (DebugException e) { 311 } 312 return null; 313 } 314 } 315 | Popular Tags |