Package com.intellij.lang

Examples of com.intellij.lang.ASTNode


    this.settings = settings;
  }

  public Indent getChildIndent(final ASTNode node) {
    final IElementType elementType = node.getElementType();
    final ASTNode prevSibling = UsefulPsiTreeUtil.getPrevSiblingSkipWhiteSpacesAndComments(node);
    final IElementType prevSiblingType = prevSibling == null ? null : prevSibling.getElementType();
    final ASTNode parent = node.getTreeParent();
    final IElementType parentType = parent != null ? parent.getElementType() : null;
    final ASTNode superParent = parent == null ? null : parent.getTreeParent();
    final IElementType superParentType = superParent == null ? null : superParent.getElementType();

    final int braceStyle = superParentType == FUNCTION_BODY ? settings.METHOD_BRACE_STYLE : settings.BRACE_STYLE;

    if (parent == null || parent.getTreeParent() == null || parentType == EMBEDDED_CONTENT) {
      return Indent.getNoneIndent();
    }

    if (elementType == MULTI_LINE_COMMENT_BODY) {
      return Indent.getContinuationIndent();
    }
    if (elementType == DOC_COMMENT_LEADING_ASTERISK || elementType == MULTI_LINE_COMMENT_END) {
      return Indent.getSpaceIndent(1, true);
    }

    if (settings.KEEP_FIRST_COLUMN_COMMENT && (elementType == SINGLE_LINE_COMMENT || elementType == MULTI_LINE_COMMENT)) {
      final ASTNode previousNode = node.getTreePrev();
      if (previousNode != null && previousNode.getElementType() == WHITE_SPACE && previousNode.getText().endsWith("\n")) {
        return Indent.getAbsoluteNoneIndent();
      }
    }

    if (COMMENTS.contains(elementType) && prevSiblingType == LBRACE && parentType == CLASS_BODY) {
View Full Code Here


      }
    }

    // sync* and async*
    if (DartTokenTypes.MUL == element.getNode().getElementType()) {
      final ASTNode previous = element.getNode().getTreePrev();
      if (previous != null && (previous.getElementType() == DartTokenTypes.SYNC ||
                               previous.getElementType() == DartTokenTypes.ASYNC ||
                               previous.getElementType() == DartTokenTypes.YIELD)) {
        createInfoAnnotation(holder, element, DartSyntaxHighlighterColors.DART_KEYWORD);
      }
    }

    if (element.getNode().getElementType() == DartTokenTypes.REGULAR_STRING_PART) {
View Full Code Here

    final PsiElement parent = declaration.getParent();

    PsiElement newLineNode = PsiParserFacade.SERVICE.getInstance(declaration.getProject()).createWhiteSpaceFromText("\n");
    parent.addAfter(newLineNode, declaration);

    final ASTNode nextChild = declaration.getNode().getTreeNext();
    parent.getNode().addLeaf(DartTokenTypes.SEMICOLON, ";", nextChild);
  }
View Full Code Here

    return DartBundle.message("dart.make.static.fix.name", myComponent.getName(), componentTypeString);
  }

  @Override
  protected void applyFix(Project project, @NotNull PsiElement psiElement, @Nullable Editor editor) {
    ASTNode node = myComponent.getNode();
    ASTNode anchor = node.getFirstChildNode();
    node.addLeaf(DartTokenTypes.STATIC, DartTokenTypes.STATIC.toString(), anchor);
    node.addLeaf(TokenType.WHITE_SPACE, " ", anchor);
  }
View Full Code Here

        return scriptTag.isInsideTag(offset);
      }
      else {
        PsiElement firstChild = file.getFirstChild();
        if (firstChild != null) {
          ASTNode theDeepestChild = firstChild.getNode();
          if (theDeepestChild == null) {
            return false;
          }
          while (theDeepestChild.getFirstChildNode() != null) {
            theDeepestChild = theDeepestChild.getFirstChildNode();
          }
          IElementType elementType = theDeepestChild.getElementType();
          if (elementType == CfscriptTokenTypes.COMMENT ||
              elementType == CfscriptTokenTypes.COMPONENT_KEYWORD ||
              elementType == CfscriptTokenTypes.INTERFACE_KEYWORD ||
              elementType == CfscriptTokenTypes.IMPORT_KEYWORD) {
            return true;
View Full Code Here

    return Arrays.copyOfRange(elements, i, to);
  }

  private static int findChildIndex(ASTNode[] children, int offset) {
    for (int i = 0, length = children.length; i < length; i++) {
      ASTNode child = children[i];
      if (child.getTextRange().contains(offset)) {
        return i;
      }
    }

    return -1;
View Full Code Here

  }

  @Nullable
  public static ASTNode getPrevSiblingSkipWhiteSpacesAndComments(@Nullable ASTNode sibling) {
    if (sibling == null) return null;
    ASTNode result = sibling.getTreePrev();
    while (result != null && isWhitespaceOrComment(result.getPsi())) {
      result = result.getTreePrev();
    }
    return result;
  }
View Full Code Here

  }

  @Override
  @NotNull
  protected String getElementText() {
    final ASTNode node = getNode();
    final ASTNode[] children = node.getChildren(TEXT_FILTER);
    return StringUtil.join(children, new Function<ASTNode, String>() {
      public String fun(ASTNode astNode) {
        return astNode.getText();
      }
    }, "").trim();
View Full Code Here

    return PsiTreeUtil.findChildOfType(this, GherkinPystring.class);
  }

  @Nullable
  public GherkinTable getTable() {
    final ASTNode tableNode = getNode().findChildByType(GherkinElementTypes.TABLE);
    return tableNode == null ? null : (GherkinTable)tableNode.getPsi();
  }
View Full Code Here

    return tableNode == null ? null : (GherkinTable)tableNode.getPsi();
  }

  @Override
  protected String getPresentableText() {
    final ASTNode keywordNode = getKeyword();
    final String prefix = keywordNode != null ? keywordNode.getText() + ": " : "Step: ";
    return prefix + getStepName();
  }
View Full Code Here

TOP

Related Classes of com.intellij.lang.ASTNode

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.