Repository: godotengine/godot
File: editor/file_system/dependency_editor.cpp (C++)

Code before:

	bool broken = false;

	for (const String &dep : deps) {
		TreeItem *item = tree->create_item(root);

		const String path = _get_resolved_dep_path(dep);
		if (FileAccess::exists(path)) {
			item->set_text(0, path.get_file());
			item->set_text(1, path);
		} else {
			const String &stored_path = _get_stored_dep_path(dep);
			item->set_text(0, stored_path.get_file());
			item->set_text(1, stored_path);
			item->set_custom_color(1, Color(1, 0.4, 0.3));
			missing.push_back(stored_path);
			broken = true;
		}

		const String type = dep.contains("::") ? dep.get_slice("::", 1) : "Resource";
		String name = path.get_file();
		Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type);
		item->set_icon((int)DependencyEditorColumn::TYPE, icon);
		item->set_text((int)DependencyEditorColumn::TYPE, type);
		item->set_text((int)DependencyEditorColumn::NAME, name);
		item->set_metadata((int)DependencyEditorColumn::TYPE, type);
		item->set_text((int)DependencyEditorColumn::PATH, path);

		if (!FileAccess::exists(path)) {
			item->set_custom_color((int)DependencyEditorColumn::PATH, Color(1, 0.4, 0.3));
			missing.push_back(path);
			broken = true;
		}

		item->add_button((int)DependencyEditorColumn::PATH, folder, 0);
	}

	fixdeps->set_disabled(!broken);
}

void DependencyEditor::edit(const String &p_path) {
	editing = p_path;
	set_title(TTR("Dependencies For:") + " " + p_path.get_file());

	filter->set_text("");
	sort_by = DependencyEditorSortBy::PATH;

	_update_menu_sort();
	_update_list();

	if (EditorNode::get_singleton()->is_scene_open(p_path)) {

Review comment (suggestion):
The metadata is used with `0` as index. Either usages should be updated or this also need to be changed to `0`.
```suggestion
		item->set_metadata(0, type);
```
Since it's not displayed and technically can be in any column, it's fine to skip the enum in this case.

EDIT:
I noticed the enum is used inconsistently in other places too (like when setting missing dep color few lines above). It'd be nice to update the old code to use the enum columns, but can be done in a separate PR.

Code after:
	filter->set_text("");

	_update_menu_sort();
	_update_list();

	if (EditorNode::get_singleton()->is_scene_open(p_path)) {
		warning_label->show();
		warning_label->set_text(vformat(TTR("Scene \"%s\" is currently being edited. Changes will only take effect when reloaded."), p_path.get_file()));
	} else if (ResourceCache::has(p_path)) {
		warning_label->show();
		warning_label->set_text(vformat(TTR("Resource \"%s\" is in use. Changes will only take effect when reloaded."), p_path.get_file()));
	} else {
		warning_label->hide();
	}
	popup_centered_ratio(0.4);
}

void DependencyEditor::_sort_option_selected(int p_id) {
	sort_by = (DependencyEditorSortBy)p_id;
	_update_menu_sort();
	_update_list();
}

void DependencyEditor::_update_menu_sort() {
	for (int i = 0; i != (int)DependencyEditorSortBy::MAX; i++) {
		menu_sort->get_popup()->set_item_checked(i, (i == (int)sort_by));
	}
}

DependencyEditor::DependencyEditor() {
	VBoxContainer *vb = memnew(VBoxContainer);
	add_child(vb);

	tree = memnew(Tree);
	tree->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
	tree->set_theme_type_variation("TreeTable");
	tree->set_hide_folding(true);
	tree->set_columns((int)Column::MAX);
	tree->set_column_titles_visible(true);
	tree->set_column_title((int)Column::TYPE, TTRC("Type"));
	tree->set_column_clip_content((int)Column::TYPE, true);
	tree->set_column_expand_ratio((int)Column::TYPE, 2);
	tree->set_column_title((int)Column::NAME, TTRC("Name"));
	tree->set_column_clip_content((int)Column::NAME, true);
	tree->set_column_expand_ratio((int)Column::NAME, 3);
	tree->set_column_title((int)Column::PATH, TTRC("Path"));
	tree->set_column_clip_content((int)Column::PATH, true);
	tree->set_column_expand_ratio((int)Column::PATH, 5);
	tree->set_hide_root(true);
	tree->connect("button_clicked", callable_mp(this, &DependencyEditor::_load_pressed));