Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tokenizers.Chars: remove unused methods #3331

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package internal
package tokenizers

import scala.annotation.switch
import java.lang.{Character => JCharacter}
import scala.language.postfixOps

/** Contains constants and classifier methods for characters */
Expand Down Expand Up @@ -33,36 +32,6 @@ object Chars {
if (0 <= num && num < base) num else -1
}

/** Buffer for creating '\ u XXXX' strings. */
private[this] val char2uescapeArray = Array[Char]('\\', 'u', 0, 0, 0, 0)

/** Convert a character to a backslash-u escape */
def char2uescape(c: Char): String = {
@inline def hexChar(ch: Int): Char =
(if (ch < 10) '0' else 'A' - 10) + ch toChar

char2uescapeArray(2) = hexChar((c >> 12))
char2uescapeArray(3) = hexChar((c >> 8) % 16)
char2uescapeArray(4) = hexChar((c >> 4) % 16)
char2uescapeArray(5) = hexChar((c) % 16)

new String(char2uescapeArray)
}

/** Is character a line break? */
def isLineBreakChar(c: Char) = (c: @switch) match {
case LF | FF | CR | SU => true
case _ => false
}

/** Is character a whitespace character (but not a new line)? */
def isWhitespace(c: Char) =
c == ' ' || c == '\t' || c == CR

/** Can character form part of a doc comment variable xxx? */
def isVarPart(c: Char) =
'0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'

/** Can character start an alphanumeric Scala identifier? */
@inline def isIdentifierStart(c: Char): Boolean =
(c == '_') || isIdentifierPart(c)
Expand All @@ -81,13 +50,6 @@ object Chars {
chtp == Character.MATH_SYMBOL.toInt || chtp == Character.OTHER_SYMBOL.toInt
}

private final val otherLetters = Set[Char]('\u0024', '\u005F') // '$' and '_'
private final val letterGroups = {
import JCharacter._
Set[Byte](LOWERCASE_LETTER, UPPERCASE_LETTER, OTHER_LETTER, TITLECASE_LETTER, LETTER_NUMBER)
}
def isScalaLetter(ch: Char) = letterGroups(JCharacter.getType(ch).toByte) || otherLetters(ch)

/** Can character form part of a Scala operator name? */
def isOperatorPart(c: Char): Boolean = (c: @switch) match {
case '~' | '!' | '@' | '#' | '%' | '^' | '*' | '+' | '-' | '<' | '>' | '?' | ':' | '=' | '&' |
Expand All @@ -96,16 +58,6 @@ object Chars {
case c => isSpecial(c)
}

/**
* {{{
* (#x20 | #x9 | #xD | #xA)
* }}}
*/
final def isSpace(ch: Char): Boolean = ch match {
case '\u0009' | '\u000A' | '\u000D' | '\u0020' => true
case _ => false
}

/**
* {{{
* NameChar ::= Letter | Digit | '.' | '-' | '_' | ':'
Expand Down