PsiElement () { final GrVariable variable = getVariable(); if (variable instanceof PsiField) { return ((PsiField)getVariable()).getContainingClass(); } else { final PsiFile file = variable.getContainingFile(); if (file instanceof GroovyFile) { return ((GroovyFile)file).getScriptClass(); } else { return null; } } }