PsiClassType (GroovyScriptClass scriptClass) { GrVariableDeclaration declaration = findDeclaration(scriptClass.getContainingFile()); if (declaration != null) { GrTypeElement typeElement = declaration.getTypeElementGroovy(); if (typeElement != null) { PsiType type = typeElement.getType(); if (type instanceof PsiClassType) { return (PsiClassType)type; } } } return null; }