Package com.intellij.lang.folding

Examples of com.intellij.lang.folding.FoldingDescriptor


                                        @NotNull final Collection<PsiElement> psiElements) {
    for (PsiElement psiElement : psiElements) {
      if (psiElement instanceof DartTypeArguments) {
        DartTypeArguments dartTypeArguments = (DartTypeArguments)psiElement;
        if (PsiTreeUtil.getParentOfType(dartTypeArguments, DartNewExpression.class, DartTypeArguments.class) instanceof DartNewExpression) {
          descriptors.add(new FoldingDescriptor(dartTypeArguments, TextRange
            .create(dartTypeArguments.getTextOffset(), dartTypeArguments.getTextRange().getEndOffset())));
        }
      }
    }
  }
View Full Code Here


      // tags before we allow folding
      if (commentText.length() > 6
          && commentText.substring(0, 3).equals("{{!")
          && commentText.substring(commentText.length() - 2, commentText.length()).equals("}}")) {
        TextRange range = new TextRange(commentNode.getTextRange().getStartOffset() + 3, commentNode.getTextRange().getEndOffset() - 2);
        descriptors.add(new FoldingDescriptor(commentNode, range));
      }
    }

    if (psi instanceof HbBlockWrapper) {

      PsiElement endOpenBlockStache = getOpenBlockCloseStacheElement(psi.getFirstChild());
      PsiElement endCloseBlockStache = getCloseBlockCloseStacheElement(psi.getLastChild());

      // if we've got a well formed block with the open and close elems we need, define a region to fold
      if (endOpenBlockStache != null && endCloseBlockStache != null) {
        int endOfFirstOpenStacheLine
          = document.getLineEndOffset(document.getLineNumber(psi.getTextRange().getStartOffset()));

        // we set the start of the text we'll fold to be just before the close braces of the open stache,
        //     or, if the open stache spans multiple lines, to the end of the first line
        int foldingRangeStartOffset = Math.min(endOpenBlockStache.getTextRange().getStartOffset(), endOfFirstOpenStacheLine);
        // we set the end of the text we'll fold to be just before the final close braces in this block
        int foldingRangeEndOffset = endCloseBlockStache.getTextRange().getStartOffset();

        TextRange range = new TextRange(foldingRangeStartOffset, foldingRangeEndOffset);

        descriptors.add(new FoldingDescriptor(psi, range));
      }
    }

    PsiElement child = psi.getFirstChild();
    while (child != null) {
View Full Code Here

    return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
  }

  private void appendDescriptors(ASTNode node, List<FoldingDescriptor> descriptors) {
    if (BLOCKS_TO_FOLD.contains(node.getElementType()) && node.getTextRange().getLength() >= 2) {
      descriptors.add(new FoldingDescriptor(node, node.getTextRange()));
    }
    ASTNode child = node.getFirstChildNode();
    while (child != null) {
      appendDescriptors(child, descriptors);
      child = child.getTreeNext();
View Full Code Here

          }
        }
      }

      if (range != null) {
        descriptors.add(new FoldingDescriptor(astNode, range));
      }

      // TODO: insert condition
      addFoldingDescriptorsFromChildren(descriptors, tag, document);
    }
View Full Code Here

    final ArrayList<FoldingDescriptor> result = new ArrayList<FoldingDescriptor>();
    for (BnfAttrs attrs : file.getAttributes()) {
      TextRange textRange = attrs.getTextRange();
      if (textRange.getLength() <= 2) continue;
      result.add(new FoldingDescriptor(attrs, textRange));
    }
    for (BnfRule rule : file.getRules()) {
      //result.add(new FoldingDescriptor(rule, rule.getTextRange()));
      BnfAttrs attrs = rule.getAttrs();
      if (attrs != null) {
        result.add(new FoldingDescriptor(attrs, attrs.getTextRange()));
      }
    }
    if (!quick) {
      PsiTreeUtil.processElements(file, new PsiElementProcessor() {
        @Override
        public boolean execute(@NotNull PsiElement element) {
          if (element.getNode().getElementType() == BnfParserDefinition.BNF_BLOCK_COMMENT) {
            result.add(new FoldingDescriptor(element, element.getTextRange()));
          }
          return true;
        }
      });
    }
View Full Code Here

        ASTNode node = psi.getNode();
        if (node == null || !isMultiline(psi)) return;
        IElementType type = node.getElementType();

        if (mML_COMMENT == type) {
            descriptors.add(new FoldingDescriptor(node, node.getTextRange()));
            return;
        }

        if ( TYPE_DECLARATIONS == type) {
            addDescriptorStartFromChildNode(descriptors, node, "{");
            return;
        }

        if (CONST_DECLARATIONS == type || VAR_DECLARATIONS == type || IMPORT_DECLARATIONS == type) {
            addDescriptorStartFromChildNode(descriptors, node, "(");
            return;
        }

        if ( BLOCK_STATEMENT == type) {
            descriptors.add(new FoldingDescriptor(node, node.getTextRange()));
        }

        PsiElement child = psi.getFirstChild();
        while (child != null) {
            appendDescriptors(child, document, descriptors);
View Full Code Here

    private void addDescriptorStartFromChildNode(List<FoldingDescriptor> descriptors, ASTNode node, String childText) {
        ASTNode startNode = findChildOfText(node, childText);
        if (startNode != null) {
            int end = node.getStartOffset() + node.getTextLength();
            descriptors.add(new FoldingDescriptor(node, new TextRange(startNode.getStartOffset(), end)));
        }
    }
View Full Code Here

        return C_STYLE_COMMENT.equals(astNode.getElementType());
    }

    private void appendDescriptors(ASTNode curNode, List<FoldingDescriptor> descriptors) {
        if (BLOCKS.contains(curNode.getElementType()) && isMultiline(curNode)) {
            descriptors.add(new FoldingDescriptor(curNode, curNode.getTextRange()));
        }
        if (C_STYLE_COMMENT.equals(curNode.getElementType()) && isMultiline(curNode)) {    //todo [low] check for well ended
            descriptors.add(new FoldingDescriptor(curNode, curNode.getTextRange()));
        }

        ASTNode child = curNode.getFirstChildNode();
        while (child != null) {
            appendDescriptors(child, descriptors);
View Full Code Here

            String value = (String) literalExpression.getValue();
            if (value != null && value.startsWith("simple:")) {
                Project project = literalExpression.getProject();
                final List<SimpleProperty> properties = SimpleUtil.findProperties(project, value.substring(7));
                if (properties.size() == 1) {
                    descriptors.add(new FoldingDescriptor(literalExpression.getNode(),
                            new TextRange(literalExpression.getTextRange().getStartOffset() + 1,
                                    literalExpression.getTextRange().getEndOffset() - 1), group) {
                        @Nullable
                        @Override
                        public String getPlaceholderText() {
View Full Code Here

                if(contents.length() > 0 && routes.containsKey(contents)) {
                    final Route route = routes.get(contents);

                    final String url = RouteHelper.getRouteUrl(route);
                    if(url != null) {
                        descriptors.add(new FoldingDescriptor(stringLiteralExpression.getNode(),
                            new TextRange(stringLiteralExpression.getTextRange().getStartOffset() + 1, stringLiteralExpression.getTextRange().getEndOffset() - 1), group) {
                            @Nullable
                            @Override
                            public String getPlaceholderText() {
                                return url;
View Full Code Here

TOP

Related Classes of com.intellij.lang.folding.FoldingDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.