Search in sources :

Example 1 with LighterASTNode

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

the class JavaModifierListElementType method shouldCreateStub.

@Override
public boolean shouldCreateStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub) {
    final LighterASTNode parent = tree.getParent(node);
    final IElementType parentType = parent != null ? parent.getTokenType() : null;
    return shouldCreateStub(parentType);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) LighterASTNode(com.intellij.lang.LighterASTNode)

Example 2 with LighterASTNode

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

the class FileLocalResolver method getShortClassTypeName.

/**
   * Determine the type name of the given variable. Can be used to later iterate over all classes with this name for lightweight checks
   * before loading AST and fully resolving the type.
   * @param var Variable node
   * @return the short name of the class corresponding to the type of the variable, or null if the variable is not of class type or
   * the type is generic
   */
@Nullable
public String getShortClassTypeName(@NotNull LighterASTNode var) {
    LighterASTNode typeRef = LightTreeUtil.firstChildOfType(myTree, LightTreeUtil.firstChildOfType(myTree, var, TYPE), JAVA_CODE_REFERENCE);
    String refName = JavaLightTreeUtil.getNameIdentifierText(myTree, typeRef);
    if (refName == null)
        return null;
    if (LightTreeUtil.firstChildOfType(myTree, typeRef, JAVA_CODE_REFERENCE) != null)
        return refName;
    if (isTypeParameter(refName, var))
        return null;
    return refName;
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with LighterASTNode

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

the class JavaLightStubBuilder method createStubForFile.

@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file, @NotNull LighterAST tree) {
    if (!(file instanceof PsiJavaFile)) {
        return super.createStubForFile(file, tree);
    }
    String refText = "";
    LighterASTNode pkg = LightTreeUtil.firstChildOfType(tree, tree.getRoot(), JavaElementType.PACKAGE_STATEMENT);
    if (pkg != null) {
        LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE);
        if (ref != null) {
            refText = JavaSourceUtil.getReferenceText(tree, ref);
        }
    }
    return new PsiJavaFileStubImpl((PsiJavaFile) file, refText, null, false);
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) PsiJavaFileStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl) PsiJavaFile(com.intellij.psi.PsiJavaFile) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with LighterASTNode

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

the class JavaLightTreeUtil method getArgList.

@Nullable
@Contract("_,null->null")
public static List<LighterASTNode> getArgList(@NotNull LighterAST tree, @Nullable LighterASTNode call) {
    LighterASTNode anonClass = LightTreeUtil.firstChildOfType(tree, call, ANONYMOUS_CLASS);
    LighterASTNode exprList = LightTreeUtil.firstChildOfType(tree, anonClass != null ? anonClass : call, EXPRESSION_LIST);
    return exprList == null ? null : getExpressionChildren(tree, exprList);
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with LighterASTNode

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

the class JavaPackageAccessibilityStatementElementType method createStub.

@Override
public PsiPackageAccessibilityStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
    String refText = null;
    List<String> to = ContainerUtil.newSmartList();
    for (LighterASTNode child : tree.getChildren(node)) {
        IElementType type = child.getTokenType();
        if (type == JavaElementType.JAVA_CODE_REFERENCE)
            refText = JavaSourceUtil.getReferenceText(tree, child);
        else if (type == JavaElementType.MODULE_REFERENCE)
            to.add(JavaSourceUtil.getReferenceText(tree, child));
    }
    return new PsiPackageAccessibilityStatementStubImpl(parentStub, this, refText, to);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) LighterASTNode(com.intellij.lang.LighterASTNode) PsiPackageAccessibilityStatementStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiPackageAccessibilityStatementStubImpl)

Aggregations

LighterASTNode (com.intellij.lang.LighterASTNode)48 IElementType (com.intellij.psi.tree.IElementType)14 Nullable (org.jetbrains.annotations.Nullable)12 NotNull (org.jetbrains.annotations.NotNull)11 PsiBuilder (com.intellij.lang.PsiBuilder)6 LighterAST (com.intellij.lang.LighterAST)4 ValueConstraint (com.intellij.codeInspection.dataFlow.MethodContract.ValueConstraint)3 TypeInfo (com.intellij.psi.impl.cache.TypeInfo)3 SmartList (com.intellij.util.SmartList)3 JavaTokenType (com.intellij.psi.JavaTokenType)2 JavaLightTreeUtil (com.intellij.psi.impl.source.JavaLightTreeUtil)2 JavaLightTreeUtil.findExpressionChild (com.intellij.psi.impl.source.JavaLightTreeUtil.findExpressionChild)2 JavaLightTreeUtil.getExpressionChildren (com.intellij.psi.impl.source.JavaLightTreeUtil.getExpressionChildren)2 ElementType (com.intellij.psi.impl.source.tree.ElementType)2 JavaElementType (com.intellij.psi.impl.source.tree.JavaElementType)2 LightTreeUtil.firstChildOfType (com.intellij.psi.impl.source.tree.LightTreeUtil.firstChildOfType)2 LightTreeUtil.getChildrenOfType (com.intellij.psi.impl.source.tree.LightTreeUtil.getChildrenOfType)2 ContainerUtil (com.intellij.util.containers.ContainerUtil)2 DuplicatesProfile (com.intellij.dupLocator.DuplicatesProfile)1 DuplocatorState (com.intellij.dupLocator.DuplocatorState)1