@@ -9,7 +9,7 @@ import Denotations.SingleDenotation
99import SymDenotations .SymDenotation
1010import NameKinds .{WildcardParamName , ContextFunctionParamName }
1111import parsing .Scanners .Token
12- import parsing .Tokens
12+ import parsing .Tokens , Tokens . showToken
1313import printing .Highlighting .*
1414import printing .Formatting
1515import ErrorMessageID .*
@@ -1233,12 +1233,12 @@ extends ReferenceMsg(ForwardReferenceExtendsOverDefinitionID) {
12331233class ExpectedTokenButFound (expected : Token , found : Token , prefix : String = " " , suffix : String = " " )(using Context )
12341234extends SyntaxMsg (ExpectedTokenButFoundID ) {
12351235
1236- private def foundText = Tokens . showToken(found)
1236+ private def foundText = showToken(found)
12371237
12381238 def msg (using Context ) =
12391239 val expectedText =
12401240 if (Tokens .isIdentifier(expected)) " an identifier"
1241- else Tokens . showToken(expected)
1241+ else showToken(expected)
12421242 i """ $prefix$expectedText expected, but $foundText found $suffix"""
12431243
12441244 def explain (using Context ) =
@@ -1940,7 +1940,7 @@ class ExtendFinalClass(clazz:Symbol, finalClazz: Symbol)(using Context)
19401940
19411941class ExpectedTypeBoundOrEquals (found : Token )(using Context )
19421942 extends SyntaxMsg (ExpectedTypeBoundOrEqualsID ) {
1943- def msg (using Context ) = i " ${hl(" =" )}, ${hl(" >:" )}, or ${hl(" <:" )} expected, but ${Tokens . showToken(found)} found "
1943+ def msg (using Context ) = i " ${hl(" =" )}, ${hl(" >:" )}, or ${hl(" <:" )} expected, but ${showToken(found)} found "
19441944
19451945 def explain (using Context ) =
19461946 i """ Type parameters and abstract types may be constrained by a type bound.
@@ -3745,3 +3745,14 @@ class AmbiguousTemplateName(tree: NamedDefTree[?])(using Context) extends Syntax
37453745 override protected def msg (using Context ) = i " name ` ${tree.name}` should be enclosed in backticks "
37463746 override protected def explain (using Context ): String =
37473747 " Names with trailing operator characters may fuse with a subsequent colon if not set off by backquotes or spaces."
3748+
3749+ class IndentationWarning (isLeft : Boolean = false , before : String = " " , missing : Token * )(using Context )
3750+ extends SyntaxMsg (IndentationWarningID ):
3751+ override protected def msg (using Context ) =
3752+ s " Line is indented too far to the ${if isLeft then " left" else " right" }, or a ${
3753+ missing.map(showToken).mkString(" or " )
3754+ } is missing ${
3755+ if ! before.isEmpty then i " before: \n\n $before" else " "
3756+ }"
3757+ override protected def explain (using Context ): String =
3758+ " Indentation that does not reflect syntactic nesting may be due to a typo such as missing punctuation."
0 commit comments