Set<String> (@NotNull PsiElement originalPosition, PsiElement computedPosition) { YAMLMapping object = PsiTreeUtil.getParentOfType(originalPosition, YAMLMapping.class, false); YAMLMapping otherObject = PsiTreeUtil.getParentOfType(computedPosition, YAMLMapping.class, false); // the original position can be either a sound element or a whitespace; whitespaces can belong to the parent if (object == null || otherObject != null && PsiTreeUtil.isAncestor(CompletionUtil.getOriginalOrSelf(object), CompletionUtil.getOriginalOrSelf(otherObject), true)) { object = otherObject; } if (object == null) return Collections.emptySet(); return new YamlObjectAdapter(object).getPropertyList().stream().map(p -> p.getName()).collect(Collectors.toSet()); }