コード例 #1
0
    @Override
    public void runWithEvent(Event event) {
      if (mCanFix) {
        ITextOperationTarget operation =
            (ITextOperationTarget) mTextEditor.getAdapter(ITextOperationTarget.class);
        final int opCode = ISourceViewer.QUICK_ASSIST;
        if (operation != null && operation.canDoOperation(opCode)) {
          mTextEditor.selectAndReveal(mPosition.getOffset(), mPosition.getLength());
          operation.doOperation(opCode);
        }
        return;
      }

      super.run();
    }
コード例 #2
0
    private void findAnnotation() {
      mPosition = null;
      mCanFix = false;

      IDocumentProvider provider = mTextEditor.getDocumentProvider();
      IAnnotationModel model = provider.getAnnotationModel(mTextEditor.getEditorInput());
      IAnnotationAccessExtension annotationAccess = getAnnotationAccessExtension();

      IDocument document = getDocument();
      if (model == null) {
        return;
      }

      Iterator<?> iter = model.getAnnotationIterator();
      int layer = Integer.MIN_VALUE;

      while (iter.hasNext()) {
        Annotation annotation = (Annotation) iter.next();
        if (annotation.isMarkedDeleted()) {
          continue;
        }

        int annotationLayer = Integer.MAX_VALUE;
        if (annotationAccess != null) {
          annotationLayer = annotationAccess.getLayer(annotation);
          if (annotationLayer < layer) {
            continue;
          }
        }

        Position position = model.getPosition(annotation);
        if (!includesRulerLine(position, document)) {
          continue;
        }

        boolean isReadOnly =
            mTextEditor instanceof ITextEditorExtension
                && ((ITextEditorExtension) mTextEditor).isEditorInputReadOnly();
        if (!isReadOnly
            && annotation instanceof INIProblemAnnotation
            && ((INIProblemAnnotation) annotation).isQuickFixable()) {
          mPosition = position;
          mCanFix = true;
          layer = annotationLayer;
          continue;
        } else {
          AnnotationPreference preference =
              mAnnotationPreferenceLookup.getAnnotationPreference(annotation);
          if (preference == null) {
            continue;
          }

          String key = preference.getVerticalRulerPreferenceKey();
          if (key == null) {
            continue;
          }

          if (mStore.getBoolean(key)) {
            mPosition = position;
            mCanFix = false;
            layer = annotationLayer;
          }
        }
      }
    }