Search in sources :

Example 56 with ASTNode

use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.

the class XPathElementImpl method addAfter.

public PsiElement addAfter(@NotNull PsiElement psiElement, final PsiElement anchor) throws IncorrectOperationException {
    final ASTNode astNode = anchor.getNode();
    assert astNode != null;
    final ASTNode next = astNode.getTreeNext();
    final ASTNode node = getNode();
    final ASTNode newNode = psiElement.getNode();
    assert newNode != null;
    if (next != null) {
        node.addChild(newNode, next);
    } else {
        node.addChild(newNode);
    }
    return node.getPsi();
}
Also used : ASTNode(com.intellij.lang.ASTNode)

Example 57 with ASTNode

use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.

the class XPathElementImpl method addBefore.

public PsiElement addBefore(@NotNull PsiElement psiElement, final PsiElement anchor) throws IncorrectOperationException {
    final ASTNode node = getNode();
    final ASTNode child = psiElement.getNode();
    assert child != null;
    node.addChild(child, anchor.getNode());
    return node.getPsi();
}
Also used : ASTNode(com.intellij.lang.ASTNode)

Example 58 with ASTNode

use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.

the class XPathFunctionCallImpl method getFunctionName.

@NotNull
public String getFunctionName() {
    final ASTNode node = getNameNode();
    final String name = node != null ? node.getText() : null;
    assert name != null : unexpectedPsiAssertion();
    return name;
}
Also used : ASTNode(com.intellij.lang.ASTNode) NotNull(org.jetbrains.annotations.NotNull)

Example 59 with ASTNode

use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.

the class XPathVariableReferenceImpl method renameTo.

private void renameTo(String newElementName) {
    final XPathVariableReference child = XPathChangeUtil.createVariableReference(this, newElementName);
    final PrefixedNameImpl newName = ((PrefixedNameImpl) child.getQName());
    final PrefixedNameImpl oldName = ((PrefixedNameImpl) getQName());
    assert newName != null;
    assert oldName != null;
    final ASTNode localNode = newName.getLocalNode();
    getNode().replaceChild(oldName.getLocalNode(), localNode);
}
Also used : ASTNode(com.intellij.lang.ASTNode)

Example 60 with ASTNode

use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.

the class PyNamedParameterImpl method getDefaultValue.

@Nullable
public PyExpression getDefaultValue() {
    final PyNamedParameterStub stub = getStub();
    if (stub != null && !stub.hasDefaultValue()) {
        return null;
    }
    ASTNode[] nodes = getNode().getChildren(PythonDialectsTokenSetProvider.INSTANCE.getExpressionTokens());
    if (nodes.length > 0) {
        return (PyExpression) nodes[0].getPsi();
    }
    return null;
}
Also used : ASTNode(com.intellij.lang.ASTNode) PyNamedParameterStub(com.jetbrains.python.psi.stubs.PyNamedParameterStub) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ASTNode (com.intellij.lang.ASTNode)748 PsiElement (com.intellij.psi.PsiElement)142 NotNull (org.jetbrains.annotations.NotNull)132 IElementType (com.intellij.psi.tree.IElementType)127 Nullable (org.jetbrains.annotations.Nullable)99 TextRange (com.intellij.openapi.util.TextRange)91 ArrayList (java.util.ArrayList)53 IncorrectOperationException (com.intellij.util.IncorrectOperationException)35 PsiFile (com.intellij.psi.PsiFile)31 Annotation (com.intellij.lang.annotation.Annotation)22 CharTable (com.intellij.util.CharTable)22 Document (com.intellij.openapi.editor.Document)18 FoldingDescriptor (com.intellij.lang.folding.FoldingDescriptor)17 XmlTag (com.intellij.psi.xml.XmlTag)17 Project (com.intellij.openapi.project.Project)16 AbstractBlock (com.intellij.psi.formatter.common.AbstractBlock)16 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)16 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)15 CompositeElement (com.intellij.psi.impl.source.tree.CompositeElement)15 PsiReference (com.intellij.psi.PsiReference)14