<commit_before>package org.jetbrains.kotlin.ui.editors

import org.eclipse.jdt.core.IBuffer
import org.eclipse.jdt.core.IClassFile
import org.eclipse.jdt.core.IJavaProject
import org.eclipse.jdt.core.JavaModelException
import org.eclipse.jdt.internal.core.BufferManager
import org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput
import org.eclipse.jdt.internal.compiler.env.IBinaryType
import org.jetbrains.kotlin.core.resolve.KotlinSourceIndex
import org.eclipse.jdt.internal.core.PackageFragment
import org.eclipse.jdt.internal.core.ClassFile
import org.eclipse.jdt.internal.core.BinaryType

public class KotlinClassFileEditorInput(classFile:IClassFile, private val javaProject:IJavaProject?):InternalClassFileEditorInput(classFile) {

    private fun compareSources(another:KotlinClassFileEditorInput):Boolean {
        try {
            val sourceShortName = getSourceShortName() ?: return false
            val anotherSourceShortName = another.getSourceShortName() ?: return false
            return when {
                sourceShortName != anotherSourceShortName -> false
                getClassFile().getParent() == another.getClassFile().getParent() -> true
                else -> resolveShortSourceName(sourceShortName) == another.resolveShortSourceName(anotherSourceShortName)
            }
        } catch (e:JavaModelException) {
            return false
        }
    }

    override public fun equals(other: Any?):Boolean =
            when {
                super.equals(other) -> true
                other is KotlinClassFileEditorInput -> compareSources(other)
                else -> false
            }

    private fun getSourceShortName() =
            (getClassFile().getType() as? BinaryType)?.getSourceFileName(null)?.toString()

    private fun resolveShortSourceName(simpleSourceFileName: String): String {
        val index = KotlinSourceIndex.getInstance(javaProject);
        val packageFragment = getClassFile().getParent() as PackageFragment;
        return index.resolvePath(packageFragment, simpleSourceFileName);
    }
}<commit_msg>Source filename is used as a tooltip and a tab name in the class file editor now.<commit_after>package org.jetbrains.kotlin.ui.editors

import org.eclipse.jdt.core.IBuffer
import org.eclipse.jdt.core.IClassFile
import org.eclipse.jdt.core.IJavaProject
import org.eclipse.jdt.core.JavaModelException
import org.eclipse.jdt.internal.core.BufferManager
import org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput
import org.eclipse.jdt.internal.compiler.env.IBinaryType
import org.jetbrains.kotlin.core.resolve.KotlinSourceIndex
import org.eclipse.jdt.internal.core.PackageFragment
import org.eclipse.jdt.internal.core.ClassFile
import org.eclipse.jdt.internal.core.BinaryType

public class KotlinClassFileEditorInput(classFile:IClassFile, private val javaProject:IJavaProject?):InternalClassFileEditorInput(classFile) {
    private val sourceShortName: String?
    private val sourceFullPath: String?

    init {
        sourceShortName = (getClassFile().getType() as? BinaryType)?.getSourceFileName(null)?.toString()
        sourceFullPath = if (sourceShortName != null) {
            val index = KotlinSourceIndex.getInstance(javaProject)
            val packageFragment = getClassFile().getParent() as PackageFragment
            index.resolvePath(packageFragment, sourceShortName)
        } else {
            null
        }
    }

    private fun compareSources(another:KotlinClassFileEditorInput):Boolean {
        if (sourceShortName == null || another.sourceShortName == null) {
            return false
        }
        return when {
            sourceShortName != another.sourceShortName -> false
            getClassFile().getParent() == another.getClassFile().getParent() -> true
            else -> sourceFullPath == another.sourceFullPath
        }
    }

    override public fun equals(other: Any?):Boolean =
            when {
                super.equals(other) -> true
                other is KotlinClassFileEditorInput -> compareSources(other)
                else -> false
            }

    override fun getName() =
            sourceShortName ?: super.getName()

    override fun getToolTipText() =
            sourceFullPath ?: super.getToolTipText()
}
{'fraction_non_alphanumeric': 0.0895906432748538, 'fraction_numerical': 0.0, 'mean_word_length': 3.250497017892644, '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': '1093023', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1112, 'n_words': 215}