EditorConfigHeader (@NotNull PsiElement contextElement) { if (contextElement instanceof PsiWhiteSpace) { PsiElement prev = contextElement.getPrevSibling(); if (prev instanceof EditorConfigSection) { return ((EditorConfigSection)prev).getHeader(); } } PsiElement parent = contextElement.getParent(); while (parent != null && !(parent instanceof PsiFile)) { if (parent instanceof EditorConfigSection) { return ((EditorConfigSection)parent).getHeader(); } parent = parent.getParent(); } return null; }