Search in sources :

Example 1 with GrFileStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub in project intellij-community by JetBrains.

the class GrStubFileElementType method deserialize.

@NotNull
@Override
public GrFileStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
    StringRef name = dataStream.readName();
    boolean isScript = dataStream.readBoolean();
    return new GrFileStub(name, isScript, GrStubUtils.readStringArray(dataStream));
}
Also used : StringRef(com.intellij.util.io.StringRef) GrFileStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with GrFileStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub in project intellij-community by JetBrains.

the class GroovyFileImpl method isScript.

@Override
public boolean isScript() {
    final StubElement stub = getStub();
    if (stub instanceof GrFileStub) {
        return ((GrFileStub) stub).isScript();
    }
    Boolean isScript = myScript;
    if (isScript == null) {
        isScript = checkIsScript();
        myScript = isScript;
    }
    return isScript;
}
Also used : StubElement(com.intellij.psi.stubs.StubElement) GrFileStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub)

Example 3 with GrFileStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub in project intellij-community by JetBrains.

the class GrStubFileElementType method getBuilder.

@Override
public StubBuilder getBuilder() {
    return new DefaultStubBuilder() {

        @NotNull
        @Override
        protected StubElement createStubForFile(@NotNull final PsiFile file) {
            if (file instanceof GroovyFile) {
                return new GrFileStub((GroovyFile) file);
            }
            return super.createStubForFile(file);
        }

        @Override
        public boolean skipChildProcessingWhenBuildingStubs(@NotNull ASTNode parent, @NotNull ASTNode node) {
            IElementType childType = node.getElementType();
            IElementType parentType = parent.getElementType();
            if (childType == GroovyElementTypes.PARAMETER && parentType != GroovyElementTypes.PARAMETERS_LIST) {
                return true;
            }
            if (childType == GroovyElementTypes.PARAMETERS_LIST && !(parent.getPsi() instanceof GrMethod)) {
                return true;
            }
            if (childType == GroovyElementTypes.MODIFIERS) {
                if (parentType == GroovyElementTypes.CLASS_INITIALIZER) {
                    return true;
                }
                if (parentType == GroovyElementTypes.VARIABLE_DEFINITION && !GroovyElementTypes.VARIABLE_DEFINITION.shouldCreateStub(parent)) {
                    return true;
                }
            }
            return false;
        }
    };
}
Also used : IElementType(com.intellij.psi.tree.IElementType) ASTNode(com.intellij.lang.ASTNode) GrMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod) PsiFile(com.intellij.psi.PsiFile) NotNull(org.jetbrains.annotations.NotNull) GroovyFile(org.jetbrains.plugins.groovy.lang.psi.GroovyFile) GrFileStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub)

Aggregations

GrFileStub (org.jetbrains.plugins.groovy.lang.psi.stubs.GrFileStub)3 NotNull (org.jetbrains.annotations.NotNull)2 ASTNode (com.intellij.lang.ASTNode)1 PsiFile (com.intellij.psi.PsiFile)1 StubElement (com.intellij.psi.stubs.StubElement)1 IElementType (com.intellij.psi.tree.IElementType)1 StringRef (com.intellij.util.io.StringRef)1 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)1 GrMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod)1