@Override
  public void doCollectInformation(@NotNull ProgressIndicator progress) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      return;
    }

    if (!WebEditorOptions.getInstance().isTagTreeHighlightingEnabled()) {
      return;
    }

    final PsiElement[] elements =
        BreadcrumbsXmlWrapper.getLinePsiElements(
            myEditor.getCaretModel().getOffset(),
            myFile.getVirtualFile(),
            myProject,
            myInfoProvider);

    if (elements == null || elements.length == 0) {
      return;
    }

    if (!XmlTagTreeHighlightingUtil.containsTagsWithSameName(elements)) {
      return;
    }

    for (int i = elements.length - 1; i >= 0; i--) {
      if (elements[i] instanceof XmlTag) {
        myPairsToHighlight.add(getTagRanges((XmlTag) elements[i]));
      }
    }
  }
예제 #2
0
 public boolean isApplicable(PsiFile file, int offset, boolean wrapping) {
   WebEditorOptions webEditorOptions = WebEditorOptions.getInstance();
   if (!webEditorOptions.isZenCodingEnabled()) {
     return false;
   }
   if (file == null) {
     return false;
   }
   PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments();
   PsiElement element = CustomTemplateCallback.getContext(file, offset);
   return findApplicableDefaultGenerator(element, wrapping) != null;
 }
  @Override
  public void doCollectInformation(@NotNull ProgressIndicator progress) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      return;
    }

    if (!WebEditorOptions.getInstance().isTagTreeHighlightingEnabled()) {
      return;
    }

    final int offset = myEditor.getCaretModel().getOffset();
    PsiElement[] elements =
        BreadcrumbsXmlWrapper.getLinePsiElements(
            offset, myFile.getVirtualFile(), myProject, myInfoProvider);

    if (elements == null
        || elements.length == 0
        || !XmlTagTreeHighlightingUtil.containsTagsWithSameName(elements)) {
      elements = PsiElement.EMPTY_ARRAY;
      final FileViewProvider provider = myFile.getViewProvider();
      for (Language language : provider.getLanguages()) {
        PsiElement element = provider.findElementAt(offset, language);
        if (!isTagStartOrEnd(element)) {
          element = null;
        }
        if (element == null && offset > 0) {
          element = provider.findElementAt(offset - 1, language);
          if (!isTagStartOrEnd(element)) element = null;
        }

        final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
        if (tag != null) {
          elements = new PsiElement[] {tag};
        }
      }
    }

    for (int i = elements.length - 1; i >= 0; i--) {
      if (elements[i] instanceof XmlTag) {
        myPairsToHighlight.add(getTagRanges((XmlTag) elements[i]));
      }
    }
  }
  private Color[] toColorsForEditor(Color[] baseColors) {
    final Color tagBackground = myEditor.getBackgroundColor();

    if (tagBackground == null) {
      return baseColors;
    }

    final Color[] resultColors = new Color[baseColors.length];
    // todo: make configurable
    final double transparency =
        WebEditorOptions.getInstance().getTagTreeHighlightingOpacity() * 0.01;

    for (int i = 0; i < resultColors.length; i++) {
      final Color color = baseColors[i];

      final Color color1 =
          color != null
              ? XmlTagTreeHighlightingUtil.makeTransparent(color, tagBackground, transparency)
              : null;
      resultColors[i] = color1;
    }

    return resultColors;
  }
예제 #5
0
 public char getShortcut() {
   return (char) WebEditorOptions.getInstance().getZenCodingExpandShortcut();
 }