<commit_before>package org.rust.lang.icons

import com.intellij.ide.IconProvider
import com.intellij.openapi.util.Iconable
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiUtil
import com.intellij.ui.RowIcon
import com.intellij.util.PlatformIcons
import com.intellij.util.VisibilityIcons
import com.intellij.util.ui.EmptyIcon
import org.rust.lang.core.psi.RustStructDeclField
import org.rust.lang.core.psi.impl.*
import javax.swing.Icon

class RustIconProvider: IconProvider() {
    override fun getIcon(element: PsiElement, flags: Int): Icon? {
        return when (element) {
            is RustEnumItemImpl -> RustIcons.ENUM
            is RustStructItemImpl -> RustIcons.CLASS
            is RustStructDeclField -> getStructDeclFieldIcon(element, flags)
            is RustFnItemImpl -> RustIcons.FUNCTION
            is RustImplMethodImpl -> RustIcons.METHOD
            else -> null
        }
    }

    private fun getStructDeclFieldIcon(element: RustStructDeclField, flags: Int): Icon? {
        if ((flags and Iconable.ICON_FLAG_VISIBILITY) == 0)
            return RustIcons.FIELD;

        val icon = RowIcon(RustIcons.FIELD, EmptyIcon.create(PlatformIcons.PUBLIC_ICON))
        val visibility = if (element.pub == null) PsiUtil.ACCESS_LEVEL_PRIVATE else PsiUtil.ACCESS_LEVEL_PUBLIC<commit_msg>Structure View: Add visibility icons to structs<commit_after>package org.rust.lang.icons

import com.intellij.ide.IconProvider
import com.intellij.openapi.util.Iconable
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiUtil
import com.intellij.ui.RowIcon
import com.intellij.util.PlatformIcons
import com.intellij.util.VisibilityIcons
import com.intellij.util.ui.EmptyIcon
import org.rust.lang.core.psi.RustItem
import org.rust.lang.core.psi.RustStructDeclField
import org.rust.lang.core.psi.RustStructItem
import org.rust.lang.core.psi.impl.*
import javax.swing.Icon

class RustIconProvider: IconProvider() {
    override fun getIcon(element: PsiElement, flags: Int): Icon? {
        return when (element) {
            is RustEnumItemImpl -> RustIcons.ENUM
            is RustStructItemImpl -> getStructIcon(element, flags)
            is RustStructDeclField -> getStructDeclFieldIcon(element, flags)
            is RustFnItemImpl -> RustIcons.FUNCTION
            is RustImplMethodImpl -> RustIcons.METHOD
            else -> null
        }
    }

    private fun getStructIcon(element: RustStructItem, flags: Int): Icon? {
        if ((flags and Iconable.ICON_FLAG_VISIBILITY) == 0)
            return RustIcons.CLASS;

        val parent = element.parent?.parent as RustItem?

        val icon = RowIcon(RustIcons.CLASS, EmptyIcon.create(PlatformIcons.PUBLIC_ICON))
        val visibility = if (parent?.pub == null) PsiUtil.ACCESS_LEVEL_PRIVATE else PsiUtil.ACCESS_LEVEL_PUBLIC
        VisibilityIcons.setVisibilityIcon(visibility, icon);
        return icon;
    }

    private fun getStructDeclFieldIcon(element: RustStructDeclField, flags: Int): Icon? {
        if ((flags and Iconable.ICON_FLAG_VISIBILITY) == 0)
            return RustIcons.FIELD;

        val icon = RowIcon(RustIcons.FIELD, EmptyIcon.create(PlatformIcons.PUBLIC_ICON))
        val visibility = if (element.pub == null) PsiUtil.ACCESS_LEVEL_PRIVATE else PsiUtil.ACCESS_LEVEL_PUBLIC
{'fraction_non_alphanumeric': 0.08911791451955138, 'fraction_numerical': 0.0009093664746892998, 'mean_word_length': 3.465493910690122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2224714', 'n_tokens_mistral': 1038, 'n_tokens_neox': 988, 'n_words': 207}