コード例 #1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.ui.texteditor.IMarkerUpdater#updateMarker(org.eclipse.core
  * .resources.IMarker, org.eclipse.jface.text.IDocument,
  * org.eclipse.jface.text.Position)
  */
 public boolean updateMarker(
     final IMarker marker, final IDocument document, final Position position) {
   if (position.isDeleted()) {
     return false;
   }
   try {
     final int line = MarkerUtilities.getLineNumber(marker);
     final int newLine = document.getLineOfOffset(position.getOffset()) + 1;
     if (line == newLine) {
       return true;
     }
     final IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
     final IBreakpoint breakpoint = manager.getBreakpoint(marker);
     if (breakpoint == null) {
       return false;
     }
     if (breakpoint instanceof ErlangLineBreakpoint) {
       final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) breakpoint;
       final ErlangDebugTarget target = erlangLineBreakpoint.getTarget();
       erlangLineBreakpoint.remove(target);
       MarkerUtilities.setLineNumber(marker, newLine);
       erlangLineBreakpoint.install(target);
       return true;
     }
     // if there exists a breakpoint on the line remove this one
     if (isLineBreakpointMarker(marker)) {
       ensureRanges(document, marker, line);
       return lineBreakpointExists(marker.getResource(), line, marker) == null;
     }
     // if the line info is a valid location with an invalid line
     // number,
     // a line breakpoint must be removed
     if (isLineBreakpointMarker(marker) && line == -1) {
       return false;
     }
     MarkerUtilities.setLineNumber(marker, line);
     if (isLineBreakpointMarker(marker)) {
       ensureRanges(document, marker, line);
     }
     return true;
   } catch (final BadLocationException e) {
     ErlLogger.error(e);
   } catch (final CoreException e) {
     ErlLogger.error(e);
   }
   return false;
 }
 /* (non-Javadoc)
  * @see org.eclipse.ui.texteditor.IMarkerUpdater#updateMarker(org.eclipse.core.resources.IMarker, org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position)
  */
 public boolean updateMarker(IMarker marker, IDocument document, Position position) {
   if (position.isDeleted()) {
     return false;
   }
   IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
   IBreakpoint breakpoint = manager.getBreakpoint(marker);
   if (breakpoint == null) {
     return false;
   }
   IFile file = (IFile) marker.getResource();
   if (JavaScriptCore.isJavaScriptLikeFileName(file.getName())) {
     IJavaScriptUnit unit = JavaScriptCore.createCompilationUnitFrom(file);
     if (unit == null) {
       return false;
     }
     JavaScriptUnit jsunit =
         JavaScriptPlugin.getDefault().getASTProvider().getAST(unit, ASTProvider.WAIT_YES, null);
     try {
       BreakpointLocationFinder finder =
           new BreakpointLocationFinder(
               jsunit, document.getLineOfOffset(position.getOffset()) + 1, true);
       jsunit.accept(finder);
       if (finder.getLocation() == BreakpointLocationFinder.UNKNOWN) {
         return false;
       }
       int line = finder.getLineNumber();
       if (MarkerUtilities.getLineNumber(marker) == line) {
         // if there exists a breakpoint on the line remove this one
         if (isLineBreakpoint(marker)) {
           ensureRanges(document, marker, line);
           return lineBreakpointExists(
                   marker.getResource(),
                   ((IJavaScriptLineBreakpoint) breakpoint).getScriptPath(),
                   line,
                   marker,
                   true)
               == null;
         }
         return true;
       }
       if (isLineBreakpoint(marker) & line == -1) {
         return false;
       }
       if (lineBreakpointExists(
               marker.getResource(),
               ((IJavaScriptLineBreakpoint) breakpoint).getScriptPath(),
               line,
               marker,
               false)
           != null) {
         return false;
       }
       MarkerUtilities.setLineNumber(marker, line);
       if (isLineBreakpoint(marker)) {
         ensureRanges(document, marker, line);
       }
       return true;
     } catch (BadLocationException ble) {
       JavaScriptDebugUIPlugin.log(ble);
     } catch (CoreException e) {
       JavaScriptDebugUIPlugin.log(e);
     }
   }
   return true;
 }