<commit_before>package org.rust.lang.core.psi.impl

import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.tree.IElementType
import org.rust.lang.core.psi.RustLiteral
import org.rust.lang.core.psi.RustLiteralTokenType
import org.rust.lang.core.psi.RustTokenElementTypes.FLOAT_LITERAL
import org.rust.lang.core.psi.RustTokenElementTypes.INTEGER_LITERAL
import org.rust.lang.core.psi.visitors.RustVisitorEx

class RustNumericLiteralImpl(type: IElementType, text: CharSequence) : RustLiteral.Number(type, text) {
    override val valueAsLong: Long?
        get() = this.valueString
            ?.filter { it != '_' }
            ?.let {
                val (start, radix) = when (it.take(2)) {
                    "0b" -> 2 to 2
                    "0o" -> 2 to 8
                    "0x" -> 2 to 16
                    else -> 0 to 10
                }
                try {
                    java.lang.Long.parseUnsignedLong(it.substring(start), radix)
                } catch(e: NumberFormatException) {
                    null
                }
            }

    override val valueAsDouble: Double?
        get() = this.valueString
            ?.filter { it != '_' }
            ?.let {
                try {
                    it.toDouble()
                } catch(e: NumberFormatException) {
                    null
                }
            }

    override val possibleSuffixes: Collection<String>
        get() = when (tokenType) {<commit_msg>(PSI): don't rely on Java 8<commit_after>package org.rust.lang.core.psi.impl

import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.tree.IElementType
import org.rust.lang.core.psi.RustLiteral
import org.rust.lang.core.psi.RustLiteralTokenType
import org.rust.lang.core.psi.RustTokenElementTypes.FLOAT_LITERAL
import org.rust.lang.core.psi.RustTokenElementTypes.INTEGER_LITERAL
import org.rust.lang.core.psi.visitors.RustVisitorEx

class RustNumericLiteralImpl(type: IElementType, text: CharSequence) : RustLiteral.Number(type, text) {
    override val valueAsLong: Long?
        get() = this.valueString
            ?.filter { it != '_' }
            ?.let {
                // We do not expect negative values, because they are treated as
                // unary expressions, not literals, in our lexing/parsing code.
                val (start, radix) = when (it.take(2)) {
                    "0b" -> 2 to 2
                    "0o" -> 2 to 8
                    "0x" -> 2 to 16
                    else -> 0 to 10
                }
                try {
                    java.lang.Long.parseLong(it.substring(start), radix)
                    // TODO: Replace this with: (when we migrate to Java 8)
                    // java.lang.Long.parseUnsignedLong(it.substring(start), radix)
                } catch(e: NumberFormatException) {
                    null
                }
            }

    override val valueAsDouble: Double?
        get() = this.valueString
            ?.filter { it != '_' }
            ?.let {
                try {
                    it.toDouble()
                } catch(e: NumberFormatException) {
                    null
                }
            }

    override val possibleSuffixes: Collection<String>
        get() = when (tokenType) {
{'fraction_non_alphanumeric': 0.10086541330945986, 'fraction_numerical': 0.008952551477170993, 'mean_word_length': 1.624902114330462, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '6890314', 'n_tokens_mistral': 1006, 'n_tokens_neox': 927, 'n_words': 200}