Search in sources :

Example 41 with LighterASTNode

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

the class JavaUsesStatementElementType method createStub.

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

Example 42 with LighterASTNode

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

the class LambdaExpressionElementType method formatParameter.

private static void formatParameter(@NotNull LighterAST tree, @NotNull LighterASTNode parameter, StringBuilder buf) {
    final List<LighterASTNode> children = tree.getChildren(parameter);
    for (LighterASTNode node : children) {
        final IElementType tokenType = node.getTokenType();
        if (tokenType == JavaElementType.TYPE) {
            formatType(tree, node, buf);
            buf.append(' ');
        } else if (tokenType == JavaTokenType.IDENTIFIER) {
            buf.append(RecordUtil.intern(tree.getCharTable(), node));
        }
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType) LighterASTNode(com.intellij.lang.LighterASTNode)

Example 43 with LighterASTNode

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

the class FileLocalResolver method resolveLocally.

/**
   * @param ref reference node
   * @return a resolve result corresponding to a local variable, parameter or field that the given reference resolves to.
   */
@NotNull
public LightResolveResult resolveLocally(@NotNull LighterASTNode ref) {
    final String refName = JavaLightTreeUtil.getNameIdentifierText(myTree, ref);
    if (refName == null)
        return LightResolveResult.UNKNOWN;
    if (!canResolveToLocalVariable(myTree, ref))
        return LightResolveResult.NON_LOCAL;
    boolean passedClass = false;
    LighterASTNode lastParent = ref;
    while (true) {
        LighterASTNode scope = myTree.getParent(lastParent);
        if (scope == null)
            return LightResolveResult.NON_LOCAL;
        for (LighterASTNode var : getDeclarations(scope, lastParent)) {
            if (refName.equals(JavaLightTreeUtil.getNameIdentifierText(myTree, var))) {
                if (passedClass)
                    return var.getTokenType() == FIELD ? LightResolveResult.NON_LOCAL : LightResolveResult.UNKNOWN;
                return LightResolveResult.resolved(var);
            }
        }
        lastParent = scope;
        passedClass |= scope.getTokenType() == CLASS || scope.getTokenType() == ANONYMOUS_CLASS;
    }
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) NotNull(org.jetbrains.annotations.NotNull)

Example 44 with LighterASTNode

use of com.intellij.lang.LighterASTNode in project Perl5-IDEA by Camelcade.

the class TemplateToolkitParserUtil method parseMacroBody.

public static boolean parseMacroBody(PsiBuilder b, int l) {
    boolean r = false;
    LighterASTNode latestDoneMarker = null;
    PsiBuilder.Marker outerMarker = b.mark();
    if (TemplateToolkitParser.directive(b, l)) {
        latestDoneMarker = b.getLatestDoneMarker();
        PsiBuilder.Marker m = null;
        while (!b.eof()) {
            if (isEndMarker(b)) {
                break;
            }
            if (m == null) {
                m = b.mark();
            }
            b.advanceLexer();
        }
        if (m != null) {
            m.error(PerlBundle.message("ttk2.unexpected.token"));
        }
        consumeToken(b, TT2_HARD_NEWLINE);
        consumeToken(b, TT2_SEMI);
        consumeToken(b, TT2_CLOSE_TAG);
        r = true;
    }
    processMarkers(b, l, latestDoneMarker, outerMarker);
    return r;
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) PsiBuilder(com.intellij.lang.PsiBuilder)

Example 45 with LighterASTNode

use of com.intellij.lang.LighterASTNode in project Perl5-IDEA by Camelcade.

the class TemplateToolkitParserUtil method parseSwitchBlockContent.

public static boolean parseSwitchBlockContent(PsiBuilder b, int l) {
    PsiBuilder.Marker branchMarker = null;
    while (!b.eof()) {
        PsiBuilder.Marker currentMarker = b.mark();
        if (TemplateToolkitParser.element(b, l)) {
            LighterASTNode latestDoneMarker = b.getLatestDoneMarker();
            if (latestDoneMarker != null) {
                if (latestDoneMarker.getTokenType() == END_DIRECTIVE) {
                    if (branchMarker != null) {
                        branchMarker.doneBefore(CASE_BLOCK, currentMarker);
                        branchMarker.setCustomEdgeTokenBinders(WhitespacesBinders.DEFAULT_LEFT_BINDER, WhitespacesBinders.GREEDY_RIGHT_BINDER);
                    }
                    branchMarker = null;
                    currentMarker.drop();
                    break;
                } else if (latestDoneMarker.getTokenType() == CASE_DIRECTIVE) {
                    if (branchMarker != null) {
                        branchMarker.doneBefore(CASE_BLOCK, currentMarker);
                        branchMarker.setCustomEdgeTokenBinders(WhitespacesBinders.DEFAULT_LEFT_BINDER, WhitespacesBinders.GREEDY_RIGHT_BINDER);
                    }
                    branchMarker = currentMarker.precede();
                }
            }
        }
        currentMarker.drop();
    }
    if (branchMarker != null) {
        branchMarker.done(CASE_BLOCK);
        branchMarker.setCustomEdgeTokenBinders(WhitespacesBinders.DEFAULT_LEFT_BINDER, WhitespacesBinders.GREEDY_RIGHT_BINDER);
    }
    return true;
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) PsiBuilder(com.intellij.lang.PsiBuilder)

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