public static SearchScope getLocalElementSearchScope(GoPsiElement element) {
GoStatement statement = findParentOfType(element, GoStatement.class);
if (statement == null) {
GoFunctionDeclaration functionDeclaration = findParentOfType(element, GoFunctionDeclaration.class);
if (functionDeclaration != null) {
return new LocalSearchScope(functionDeclaration);
}
return new LocalSearchScope(element);
}
PsiElement scope = statement.getParent();
if (scope instanceof GoVarDeclarations) {
scope = scope.getParent();
}
if (scope == null) {
scope = element;
}
return new LocalSearchScope(scope);
}