String (@NotNull Editor editor, @NotNull List<String> keys, @NotNull PsiElement element, int caretOffset, int indent) { while (true) { // TODO: RUBY-22437 support JSON-like mappings YAMLBlockMappingImpl blockMapping; if (element.getParent() instanceof YAMLFile) { // We are at the end of the file PsiElement prev = element.getPrevSibling(); if (!(prev instanceof YAMLDocument)) { return null; } element = ((YAMLDocument)prev).getTopLevelValue(); if (!(element instanceof YAMLBlockMappingImpl)) { return null; } blockMapping = ((YAMLBlockMappingImpl)element); } else { blockMapping = PsiTreeUtil.getParentOfType(element, YAMLBlockMappingImpl.class); } if (blockMapping == null) { return null; } int mappingIndent = YAMLUtil.getIndentToThisElement(blockMapping); if (mappingIndent == indent) { YAMLKeyValue keyValue = ApplicationManager.getApplication().runWriteAction( (Computable<YAMLKeyValue>)() -> { YAMLKeyValue lastKeyVal = blockMapping.getOrCreateKeySequence(keys, caretOffset); if (lastKeyVal == null) { return null; } ASTNode colon = lastKeyVal.getNode().findChildByType(YAMLTokenTypes.COLON); if (colon != null) { int newOffset = colon.getTextRange().getEndOffset(); editor.getCaretModel().moveToOffset(newOffset); } return lastKeyVal; } ); if (keyValue != null) { return ""; } } element = blockMapping; } }