From 1c140f6078cc4add08e1a138e24b369239963136 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Tue, 26 Sep 2023 21:06:24 +0200 Subject: [PATCH] chore: Update Scalameta to 4.8.11 --- .../internal/pc/completions/Completions.scala | 2 +- .../metals/docstrings/ScaladocUtils.scala | 8 ++++++++ .../meta/internal/mtags/JavaToplevelMtags.scala | 17 +++++++++-------- .../internal/mtags/ScalaToplevelMtags.scala | 1 - project/V.scala | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/completions/Completions.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/completions/Completions.scala index ceba2fc348f..ca6dd82739c 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/completions/Completions.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/completions/Completions.scala @@ -876,7 +876,7 @@ trait Completions { this: MetalsGlobal => def inferStart( pos: Position, text: String, - charPred: Char => Boolean + charPred: Int => Boolean ): Int = { def fallback: Int = { var i = pos.point - 1 diff --git a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/ScaladocUtils.scala b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/ScaladocUtils.scala index 5c4b5129b2c..8ae2fd090b1 100644 --- a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/ScaladocUtils.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/ScaladocUtils.scala @@ -7,6 +7,10 @@ import scala.meta.internal.tokenizers.Chars._ */ object ScaladocUtils { + /** Is character a whitespace character (but not a new line)? */ + def isWhitespace(c: Char) = + c == ' ' || c == '\t' || c == CR + /** * Returns index of string `str` following `start` skipping longest * sequence of whitespace characters characters (but no newlines) @@ -194,6 +198,10 @@ object ScaladocUtils { else str + /** Can character form part of a doc comment variable xxx? */ + def isVarPart(c: Char) = + '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' + /** * Returns index following variable, or start index if no variable was recognized */ diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/JavaToplevelMtags.scala b/mtags/src/main/scala/scala/meta/internal/mtags/JavaToplevelMtags.scala index 80fee852cfb..1d190bf9d58 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/JavaToplevelMtags.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/JavaToplevelMtags.scala @@ -82,13 +82,14 @@ class JavaToplevelMtags(val input: Input.VirtualFile) extends MtagsIndexer { val ch = reader.ch if (ch != SU && Character.isJavaIdentifierPart(ch)) { reader.nextChar() - kwOrIdent(start, builder.append(ch)) + kwOrIdent(start, builder.append(ch.toChar)) } else if (builder.isEmpty) { throw new Exception( s"Unexpected symbol at word pos: '$ch'. Line: '$readCurrentLine'" ) } else { - val pos = Position.Range(input, start, reader.charOffset) + + val pos = Position.Range(input, start, reader.endCharOffset) builder.mkString match { case "package" => Token.Package case "class" => Token.Class @@ -133,13 +134,13 @@ class JavaToplevelMtags(val input: Input.VirtualFile) extends MtagsIndexer { parseToken case _ => val token = kwOrIdent( - reader.charOffset - 1, - new StringBuilder().append(first).append(next) + reader.begCharOffset, + new StringBuilder().append(first.toChar).append(next.toChar) ) (token, true) } case _ => - val token = kwOrIdent(reader.charOffset, new StringBuilder(first)) + val token = kwOrIdent(reader.endCharOffset, new StringBuilder(first)) (token, true) } } @@ -205,7 +206,7 @@ class JavaToplevelMtags(val input: Input.VirtualFile) extends MtagsIndexer { @tailrec private def toNextNonWhiteSpace(): Unit = { - if (isWhitespace(reader.ch)) { + if (isWhitespace(reader.ch.toChar)) { reader.nextChar() toNextNonWhiteSpace() } @@ -213,7 +214,7 @@ class JavaToplevelMtags(val input: Input.VirtualFile) extends MtagsIndexer { private def readCurrentLine: String = { def loop(builder: StringBuilder): String = { - val ch = reader.ch + val ch = reader.ch.toChar if (ch == '\n' || ch == SU) builder.mkString else { @@ -224,7 +225,7 @@ class JavaToplevelMtags(val input: Input.VirtualFile) extends MtagsIndexer { } val lineOffset = reader.lineStartOffset - val existing = input.text.substring(lineOffset, reader.charOffset) + val existing = input.text.substring(lineOffset, reader.endCharOffset) loop(new StringBuilder().append(existing)) } diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala b/mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala index 3ba1066a8cd..ca8e71bfd76 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala @@ -688,7 +688,6 @@ class ScalaToplevelMtags( case WHITESPACE => nextIsNL() case COMMENT => - scanner.skipComment() nextIsNL() case _ => false } diff --git a/project/V.scala b/project/V.scala index b855fec30e3..376933077fe 100644 --- a/project/V.scala +++ b/project/V.scala @@ -41,7 +41,7 @@ object V { val scalaCli = "1.0.4" val scalafix = "0.11.1" val scalafmt = "3.7.14" - val scalameta = "4.8.10" + val scalameta = "4.8.11" val scribe = "3.12.2" val qdox = "2.0.3"