GrVariable (@NotNull PsiFile file, int startOffset, int endOffset) { GrVariable var = PsiImplUtil.findElementInRange(file, startOffset, endOffset, GrVariable.class); if (var == null) { final GrVariableDeclaration variableDeclaration = PsiImplUtil.findElementInRange(file, startOffset, endOffset, GrVariableDeclaration.class); if (variableDeclaration == null) return null; final GrVariable[] variables = variableDeclaration.getVariables(); if (variables.length == 1) { var = variables[0]; } } if (var instanceof GrParameter || var instanceof GrField) { return null; } return var; }