Search in sources :

Example 6 with LighterASTNode

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

the class JavaParameterElementType method createStub.

@Override
public PsiParameterStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
    TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
    LighterASTNode id = LightTreeUtil.requiredChildOfType(tree, node, JavaTokenType.IDENTIFIER);
    String name = RecordUtil.intern(tree.getCharTable(), id);
    return new PsiParameterStubImpl(parentStub, name, typeInfo, typeInfo.isEllipsis, false);
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) PsiParameterStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl) TypeInfo(com.intellij.psi.impl.cache.TypeInfo)

Example 7 with LighterASTNode

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

the class JavaRequiresStatementElementType method createStub.

@Override
public PsiRequiresStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
    LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.MODULE_REFERENCE);
    String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null;
    return new PsiRequiresStatementStubImpl(parentStub, refText);
}
Also used : PsiRequiresStatementStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiRequiresStatementStubImpl) LighterASTNode(com.intellij.lang.LighterASTNode)

Example 8 with LighterASTNode

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

the class LambdaExpressionElementType method formatTypeParameters.

private static void formatTypeParameters(LighterAST tree, LighterASTNode typeParameters, StringBuilder buf) {
    final List<LighterASTNode> children = LightTreeUtil.getChildrenOfType(tree, typeParameters, JavaElementType.TYPE);
    if (children.isEmpty())
        return;
    buf.append('<');
    for (int i = 0; i < children.size(); i++) {
        LighterASTNode child = children.get(i);
        formatType(tree, child, buf);
        if (i != children.size() - 1) {
            buf.append(", ");
        }
    }
    buf.append('>');
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode)

Example 9 with LighterASTNode

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

the class LambdaExpressionElementType method formatParameterList.

private static void formatParameterList(@NotNull LighterAST tree, @NotNull LighterASTNode parameterList, StringBuilder buf) {
    final List<LighterASTNode> children = tree.getChildren(parameterList);
    boolean isFirstParameter = true;
    boolean appendCloseBracket = false;
    for (final LighterASTNode node : children) {
        final IElementType tokenType = node.getTokenType();
        if (tokenType == JavaTokenType.LPARENTH) {
            buf.append('(');
            appendCloseBracket = true;
        } else if (tokenType == JavaStubElementTypes.PARAMETER) {
            if (!isFirstParameter) {
                buf.append(", ");
            }
            formatParameter(tree, node, buf);
            if (isFirstParameter) {
                isFirstParameter = false;
            }
        }
    }
    if (appendCloseBracket)
        buf.append(')');
}
Also used : IElementType(com.intellij.psi.tree.IElementType) LighterASTNode(com.intellij.lang.LighterASTNode)

Example 10 with LighterASTNode

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

the class LightTreeUtil method getChildrenOfType.

@NotNull
public static List<LighterASTNode> getChildrenOfType(@NotNull LighterAST tree, @NotNull LighterASTNode node, @NotNull IElementType type) {
    List<LighterASTNode> result = null;
    List<LighterASTNode> children = tree.getChildren(node);
    for (int i = 0, size = children.size(); i < size; ++i) {
        LighterASTNode child = children.get(i);
        if (child.getTokenType() == type) {
            if (result == null)
                result = new SmartList<>();
            result.add(child);
        }
    }
    return result != null ? result : Collections.<LighterASTNode>emptyList();
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) SmartList(com.intellij.util.SmartList) NotNull(org.jetbrains.annotations.NotNull)

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