class SourceFileScanner extends Scanner
A scanner for a given source file not necessarily attached to a compilation unit. Useful for looking inside source files that are not currently compiled to see what's there
- Source
- Scanners.scala
- Alphabetic
- By Inheritance
- SourceFileScanner
- Scanner
- DocScanner
- ScannerCommon
- ScannerData
- TokenData
- CommonTokenData
- CharArrayReader
- CharArrayReaderData
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new SourceFileScanner(source: SourceFile)
Type Members
- class CharArrayLookaheadReader extends CharArrayReader
- Definition Classes
- CharArrayReader
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from SourceFileScanner toany2stringadd[SourceFileScanner] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (SourceFileScanner, B)
- Implicit
- This member is added by an implicit conversion from SourceFileScanner toArrowAssoc[SourceFileScanner] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def adjustSepRegions(lastToken: Scanners.Token): Unit
- Definition Classes
- Scanner
- def applyBracePatch(): Boolean
overridden in UnitScanners: apply brace patch if one exists for this offset return true if subsequent end of line handling should be suppressed.
overridden in UnitScanners: apply brace patch if one exists for this offset return true if subsequent end of line handling should be suppressed.
- Definition Classes
- Scanner
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- val base: Int
the base of a number
the base of a number
- Definition Classes
- TokenData
- def beginDocComment(prefix: String): Unit
- Attributes
- protected
- Definition Classes
- DocScanner
- val buf: Array[Char]
- Definition Classes
- SourceFileScanner → CharArrayReader
- val cbuf: java.lang.StringBuilder
A character buffer for literals
A character buffer for literals
- Definition Classes
- Scanner
- val ch: Char
the last read character
the last read character
- Definition Classes
- CharArrayReaderData
- def charLitOr(op: () => Unit): Unit
Parse character literal if current character is followed by \', or follow with given op and return a symbol literal token
Parse character literal if current character is followed by \', or follow with given op and return a symbol literal token
- Definition Classes
- Scanner
- val charOffset: Int
The offset one past the last read character
The offset one past the last read character
- Definition Classes
- CharArrayReaderData
- def charVal: Char
Convert current strVal to char value.
Convert current strVal to char value.
- Definition Classes
- Scanner
- def checkNoLetter(): Unit
- Definition Classes
- Scanner
- Annotations
- @inline()
- def checkNoTrailingSeparator(): Unit
- Definition Classes
- Scanner
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def copyFrom(sd: ScannerData): SourceFileScanner.this.type
- Definition Classes
- ScannerData
- def copyFrom(td: TokenData): SourceFileScanner.this.type
- Definition Classes
- TokenData
- def copyFrom(cd: CharArrayReaderData): SourceFileScanner.this.type
- Definition Classes
- CharArrayReaderData
- def deprecationWarning(off: Scanners.Offset, msg: String, since: String): Unit
- Definition Classes
- SourceFileScanner → ScannerCommon
- def deprecationWarning(msg: String, since: String): Unit
- Definition Classes
- Scanner
- def discardDocBuffer(): Unit
To prevent doc comments attached to expressions from leaking out of scope onto the next documentable entity, they are discarded upon passing a right brace, bracket, or parenthesis.
To prevent doc comments attached to expressions from leaking out of scope onto the next documentable entity, they are discarded upon passing a right brace, bracket, or parenthesis.
- Definition Classes
- DocScanner
- def doubleVal: Double
- Definition Classes
- Scanner
- Annotations
- @inline()
- def doubleVal(negated: Boolean): Double
Convert current strVal, base to double value.
Convert current strVal, base to double value.
- Definition Classes
- Scanner
- def emitIdentifierDeprecationWarnings: Boolean
Determines whether this scanner should emit identifier deprecation warnings, e.g.
Determines whether this scanner should emit identifier deprecation warnings, e.g. when seeing
macro
orthen
, which are planned to become keywords in future versions of Scala.- Attributes
- protected
- Definition Classes
- Scanner
- def ensuring(cond: (SourceFileScanner) => Boolean, msg: => Any): SourceFileScanner
- Implicit
- This member is added by an implicit conversion from SourceFileScanner toEnsuring[SourceFileScanner] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (SourceFileScanner) => Boolean): SourceFileScanner
- Implicit
- This member is added by an implicit conversion from SourceFileScanner toEnsuring[SourceFileScanner] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): SourceFileScanner
- Implicit
- This member is added by an implicit conversion from SourceFileScanner toEnsuring[SourceFileScanner] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): SourceFileScanner
- Implicit
- This member is added by an implicit conversion from SourceFileScanner toEnsuring[SourceFileScanner] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def error(off: Scanners.Offset, msg: String): Unit
- Definition Classes
- SourceFileScanner → ScannerCommon
- final def fetchToken(): Unit
read next token, filling TokenData fields of Scanner.
read next token, filling TokenData fields of Scanner.
- Attributes
- protected
- Definition Classes
- Scanner
- Annotations
- @tailrec()
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def finishDocComment(): Unit
- Attributes
- protected
- Definition Classes
- DocScanner
- def floatVal: Float
- Definition Classes
- Scanner
- Annotations
- @inline()
- def floatVal(negated: Boolean): Float
Convert current strVal, base to float value.
Convert current strVal, base to float value.
- Definition Classes
- Scanner
- def flushDoc(): Global.DocComment
- Definition Classes
- DocScanner
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from SourceFileScanner toStringFormat[SourceFileScanner] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getFraction(): Unit
read fractional part and exponent of floating point number if one is present.
read fractional part and exponent of floating point number if one is present.
- Attributes
- protected
- Definition Classes
- Scanner
- def getLitChar(): Unit
copy current character into cbuf, interpreting any escape sequences, and advance to next character.
copy current character into cbuf, interpreting any escape sequences, and advance to next character.
- Attributes
- protected
- Definition Classes
- Scanner
- def getNumber(): Unit
Read a number into strVal.
Read a number into strVal.
The
base
can be 2, 10 or 16.- Attributes
- protected
- Definition Classes
- Scanner
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def healBraces(): List[BracePatch]
overridden in UnitScanners
overridden in UnitScanners
- Definition Classes
- Scanner
- def inFirstOfStat(token: Scanners.Token): Boolean
Can token start a statement?
Can token start a statement?
- Definition Classes
- Scanner
- def inLastOfStat(token: Scanners.Token): Boolean
Can token end a statement?
Can token end a statement?
- Definition Classes
- Scanner
- def incompleteInputError(off: Scanners.Offset, msg: String): Unit
- Definition Classes
- SourceFileScanner → ScannerCommon
- def incompleteInputError(msg: String): Unit
signal an error where the input ended in the middle of a token
signal an error where the input ended in the middle of a token
- Definition Classes
- Scanner
- def init(): Unit
Initialization method: read first char, then first token
Initialization method: read first char, then first token
- Definition Classes
- Scanner
- def intVal: Long
- Definition Classes
- Scanner
- Annotations
- @inline()
- def intVal(negated: Boolean): Long
Convert current strVal, base to long value.
Convert current strVal, base to long value. This is tricky because of max negative value.
Conversions in base 2, 10 and 16 are supported. Number separators are skipped on the fly.
- Definition Classes
- Scanner
- def invalidEscape(): Unit
- Attributes
- protected
- Definition Classes
- Scanner
- def invalidUnicodeEscape(n: Int): Unit
- Attributes
- protected
- Definition Classes
- Scanner
- def isAtEnd: Boolean
- Definition Classes
- Scanner
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isTrailingComma(right: Scanners.Token): Boolean
- Definition Classes
- Scanner
- val lastLineStartOffset: Int
The start offset of the line before the current one
The start offset of the line before the current one
- Definition Classes
- CharArrayReaderData
- val lastOffset: Scanners.Offset
the offset of the character following the token preceding this one
the offset of the character following the token preceding this one
- Definition Classes
- TokenData
- val lineStartOffset: Int
The start offset of the current line
The start offset of the current line
- Definition Classes
- CharArrayReaderData
- def lookaheadReader: CharArrayLookaheadReader
A new reader that takes off at the current character position
A new reader that takes off at the current character position
- Definition Classes
- CharArrayReader
- def lookingAhead[A](body: => A): A
- Definition Classes
- Scanner
- val name: Global.TermName
the name of an identifier
the name of an identifier
- Definition Classes
- TokenData → CommonTokenData
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val next: TokenData
we need one token lookahead and one token history
we need one token lookahead and one token history
- Definition Classes
- ScannerData
- final def nextChar(): Unit
Advance one character; reducing CR;LF pairs to just LF
Advance one character; reducing CR;LF pairs to just LF
- Definition Classes
- CharArrayReader
- final def nextRawChar(): Unit
Advance one character, leaving CR;LF pairs intact.
Advance one character, leaving CR;LF pairs intact. This is for use in multi-line strings, so there are no "potential line ends" here.
- Definition Classes
- CharArrayReader
- def nextToken(): Unit
Produce next token, filling TokenData fields of Scanner.
Produce next token, filling TokenData fields of Scanner.
- Definition Classes
- Scanner → ScannerCommon
- def nextTokenAllow(name: Global.Name): Unit
Get next token, and allow the otherwise deprecated ident
name
Get next token, and allow the otherwise deprecated ident
name
- Definition Classes
- Scanner
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val offset: Scanners.Offset
the offset of the first character of the current token
the offset of the first character of the current token
- Definition Classes
- TokenData
- def parenBalance(token: Scanners.Token): Int
overridden in UnitScanners
overridden in UnitScanners
- Definition Classes
- Scanner
- def postProcessToken(): Unit
- Definition Classes
- Scanner
- val prev: TokenData
- Definition Classes
- ScannerData
- def processCommentChar(): Unit
- Attributes
- protected
- Definition Classes
- DocScanner
- def putChar(c: Char): Unit
append Unicode character to "cbuf" buffer
append Unicode character to "cbuf" buffer
- Attributes
- protected
- Definition Classes
- Scanner
- final def putCommentChar(): Unit
- Attributes
- protected
- Definition Classes
- Scanner
- def registerDocComment(raw: String, pos: Global.Position): Unit
- Definition Classes
- DocScanner
- def resume(lastCode: Scanners.Token): Unit
- Definition Classes
- Scanner
- var sepRegions: List[Scanners.Token]
a stack of tokens which indicates whether line-ends can be statement separators also used for keeping track of nesting levels.
a stack of tokens which indicates whether line-ends can be statement separators also used for keeping track of nesting levels. We keep track of the closing symbol of a region. This can be RPAREN if region starts with '(' RBRACKET if region starts with '[' RBRACE if region starts with '{' ARROW if region starts with 'case' STRINGLIT if region is a string interpolation expression starting with '${' (the STRINGLIT appears twice in succession on the stack iff the expression is a multiline string literal).
- Definition Classes
- Scanner
- final def skipComment(): Boolean
Returns true if a comment was skipped.
Returns true if a comment was skipped.
- Definition Classes
- Scanner
- Note
Pre-condition: ch == '/'
- final def skipNestedComments(): Unit
- Definition Classes
- Scanner
- Annotations
- @tailrec()
- def skipToken(): Scanners.Offset
read next token and return last offset
read next token and return last offset
- Definition Classes
- Scanner
- def skipTrailingComma(right: Scanners.Token): Boolean
- Definition Classes
- Scanner → ScannerCommon
- val source: SourceFile
- val strVal: String
the string value of a literal
the string value of a literal
- Definition Classes
- TokenData
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def syntaxError(msg: String): Unit
generate an error at the current token offset
generate an error at the current token offset
- Definition Classes
- Scanner
- def syntaxError(off: Scanners.Offset, msg: String): Unit
generate an error at the given offset
generate an error at the given offset
- Definition Classes
- Scanner
- def toString(): String
- Definition Classes
- Scanner → AnyRef → Any
- val token: Scanners.Token
the next token
the next token
- Definition Classes
- TokenData → CommonTokenData
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def warning(off: Scanners.Offset, msg: String, category: WarningCategory): Unit
- Definition Classes
- SourceFileScanner → ScannerCommon
Deprecated Value Members
- def →[B](y: B): (SourceFileScanner, B)
- Implicit
- This member is added by an implicit conversion from SourceFileScanner toArrowAssoc[SourceFileScanner] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.
The Scala compiler and reflection APIs.