1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 Vicente Fernando - Initial implementation - www.alfersoft.com.ar
10 **********************************************************************/
11 package net.sourceforge.phpdt.internal.debug.core.breakpoints;
15 import org.eclipse.core.resources.IMarker;
16 import org.eclipse.core.resources.IResource;
17 import org.eclipse.core.resources.IWorkspaceRunnable;
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.debug.core.DebugException;
21 import org.eclipse.debug.core.model.IBreakpoint;
22 import org.eclipse.debug.core.model.ILineBreakpoint;
25 * A breakpoint that can be located at a specific line of source code.
27 public class PHPLineBreakpoint extends PHPBreakpoint implements IBreakpoint, ILineBreakpoint {
29 private static final String PHP_LINE_BREAKPOINT = "net.sourceforge.phpeclipse.debug.core.phpLineBreakpointMarker"; //$NON-NLS-1$
31 public PHPLineBreakpoint() {
34 public PHPLineBreakpoint(IResource resource, int lineNumber, int charStart, int charEnd, int hitCount, boolean add, Map attributes) throws DebugException {
35 this(resource, lineNumber, charStart, charEnd, hitCount, add, attributes, PHP_LINE_BREAKPOINT);
38 public PHPLineBreakpoint(IResource resource, int lineNumber, int hitCount, boolean add, Map attributes) throws DebugException {
39 this(resource, lineNumber, -1, -1, hitCount, add, attributes, PHP_LINE_BREAKPOINT);
43 protected PHPLineBreakpoint(final IResource resource, final int lineNumber, final int charStart, final int charEnd, final int hitCount, final boolean add, final Map attributes, final String markerType) throws DebugException {
44 IWorkspaceRunnable wr= new IWorkspaceRunnable() {
45 public void run(IProgressMonitor monitor) throws CoreException {
48 setMarker(resource.createMarker(markerType));
51 addLineBreakpointAttributes(attributes, getModelIdentifier(), true, lineNumber, charStart, charEnd);
54 ensureMarker().setAttributes(attributes);
56 // add to breakpoint manager if requested
64 public void addLineBreakpointAttributes(Map attributes, String modelIdentifier, boolean enabled, int lineNumber, int charStart, int charEnd) {
65 attributes.put(IBreakpoint.ID, modelIdentifier);
66 attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
67 attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
70 attributes.put(IMarker.CHAR_START, new Integer(charStart));
71 attributes.put(IMarker.CHAR_END, new Integer(charEnd));
73 attributes.put(TYPE_NAME, "typeName");
77 * @see ILineBreakpoint#getLineNumber()
79 public int getLineNumber() throws CoreException {
80 return ensureMarker().getAttribute(IMarker.LINE_NUMBER, -1);
84 * @see ILineBreakpoint#getCharStart()
86 public int getCharStart() throws CoreException {
87 return ensureMarker().getAttribute(IMarker.CHAR_START, -1);
91 * @see ILineBreakpoint#getCharEnd()
93 public int getCharEnd() throws CoreException {
94 return ensureMarker().getAttribute(IMarker.CHAR_END, -1);
98 * Returns the type of marker associated with Java line breakpoints
100 public static String getMarkerType() {
101 return PHP_LINE_BREAKPOINT;