コード例 #1
0
  private List<IMarkerResolution> collectResolutions(IMarker[] markers) {
    List<IMarkerResolution> resolutions = new ArrayList<>();
    for (IMarker marker : markers) {
      if (IDE.getMarkerHelpRegistry().hasResolutions(marker)) {
        IMarkerResolution[] markerResolutions = IDE.getMarkerHelpRegistry().getResolutions(marker);
        if (markerResolutions.length > 0) {
          resolutions.add(markerResolutions[0]);
        }
      }
    }

    return resolutions;
  }
コード例 #2
0
  private void addActionsForSelection(IMenuManager menuManager) {
    IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();

    if (selection.size() == 1) {
      Object element = selection.getFirstElement();

      if (!(element instanceof IMarker)) {
        return;
      }

      final IMarker marker = (IMarker) element;

      IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(marker);

      for (final IMarkerResolution resolution : resolutions) {
        Action action =
            new Action(escapeSpecialChars(resolution.getLabel())) {
              @Override
              public void run() {
                resolution.run(marker);
              }
            };

        if (resolution instanceof IMarkerResolution2) {
          IMarkerResolution2 resolution2 = (IMarkerResolution2) resolution;
          Image image = resolution2.getImage();
          if (image != null) {
            action.setImageDescriptor(ImageDescriptor.createFromImage(image));
          }
        }

        menuManager.add(action);
      }
    }
  }
コード例 #3
0
  private static boolean hasCorrections(IMarker marker) {
    if (marker == null || !marker.exists()) {
      return false;
    }

    IMarkerHelpRegistry registry = IDE.getMarkerHelpRegistry();
    return registry != null && registry.hasResolutions(marker);
  }
コード例 #4
0
 private static void collectMarkerProposals(
     SimpleMarkerAnnotation annotation, Collection<IDartCompletionProposal> proposals) {
   IMarker marker = annotation.getMarker();
   IMarkerResolution[] res = IDE.getMarkerHelpRegistry().getResolutions(marker);
   if (res.length > 0) {
     for (int i = 0; i < res.length; i++) {
       proposals.add(new MarkerResolutionProposal(res[i], marker));
     }
   }
 }
コード例 #5
0
    private Image decorateImage(IMarker marker, Image image) {
      if (image == null) {
        return null;
      }

      if (IDE.getMarkerHelpRegistry().hasResolutions(marker)) {
        ImageDescriptor[] descriptors = new ImageDescriptor[5];

        descriptors[IDecoration.BOTTOM_RIGHT] =
            DartToolsPlugin.getBundledImageDescriptor("icons/full/ovr16/contassist_ovr.gif");

        image = getImageManager().createImage(new DecorationOverlayIcon(image, descriptors));
      }

      return image;
    }
コード例 #6
0
 @Override
 public boolean canFix(Annotation annotation) {
   boolean bRetVal = false;
   if (annotation instanceof SimpleMarkerAnnotation) {
     // check local resolutions first
     IMarker marker = ((SimpleMarkerAnnotation) annotation).getMarker();
     IMarkerResolution[] localResolutions = fGenerator.getResolutions(marker);
     if (localResolutions.length > 0) {
       bRetVal = true;
     }
     // check the contributed resolutions if needed
     if (!bRetVal) {
       IMarkerResolution[] contributedResolutions =
           IDE.getMarkerHelpRegistry().getResolutions(marker);
       if (contributedResolutions.length > 0) {
         bRetVal = true;
       }
     }
   }
   return bRetVal;
 }
コード例 #7
0
    private void populateDataModelForAnnotation(SimpleMarkerAnnotation annotation) {
      // grab the local resolutions first
      IMarker marker = annotation.getMarker();
      if (!fResMap.containsKey(marker)) {
        ArrayList<IMarkerResolution> resolutions = new ArrayList<>(5);
        IMarkerResolution[] localResolutions = fGenerator.getResolutions(marker);
        resolutions.addAll(Arrays.asList(localResolutions));

        // grab the contributed resolutions
        IMarkerResolution[] contributedResolutions =
            IDE.getMarkerHelpRegistry().getResolutions(marker);
        for (int i = 0; i < contributedResolutions.length; i++) {
          IMarkerResolution resolution = contributedResolutions[i];
          // only add contributed marker resolutions if they don't come from PDE
          if (!(resolution instanceof AbstractPDEMarkerResolution)
              && !resolutions.contains(contributedResolutions[i]))
            resolutions.add(contributedResolutions[i]);
        }
        if (resolutions.size() > 0) {
          fResMap.put(marker, resolutions.toArray(new IMarkerResolution[resolutions.size()]));
        }
      }
    }