/**
  * 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;
 }
 /**
  * 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;
 }
示例#3
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();
    }
  }
  @Override
  public void connectorXReferenceAdded(final Connector connector, final IXReference xref) {
    //    	Thread thread = new Thread(new Runnable() {
    //
    //			@Override
    //			public void run() {
    if (connector.isEnvisaged()
        || ignoreViolations()
        || !isAttachedToProject(xref.getSource().getResource().getProject())) return;

    IResource resource = xref.getSource().getResource();

    try {
      IMarker marker = resource.createMarker(defaults.MARKER_TYPE);
      marker.setAttribute(IMarker.SEVERITY, getViolationSeverity());
      marker.setAttribute(
          IMarker.MESSAGE,
          "Element "
              + xref.getTarget().getName()
              + " should not be accessed in this context "
              + "("
              + connector.getSource().getName()
              + "->"
              + connector.getTarget().getName()
              + ")");

      marker.setAttribute(IMarker.CHAR_START, xref.getOffset());
      marker.setAttribute(IMarker.CHAR_END, xref.getOffset() + xref.getLength());
      marker.setAttribute(IMarker.LINE_NUMBER, xref.getLine());
      marker.setAttribute(defaults.MODEL, model.getResource().getFullPath());
      marker.setAttribute(defaults.CONNECTOR_ID, connector.toString());
      violations.put(ArchitectureModel.xrefStringFactory.toString(xref), marker.getId());
    } catch (CoreException ex) {
      // TODO: Do something better here;
      ex.printStackTrace();
    }

    //			}
    //		});thread.start();

  }