Search in sources :

Example 91 with ASTNode

use of com.intellij.lang.ASTNode in project kotlin by JetBrains.

the class KtProperty method getReceiverTypeRefByTree.

@Nullable
private KtTypeReference getReceiverTypeRefByTree() {
    ASTNode node = getNode().getFirstChildNode();
    while (node != null) {
        IElementType tt = node.getElementType();
        if (tt == KtTokens.COLON)
            break;
        if (tt == KtNodeTypes.TYPE_REFERENCE) {
            return (KtTypeReference) node.getPsi();
        }
        node = node.getTreeNext();
    }
    return null;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) ASTNode(com.intellij.lang.ASTNode) Nullable(org.jetbrains.annotations.Nullable)

Example 92 with ASTNode

use of com.intellij.lang.ASTNode in project kotlin by JetBrains.

the class KtImportDirective method getAliasName.

@Nullable
public String getAliasName() {
    KotlinImportDirectiveStub stub = getStub();
    if (stub != null) {
        return stub.getAliasName();
    }
    ASTNode aliasNameNode = getAliasNameNode();
    if (aliasNameNode == null) {
        return null;
    }
    return aliasNameNode.getText();
}
Also used : KotlinImportDirectiveStub(org.jetbrains.kotlin.psi.stubs.KotlinImportDirectiveStub) ASTNode(com.intellij.lang.ASTNode) Nullable(org.jetbrains.annotations.Nullable)

Example 93 with ASTNode

use of com.intellij.lang.ASTNode in project kotlin by JetBrains.

the class KtStubElementType method createStubDependingOnParent.

private static boolean createStubDependingOnParent(ASTNode node) {
    ASTNode parent = node.getTreeParent();
    IElementType parentType = parent.getElementType();
    if (parentType instanceof IStubElementType) {
        return ((IStubElementType) parentType).shouldCreateStub(parent);
    }
    if (parentType instanceof IStubFileElementType) {
        return true;
    }
    return false;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) IStubFileElementType(com.intellij.psi.tree.IStubFileElementType) ASTNode(com.intellij.lang.ASTNode) IStubElementType(com.intellij.psi.stubs.IStubElementType)

Example 94 with ASTNode

use of com.intellij.lang.ASTNode in project kotlin by JetBrains.

the class KtBinaryExpression method getRight.

@Nullable
@IfNotParsed
public KtExpression getRight() {
    ASTNode node = getOperationReference().getNode().getTreeNext();
    while (node != null) {
        PsiElement psi = node.getPsi();
        if (psi instanceof KtExpression) {
            return (KtExpression) psi;
        }
        node = node.getTreeNext();
    }
    return null;
}
Also used : ASTNode(com.intellij.lang.ASTNode) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 95 with ASTNode

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

the class PyArgumentListImpl method getKeywordArgument.

@Nullable
public PyKeywordArgument getKeywordArgument(String name) {
    ASTNode node = getNode().getFirstChildNode();
    while (node != null) {
        if (node.getElementType() == PyElementTypes.KEYWORD_ARGUMENT_EXPRESSION) {
            PyKeywordArgument arg = (PyKeywordArgument) node.getPsi();
            String keyword = arg.getKeyword();
            if (keyword != null && keyword.equals(name))
                return arg;
        }
        node = node.getTreeNext();
    }
    return null;
}
Also used : ASTNode(com.intellij.lang.ASTNode) 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