示例#1
0
 private static void deleteMarkersWithCompiledFile(final IProject project, final IFile file) {
   if (!project.isAccessible()) {
     return;
   }
   try {
     for (final IMarker m : project.findMarkers(PROBLEM_MARKER, true, IResource.DEPTH_INFINITE)) {
       final Object source_id = m.getAttribute(IMarker.SOURCE_ID);
       if (source_id != null
           && source_id instanceof String
           && source_id.equals(file.getFullPath().toString())) {
         try {
           m.delete();
         } catch (final CoreException e) {
           // not much to do
         }
       }
     }
     for (final IMarker m : project.findMarkers(TASK_MARKER, true, IResource.DEPTH_INFINITE)) {
       final Object source_id = m.getAttribute(IMarker.SOURCE_ID);
       if (source_id != null
           && source_id instanceof String
           && source_id.equals(file.getFullPath().toString())) {
         try {
           m.delete();
         } catch (final CoreException e) {
           // not much to do
         }
       }
     }
   } catch (final CoreException e) {
     // not much to do
   }
 }
 public void setMarker(IMarker marker) throws CoreException {
   super.setMarker(marker);
   fCondition = (String) marker.getAttribute(IPHPDebugConstants.Condition);
   Boolean enabled = (Boolean) marker.getAttribute(IPHPDebugConstants.ConditionEnabled);
   fConditionEnabled = enabled != null ? enabled.booleanValue() : false;
   addConditionToBP();
 }
 /** @since 2.3 */
 @Override
 public List<?> getTargetObjects(Object object, IMarker marker) {
   if (object instanceof AdapterFactoryEditingDomain) {
     ArrayList<Object> result = new ArrayList<Object>();
     AdapterFactoryEditingDomain editingDomain = (AdapterFactoryEditingDomain) object;
     String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
     if (uriAttribute != null) {
       URI uri = URI.createURI(uriAttribute);
       EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
       if (eObject != null) {
         result.add(editingDomain.getWrapper(eObject));
       }
     }
     String relatedURIsAttribute = marker.getAttribute(EValidator.RELATED_URIS_ATTRIBUTE, null);
     if (relatedURIsAttribute != null) {
       for (String relatedURI : relatedURIsAttribute.split(" ")) {
         URI uri = URI.createURI(URI.decode(relatedURI));
         EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
         if (eObject != null) {
           result.add(editingDomain.getWrapper(eObject));
         }
       }
     }
     return result;
   } else {
     return super.getTargetObjects(object, marker);
   }
 }
  /** This leaves a bit of a mess e.g. "import " or "from " for some later process to clean up. */
  private void deleteImport(PySelection ps, MarkerAnnotationAndPosition markerInfo)
      throws BadLocationException, CoreException {
    IMarker marker = markerInfo.markerAnnotation.getMarker();

    Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
    Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
    IDocument doc = ps.getDoc();
    while (start > 0) {
      char c;
      try {
        c = doc.getChar(start - 1);
      } catch (Exception e) {
        break;
      }
      if (c == '\r' || c == '\n') {
        break;
      }
      if (Character.isWhitespace(c) || c == ',') {
        start--;
        continue;
      }
      break;
    }
    ps.setSelection(start, end);
    ps.deleteSelection();
  }
  @Override
  public ICompletionProposal getCompletionProposal(final IMarker marker, final IDocument document) {
    String msg = marker.getAttribute(IMarker.MESSAGE, ""); // $NON-NLS-1$
    String toSearch = GhcMessages.WARNING_INFERREDTYPE_START;
    int ix = msg.toLowerCase().indexOf(toSearch);
    String type = msg.substring(ix + toSearch.length()).trim();

    int line = marker.getAttribute(IMarker.LINE_NUMBER, 0);
    try {

      int offset = document.getLineOffset(line - 1);
      String txt = type + PlatformUtil.NL;
      return new CompletionProposal(
          getLineStartAddition(txt, marker.getResource()),
          offset,
          0,
          offset + txt.length(),
          HaskellUIImages.getImage(IImageNames.TYPE_SIGNATURE),
          getLabel(),
          null,
          null);
      // doc.replace( offset, 0, type+NL );

    } catch (BadLocationException ex) {
      HaskellUIPlugin.log(ex);
    }
    return null;
  }
示例#6
0
  /**
   * Processes a new/old/updated marker.
   *
   * @param marker The marker being added/removed/changed
   * @param nodeList the list of activity/service/provider/receiver nodes.
   * @param kind the change kind. Can be {@link IResourceDelta#ADDED}, {@link
   *     IResourceDelta#REMOVED}, or {@link IResourceDelta#CHANGED}
   */
  private void processMarker(IMarker marker, List<UiElementNode> nodeList, int kind) {
    // get the data from the marker
    String nodeType = marker.getAttribute(AdtConstants.MARKER_ATTR_TYPE, EMPTY);
    if (nodeType == EMPTY) {
      return;
    }

    String className = marker.getAttribute(AdtConstants.MARKER_ATTR_CLASS, EMPTY);
    if (className == EMPTY) {
      return;
    }

    for (UiElementNode ui_node : nodeList) {
      if (ui_node.getDescriptor().getXmlName().equals(nodeType)) {
        for (UiAttributeNode attr : ui_node.getAllUiAttributes()) {
          if (attr.getDescriptor()
              .getXmlLocalName()
              .equals(AndroidManifestDescriptors.ANDROID_NAME_ATTR)) {
            if (attr.getCurrentValue().equals(className)) {
              if (kind == IResourceDelta.REMOVED) {
                attr.setHasError(false);
              } else {
                attr.setHasError(true);
              }
              return;
            }
          }
        }
      }
    }
  }
示例#7
0
 /**
  * Propagates the given marker to the given source line
  *
  * @param marker The marker to propagate
  * @param file The features file
  * @param line The marker line at the features file
  */
 protected void propagateMarker(IMarker marker, IFile file, int line) {
   if (file != null && file.exists()) {
     Object severity = null;
     String message = marker.getAttribute(IMarker.MESSAGE, NO_ATTRIBUTE);
     if (NO_ATTRIBUTE.equals(message)) {
       return;
     }
     try {
       severity = marker.getAttribute(IMarker.SEVERITY);
     } catch (CoreException e) {
       severity = IMarker.SEVERITY_ERROR;
     }
     if (!hasSameMarker(message, line, file)) {
       IMarker newMarker = null;
       try {
         newMarker = file.createMarker(FeatureHouseCorePlugin.BUILDER_PROBLEM_MARKER);
         newMarker.setAttribute(IMarker.LINE_NUMBER, line);
         newMarker.setAttribute(IMarker.MESSAGE, message);
         newMarker.setAttribute(IMarker.SEVERITY, severity);
       } catch (CoreException e) {
         FeatureHouseCorePlugin.getDefault().logError(e);
       }
     }
   }
 }
示例#8
0
 static void applyCatchByReferenceQuickFix(IMarker marker, IDocument document, boolean addConst) {
   try {
     int left = marker.getAttribute(IMarker.CHAR_START, -1);
     int right = marker.getAttribute(IMarker.CHAR_END, -1);
     String inStr = document.get(left, right - left);
     document.replace(left, right - left, getCatchByReferenceString(inStr, addConst));
   } catch (BadLocationException e) {
     CheckersUiActivator.log(e);
   }
 }
 private boolean isNeedToCreate(IMarker marker) {
   String message = marker.getAttribute(IMarker.MESSAGE, "");
   String attribute = marker.getAttribute(ATTRIBUTE_NAME, "");
   if (attribute.equals(VALIDATOR_ID)
       && marker.getResource() instanceof IFile
       && message.endsWith(MESSAGE)) {
     return true;
   }
   return false;
 }
示例#10
0
 @Override
 public void setMarker(IMarker marker) throws CoreException {
   super.setMarker(marker);
   m_methodName = marker.getAttribute(METHOD_NAME, null);
   m_methodSignature = marker.getAttribute(METHOD_SIGNATURE, null);
   String typePattern = marker.getAttribute(TYPE_NAME, ""); // $NON-NLS-1$
   if (typePattern != null) {
     fPattern = Pattern.compile(convertToRegularExpression(typePattern));
   }
 }
  public static boolean canHandle(final IMarker marker) {
    final int code = marker.getAttribute(IMarker.PROBLEM, 0);
    final String sourceId = marker.getAttribute(IMarker.SOURCE_ID, "");

    if (marker.getResource().getName().endsWith(SpdPackage.FILE_EXTENSION)
        && code == EventPortConstraint.STATUS_CODE
        && sourceId.equals(EventPortConstraint.SOURCE_ID)) {
      return true;
    }
    return false;
  }
    @Override
    public int compare(IMarker marker1, IMarker marker2) {
      int line1 = marker1.getAttribute(IMarker.LINE_NUMBER, -1);
      int line2 = marker2.getAttribute(IMarker.LINE_NUMBER, -1);

      if (line1 > line2) {
        return 1;
      } else if (line2 > line1) {
        return -1;
      }
      return 0;
    }
示例#13
0
  /**
   * Make sure the images in the drawers are up to date. Recalculate them and inform the border of
   * any changes.
   */
  @Override
  protected void refreshDrawerImages() {
    ScopeBorder border = getScopeBorder();

    if (topImage != null) {
      topImage.dispose();
      topImage = null;
    }
    if (bottomImage != null) {
      bottomImage.dispose();
      bottomImage = null;
    }
    IMarkerHolder holder = BPELUtil.adapt(getActivity(), IMarkerHolder.class);
    IMarker[] markers = holder.getMarkers(getActivity());
    int topMarkerPriority = Integer.MIN_VALUE;
    int bottomMarkerPriority = Integer.MIN_VALUE;
    IMarker topMarker = null;
    IMarker bottomMarker = null;
    for (int i = 0; i < markers.length; i++) {
      IMarker marker = markers[i];
      String value =
          marker.getAttribute(
              IModelMarkerConstants.DECORATION_GRAPHICAL_MARKER_ANCHOR_POINT_ATTR,
              ""); //$NON-NLS-1$
      if (value.equals(IBPELUIConstants.MARKER_ANCHORPOINT_DRAWER_TOP)) {
        if (marker.getAttribute(IModelMarkerConstants.DECORATION_MARKER_VISIBLE_ATTR, true)) {
          int priority =
              marker.getAttribute(
                  IModelMarkerConstants.DECORATION_MARKER_PRIORITY_ATTR, Integer.MIN_VALUE);
          if (priority > topMarkerPriority) {
            topMarkerPriority = priority;
            topImage = BPELUtil.getImage(marker);
            topMarker = marker;
          }
        }
      } else if (value.equals(IBPELUIConstants.MARKER_ANCHORPOINT_DRAWER_BOTTOM)) {
        if (marker.getAttribute(IModelMarkerConstants.DECORATION_MARKER_VISIBLE_ATTR, true)) {
          int priority =
              marker.getAttribute(
                  IModelMarkerConstants.DECORATION_MARKER_PRIORITY_ATTR, Integer.MIN_VALUE);
          if (priority > bottomMarkerPriority) {
            bottomMarkerPriority = priority;
            bottomImage = BPELUtil.getImage(marker);
            bottomMarker = marker;
          }
        }
      }
    }
    border.setTopImage(topImage);
    border.setBottomImage(bottomImage);
    border.setTopMarker(topMarker);
    border.setBottomMarker(bottomMarker);
  }
示例#14
0
 private static boolean isMarkerInRange(final IMarker marker, final ISourceReference sourceElement)
     throws CoreException {
   final int pos = marker.getAttribute(IMarker.CHAR_START, -1);
   if (pos != -1) {
     return isInside(pos, sourceElement);
   }
   final int line = marker.getAttribute(IMarker.LINE_NUMBER, -1);
   if (line != -1) {
     return isInsideLines(line - 1, sourceElement);
   }
   return false;
 }
 /* (non-Javadoc)
  * @see org.eclipse.debug.core.model.Breakpoint#setMarker(org.eclipse.core.resources.IMarker)
  */
 @Override
 public void setMarker(IMarker marker) throws CoreException {
   super.setMarker(marker);
   this.projectName =
       marker.getAttribute(ICamelDebugConstants.MARKER_ATTRIBUTE_PROJECTNAME, this.projectName);
   this.endpointNodeId =
       marker.getAttribute(ICamelDebugConstants.MARKER_ATTRIBUTE_ENDPOINTID, this.endpointNodeId);
   this.fileName =
       marker.getAttribute(ICamelDebugConstants.MARKER_ATTRIBUTE_FILENAME, this.fileName);
   this.contextId =
       marker.getAttribute(ICamelDebugConstants.MARKER_ATTRIBUTE_CONTEXTID, this.contextId);
   this.resource = marker.getResource();
 }
  /**
   * Adds a new quickmark in the active editor. If the same quickmark number already exists (in the
   * workspace), the existing quickmark is replaced with the new (i.e. the quickmark is moved). If
   * the same quickmark already exists in the same location, the quickmark is removed.
   *
   * @param quickmarkNumber
   */
  private void addBookmark(int quickmarkNumber) {
    ITextEditor editor = getActiveEditor();
    if (editor != null) {
      Integer key = new Integer(quickmarkNumber);

      Map attributes = new HashMap();
      ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();

      int charStart = selection.getOffset();
      int charEnd = charStart;
      MarkerUtilities.setCharStart(attributes, charStart);
      MarkerUtilities.setCharEnd(attributes, charEnd);

      IFile file = getActiveFile();

      String message =
          MessageFormat.format(
              Messages.getString("SetQuickmarkAction.quickmarkMessage"),
              new Object[] {key}); // $NON-NLS-1$
      MarkerUtilities.setMessage(attributes, message);
      attributes.put(QuickmarksPlugin.NUMBER, key);
      attributes.put(QuickmarksPlugin.FILE, file);

      boolean OK = true;
      Map markers = getMarkers();
      if (markers.containsKey(key)) {
        IMarker marker = (IMarker) markers.get(key);
        try {
          Integer markerCharStart = (Integer) marker.getAttribute(IMarker.CHAR_START);
          Integer markerCharEnd = (Integer) marker.getAttribute(IMarker.CHAR_END);
          if (markerCharStart != null
              && markerCharStart.intValue() == charStart
              && markerCharEnd != null
              && markerCharEnd.intValue() == charEnd) {
            OK = false;
          }
          marker.delete();
        } catch (CoreException e) {
          QuickmarksPlugin.debug(e);
        }
      }

      if (OK) {
        try {
          MarkerUtilities.createMarker(file, attributes, getMarkerType());
        } catch (Exception e) {
          QuickmarksPlugin.log(e);
        }
      }
    }
  }
 /**
  * Compares two AadlMarkers based on the <code>ReporterSettings</code> that an object of this
  * class is constructed with.
  *
  * @param marker1 The first AadlMarker to be compared.
  * @param marker2 The second AadlMarker to be compared.
  * @return a negative integer, zero, or a positive integer as the first marker is less than, equal
  *     to, or greater than the second.
  * @throws CoreException If this method fails. Reasons include:
  *     <ul>
  *       <li>This marker does not exist.
  *     </ul>
  */
 public int compare(IMarker marker1, IMarker marker2) {
   try {
     int compareResult = 0;
     if (settings.getGroupByAndSortBy(ReporterSettings.GROUP_BY_FIELD)
         == ReporterSettings.GROUP_BY_FILE) {
       if (settings.getGroupByAndSortBy(ReporterSettings.SORT_GROUPS_BY_FIELD)
           == ReporterSettings.SORT_BY_FILE_TYPE) {
         boolean marker1IsAadl = marker1.getResource().getName().endsWith(".aadl");
         boolean marker2IsAadl = marker2.getResource().getName().endsWith(".aadl");
         if (marker1IsAadl != marker2IsAadl) compareResult = (marker1IsAadl) ? -1 : 1;
       }
       if (compareResult == 0)
         compareResult =
             marker1.getResource().getName().compareTo(marker2.getResource().getName());
     }
     // group by type
     else compareResult = marker1.getType().compareTo(marker2.getType());
     for (int i = ReporterSettings.SORT_MARKERS_BY_FIRST;
         (i <= ReporterSettings.SORT_MARKERS_BY_FOURTH) && (compareResult == 0);
         i++)
       switch (settings.getGroupByAndSortBy(i)) {
         case ReporterSettings.SORT_BY_SEVERITY:
           int marker1Severity = ((Integer) marker1.getAttribute(IMarker.SEVERITY)).intValue();
           int marker2Severity = ((Integer) marker2.getAttribute(IMarker.SEVERITY)).intValue();
           if (marker1Severity != marker2Severity)
             compareResult = (marker1Severity > marker2Severity) ? -1 : 1;
           break;
         case ReporterSettings.SORT_BY_MESSAGE:
           compareResult =
               marker1
                   .getAttribute(IMarker.MESSAGE)
                   .toString()
                   .compareTo(marker2.getAttribute(IMarker.MESSAGE).toString());
           break;
         case ReporterSettings.SORT_BY_LOCATION:
           String marker1Location =
               (marker1.getType().endsWith("AadlTextMarker"))
                   ? marker1.getAttribute(IMarker.LINE_NUMBER).toString()
                   : marker1.getAttribute(AadlConstants.AADLURI).toString();
           String marker2Location =
               (marker2.getType().endsWith("AadlTextMarker"))
                   ? marker2.getAttribute(IMarker.LINE_NUMBER).toString()
                   : marker2.getAttribute(AadlConstants.AADLURI).toString();
           compareResult = marker1Location.compareTo(marker2Location);
           break;
         case ReporterSettings.SORT_BY_FILE_NAME:
           compareResult =
               marker1.getResource().getName().compareTo(marker2.getResource().getName());
           break;
         case ReporterSettings.SORT_BY_MARKER_TYPE:
           compareResult = marker1.getType().compareTo(marker2.getType());
           break;
       }
     return compareResult;
   } catch (CoreException e) {
     OsateUiPlugin.log(e);
     return 0;
   }
 }
示例#18
0
  private static IMarker[] getValidationTasks(IResource resource, int severity, int depth) {
    IMarker[] tempMarkers = null;
    int validCount = 0;
    IMarker[] allMarkers = null;
    try {
      allMarkers = resource.findMarkers(VALIDATION_MARKER, true, depth);
    } catch (CoreException e) {
      if (Tracing.isLogging()) ValidationPlugin.getPlugin().handleException(e);
      return NO_MARKERS;
    }

    // Now filter in the markers, based on severity type.
    if (allMarkers.length != 0) {
      tempMarkers = new IMarker[allMarkers.length];
      for (IMarker marker : allMarkers) {
        Integer filterSeverity = null;
        try {
          filterSeverity = (Integer) marker.getAttribute(VALIDATION_MARKER_SEVERITY);
        } catch (CoreException e) {
          // Someone may have deleted the marker on us. All we can do is skip it.
          continue;
        }
        if (filterSeverity == null) {
          // odd...marker wasn't created correctly. How could this happen?
          // Default to the current severity and add it to the list.
          try {
            // 226541 - I was seeing markers with valid severities being reset, so I added this
            // additional test.
            if (marker.getAttribute(IMarker.SEVERITY, -1) == -1)
              marker.setAttribute(IMarker.SEVERITY, getSeverity(severity));
          } catch (Exception e) {
            ValidationPlugin.getPlugin().handleException(e);
            continue;
          }
        } else if ((severity & filterSeverity.intValue()) == 0) {
          continue;
        }
        tempMarkers[validCount++] = marker;
      }
    }

    if (validCount == 0) {
      return NO_MARKERS;
    }

    IMarker[] validMarkers = new IMarker[validCount];
    System.arraycopy(tempMarkers, 0, validMarkers, 0, validCount);
    return validMarkers;
  }
示例#19
0
  /**
   * Checks if the file already the given marker.
   *
   * @param message
   * @param line
   * @param file
   * @return
   */
  private boolean hasSameMarker(String message, int line, IFile file) {
    try {
      IMarker[] markers = file.findMarkers(null, true, IResource.DEPTH_INFINITE);
      for (IMarker m : markers) {
        if (m.getAttribute(IMarker.LINE_NUMBER, -1) == line) {
          if (m.getAttribute(IMarker.MESSAGE, "xxx").equals(message)) {
            return true;
          }
        }
      }
    } catch (CoreException e) {

    }
    return false;
  }
示例#20
0
  /**
   * This method retrieves all validation tasks from the resource. If depth is INFINITE, child tasks
   * are returned as well. Only the tasks which are owned by the specified messageOwner, and apply
   * to the named IMessage's target object (objectName) will be returned.
   */
  private static IMarker[] getValidationTasks(
      IResource resource, String[] messageOwner, String objectName, String groupName, int depth)
      throws CoreException {
    if ((messageOwner == null) || (resource == null)) {
      return NO_MARKERS;
    }

    int validCount = 0;
    IMarker[] validList = null;
    IMarker[] markers = getValidationTasks(resource, messageOwner, depth);
    if (markers != null) {
      validList = new IMarker[markers.length];
      for (int i = 0; i < markers.length; i++) {
        IMarker marker = markers[i];

        // If more than one target object resolves to the same resource, removing one
        // target's
        // messages should not remove the other target object's messages.
        if (objectName != null) {
          Object targetObject = marker.getAttribute(VALIDATION_MARKER_TARGETOBJECT);
          if ((targetObject == null)
              || !(targetObject instanceof String)
              || !(((String) targetObject).equals(objectName))) {
            continue;
          }
        }

        if (groupName != null) {
          Object group = marker.getAttribute(VALIDATION_MARKER_GROUP);
          if ((group == null)
              || !(group instanceof String)
              || !(((String) group).equals(groupName))) {
            continue;
          }
        }

        validList[validCount++] = marker;
      }
    }

    if (validCount == 0) {
      return NO_MARKERS;
    }

    IMarker[] result = new IMarker[validCount];
    System.arraycopy(validList, 0, result, 0, validCount);
    return result;
  }
 /** {@inheritDoc} */
 @Override
 public void run(final IMarker marker) {
   final String uri = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
   if (uri != null) {
     final ResourceSet set = ScaResourceFactoryUtil.createResourceSet();
     final EObject obj = set.getEObject(URI.createURI(uri), true);
     if (obj instanceof SoftPkg) {
       final SoftPkg spd = (SoftPkg) obj;
       final List<Resource> editedResources = Collections.emptyList();
       try {
         addEventPort(spd);
       } catch (final CoreException e) {
         StatusManager.getManager()
             .handle(
                 new Status(
                     e.getStatus().getSeverity(),
                     ComponentUiPlugin.PLUGIN_ID,
                     e.getLocalizedMessage(),
                     e),
                 StatusManager.SHOW | StatusManager.LOG);
         return;
       }
       save(editedResources, null);
     }
   }
 }
  /**
   * Returns the maximum problem marker severity for the given resource, and, if depth is
   * IResource.DEPTH_INFINITE, its children. The return value will be one of IMarker.SEVERITY_ERROR,
   * IMarker.SEVERITY_WARNING, IMarker.SEVERITY_INFO or 0, indicating that no problem markers exist
   * on the given resource.
   *
   * @param depth TODO
   */
  public static int getMaxProblemMarkerSeverity(IResource res, int depth) {
    if (res == null || !res.isAccessible()) return 0;

    boolean hasWarnings = false; // if resource has errors, will return error image immediately
    IMarker[] markers = null;

    try {
      markers = res.findMarkers(IMarker.PROBLEM, true, depth);
    } catch (CoreException e) {
      e.printStackTrace();
    }
    if (markers == null) return 0; // don't know - say no errors/warnings/infos

    for (int i = 0; i < markers.length; i++) {
      IMarker m = markers[i];
      int priority = m.getAttribute(IMarker.SEVERITY, -1);

      if (priority == IMarker.SEVERITY_WARNING) {
        hasWarnings = true;
      } else if (priority == IMarker.SEVERITY_ERROR) {
        return IMarker.SEVERITY_ERROR;
      }
    }
    return hasWarnings ? IMarker.SEVERITY_WARNING : 0;
  }
示例#23
0
  private void updateStatusLine(IStructuredSelection selection) {
    String message;

    if (selection == null || selection.size() == 0) {
      message = "";
    } else if (selection.size() == 1) {
      Object sel = selection.getFirstElement();

      if (sel instanceof IMarker) {
        IMarker marker = (IMarker) sel;

        message = marker.getAttribute(IMarker.MESSAGE, "");
      } else {
        message = "";
      }
    } else {
      List<IMarker> selMarkers = new ArrayList<IMarker>();

      for (Object obj : selection.toList()) {
        if (obj instanceof IMarker) {
          selMarkers.add((IMarker) obj);
        }
      }

      message = getStatusSummary(selMarkers.toArray(new IMarker[selMarkers.size()]));
    }

    getViewSite().getActionBars().getStatusLineManager().setMessage(message);
  }
 /** @was-generated */
 @Override
 public void handleMarkerAdded(IMarker marker) {
   if (marker.getAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, null)
       != null) {
     handleMarkerChanged(marker);
   }
 }
  /**
   * return message id or -1 if impossible to find
   *
   * @param marker
   * @return
   */
  private int getMessageID(IMarker marker) throws CoreException {
    Integer attribute =
        ((Integer) marker.getAttribute(SeamCoreValidator.MESSAGE_ID_ATTRIBUTE_NAME));
    if (attribute != null) return attribute.intValue();

    return -1;
  }
示例#26
0
  private static IMarker[] getValidationTasks(
      IResource resource, String[] messageOwners, int depth) {
    IMarker[] markers = getValidationTasks(resource, IMessage.ALL_MESSAGES, depth);
    if (markers.length == 0) return NO_MARKERS;

    IMarker[] temp = new IMarker[markers.length];
    int validCount = 0;
    for (IMarker marker : markers) {
      Object owner = null;
      try {
        owner = marker.getAttribute(VALIDATION_MARKER_OWNER);
      } catch (CoreException e) {
        // eat it -- if it no longer exists there is nothing we can do about it
      }

      if ((owner == null) || !(owner instanceof String)) {
        // The ValidationMigrator will remove any "unowned" validation markers.
        continue;
      }

      for (String messageOwner : messageOwners) {
        if (((String) owner).equals(messageOwner)) {
          temp[validCount++] = marker;
          break;
        }
      }
    }

    if (validCount == 0) return NO_MARKERS;

    IMarker[] result = new IMarker[validCount];
    System.arraycopy(temp, 0, result, 0, validCount);
    return result;
  }
 public void setConditionWithEnable(boolean enabled, String condition) throws CoreException {
   fCondition = condition;
   IMarker marker = getMarker();
   marker.setAttribute(IPHPDebugConstants.Condition, condition);
   fConditionEnabled = enabled;
   marker.setAttribute(IPHPDebugConstants.ConditionEnabled, new Boolean(enabled));
   int lineNumber = ((Integer) marker.getAttribute(IMarker.LINE_NUMBER)).intValue();
   if (enabled) {
     String message =
         MessageFormat.format(
             PHPDebugCoreMessages.ConditionalBreakPointMessage_1,
             new String[] {marker.getResource().getName(), Integer.toString(lineNumber)});
     message +=
         MessageFormat.format(
             PHPDebugCoreMessages.ConditionalBreakPointMessage_2, new String[] {condition});
     marker.setAttribute(IMarker.MESSAGE, message);
   } else {
     marker.setAttribute(
         IMarker.MESSAGE,
         MessageFormat.format(
             PHPDebugCoreMessages.LineBreakPointMessage_1,
             new String[] {marker.getResource().getName(), Integer.toString(lineNumber)}));
   }
   addConditionToBP();
   setConditionChanged(true);
 }
示例#28
0
 public static int getErrorTicksFromMarkers(
     final IResource res, final int depth, final ISourceReference sourceElement)
     throws CoreException {
   if (res == null || !res.isAccessible()) {
     return 0;
   }
   int severity = 0;
   if (sourceElement == null) {
     severity = res.findMaxProblemSeverity(IMarker.PROBLEM, true, depth);
   } else {
     final IMarker[] markers = res.findMarkers(IMarker.PROBLEM, true, depth);
     if (markers != null && markers.length > 0) {
       for (int i = 0; i < markers.length && severity != IMarker.SEVERITY_ERROR; i++) {
         final IMarker curr = markers[i];
         if (isMarkerInRange(curr, sourceElement)) {
           final int val = curr.getAttribute(IMarker.SEVERITY, -1);
           if (val == IMarker.SEVERITY_WARNING || val == IMarker.SEVERITY_ERROR) {
             severity = val;
           }
         }
       }
     }
   }
   if (severity == IMarker.SEVERITY_ERROR) {
     return ERRORTICK_ERROR;
   } else if (severity == IMarker.SEVERITY_WARNING) {
     return ERRORTICK_WARNING;
   }
   return 0;
 }
  private static String insertTagsForErrors(String fileText, IMarker[] markers)
      throws CoreException {
    StringBuilder result = new StringBuilder(fileText);

    Integer offset = 0;
    for (IMarker marker : markers) {
      int openTagStartOffset = getOpenTagStartOffset(marker);
      int closeTagStartOffset = getCloseTagStartOffset(marker);

      switch (marker.getAttribute(IMarker.SEVERITY, 0)) {
        case IMarker.SEVERITY_ERROR:
          offset += insertTagByOffset(result, ERROR_TAG_OPEN, openTagStartOffset, offset);
          offset += insertTagByOffset(result, ERROR_TAG_CLOSE, closeTagStartOffset, offset);
          break;
        case IMarker.SEVERITY_WARNING:
          offset += insertTagByOffset(result, WARNING_TAG_OPEN, openTagStartOffset, offset);
          offset += insertTagByOffset(result, WARNING_TAG_CLOSE, closeTagStartOffset, offset);
          break;
        default:
          break;
      }
    }

    return result.toString();
  }
 private static int hasSpawnpointChanges(IMarkerDelta delta, IScriptBreakpoint breakpoint) {
   final String[] attrs = breakpoint.getUpdatableAttributes();
   try {
     final IMarker marker = delta.getMarker();
     for (int i = 0; i < attrs.length; ++i) {
       final String attr = attrs[i];
       if (IBreakpoint.ENABLED.equals(attr) || IMarker.LINE_NUMBER.equals(attr)) {
         final Object oldValue = delta.getAttribute(attr);
         final Object newValue = marker.getAttribute(attr);
         if (oldValue == null) {
           if (newValue != null) {
             return IMarker.LINE_NUMBER.equals(attr) ? MAJOR_CHANGE : MINOR_CHANGE;
           }
           continue;
         }
         if (newValue == null) {
           return IMarker.LINE_NUMBER.equals(attr) ? MAJOR_CHANGE : MINOR_CHANGE;
         }
         if (!oldValue.equals(newValue)) {
           return IMarker.LINE_NUMBER.equals(attr) ? MAJOR_CHANGE : MINOR_CHANGE;
         }
       }
     }
   } catch (CoreException e) {
     DLTKDebugPlugin.log(e);
   }
   return NO_CHANGES;
 }