@@ -9,7 +9,7 @@ import Denotations.SingleDenotation
9
9
import SymDenotations .SymDenotation
10
10
import NameKinds .{WildcardParamName , ContextFunctionParamName }
11
11
import parsing .Scanners .Token
12
- import parsing .Tokens
12
+ import parsing .Tokens , Tokens . showToken
13
13
import printing .Highlighting .*
14
14
import printing .Formatting
15
15
import ErrorMessageID .*
@@ -1233,12 +1233,12 @@ extends ReferenceMsg(ForwardReferenceExtendsOverDefinitionID) {
1233
1233
class ExpectedTokenButFound (expected : Token , found : Token , prefix : String = " " , suffix : String = " " )(using Context )
1234
1234
extends SyntaxMsg (ExpectedTokenButFoundID ) {
1235
1235
1236
- private def foundText = Tokens . showToken(found)
1236
+ private def foundText = showToken(found)
1237
1237
1238
1238
def msg (using Context ) =
1239
1239
val expectedText =
1240
1240
if (Tokens .isIdentifier(expected)) " an identifier"
1241
- else Tokens . showToken(expected)
1241
+ else showToken(expected)
1242
1242
i """ $prefix$expectedText expected, but $foundText found $suffix"""
1243
1243
1244
1244
def explain (using Context ) =
@@ -1940,7 +1940,7 @@ class ExtendFinalClass(clazz:Symbol, finalClazz: Symbol)(using Context)
1940
1940
1941
1941
class ExpectedTypeBoundOrEquals (found : Token )(using Context )
1942
1942
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 "
1944
1944
1945
1945
def explain (using Context ) =
1946
1946
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
3745
3745
override protected def msg (using Context ) = i " name ` ${tree.name}` should be enclosed in backticks "
3746
3746
override protected def explain (using Context ): String =
3747
3747
" 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