protected String getSourceHandle(IDeclaration declaration) { ITranslationUnit tu = declaration.getTranslationUnit(); if (tu != null) { IPath location = tu.getLocation(); if (location != null) { return location.toOSString(); } } return ""; //$NON-NLS-1$ }
private void updateMethodBreakpoints( boolean toggle, boolean interactive, IWorkbenchPart part, IDeclaration declaration) throws CoreException { String sourceHandle = getSourceHandle(declaration); IResource resource = getElementResource(declaration); String functionName = (declaration instanceof IFunction) ? getFunctionName((IFunction) declaration) : getMethodName((IMethod) declaration); ICFunctionBreakpoint breakpoint = findFunctionBreakpoint(sourceHandle, resource, functionName); if (toggle && breakpoint != null) { if (interactive) { CDebugUIUtils.editBreakpointProperties(part, breakpoint); } else { DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(breakpoint, true); } } else { int lineNumber = -1; int charStart = -1; int charEnd = -1; try { ISourceRange sourceRange = declaration.getSourceRange(); if (sourceRange != null) { charStart = sourceRange.getStartPos(); charEnd = charStart + sourceRange.getLength(); if (charEnd <= 0) { charStart = -1; charEnd = -1; } lineNumber = sourceRange.getStartLine(); } } catch (CModelException e) { DebugPlugin.log(e); } createFunctionBreakpoint( interactive, part, sourceHandle, resource, functionName, charStart, charEnd, lineNumber); } }
protected IResource getElementResource(IDeclaration declaration) { return declaration.getUnderlyingResource(); }