Skip to content

Make sure deprecated Chars is not used #6926

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/NameOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package core
import java.security.MessageDigest
import scala.io.Codec
import Names._, StdNames._, Contexts._, Symbols._, Flags._, NameKinds._, Types._
import scala.tasty.util.Chars
import scala.internal.Chars
import Chars.isOperatorPart
import Definitions._

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import util.NameTransformer
import printing.{Showable, Texts, Printer}
import Texts.Text
import StdNames.str
import scala.tasty.util.Chars.isIdentifierStart
import scala.internal.Chars.isIdentifierStart
import collection.immutable
import config.Config
import java.util.HashMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools
package dotc
package parsing

import scala.tasty.util.Chars._
import scala.internal.Chars._

abstract class CharArrayReader { self =>

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Scanners._
import util.SourceFile
import JavaTokens._
import scala.annotation.{ switch, tailrec }
import scala.tasty.util.Chars._
import scala.internal.Chars._

object JavaScanners {

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Constants._
import Symbols.defn
import ScriptParsers._
import Decorators._
import scala.tasty.util.Chars.isIdentifierStart
import scala.internal.Chars.isIdentifierStart
import scala.annotation.{tailrec, switch}
import rewrites.Rewrites.patch

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import core.Names._, core.Contexts._, core.Decorators._, util.Spans._
import core.StdNames._, core.Comments._
import util.SourceFile
import java.lang.Character.isDigit
import scala.tasty.util.Chars._
import scala.internal.Chars._
import util.NameTransformer.avoidIllegalChars
import util.Spans.Span
import Tokens._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/package.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dotty.tools.dotc

import scala.tasty.util.Chars._
import scala.internal.Chars._
import core.Names.Name
import core.StdNames.nme
import core.NameOps._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package parsing
package xml

import Utility._
import scala.tasty.util.Chars.SU
import scala.internal.Chars.SU



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package xml
import scala.collection.mutable
import mutable.{ Buffer, ArrayBuffer, ListBuffer }
import scala.util.control.ControlThrowable
import scala.tasty.util.Chars.SU
import scala.internal.Chars.SU
import Parsers._
import util.Spans._
import core._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/xml/Utility.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scala.collection.mutable
* @author Burak Emir
*/
object Utility {
import scala.tasty.util.Chars.SU
import scala.internal.Chars.SU

private val unescMap = Map(
"lt" -> '<',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import typer.ProtoTypes._
import Trees._
import TypeApplications._
import Decorators._
import scala.tasty.util.Chars.isOperatorPart
import scala.internal.Chars.isOperatorPart
import transform.TypeUtils._

import language.implicitConversions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import printing.SyntaxHighlighting
import diagnostic.{ErrorMessageID, Message, MessageContainer}
import diagnostic.messages._
import util.SourcePosition
import scala.tasty.util.Chars.{ LF, CR, FF, SU }
import scala.internal.Chars.{ LF, CR, FF, SU }
import scala.annotation.switch

import scala.collection.mutable
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/TreeChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import typer.ErrorReporting._
import reporting.ThrowingReporter
import ast.Trees._
import ast.{tpd, untpd}
import scala.tasty.util.Chars._
import scala.internal.Chars._
import collection.mutable
import ProtoTypes._

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import transform.patmat.SpaceEngine.isIrrefutableUnapply
import collection.mutable
import reporting.diagnostic.Message
import reporting.diagnostic.messages._
import scala.tasty.util.Chars.isOperatorPart
import scala.internal.Chars.isOperatorPart

object Checking {
import tpd._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/util/CommentParsing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import scala.collection.mutable
* handled by dottydoc.
*/
object CommentParsing {
import scala.tasty.util.Chars._
import scala.internal.Chars._

/** Returns index of string `str` following `start` skipping longest
* sequence of whitespace characters characters (but no newlines)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/util/SourceFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import scala.collection.mutable.ArrayBuffer
import dotty.tools.io._
import java.util.regex.Pattern
import java.io.IOException
import scala.tasty.util.Chars._
import scala.internal.Chars._
import Spans._
import scala.io.Codec
import core.Names.TermName
Expand Down
16 changes: 16 additions & 0 deletions library/src/scala/tasty/util/Chars.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ import java.lang.Character.UPPERCASE_LETTER
@deprecated("Use scala.internal.Chars", "0.17")
object Chars {

@deprecated("Use scala.internal.Chars", "0.18")
final val LF = '\u000A'
@deprecated("Use scala.internal.Chars", "0.18")
final val FF = '\u000C'
@deprecated("Use scala.internal.Chars", "0.18")
final val CR = '\u000D'
@deprecated("Use scala.internal.Chars", "0.18")
final val SU = '\u001A'

/** Convert a character digit to an Int according to given base,
* -1 if no success
*/
@deprecated("Use scala.internal.Chars", "0.18")
def digit2int(ch: Char, base: Int): Int = {
val num = (
if (ch <= '9') ch - '0'
Expand All @@ -33,6 +38,7 @@ object Chars {
private[this] val char2uescapeArray = Array[Char]('\\', 'u', 0, 0, 0, 0)

/** Convert a character to a backslash-u escape */
@deprecated("Use scala.internal.Chars", "0.18")
def char2uescape(c: Char): String = {
@forceInline def hexChar(ch: Int): Char =
(( if (ch < 10) '0' else 'A' - 10 ) + ch).toChar
Expand All @@ -46,36 +52,44 @@ object Chars {
}

/** Is character a line break? */
@deprecated("Use scala.internal.Chars", "0.18")
def isLineBreakChar(c: Char): Boolean = (c: @switch) match {
case LF|FF|CR|SU => true
case _ => false
}

/** Is character a whitespace character (but not a new line)? */
@deprecated("Use scala.internal.Chars", "0.18")
def isWhitespace(c: Char): Boolean =
c == ' ' || c == '\t' || c == CR

/** Can character form part of a doc comment variable $xxx? */
@deprecated("Use scala.internal.Chars", "0.18")
def isVarPart(c: Char): Boolean =
'0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'

/** Can character start an alphanumeric Scala identifier? */
@deprecated("Use scala.internal.Chars", "0.18")
def isIdentifierStart(c: Char): Boolean =
(c == '_') || (c == '$') || JCharacter.isUnicodeIdentifierStart(c)

/** Can character form part of an alphanumeric Scala identifier? */
@deprecated("Use scala.internal.Chars", "0.18")
def isIdentifierPart(c: Char): Boolean =
(c == '$') || JCharacter.isUnicodeIdentifierPart(c)

/** Is character a math or other symbol in Unicode? */
@deprecated("Use scala.internal.Chars", "0.18")
def isSpecial(c: Char): Boolean = {
val chtp = JCharacter.getType(c)
chtp == JCharacter.MATH_SYMBOL.toInt || chtp == JCharacter.OTHER_SYMBOL.toInt
}

@deprecated("Use scala.internal.Chars", "0.18")
def isValidJVMChar(c: Char): Boolean =
!(c == '.' || c == ';' || c =='[' || c == '/')

@deprecated("Use scala.internal.Chars", "0.18")
def isValidJVMMethodChar(c: Char): Boolean =
!(c == '.' || c == ';' || c =='[' || c == '/' || c == '<' || c == '>')

Expand All @@ -84,9 +98,11 @@ object Chars {
import JCharacter._
Set[Byte](LOWERCASE_LETTER, UPPERCASE_LETTER, OTHER_LETTER, TITLECASE_LETTER, LETTER_NUMBER)
}
@deprecated("Use scala.internal.Chars", "0.18")
def isScalaLetter(ch: Char): Boolean = letterGroups(JCharacter.getType(ch).toByte) || otherLetters(ch)

/** Can character form part of a Scala operator name? */
@deprecated("Use scala.internal.Chars", "0.18")
def isOperatorPart(c : Char) : Boolean = (c: @switch) match {
case '~' | '!' | '@' | '#' | '%' |
'^' | '*' | '+' | '-' | '<' |
Expand Down