Package com.intellij.lang

Examples of com.intellij.lang.ASTNode


    return super.getChildAttributes(newChildIndex);
  }

  @Override
  public boolean isIncomplete() {
    ASTNode lastChild = myNode.getLastChildNode();
    while (lastChild != null && lastChild.getElementType() == TokenType.WHITE_SPACE) {
      lastChild = lastChild.getTreePrev();
    }
    if (lastChild == null) return false;
    if (lastChild.getElementType() == TokenType.ERROR_ELEMENT) return true;
    return FormatterUtil.isIncomplete(lastChild);
  }
View Full Code Here


*/
public class MathematicaIndentProcessor {

  public static Indent getChildIndent(ASTNode node) {
    IElementType elementType = node.getElementType();
    ASTNode parent = node.getTreeParent();
    IElementType parentType = parent != null ? parent.getElementType() : null;
    ASTNode grandfather = parent != null ? parent.getTreeParent() : null;
    IElementType grandfatherType = grandfather != null ? grandfather.getElementType() : null;
    ASTNode prevSibling = FormatterUtil.getPreviousNonWhitespaceSibling(node);
    IElementType prevSiblingElementType = prevSibling != null ? prevSibling.getElementType() : null;


    if (parent == null ||
        elementType == COMMENT ||
        parentType == FILE) {
View Full Code Here

   * @param node
   *     the node to check
   * @return true if node is in the function head or the opening bracket
   */
  private static boolean isInFunctionHead(ASTNode node) {
    final ASTNode treeParent = node.getTreeParent();
    if (treeParent == null) {
      return false;
    }
    for (ASTNode child = treeParent.getFirstChildNode(); child != null; child = FormatterUtil.getNextNonWhitespaceSibling(child)) {
      if (child == node) {
        return true;
      }
      if (child.getElementType() == LEFT_BRACKET) {
        return false;
View Full Code Here

   * @param node
   *     the node to check
   * @return true if the node is between the opening and closing bracket of <code >func[....]</code>
   */
  private static boolean isInFunctionBody(ASTNode node) {
    final ASTNode treeParent = node.getTreeParent();
    if (treeParent == null) {
      return false;
    }
    boolean inBody = false;
    for (ASTNode child = treeParent.getFirstChildNode(); child != null; child = FormatterUtil.getNextNonWhitespaceSibling(child)) {
      if (!inBody) {
        if (child.getElementType() == LEFT_BRACKET) {
          inBody = true;
        }
        continue;
View Full Code Here

    super(node);
  }

  @Override
  public PsiElement setName(@NonNls @NotNull String name) {
    ASTNode identifierNode = getNode().findChildByType(MathematicaElementTypes.IDENTIFIER);
    final PsiFileFactory fileFactory = PsiFileFactory.getInstance(getProject());
    final MathematicaPsiFileImpl file = (MathematicaPsiFileImpl) fileFactory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, name);
    ASTNode newElm = file.getFirstChild().getNode().findChildByType(MathematicaElementTypes.IDENTIFIER);
    if (identifierNode != null && newElm != null) {
      getNode().replaceChild(identifierNode, newElm);
    }
    return this;
  }
View Full Code Here

    myIsUpToDate = false;
  }

  @Override
  public PsiElement setName(@NonNls @NotNull String name) {
    ASTNode identifierNode = getNode().findChildByType(MathematicaElementTypes.IDENTIFIER);
    final PsiFileFactory fileFactory = PsiFileFactory.getInstance(getProject());
    final MathematicaPsiFileImpl file = (MathematicaPsiFileImpl) fileFactory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, name);
    ASTNode newElm = file.getFirstChild().getNode().findChildByType(MathematicaElementTypes.IDENTIFIER);
    if (identifierNode != null && newElm != null) {
      getNode().replaceChild(identifierNode, newElm);
    }
    return this;
  }
View Full Code Here

   * and uses no name (i.e. the "{^}" icon is the representative) in the simple
   * inverse case
   */
  @Override
  public String getName() {
    ASTNode elseNode = getElseNode();
    if (elseNode != null) {
      return elseNode.getText();
    }
    return ""; // no name for "{{^}}" expressions
  }
View Full Code Here

    if (provider instanceof HbFileViewProvider) {
      if (HbConfig.isAutocompleteMustachesEnabled() && c == '}' && !previousChar.equals("}")) {
        // we may be able to complete the second brace
        PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
        PsiElement elementAt = provider.findElementAt(offset - 1, HbLanguage.class);
        ASTNode node = elementAt != null ? elementAt.getNode() : null;
        if (node != null && node.getElementType() == HbTokenTypes.INVALID) {
          // we should be looking at the beginning of a close brace.  Find its matching open brace and auto-complete based on its type
          PsiElement mustache = PsiTreeUtil.findFirstParent(elementAt, new Condition<PsiElement>() {
            @Override
            public boolean value(PsiElement psiElement) {
              return psiElement instanceof HbMustache;
View Full Code Here

        return isPrefixInfixIdent() ? getParent().getNode() : getNode();
    }

    @Override
    protected ASTNode getNodeToBeInsertedTo() {
        ASTNode parent = getParent().getNode();
        return isPrefixInfixIdent() ? parent.getTreeParent() : parent;
    }
View Full Code Here

        return isPrefixInfixIdent() ? parent.getTreeParent() : parent;
    }

    @Override
    protected boolean isPrefixInfixIdent() {
        ASTNode parentNode = getParent().getNode();
        ASTNode grandParentNode = parentNode.getTreeParent();
        HaskellTokenType infixPrefixIdentType = HaskellElementTypes.INFIX_PREFIX_IDENT;
        IElementType parentType = grandParentNode.getElementType() == infixPrefixIdentType ? infixPrefixIdentType : parentNode.getElementType();
        return parentType == infixPrefixIdentType;
    }
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.