StubBuilder () { 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 == GroovyStubElementTypes.PARAMETER && parentType != GroovyEmptyStubElementTypes.PARAMETER_LIST) { return true; } if (childType == GroovyEmptyStubElementTypes.PARAMETER_LIST && !(parent.getPsi() instanceof GrMethod || parentType == GroovyStubElementTypes.RECORD_TYPE_DEFINITION)) { return true; } if (childType == GroovyStubElementTypes.MODIFIER_LIST) { if (parentType == GroovyElementTypes.CLASS_INITIALIZER) { return true; } if (parentType == GroovyStubElementTypes.VARIABLE_DECLARATION && !GroovyStubElementTypes.VARIABLE_DECLARATION.shouldCreateStub(parent)) { return true; } } return false; } }; }