@@ -109,26 +109,26 @@ class JLineTerminal extends java.io.Closeable {
109109 def words = java.util.Collections .emptyList[String ]
110110 }
111111
112- def parse (input : String , cursor : Int , context : ParseContext ): reader.ParsedLine = {
113- def parsedLine (word : String , wordCursor : Int ) =
114- new ParsedLine (cursor, input, word, wordCursor)
112+ def parse (input : String , cursor : Int , context : ParseContext ): reader.ParsedLine =
113+ def parsedLine (word : String , wordCursor : Int ) = ParsedLine (cursor, input, word, wordCursor)
115114 // Used when no word is being completed
116115 def defaultParsedLine = parsedLine(" " , 0 )
117116
118- def incomplete (): Nothing = throw new EOFError (
117+ def incomplete (): Nothing = throw EOFError (
119118 // Using dummy values, not sure what they are used for
120119 /* line = */ - 1 ,
121120 /* column = */ - 1 ,
122121 /* message = */ " " ,
123122 /* missing = */ newLinePrompt)
124123
125124 case class TokenData (token : Token , start : Int , end : Int )
126- def currentToken : TokenData /* | Null */ = {
125+
126+ def currentToken : TokenData /* | Null */ =
127127 val source = SourceFile .virtual(" <completions>" , input)
128128 val scanner = new Scanner (source)(using ctx.fresh.setReporter(Reporter .NoReporter ))
129129 var lastBacktickErrorStart : Option [Int ] = None
130130
131- while ( scanner.token != EOF ) {
131+ while scanner.token != EOF do
132132 val start = scanner.offset
133133 val token = scanner.token
134134 scanner.nextToken()
@@ -138,15 +138,13 @@ class JLineTerminal extends java.io.Closeable {
138138 if (isCurrentToken)
139139 return TokenData (token, lastBacktickErrorStart.getOrElse(start), end)
140140
141-
142141 // we need to enclose the last backtick, which unclosed produces ERROR token
143142 if (token == ERROR && input(start) == '`' ) then
144143 lastBacktickErrorStart = Some (start)
145144 else
146145 lastBacktickErrorStart = None
147- }
148146 null
149- }
147+ end currentToken
150148
151149 def acceptLine = {
152150 val onLastLine = ! input.substring(cursor).contains(System .lineSeparator)
@@ -162,9 +160,9 @@ class JLineTerminal extends java.io.Closeable {
162160 // complete we need to ensure that the :<partial-word> isn't split into
163161 // 2 tokens, but rather the entire thing is treated as the "word", in
164162 // order to insure the : is replaced in the completion.
165- case ParseContext .COMPLETE if
166- ParseResult .commands.exists(command => command._1.startsWith(input)) =>
167- parsedLine(input, cursor)
163+ case ParseContext .COMPLETE
164+ if ParseResult .commands.exists(command => command._1.startsWith(input)) =>
165+ parsedLine(input, cursor)
168166
169167 case ParseContext .COMPLETE =>
170168 // Parse to find completions (typically after a Tab).
@@ -181,6 +179,6 @@ class JLineTerminal extends java.io.Closeable {
181179 case _ =>
182180 incomplete()
183181 }
184- }
182+ end parse
185183 }
186184}
0 commit comments