MetaTypeProxy (@NotNull YAMLValue value) { PsiElement typed = PsiTreeUtil.getParentOfType(value, YAMLKeyValue.class, YAMLSequenceItem.class, YAMLDocument.class); if (typed instanceof YAMLDocument) { Field root = myMetaModel.getRoot((YAMLDocument)typed); return FieldAndRelation.forNullable(root, Field.Relation.OBJECT_CONTENTS); } if (typed instanceof YAMLSequenceItem sequenceItem) { YAMLSequence sequence = ObjectUtils.tryCast(sequenceItem.getParent(), YAMLSequence.class); if (sequence == null) { debug(() -> "Unexpected: sequenceItem parent is not a sequence: " + sequenceItem.getParent()); return null; } MetaTypeProxy sequenceMeta = getMetaTypeProxy(sequence); if (sequenceMeta != null) { YamlMetaType sequenceMetaType = sequenceMeta.getMetaType(); Field resultField = value instanceof YAMLSequence && sequenceMetaType instanceof YamlArrayType ? new Field("<array>", sequenceMetaType) : // unwind nested array sequenceMeta.getField(); return FieldAndRelation.forNullable(specializeField(resultField, sequenceItem.getValue()), Field.Relation.SEQUENCE_ITEM); } return null; } if (typed instanceof YAMLKeyValue keyValue) { Field keyValueType = computeMetaType(keyValue); if (keyValueType == null) { return null; } Field.Relation relation = Field.Relation.OBJECT_CONTENTS; if (value instanceof YAMLScalar) { relation = computeScalarValueRelation(keyValue, (YAMLScalar)value); } else if (value instanceof YAMLSequence) { relation = Field.Relation.SEQUENCE_ITEM; } return FieldAndRelation.forNullable(keyValueType, relation); } return null; }