/**
  * Looks up the {@link IJavaScriptLineBreakpoint} that is associated with the given marker.
  * Returns <code>null</code> if one does not exist
  *
  * @param resource
  * @param typeName
  * @param lineNumber
  * @param currentmarker
  * @param useid if the id of the markers should be compared
  * @return the {@link IJavaScriptLineBreakpoint} for the given marker or <code>null</code> if one
  *     does not exist
  * @throws CoreException
  */
 IJavaScriptLineBreakpoint lineBreakpointExists(
     IResource resource, String typeName, int lineNumber, IMarker currentmarker, boolean useid)
     throws CoreException {
   String modelId = JavaScriptDebugModel.MODEL_ID;
   IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
   IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
   for (int i = 0; i < breakpoints.length; i++) {
     if ((breakpoints[i] instanceof IJavaScriptLineBreakpoint)) {
       IJavaScriptLineBreakpoint breakpoint = (IJavaScriptLineBreakpoint) breakpoints[i];
       if (breakpoint.getLineNumber() == lineNumber) {
         IMarker marker = breakpoint.getMarker();
         if (marker != null
             && marker.exists()
             && marker.getType().equals(IJavaScriptLineBreakpoint.MARKER_ID)
             && pathsEqual(breakpoint.getScriptPath(), typeName)
             && resource.equals(marker.getResource())) {
           if (useid) {
             if (currentmarker.getId() != marker.getId()) {
               return breakpoint;
             }
             return null;
           }
           return breakpoint;
         }
       }
     }
   }
   return null;
 }
示例#2
0
 public void run(IMarker marker) {
   if (marker != this.marker || !marker.exists()) {
     return;
   }
   if (Display.getCurrent() != null) {
     IReplacementProposal proposal = this.problem.getProposals()[proposalIndex];
     try {
       proposal.apply(problem.getDocument());
     } catch (BadLocationException e) {
       ParsedWaypointPlugin.getDefault().log(e);
     }
   } else {
     Display.getDefault()
         .syncExec(
             new Runnable() {
               public void run() {
                 IReplacementProposal proposal = problem.getProposals()[proposalIndex];
                 try {
                   proposal.apply(problem.getDocument());
                 } catch (BadLocationException e) {
                   ParsedWaypointPlugin.getDefault().log(e);
                 }
               };
             });
   }
 }
 /**
  * Searches for an existing line breakpoint on the specified line in the current type that does
  * not match the id of the specified marker
  *
  * @param resource the resource to care about
  * @param typeName the name of the type the breakpoint is in
  * @param lineNumber the number of the line the breakpoint is on
  * @param currentmarker the current marker we are comparing to see if it will be moved onto an
  *     existing one
  * @return an existing line breakpoint on the current line of the given resource and type if there
  *     is one
  * @throws CoreException
  * @since 3.4
  */
 private IErlangBreakpoint lineBreakpointExists(
     final IResource resource, final int lineNumber, final IMarker currentmarker)
     throws CoreException {
   final IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
   final IBreakpoint[] breakpoints =
       manager.getBreakpoints(ErlDebugConstants.ID_ERLANG_DEBUG_MODEL);
   final String markerType = currentmarker.getType();
   for (int i = 0; i < breakpoints.length; i++) {
     if (!(breakpoints[i] instanceof IErlangBreakpoint)) {
       continue;
     }
     final IErlangBreakpoint breakpoint = (IErlangBreakpoint) breakpoints[i];
     final IMarker marker = breakpoint.getMarker();
     if (marker != null
         && marker.exists()
         && marker.getType().equals(markerType)
         && currentmarker.getId() != marker.getId()) {
       if (marker instanceof ErlangLineBreakpoint) {
         final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) marker;
         if (erlangLineBreakpoint.getLineNumber() == lineNumber) {
           return erlangLineBreakpoint;
         }
       }
     }
   }
   return null;
 }
  private static boolean hasCorrections(IMarker marker) {
    if (marker == null || !marker.exists()) {
      return false;
    }

    IMarkerHelpRegistry registry = IDE.getMarkerHelpRegistry();
    return registry != null && registry.hasResolutions(marker);
  }
 public boolean hasResolutions(IMarker marker) {
   if (marker.exists()) {
     try {
       return getMessageID(marker) >= 0;
     } catch (CoreException ex) {
       SeamGuiPlugin.getPluginLog().logError(ex);
     }
   }
   return false;
 }
  /**
   * Compares two breakpoints.
   *
   * @param b1
   * @param b2
   * @return
   */
  private int doCompare(IBreakpoint b1, IBreakpoint b2) {
    String text1 = IInternalDebugCoreConstants.EMPTY_STRING;
    String text2 = IInternalDebugCoreConstants.EMPTY_STRING;

    text1 += b1.getModelIdentifier();
    text2 += b2.getModelIdentifier();

    IMarker marker1 = b1.getMarker();
    IMarker marker2 = b2.getMarker();
    try {
      if (marker1.exists() && marker2.exists()) {
        text1 += SPACE + marker1.getType();
        text2 += SPACE + marker2.getType();
      }
    } catch (CoreException e) {
      DebugUIPlugin.log(e);
    }

    int result = text1.compareTo(text2);
    if (result != 0) {
      return result;
    }

    // model and type are the same
    if (fContext != null) {
      String name1 = fContext.getModelPresentation().getText(b1);
      String name2 = fContext.getModelPresentation().getText(b2);

      boolean lineBreakpoint = false;
      try {
        lineBreakpoint = marker1.isSubtypeOf(IBreakpoint.LINE_BREAKPOINT_MARKER);
      } catch (CoreException ce) {
      }
      if (lineBreakpoint) {
        return compareLineBreakpoints(b1, b2, name1, name2);
      }

      return name1.compareTo(name2);
    }

    return result;
  }
示例#7
0
 /*
  * (non-Javadoc)
  *
  * @see featureide.core.internal.IMarkerHandler#createModelMarker(java.lang.String,
  *      int)
  */
 public void createModelMarker(String message, int severity, int lineNumber) {
   try {
     IResource resource = modelFile.exists() ? modelFile : project;
     IMarker marker = resource.createMarker(MODEL_MARKER);
     if (marker.exists()) {
       marker.setAttribute(IMarker.MESSAGE, message);
       marker.setAttribute(IMarker.SEVERITY, severity);
       marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
     }
   } catch (CoreException e) {
     e.printStackTrace();
   }
 }
 private IMarker isAnnotationInRange(
     IAnnotationModel model, Annotation annot /*, ISourceReference sourceElement */)
     throws CoreException {
   if (annot instanceof MarkerAnnotation) {
     //          if (sourceElement == null || isInside(model.getPosition(annot), sourceElement)) {
     IMarker marker = ((MarkerAnnotation) annot).getMarker();
     if (marker.exists() && marker.isSubtypeOf(IMarker.PROBLEM)) {
       return marker;
     }
     //          }
   }
   return null;
 }
示例#9
0
 /**
  * Returns the marker associated with this breakpoint.
  *
  * @return breakpoint marker
  * @exception DebugException if no marker is associated with this breakpoint or the associated
  *     marker does not exist
  */
 @Override
 protected IMarker ensureMarker() throws DebugException {
   IMarker m = getMarker();
   if (m == null || !m.exists()) {
     throw new DebugException(
         new Status(
             IStatus.ERROR,
             DebugPlugin.getUniqueIdentifier(),
             DebugException.REQUEST_FAILED,
             "Breakpoint_no_associated_marker",
             null));
   }
   return m;
 }
示例#10
0
 private void markWelltyped(ITypingCheck check) {
   // remove marker in case one exists (can happen during reevaluation)
   assert check.getFile() != null;
   if (markerIds.containsKey(check)) {
     long markerId = markerIds.remove(check);
     IMarker marker = check.getFile().getResource().getMarker(markerId);
     if (marker.exists())
       try {
         marker.delete();
       } catch (CoreException e) {
         e.printStackTrace();
       }
   }
 }
示例#11
0
  private void markIlltyped(ITypingCheck check) {

    try {
      if (markerIds.containsKey(check)) {
        long markerId = markerIds.get(check);
        IMarker marker = check.getFile().getResource().getMarker(markerId);
        if (marker.exists()) {
          new TypingMarkerFactory().updateErrorMarker(marker, check);
          return;
        }
      }
      IMarker marker = new TypingMarkerFactory().createErrorMarker(check);
      markerIds.put(check, marker.getId());
    } catch (CoreException e) {
      e.printStackTrace();
    }
  }
示例#12
0
  /*
   * @see IJavaAnnotation#getId()
   */
  public int getId() {
    IMarker marker = getMarker();
    if (marker == null || !marker.exists()) return -1;

    if (isProblem()) return marker.getAttribute(IJavaModelMarker.ID, -1);

    //		if (TASK_ANNOTATION_TYPE.equals(getAnnotationType())) {
    //			try {
    //				if (marker.isSubtypeOf(IJavaModelMarker.TASK_MARKER)) {
    //					return IProblem.Task;
    //				}
    //			} catch (CoreException e) {
    //				JavaPlugin.log(e); // should no happen, we test for marker.exists
    //			}
    //		}

    return -1;
  }
 /**
  * Returns a Java line breakpoint that is already registered with the breakpoint manager for a
  * type with the given name at the given line number.
  *
  * @param typeName fully qualified type name
  * @param lineNumber line number
  * @return a Java line breakpoint that is already registered with the breakpoint manager for a
  *     type with the given name at the given line number or <code>null</code> if no such
  *     breakpoint is registered
  * @exception CoreException if unable to retrieve the associated marker attributes (line number).
  */
 public static IJavaLineBreakpoint findStratumBreakpoint(IResource resource, int lineNumber)
     throws CoreException {
   String modelId = JDT_DEBUG_PLUGIN_ID;
   String markerType = "org.eclipse.jdt.debug.javaStratumLineBreakpointMarker";
   IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
   IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
   for (int i = 0; i < breakpoints.length; i++) {
     if (!(breakpoints[i] instanceof IJavaLineBreakpoint)) {
       continue;
     }
     IJavaLineBreakpoint breakpoint = (IJavaLineBreakpoint) breakpoints[i];
     IMarker marker = breakpoint.getMarker();
     if (marker != null && marker.exists() && marker.getType().equals(markerType)) {
       if (breakpoint.getLineNumber() == lineNumber && resource.equals(marker.getResource())) {
         return breakpoint;
       }
     }
   }
   return null;
 }
示例#14
0
    @Override
    public Image getImage(Object element) {
      if (element instanceof IMarker) {
        IMarker marker = (IMarker) element;

        if (marker != null && marker.exists()) {
          Image image = AnnotationTypesExtManager.getModel().getImageForMarker(marker);

          if (image != null) {
            image = decorateImage(marker, image);
          } else {
            try {
              image = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider().getImage(marker);
            } catch (Throwable t) {

            }
          }

          return image;
        }
      }

      return null;
    }
 public boolean hasResolutions(IMarker marker) {
   return marker.exists() && isNeedToCreate(marker);
 }
示例#16
0
    private final int compareMarkers(IMarker marker1, IMarker marker2) {
      // sort by severity
      // then by resource name
      // then by line number
      // then by problem description

      if (marker1 == null || marker2 == null || !marker1.exists() || !marker2.exists()) {
        return 0;
      }

      int val = 0;

      if (sortColumn == 0) {
        val = compareSeverity(marker1, marker2);

        if (val != 0) {
          return val;
        }

        val = compareProblemDescription(marker1, marker2);

        if (val != 0) {
          return val;
        }

        val = compareResourceName(marker1, marker2);

        if (val != 0) {
          return val;
        }

        return compareLineNumber(marker1, marker2);
      } else if (sortColumn == 1) {
        val = compareSeverity(marker1, marker2);

        if (val != 0) {
          return val;
        }

        val = compareResourceName(marker1, marker2);

        if (val != 0) {
          return val;
        }

        val = compareLineNumber(marker1, marker2);

        if (val != 0) {
          return val;
        }

        return compareProblemDescription(marker1, marker2);
      } else {
        val = compareType(marker1, marker2);

        if (val != 0) {
          return val;
        }

        val = compareSeverity(marker1, marker2);

        if (val != 0) {
          return val;
        }

        val = compareResourceName(marker1, marker2);

        if (val != 0) {
          return val;
        }

        val = compareLineNumber(marker1, marker2);

        if (val != 0) {
          return val;
        }

        return compareProblemDescription(marker1, marker2);
      }
    }
示例#17
0
  /*
   * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#getMarkerType()
   */
  public String getMarkerType() {
    IMarker marker = getMarker();
    if (marker == null || !marker.exists()) return null;

    return MarkerUtilities.getMarkerType(getMarker());
  }
示例#18
0
 /*
  * @see IJavaAnnotation#getArguments()
  */
 public String[] getArguments() {
   IMarker marker = getMarker();
   if (marker != null && marker.exists() && isProblem())
     return CorrectionEngine.getProblemArguments(marker);
   return null;
 }
示例#19
0
  /**
   * Propagates all markers of the given file
   *
   * @param markers
   * @param file
   */
  private void propagateMarkers(AbstractCollection<IMarker> markers, IFile file) {
    if (!file.exists()) {
      return;
    }

    String content = getFileContent(file);
    LinkedList<FSTField> fields = new LinkedList<FSTField>();
    LinkedList<FSTMethod> methods = new LinkedList<FSTMethod>();
    IFeatureProject project = CorePlugin.getFeatureProject(file);
    if (project == null) {
      return;
    }
    FSTModel model = project.getFSTModel();
    if (model == null) {
      return;
    }
    for (FSTFeature f : model.getFeaturesMap().values()) {
      TreeMap<String, FSTClass> z = f.getClasses();
      String fileName = file.getName();
      if (z.containsKey(fileName)) {
        FSTClass c = z.get(fileName);
        for (FSTField field : c.getFields()) {
          fields.add(field);
        }
        for (FSTMethod method : c.getMethods()) {
          methods.add(method);
        }
      }
    }
    setElementLines(content, fields, methods);

    for (IMarker marker : markers) {
      if (!marker.exists()) {
        continue;
      }

      if (marker.getAttribute(IMarker.MESSAGE, "").startsWith("The import")) {
        propagateUnsupportedMarker(marker, file);
        continue;
      }
      int markerLine = marker.getAttribute(IMarker.LINE_NUMBER, -1);
      if (markerLine == -1) {
        continue;
      }

      boolean propagated = false;
      for (FSTField f : fields) {
        if (f.getEndLine() == -1) {
          continue;
        }
        int composedLine = f.getComposedLine();
        if (markerLine >= composedLine
            && markerLine <= composedLine + (f.getEndLine() - f.getBeginLine())) {
          propagateMarker(marker, f.getOwnFile(), f.getBeginLine() + markerLine - composedLine);
          propagated = true;
          break;
        }
      }

      if (propagated) {
        continue;
      }

      for (FSTMethod m : methods) {
        if (m.getEndLine() == -1) {
          continue;
        }
        int composedLine = m.getComposedLine();
        if (markerLine >= composedLine
            && markerLine <= composedLine + (m.getEndLine() - m.getBeginLine())) {
          propagateMarker(
              marker, m.getOwnFile(), m.getBeginLine() + markerLine - m.getComposedLine());
          propagated = true;
          break;
        }
      }

      if (propagated) {
        continue;
      }

      propagateUnsupportedMarker(marker, file);
    }
  }