public void hideCoverageData() {
    if (myEditor == null) return;
    final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
    final List<RangeHighlighter> highlighters = myEditor.getUserData(COVERAGE_HIGHLIGHTERS);
    if (highlighters != null) {
      for (final RangeHighlighter highlighter : highlighters) {
        ApplicationManager.getApplication().invokeLater(() -> highlighter.dispose());
      }
      myEditor.putUserData(COVERAGE_HIGHLIGHTERS, null);
    }

    final Map<FileEditor, EditorNotificationPanel> map =
        myFile.getCopyableUserData(NOTIFICATION_PANELS);
    if (map != null) {
      final VirtualFile vFile = myFile.getVirtualFile();
      LOG.assertTrue(vFile != null);
      boolean freeAll = !fileEditorManager.isFileOpen(vFile);
      myFile.putCopyableUserData(NOTIFICATION_PANELS, null);
      for (FileEditor fileEditor : map.keySet()) {
        if (!freeAll && !isCurrentEditor(fileEditor)) {
          continue;
        }
        fileEditorManager.removeTopComponent(fileEditor, map.get(fileEditor));
      }
    }

    final DocumentListener documentListener = myEditor.getUserData(COVERAGE_DOCUMENT_LISTENER);
    if (documentListener != null) {
      myDocument.removeDocumentListener(documentListener);
      myEditor.putUserData(COVERAGE_DOCUMENT_LISTENER, null);
    }
  }
Ejemplo n.º 2
0
    public void uninstall() {
      for (RangeHighlighter highlighter : myHighlighters) {
        highlighter.dispose();
      }

      Component internalComponent = myHighlighterView.getContentComponent();
      internalComponent.setCursor(myStoredCursor);
      internalComponent.removeKeyListener(myEditorKeyListener);
      myHighlighterView.getScrollingModel().removeVisibleAreaListener(myVisibleAreaListener);
      myFileEditorManager.removeFileEditorManagerListener(myFileEditorManagerListener);
    }
 @Override
 public boolean removeSegmentHighlighter(
     @NotNull Editor editor, @NotNull RangeHighlighter highlighter) {
   Map<RangeHighlighter, HighlightInfo> map = getHighlightInfoMap(editor, false);
   if (map == null) return false;
   HighlightInfo info = map.get(highlighter);
   if (info == null) return false;
   MarkupModel markupModel = info.editor.getMarkupModel();
   if (((MarkupModelEx) markupModel).containsHighlighter(highlighter)) {
     highlighter.dispose();
   }
   map.remove(highlighter);
   return true;
 }
  private static void clearLineMarkers(Editor editor) {
    final List<RangeHighlighter> oldHighlighters =
        editor.getUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY);

    if (oldHighlighters != null) {
      final MarkupModelEx markupModel = (MarkupModelEx) editor.getMarkupModel();

      for (RangeHighlighter highlighter : oldHighlighters) {
        if (markupModel.containsHighlighter(highlighter)) {
          highlighter.dispose();
        }
      }
      editor.putUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY, null);
    }
  }
  public static void clearHighlightingAndLineMarkers(
      final Editor editor, @NotNull Project project) {
    final MarkupModel markupModel =
        DocumentMarkupModel.forDocument(editor.getDocument(), project, true);

    for (RangeHighlighter highlighter : markupModel.getAllHighlighters()) {
      Object tooltip = highlighter.getErrorStripeTooltip();

      if (!(tooltip instanceof HighlightInfo)) {
        continue;
      }

      if (((HighlightInfo) tooltip).type == TYPE) {
        highlighter.dispose();
      }
    }

    clearLineMarkers(editor);
  }