diff --git a/compiler/src/dotty/tools/dotc/ast/NavigateAST.scala b/compiler/src/dotty/tools/dotc/ast/NavigateAST.scala index f83f12e1c027..2aeb2f7df067 100644 --- a/compiler/src/dotty/tools/dotc/ast/NavigateAST.scala +++ b/compiler/src/dotty/tools/dotc/ast/NavigateAST.scala @@ -3,6 +3,7 @@ package ast import core.Contexts.* import core.Decorators.* +import core.StdNames import util.Spans.* import Trees.{Closure, MemberDef, DefTree, WithLazyFields} import dotty.tools.dotc.core.Types.AnnotatedType @@ -76,6 +77,8 @@ object NavigateAST { var bestFit: List[Positioned] = path while (it.hasNext) { val path1 = it.next() match { + // FIXME this has to be changed to deterministicaly find recoveed tree + case untpd.Select(qual, name) if name == StdNames.nme.??? => path case p: Positioned if !p.isInstanceOf[Closure[?]] => singlePath(p, path) case m: untpd.Modifiers => childPath(m.productIterator, path) case xs: List[?] => childPath(xs.iterator, path) @@ -84,11 +87,17 @@ object NavigateAST { if ((path1 ne path) && ((bestFit eq path) || bestFit.head.span != path1.head.span && - bestFit.head.span.contains(path1.head.span))) + envelops(bestFit.head.span, path1.head.span))) bestFit = path1 } bestFit } + + def envelops(a: Span, b: Span): Boolean = + !b.exists || a.exists && ( + (a.start < b.start && a.end >= b.end ) || (a.start <= b.start && a.end > b.end) + ) + /* * Annotations trees are located in the Type */ diff --git a/compiler/src/dotty/tools/dotc/interactive/Completion.scala b/compiler/src/dotty/tools/dotc/interactive/Completion.scala index 7882d635f84a..c1449c7236d9 100644 --- a/compiler/src/dotty/tools/dotc/interactive/Completion.scala +++ b/compiler/src/dotty/tools/dotc/interactive/Completion.scala @@ -119,16 +119,17 @@ object Completion: case _ => "" + def naiveCompletionPrefix(text: String, offset: Int): String = + var i = offset - 1 + while i >= 0 && text(i).isUnicodeIdentifierPart do i -= 1 + i += 1 // move to first character + text.slice(i, offset) + /** * Inspect `path` to determine the completion prefix. Only symbols whose name start with the * returned prefix should be considered. */ def completionPrefix(path: List[untpd.Tree], pos: SourcePosition)(using Context): String = - def fallback: Int = - var i = pos.point - 1 - while i >= 0 && Character.isUnicodeIdentifierPart(pos.source.content()(i)) do i -= 1 - i + 1 - path match case GenericImportSelector(sel) => if sel.isGiven then completionPrefix(sel.bound :: Nil, pos) @@ -146,7 +147,7 @@ object Completion: case (tree: untpd.RefTree) :: _ if tree.name != nme.ERROR => tree.name.toString.take(pos.span.point - tree.span.point) - case _ => pos.source.content.slice(fallback, pos.point).mkString + case _ => naiveCompletionPrefix(pos.source.content().mkString, pos.point) end completionPrefix diff --git a/language-server/test/dotty/tools/languageserver/CompletionTest.scala b/language-server/test/dotty/tools/languageserver/CompletionTest.scala index d64bb44c1a5d..163584e2cb14 100644 --- a/language-server/test/dotty/tools/languageserver/CompletionTest.scala +++ b/language-server/test/dotty/tools/languageserver/CompletionTest.scala @@ -1705,6 +1705,15 @@ class CompletionTest { ("getOrElse", Method, "[V1 >: String](key: Int, default: => V1): V1"), )) + @Test def testtest: Unit = + code"""|object M { + | def sel$m1 + |} + |""" + .completion(m1, Set( + ("getOrElse", Method, "[V1 >: String](key: Int, default: => V1): V1"), + )) + @Test def noEnumCompletionInNewContext: Unit = code"""|enum TestEnum: | case TestCase diff --git a/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala index ded7845ffa4e..0252786c20f6 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala @@ -67,7 +67,7 @@ final class AutoImportsProvider( val results = symbols.result.filter(isExactMatch(_, name)) if results.nonEmpty then - val correctedPos = CompletionPos.infer(pos, params, path).toSourcePosition + val correctedPos = CompletionPos.infer(pos, params, path, false).toSourcePosition val mkEdit = path match // if we are in import section just specify full name diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionPos.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionPos.scala index ad571ff843c3..6d89cb663b9c 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionPos.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionPos.scala @@ -22,7 +22,8 @@ case class CompletionPos( identEnd: Int, query: String, originalCursorPosition: SourcePosition, - sourceUri: URI + sourceUri: URI, + withCURSOR: Boolean ): def queryEnd: Int = originalCursorPosition.point def stripSuffixEditRange: l.Range = new l.Range(originalCursorPosition.offsetToPos(queryStart), originalCursorPosition.offsetToPos(identEnd)) @@ -34,17 +35,19 @@ object CompletionPos: def infer( sourcePos: SourcePosition, offsetParams: OffsetParams, - adjustedPath: List[Tree] + adjustedPath: List[Tree], + wasCursorApplied: Boolean )(using Context): CompletionPos = val identEnd = adjustedPath match case (refTree: RefTree) :: _ if refTree.name.toString.contains(Cursor.value) => refTree.span.end - Cursor.value.length + case (refTree: RefTree) :: _ => refTree.span.end case _ => sourcePos.end val query = Completion.completionPrefix(adjustedPath, sourcePos) val start = sourcePos.end - query.length() - CompletionPos(start, identEnd, query.nn, sourcePos, offsetParams.uri.nn) + CompletionPos(start, identEnd, query.nn, sourcePos, offsetParams.uri.nn, wasCursorApplied) /** * Infer the indentation by counting the number of spaces in the given line. diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala index 9cd98de33141..1b8bdeb7e8cf 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala @@ -14,9 +14,12 @@ import dotty.tools.dotc.ast.tpd.* import dotty.tools.dotc.core.Constants.Constant import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Phases -import dotty.tools.dotc.core.StdNames +import dotty.tools.dotc.core.StdNames.nme +import dotty.tools.dotc.core.Flags import dotty.tools.dotc.interactive.Interactive +import dotty.tools.dotc.interactive.Completion import dotty.tools.dotc.interactive.InteractiveDriver +import dotty.tools.dotc.parsing.Tokens import dotty.tools.dotc.util.SourceFile import dotty.tools.pc.AutoImports.AutoImportEdits import dotty.tools.pc.AutoImports.AutoImportsGenerator @@ -45,23 +48,31 @@ class CompletionProvider( val uri = params.uri().nn val text = params.text().nn - val code = applyCompletionCursor(params) + val (wasCursorApplied, code) = applyCompletionCursor(params) val sourceFile = SourceFile.virtual(uri, code) driver.run(uri, sourceFile) - val ctx = driver.currentCtx + given ctx: Context = driver.currentCtx val pos = driver.sourcePosition(params) val (items, isIncomplete) = driver.compilationUnits.get(uri) match case Some(unit) => - val newctx = ctx.fresh.setCompilationUnit(unit).withPhase(Phases.typerPhase(using ctx)) - val tpdPath = Interactive.pathTo(newctx.compilationUnit.tpdTree, pos.span)(using newctx) - val adjustedPath = Interactive.resolveTypedOrUntypedPath(tpdPath, pos)(using newctx) + val tpdPath0 = Interactive.pathTo(unit.tpdTree, pos.span)(using newctx) + val adjustedPath = Interactive.resolveTypedOrUntypedPath(tpdPath0, pos)(using newctx) + + val tpdPath = tpdPath0 match + // $1$ // FIXME add check for a $1$ name to make sure we only do the below in lifting case + case Select(qual, name) :: tail if qual.symbol.is(Flags.Synthetic) => + qual.symbol.defTree match + case valdef: ValDef => Select(valdef.rhs, name) :: tail + case _ => tpdPath0 + case _ => tpdPath0 + val locatedCtx = Interactive.contextOfPath(tpdPath)(using newctx) val indexedCtx = IndexedContext(locatedCtx) - val completionPos = CompletionPos.infer(pos, params, adjustedPath)(using locatedCtx) + val completionPos = CompletionPos.infer(pos, params, adjustedPath, wasCursorApplied)(using locatedCtx) val autoImportsGen = AutoImports.generator( completionPos.toSourcePosition, @@ -111,6 +122,10 @@ class CompletionProvider( ) end completions + val allKeywords = + val softKeywords = Tokens.softModifierNames + nme.as + nme.derives + nme.extension + nme.throws + nme.using + Tokens.keywords.toList.map(Tokens.tokenString) ++ softKeywords.map(_.toString) + /** * In case if completion comes from empty line like: * {{{ @@ -123,23 +138,30 @@ class CompletionProvider( * Otherwise, completion poisition doesn't point at any tree * because scala parser trim end position to the last statement pos. */ - private def applyCompletionCursor(params: OffsetParams): String = + private def applyCompletionCursor(params: OffsetParams): (Boolean, String) = val text = params.text().nn val offset = params.offset().nn + val query = Completion.naiveCompletionPrefix(text, offset) - val isStartMultilineComment = - val i = params.offset() - i >= 3 && (text.charAt(i - 1) match - case '*' => - text.charAt(i - 2) == '*' && - text.charAt(i - 3) == '/' - case _ => false - ) - if isStartMultilineComment then - // Insert potentially missing `*/` to avoid comment out all codes after the "/**". - text.substring(0, offset).nn + Cursor.value + "*/" + text.substring(offset) + if offset > 0 && text.charAt(offset - 1).isUnicodeIdentifierPart && !allKeywords.contains(query) then + false -> text else - text.substring(0, offset).nn + Cursor.value + text.substring(offset) + val isStartMultilineComment = + + val i = params.offset() + i >= 3 && (text.charAt(i - 1) match + case '*' => + text.charAt(i - 2) == '*' && + text.charAt(i - 3) == '/' + case _ => false + ) + true -> ( + if isStartMultilineComment then + // Insert potentially missing `*/` to avoid comment out all codes after the "/**". + text.substring(0, offset).nn + Cursor.value + "*/" + text.substring(offset) + else + text.substring(0, offset).nn + Cursor.value + text.substring(offset) + ) end applyCompletionCursor private def completionItems( @@ -172,7 +194,7 @@ class CompletionProvider( Select(Apply(Select(Select(_, name), _), _), _), _ ) :: _ => - name == StdNames.nme.StringContext + name == nme.StringContext // "My name is $name" case Literal(Constant(_: String)) :: _ => true diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala index db578e32663f..24c6e51f86f0 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala @@ -63,11 +63,9 @@ class Completions( /* In case of `method@@()` we should not add snippets and the path * will contain apply as the parent of the current tree. */ - case (fun) :: (appl: GenericApply) :: _ if appl.fun == fun => - false - case _ :: (withcursor @ Select(fun, name)) :: (appl: GenericApply) :: _ - if appl.fun == withcursor && name.decoded == Cursor.value => - false + case (fun) :: (appl: GenericApply) :: _ if appl.fun == fun => false + case sel :: (funSel @ Select(fun, name)) :: (appl: GenericApply) :: _ + if appl.fun == funSel && sel == fun => false case (_: (Import | Export)) :: _ => false case _ :: (_: (Import | Export)) :: _ => false // UnApply has patterns included in MatchCaseCompletions @@ -511,14 +509,8 @@ class Completions( if tree.selectors.exists(_.renamed.sourcePos.contains(pos)) => (List.empty, true) - // From Scala 3.1.3-RC3 (as far as I know), path contains - // `Literal(Constant(null))` on head for an incomplete program, in this case, just ignore the head. - case Literal(Constant(null)) :: tl => - advancedCompletions(tl, completionPos) - case _ => val args = NamedArgCompletions.contribute( - pos, path, adjustedPath, indexedContext, diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala index 2e39c17b24b3..da46e5167834 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala @@ -224,7 +224,7 @@ object InterpolatorCompletions: buildTargetIdentifier: String )(using ctx: Context, reportsContext: ReportContext): List[CompletionValue] = val litStartPos = lit.span.start - val litEndPos = lit.span.end - Cursor.value.length() + val litEndPos = lit.span.end - (if completionPos.withCURSOR then Cursor.value.length else 0) val position = completionPos.originalCursorPosition val span = position.span val nameStart = diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/NamedArgCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/NamedArgCompletions.scala index 647b151a635b..11b0cd660f42 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/NamedArgCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/NamedArgCompletions.scala @@ -35,9 +35,8 @@ import scala.annotation.tailrec object NamedArgCompletions: def contribute( - pos: SourcePosition, path: List[Tree], - untypedPath: => List[untpd.Tree], + untypedPath: List[untpd.Tree], indexedContext: IndexedContext, clientSupportsSnippets: Boolean, )(using ctx: Context): List[CompletionValue] = @@ -64,12 +63,13 @@ object NamedArgCompletions: for app <- getApplyForContextFunctionParam(rest) if !app.fun.isInfix - yield contribute( - Some(ident), - app, - indexedContext, - clientSupportsSnippets, - ) + yield + contribute( + Some(ident), + app, + indexedContext, + clientSupportsSnippets, + ) contribution.getOrElse(Nil) case (app: Apply) :: _ => /** @@ -156,10 +156,11 @@ object NamedArgCompletions: case _ => None val matchingMethods = for - (name, indxContext) <- maybeNameAndIndexedContext(method) - potentialMatches <- indxContext.findSymbol(name) - yield potentialMatches.collect { - case m + (name, indexedContext) <- maybeNameAndIndexedContext(method) + potentialMatches <- indexedContext.findSymbol(name) + yield + potentialMatches.collect { + case m if m.is(Flags.Method) && m.vparamss.length >= argss.length && Try(m.isAccessibleFrom(apply.symbol.info)).toOption @@ -179,8 +180,7 @@ object NamedArgCompletions: end fallbackFindMatchingMethods val matchingMethods: List[Symbols.Symbol] = - if method.symbol.paramSymss.nonEmpty - then + if method.symbol.paramSymss.nonEmpty then val allArgsAreSupplied = val vparamss = method.symbol.vparamss vparamss.length == argss.length && vparamss @@ -295,6 +295,7 @@ object NamedArgCompletions: ) } + // FIXME pass query here val prefix = ident .map(_.name.toString) .getOrElse("") @@ -391,7 +392,7 @@ class FuzzyArgMatcher(tparams: List[Symbols.Symbol])(using Context): (expectedArgs.length == actualArgs.length || (!allArgsProvided && expectedArgs.length >= actualArgs.length)) && actualArgs.zipWithIndex.forall { - case (Ident(name), _) if name.endsWith(Cursor.value) => true + case (Ident(name), _) => true case (NamedArg(name, arg), _) => expectedArgs.exists { expected => expected.name == name && (!arg.hasType || arg.typeOpt.unfold diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala index 1e310ca0e8ec..28dc4ebe59c9 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala @@ -582,7 +582,7 @@ object OverrideCompletions: ) ) // class Main extends Val: - // he@@ + // he@@ case (id: Ident) :: (t: Template) :: (td: TypeDef) :: _ if t.parents.nonEmpty => Some( @@ -595,6 +595,20 @@ object OverrideCompletions: ) ) + // class Main extends Val: + // hello@ // this transforms into this.hello, thus is a Select + case (sel @ Select(th: This, name)) :: (t: Template) :: (td: TypeDef) :: _ + if t.parents.nonEmpty && th.qual.name == td.name => + Some( + ( + td, + None, + sel.sourcePos.start, + false, + Some(name.show), + ) + ) + case _ => None end OverrideExtractor diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionArgSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionArgSuite.scala index f4bfc806dbb3..d39e7686b52b 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionArgSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionArgSuite.scala @@ -614,8 +614,9 @@ class CompletionArgSuite extends BaseCompletionSuite: check( s"""|case class Context() | - |def foo(arg1: (Context) ?=> Int, arg2: Int): String = ??? - |val m = foo(ar@@) + |object Main: + | def foo(arg1: (Context) ?=> Int, arg2: Int): String = ??? + | val m = foo(ar@@) |""".stripMargin, """|arg1 = : (Context) ?=> Int |arg2 = : Int @@ -627,8 +628,9 @@ class CompletionArgSuite extends BaseCompletionSuite: check( s"""|case class Context() | - |def foo(arg1: Context ?=> Int, arg2: Context ?=> Int): String = ??? - |val m = foo(arg1 = ???, a@@) + |object Main: + | def foo(arg1: Context ?=> Int, arg2: Context ?=> Int): String = ??? + | val m = foo(arg1 = ???, a@@) |""".stripMargin, """|arg2 = : (Context) ?=> Int |""".stripMargin, @@ -639,8 +641,9 @@ class CompletionArgSuite extends BaseCompletionSuite: check( s"""|case class Context() | - |def foo(arg1: (Boolean, Context) ?=> Int ?=> String, arg2: (Boolean, Context) ?=> Int ?=> String): String = ??? - |val m = foo(arg1 = ???, a@@) + |object Main: + | def foo(arg1: (Boolean, Context) ?=> Int ?=> String, arg2: (Boolean, Context) ?=> Int ?=> String): String = ??? + | val m = foo(arg1 = ???, a@@) |""".stripMargin, """|arg2 = : (Boolean, Context) ?=> (Int) ?=> String |""".stripMargin, @@ -786,10 +789,11 @@ class CompletionArgSuite extends BaseCompletionSuite: @Test def `overloaded-with-param` = check( - """|def m(idd : String, abb: Int): Int = ??? - |def m(inn : Int, uuu: Option[Int]): Int = ??? - |def m(inn : Int, aaa: Int): Int = ??? - |def k: Int = m(1, a@@) + """|object Main: + | def m(idd : String, abb: Int): Int = ??? + | def m(inn : Int, uuu: Option[Int]): Int = ??? + | def m(inn : Int, aaa: Int): Int = ??? + | def k: Int = m(1, a@@) |""".stripMargin, """|aaa = : Int |assert(assertion: Boolean): Unit @@ -799,10 +803,11 @@ class CompletionArgSuite extends BaseCompletionSuite: @Test def `overloaded-with-named-param` = check( - """|def m(idd : String, abb: Int): Int = ??? - |def m(inn : Int, uuu: Option[Int]): Int = ??? - |def m(inn : Int, aaa: Int): Int = ??? - |def k: Int = m(inn = 1, a@@) + """|object Main: + | def m(idd : String, abb: Int): Int = ??? + | def m(inn : Int, uuu: Option[Int]): Int = ??? + | def m(inn : Int, aaa: Int): Int = ??? + | def k: Int = m(inn = 1, a@@) |""".stripMargin, """|aaa = : Int |assert(assertion: Boolean): Unit @@ -812,7 +817,7 @@ class CompletionArgSuite extends BaseCompletionSuite: @Test def `overloaded-generic` = check( - """|object M: + """|object Main: | val g = 3 | val l : List[Int] = List(1,2,3) | def m[T](inn : List[T], yy: Int, aaa: Int, abb: Option[Int]): Int = ??? @@ -899,10 +904,11 @@ class CompletionArgSuite extends BaseCompletionSuite: @Test def `overloaded-function-param` = check( - """|def m[T](i: Int)(inn: T => Int, abb: Option[Int]): Int = ??? - |def m[T](i: Int)(inn: T => Int, aaa: Int): Int = ??? - |def m[T](i: Int)(inn: T => String, acc: List[Int]): Int = ??? - |def k = m(1)(inn = identity[Int], a@@) + """|object Main: + | def m[T](i: Int)(inn: T => Int, abb: Option[Int]): Int = ??? + | def m[T](i: Int)(inn: T => Int, aaa: Int): Int = ??? + | def m[T](i: Int)(inn: T => String, acc: List[Int]): Int = ??? + | def k = m(1)(inn = identity[Int], a@@) |""".stripMargin, """|aaa = : Int |abb = : Option[Int] @@ -913,10 +919,11 @@ class CompletionArgSuite extends BaseCompletionSuite: @Test def `overloaded-function-param2` = check( - """|def m[T](i: Int)(inn: T => Int, abb: Option[Int]): Int = ??? - |def m[T](i: Int)(inn: T => Int, aaa: Int): Int = ??? - |def m[T](i: String)(inn: T => Int, acc: List[Int]): Int = ??? - |def k = m(1)(inn = identity[Int], a@@) + """|object Main: + | def m[T](i: Int)(inn: T => Int, abb: Option[Int]): Int = ??? + | def m[T](i: Int)(inn: T => Int, aaa: Int): Int = ??? + | def m[T](i: String)(inn: T => Int, acc: List[Int]): Int = ??? + | def k = m(1)(inn = identity[Int], a@@) |""".stripMargin, """|aaa = : Int |abb = : Option[Int] @@ -978,9 +985,10 @@ class CompletionArgSuite extends BaseCompletionSuite: @Test def `overloaded-function-param3` = check( - """|def m[T](inn: Int => T, abb: Option[Int]): Int = ??? - |def m[T](inn: String => T, aaa: Int): Int = ??? - |def k = m(identity[Int], a@@) + """|object Main: + | def m[T](inn: Int => T, abb: Option[Int]): Int = ??? + | def m[T](inn: String => T, aaa: Int): Int = ??? + | def k = m(identity[Int], a@@) |""".stripMargin, """|abb = : Option[Int] |""".stripMargin, @@ -1109,7 +1117,7 @@ class CompletionArgSuite extends BaseCompletionSuite: @Test def `comparison` = check( - """package a + """ |object w { | abstract class T(x: Int) { | def met(x: Int): Unit = { diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionInterpolatorSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionInterpolatorSuite.scala index 08cc1535fd56..50019928a2f3 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionInterpolatorSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionInterpolatorSuite.scala @@ -112,7 +112,7 @@ class CompletionInterpolatorSuite extends BaseCompletionSuite: |""".stripMargin.triplequoted, """|object Main { | val myName = "" - | s"$myName $$" + | s"$myName$0 $$" |} |""".stripMargin.triplequoted, filterText = "myName" diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala index 5769304919ca..57873909ace8 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala @@ -289,7 +289,8 @@ class CompletionSnippetSuite extends BaseCompletionSuite: |} |""".stripMargin, "scala.util.Try@@(1)", - "scala.util.Try(1)" + "scala.util.Try(1)", + assertSingleItem = false ) @Test def `case-class` = diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala index f660baa6af6d..bffe6dc2a735 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala @@ -529,8 +529,6 @@ class CompletionSuite extends BaseCompletionSuite: """.stripMargin, """|until(end: Int): Range |until(end: Int, step: Int): Range - |until(end: Long): Exclusive[Long] - |until(end: Long, step: Long): Exclusive[Long] |""".stripMargin, stableOrder = false ) @@ -1605,7 +1603,7 @@ class CompletionSuite extends BaseCompletionSuite: @Test def `multi-export` = check( - """export scala.collection.{AbstractMap, Set@@} + """export scala.collection.{AbstractMap, Se@@} |""".stripMargin, """Set scala.collection |SetOps scala.collection @@ -1618,7 +1616,9 @@ class CompletionSuite extends BaseCompletionSuite: |StrictOptimizedSetOps scala.collection |StrictOptimizedSortedSetOps scala.collection |GenSet = scala.collection.Set[X] - |""".stripMargin + |""".stripMargin, + filter = _.contains("Set") + ) @Test def `multi-imports` = @@ -1637,6 +1637,7 @@ class CompletionSuite extends BaseCompletionSuite: |StrictOptimizedSortedSetOps scala.collection |GenSet = scala.collection.Set[X] |""".stripMargin, + filter = _.contains("Set") ) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala index c7c9b9979404..20d56ab94938 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala @@ -28,7 +28,7 @@ class PcDefinitionSuite extends BasePcDefinitionSuite: MockLocation("scala/Predef.Ensuring#ensuring(+2).", "Predef.scala"), MockLocation("scala/Predef.Ensuring#ensuring(+3).", "Predef.scala"), MockLocation("scala/collection/immutable/List#`::`().", "List.scala"), - MockLocation("scala/collection/IterableFactory#apply().", "Factory.scala") + MockLocation("scala/package.List.", "List.scala") ) override def definitions(offsetParams: OffsetParams): List[Location] = @@ -123,7 +123,7 @@ class PcDefinitionSuite extends BasePcDefinitionSuite: check( """| |object Main { - | /*scala/collection/IterableFactory#apply(). Factory.scala*/@@List(1) + | /*scala/package.List. List.scala*/@@List(1) |} |""".stripMargin ) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala index 9ae37048caf7..0b992fe98f08 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala @@ -269,9 +269,9 @@ class HoverTermSuite extends BaseHoverSuite: | } yield x |} |""".stripMargin, - """|Option[Int] - |override def headOption: Option[A] - |""".stripMargin.hover + """|```scala + |override def headOption: Option[Int] + |```""".stripMargin.hover ) @Test def `object` =