From 033ad19fff3f15fd549410ce026a4cfdedc02291 Mon Sep 17 00:00:00 2001 From: rochala Date: Fri, 12 Apr 2024 12:09:47 +0200 Subject: [PATCH] rename MtagsEnrichments to InteractiveEnrichments, rename metalsDealias to deepDealias, dealias type members of structural types --- .../src/main/dotty/tools/pc/AutoImports.scala | 2 +- .../dotty/tools/pc/AutoImportsProvider.scala | 2 +- .../tools/pc/CompletionItemResolver.scala | 4 +-- .../pc/ConvertToNamedArgumentsProvider.scala | 2 +- .../tools/pc/ExtractMethodProvider.scala | 2 +- .../main/dotty/tools/pc/HoverProvider.scala | 10 +++---- .../main/dotty/tools/pc/IndexedContext.scala | 4 +-- .../dotty/tools/pc/InferredTypeProvider.scala | 4 +-- .../dotty/tools/pc/MetalsInteractive.scala | 2 +- .../src/main/dotty/tools/pc/PcCollector.scala | 2 +- .../dotty/tools/pc/PcDefinitionProvider.scala | 2 +- .../pc/PcDocumentHighlightProvider.scala | 2 +- .../dotty/tools/pc/PcInlayHintsProvider.scala | 4 +-- .../tools/pc/PcInlineValueProviderImpl.scala | 2 +- .../dotty/tools/pc/PcRenameProvider.scala | 2 +- .../tools/pc/PcSemanticTokensProvider.scala | 2 +- .../tools/pc/SelectionRangeProvider.scala | 2 +- .../dotty/tools/pc/SemanticdbSymbols.scala | 2 +- .../tools/pc/SignatureHelpProvider.scala | 2 +- .../tools/pc/SymbolInformationProvider.scala | 6 ++-- .../pc/WorksheetSemanticdbProvider.scala | 2 +- .../completions/AmmoniteFileCompletions.scala | 2 +- .../completions/AmmoniteIvyCompletions.scala | 2 +- .../tools/pc/completions/CompletionPos.scala | 2 +- .../pc/completions/CompletionProvider.scala | 2 +- .../pc/completions/CompletionValue.scala | 2 +- .../tools/pc/completions/Completions.scala | 2 +- .../pc/completions/FilenameCompletions.scala | 2 +- .../completions/InterpolatorCompletions.scala | 2 +- .../pc/completions/MatchCaseCompletions.scala | 14 ++++----- .../pc/completions/NamedArgCompletions.scala | 2 +- .../pc/completions/OverrideCompletions.scala | 2 +- .../pc/completions/ScalaCliCompletions.scala | 2 +- .../pc/printer/ShortenedTypePrinter.scala | 2 +- ...nts.scala => InteractiveEnrichments.scala} | 17 +++++++---- .../tools/pc/base/BaseCompletionSuite.scala | 2 +- .../dotty/tools/pc/base/BaseHoverSuite.scala | 2 +- .../tools/pc/base/BasePcDefinitionSuite.scala | 2 +- .../tools/pc/tests/hover/HoverDefnSuite.scala | 9 ++---- .../tools/pc/tests/hover/HoverTermSuite.scala | 30 +++++++++++++++++++ .../dotty/tools/pc/utils/PcAssertions.scala | 2 +- .../dotty/tools/pc/utils/TestInlayHints.scala | 2 +- 42 files changed, 98 insertions(+), 68 deletions(-) rename presentation-compiler/src/main/dotty/tools/pc/utils/{MtagsEnrichments.scala => InteractiveEnrichments.scala} (96%) diff --git a/presentation-compiler/src/main/dotty/tools/pc/AutoImports.scala b/presentation-compiler/src/main/dotty/tools/pc/AutoImports.scala index e86732c3453d..bf814ef682e0 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/AutoImports.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/AutoImports.scala @@ -13,7 +13,7 @@ import dotty.tools.dotc.core.Names.* import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.util.SourcePosition import dotty.tools.dotc.util.Spans -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala index 8546bbf62384..ded7845ffa4e 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala @@ -15,7 +15,7 @@ import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourceFile import dotty.tools.pc.AutoImports.* import dotty.tools.pc.completions.CompletionPos -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala b/presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala index c962617ac7fb..291ffe1fec30 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala @@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Flags.* import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.core.Types.TermRef -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j.CompletionItem @@ -62,7 +62,7 @@ object CompletionItemResolver extends ItemResolver: if companion == NoSymbol || gsym.is(JavaDefined) then if gsymDoc.isEmpty() then if gsym.isAliasType then - fullDocstring(gsym.info.metalsDealias.typeSymbol, search) + fullDocstring(gsym.info.deepDealias.typeSymbol, search) else if gsym.is(Method) then gsym.info.finalResultType match case tr @ TermRef(_, sym) => diff --git a/presentation-compiler/src/main/dotty/tools/pc/ConvertToNamedArgumentsProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/ConvertToNamedArgumentsProvider.scala index 00bfe17cb21b..d4f945760cc0 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/ConvertToNamedArgumentsProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/ConvertToNamedArgumentsProvider.scala @@ -12,7 +12,7 @@ import dotty.tools.dotc.core.Types.MethodType import dotty.tools.dotc.interactive.Interactive import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourceFile -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala index 55c4e4d9e4b6..4416d0c0d000 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala @@ -23,7 +23,7 @@ import dotty.tools.dotc.util.SourceFile import dotty.tools.dotc.util.SourcePosition import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.printer.ShortenedTypePrinter.IncludeDefaultParam -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j.TextEdit import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala index 6f39b4871a06..c0f2d49d341e 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala @@ -23,7 +23,7 @@ import dotty.tools.dotc.util.SourceFile import dotty.tools.dotc.util.SourcePosition import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.printer.ShortenedTypePrinter.IncludeDefaultParam -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* object HoverProvider: @@ -106,7 +106,7 @@ object HoverProvider: if symbol.name == nme.selectDynamic || symbol.name == nme.applyDynamic => fallbackToDynamics(path, printer) case symbolTpes @ ((symbol, tpe) :: _) => - val exprTpw = tpe.widenTermRefExpr.metalsDealias + val exprTpw = tpe.widenTermRefExpr.deepDealias val hoverString = tpw match // https://github.com/scala/scala3/issues/8891 @@ -121,7 +121,7 @@ object HoverProvider: if tpe != NoType then tpe else tpw - printer.hoverSymbol(sym, finalTpe) + printer.hoverSymbol(sym, finalTpe.deepDealias) end match end hoverString @@ -185,9 +185,9 @@ object HoverProvider: findRefinement(parent) case _ => None - val refTpe = sel.typeOpt.widen.metalsDealias match + val refTpe = sel.typeOpt.widen.deepDealias match case r: RefinedType => Some(r) - case t: (TermRef | TypeProxy) => Some(t.termSymbol.info.metalsDealias) + case t: (TermRef | TypeProxy) => Some(t.termSymbol.info.deepDealias) case _ => None refTpe.flatMap(findRefinement).asJava diff --git a/presentation-compiler/src/main/dotty/tools/pc/IndexedContext.scala b/presentation-compiler/src/main/dotty/tools/pc/IndexedContext.scala index ad6fe9420a81..6b74e3aa2ec1 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/IndexedContext.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/IndexedContext.scala @@ -13,7 +13,7 @@ import dotty.tools.dotc.core.Types.* import dotty.tools.dotc.interactive.Interactive import dotty.tools.dotc.typer.ImportInfo import dotty.tools.pc.IndexedContext.Result -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* sealed trait IndexedContext: given ctx: Context @@ -75,7 +75,7 @@ sealed trait IndexedContext: ) private def isTypeAliasOf(alias: Symbol, queriedSym: Symbol): Boolean = - alias.isAliasType && alias.info.metalsDealias.typeSymbol == queriedSym + alias.isAliasType && alias.info.deepDealias.typeSymbol == queriedSym final def isEmpty: Boolean = this match case IndexedContext.Empty => true diff --git a/presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala index b37b1b6dff6c..d8cdbcd8fe69 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala @@ -24,7 +24,7 @@ import dotty.tools.dotc.util.Spans import dotty.tools.dotc.util.Spans.Span import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.printer.ShortenedTypePrinter.IncludeDefaultParam -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j.TextEdit import org.eclipse.lsp4j as l @@ -101,7 +101,7 @@ final class InferredTypeProvider( case _ => true if isInScope(tpe) then tpe - else tpe.metalsDealias + else tpe.deepDealias val printer = ShortenedTypePrinter( symbolSearch, diff --git a/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala b/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala index 381e0eaec6a5..a07fc9b0076c 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala @@ -240,7 +240,7 @@ object MetalsInteractive: end match end enclosingSymbolsWithExpressionType - import dotty.tools.pc.utils.MtagsEnrichments.* + import dotty.tools.pc.utils.InteractiveEnrichments.* private def recoverError( tree: Tree, diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala b/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala index 60def237badb..c447123c8725 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala @@ -26,7 +26,7 @@ import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourceFile import dotty.tools.dotc.util.SourcePosition import dotty.tools.dotc.util.Spans.Span -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* abstract class PcCollector[T]( driver: InteractiveDriver, diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcDefinitionProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/PcDefinitionProvider.scala index 0de81ec39711..0d4100329c17 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcDefinitionProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcDefinitionProvider.scala @@ -19,7 +19,7 @@ import dotty.tools.dotc.interactive.Interactive import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourceFile import dotty.tools.dotc.util.SourcePosition -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j.Location diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcDocumentHighlightProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/PcDocumentHighlightProvider.scala index cd4f4919b1ef..d9b94ebb82a3 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcDocumentHighlightProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcDocumentHighlightProvider.scala @@ -6,7 +6,7 @@ import dotty.tools.dotc.ast.tpd.* import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourcePosition -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j.DocumentHighlight import org.eclipse.lsp4j.DocumentHighlightKind diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala index 9b40f1e6777a..43ec35eab344 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala @@ -4,7 +4,7 @@ package dotty.tools.pc import java.nio.file.Paths import scala.meta.internal.metals.ReportContext -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import dotty.tools.pc.printer.ShortenedTypePrinter import scala.meta.internal.pc.InlayHints import scala.meta.internal.pc.LabelPart @@ -140,7 +140,7 @@ class PcInlayHintsProvider( isInScope(tycon) && args.forall(isInScope) case _ => true if isInScope(tpe) then tpe - else tpe.metalsDealias(using indexedCtx.ctx) + else tpe.deepDealias(using indexedCtx.ctx) val dealiased = optDealias(tpe) val tpeStr = printer.tpe(dealiased) diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcInlineValueProviderImpl.scala b/presentation-compiler/src/main/dotty/tools/pc/PcInlineValueProviderImpl.scala index 39365475a075..38b5e8d0069b 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcInlineValueProviderImpl.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcInlineValueProviderImpl.scala @@ -17,7 +17,7 @@ import dotty.tools.dotc.core.Symbols.Symbol import dotty.tools.dotc.interactive.Interactive import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourcePosition -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcRenameProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/PcRenameProvider.scala index 8a441e1e385a..94482767f917 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcRenameProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcRenameProvider.scala @@ -8,7 +8,7 @@ import dotty.tools.dotc.core.Flags.* import dotty.tools.dotc.core.Symbols.Symbol import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourcePosition -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcSemanticTokensProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/PcSemanticTokensProvider.scala index f1a0b6a65aa7..a5332f1e4ff6 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcSemanticTokensProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcSemanticTokensProvider.scala @@ -12,7 +12,7 @@ import dotty.tools.dotc.core.Symbols.NoSymbol import dotty.tools.dotc.core.Symbols.Symbol import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourcePosition -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j.SemanticTokenModifiers import org.eclipse.lsp4j.SemanticTokenTypes diff --git a/presentation-compiler/src/main/dotty/tools/pc/SelectionRangeProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/SelectionRangeProvider.scala index 9dce37028bea..7973f4103ff6 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/SelectionRangeProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/SelectionRangeProvider.scala @@ -12,7 +12,7 @@ import dotty.tools.dotc.interactive.Interactive import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourceFile import dotty.tools.dotc.util.SourcePosition -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j import org.eclipse.lsp4j.SelectionRange diff --git a/presentation-compiler/src/main/dotty/tools/pc/SemanticdbSymbols.scala b/presentation-compiler/src/main/dotty/tools/pc/SemanticdbSymbols.scala index d298a88fc655..9ef19587948e 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/SemanticdbSymbols.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/SemanticdbSymbols.scala @@ -7,7 +7,7 @@ import dotty.tools.dotc.core.Flags.* import dotty.tools.dotc.core.Names.* import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.semanticdb.* -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* object SemanticdbSymbols: diff --git a/presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala index f7797efbfb27..9682a122fe45 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala @@ -15,7 +15,7 @@ import dotty.tools.dotc.util.Spans import dotty.tools.dotc.util.Spans.Span import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.printer.ShortenedTypePrinter.IncludeDefaultParam -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l import scala.jdk.CollectionConverters.* diff --git a/presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala index aa1508f89313..0743361f255d 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/SymbolInformationProvider.scala @@ -12,9 +12,9 @@ import dotty.tools.dotc.core.Flags import dotty.tools.dotc.core.Names.* import dotty.tools.dotc.core.StdNames.nme import dotty.tools.dotc.core.Symbols.* -import dotty.tools.pc.utils.MtagsEnrichments.metalsDealias +import dotty.tools.pc.utils.InteractiveEnrichments.deepDealias import dotty.tools.pc.SemanticdbSymbols -import dotty.tools.pc.utils.MtagsEnrichments.allSymbols +import dotty.tools.pc.utils.InteractiveEnrichments.allSymbols class SymbolInformationProvider(using Context): private def toSymbols( @@ -77,7 +77,7 @@ class SymbolInformationProvider(using Context): then classSym.asClass.parentSyms.map(SemanticdbSymbols.symbolName) else Nil val dealisedSymbol = - if sym.isAliasType then sym.info.metalsDealias.typeSymbol else sym + if sym.isAliasType then sym.info.deepDealias.typeSymbol else sym val classOwner = sym.ownersIterator.drop(1).find(s => s.isClass || s.is(Flags.Module)) val overridden = sym.denot.allOverriddenSymbols.toList diff --git a/presentation-compiler/src/main/dotty/tools/pc/WorksheetSemanticdbProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/WorksheetSemanticdbProvider.scala index 4c8c92759a3b..bd9efb49d148 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/WorksheetSemanticdbProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/WorksheetSemanticdbProvider.scala @@ -2,7 +2,7 @@ package dotty.tools.pc import java.nio.file.Path -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* trait WorksheetSemanticdbProvider: diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala index 31bf7c348119..81337c7d8dcb 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala @@ -12,7 +12,7 @@ import dotty.tools.dotc.ast.tpd.Tree import dotty.tools.dotc.ast.untpd.ImportSelector import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.StdNames.* -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteIvyCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteIvyCompletions.scala index ec4a1813a437..718b57cd4828 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteIvyCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteIvyCompletions.scala @@ -4,7 +4,7 @@ import scala.meta.internal.mtags.CoursierComplete import dotty.tools.dotc.ast.untpd.ImportSelector import dotty.tools.dotc.core.Contexts.Context -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* object AmmoniteIvyCompletions: def contribute( 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 6e828f8f2058..ad571ff843c3 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionPos.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionPos.scala @@ -10,7 +10,7 @@ import dotty.tools.dotc.core.Contexts.* import dotty.tools.dotc.util.SourcePosition import dotty.tools.dotc.util.Spans.* import dotty.tools.dotc.interactive.Completion -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l 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 2beb4460db56..5bf4cc6d9e07 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala @@ -22,7 +22,7 @@ import dotty.tools.pc.AutoImports.AutoImportEdits import dotty.tools.pc.AutoImports.AutoImportsGenerator import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.printer.ShortenedTypePrinter.IncludeDefaultParam -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j.Command import org.eclipse.lsp4j.CompletionItem diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala index 2810fe728b9a..e6f8bdb08f74 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionValue.scala @@ -10,7 +10,7 @@ import dotty.tools.dotc.core.StdNames.nme import dotty.tools.dotc.core.Symbols.Symbol import dotty.tools.dotc.core.Types.Type import dotty.tools.pc.printer.ShortenedTypePrinter -import dotty.tools.pc.utils.MtagsEnrichments.decoded +import dotty.tools.pc.utils.InteractiveEnrichments.decoded import org.eclipse.lsp4j.CompletionItemKind import org.eclipse.lsp4j.CompletionItemTag 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 81a543701817..6aca2b517e1a 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala @@ -32,7 +32,7 @@ import dotty.tools.dotc.util.SrcPos import dotty.tools.pc.AutoImports.AutoImportsGenerator import dotty.tools.pc.completions.OverrideCompletions.OverrideExtractor import dotty.tools.pc.buildinfo.BuildInfo -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import dotty.tools.dotc.core.Denotations.SingleDenotation import dotty.tools.dotc.interactive.Interactive diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/FilenameCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/FilenameCompletions.scala index a9dfa55f89bd..8d2e97856e82 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/FilenameCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/FilenameCompletions.scala @@ -4,7 +4,7 @@ package completions import dotty.tools.dotc.ast.tpd.TypeDef import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Flags -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* object FilenameCompletions: 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 2a8ead70ea33..da2218c388ac 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala @@ -17,7 +17,7 @@ import dotty.tools.dotc.core.Types.Type import dotty.tools.dotc.util.SourcePosition import dotty.tools.pc.CompilerSearchVisitor import dotty.tools.pc.IndexedContext -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/MatchCaseCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/MatchCaseCompletions.scala index 7f1d92305309..65ffdfd51822 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/MatchCaseCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/MatchCaseCompletions.scala @@ -34,7 +34,7 @@ import dotty.tools.pc.AutoImports.SymbolImport import dotty.tools.pc.MetalsInteractive.* import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.printer.ShortenedTypePrinter.IncludeDefaultParam -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l @@ -88,12 +88,12 @@ object CaseKeywordCompletion: ) => val args = head.argTypes.init if args.length > 1 then - Some(definitions.tupleType(args).widen.metalsDealias) - else args.headOption.map(_.widen.metalsDealias) + Some(definitions.tupleType(args).widen.deepDealias) + else args.headOption.map(_.widen.deepDealias) case _ => None case _ => None case sel => - Some(sel.tpe.widen.metalsDealias) + Some(sel.tpe.widen.deepDealias) selTpe .map { selTpe => @@ -158,7 +158,7 @@ object CaseKeywordCompletion: indexedContext.scopeSymbols .foreach(s => - val ts = s.info.metalsDealias.typeSymbol + val ts = s.info.deepDealias.typeSymbol if isValid(ts) then visit(autoImportsGen.inferSymbolImport(ts)) ) // Step 2: walk through known subclasses of sealed types. @@ -261,8 +261,8 @@ object CaseKeywordCompletion: clientSupportsSnippets ) - val tpeStr = printer.tpe(selector.tpe.widen.metalsDealias.bounds.hi) - val tpe = selector.typeOpt.widen.metalsDealias.bounds.hi match + val tpeStr = printer.tpe(selector.tpe.widen.deepDealias.bounds.hi) + val tpe = selector.typeOpt.widen.deepDealias.bounds.hi match case tr @ TypeRef(_, _) => tr.underlying case t => t 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 6f244d9a3414..752ff6c8b778 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/NamedArgCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/NamedArgCompletions.scala @@ -30,7 +30,7 @@ import dotty.tools.dotc.core.Types.TypeBounds import dotty.tools.dotc.core.Types.WildcardType import dotty.tools.dotc.util.SourcePosition import dotty.tools.pc.IndexedContext -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import scala.annotation.tailrec object NamedArgCompletions: 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 8d96396999da..df0bb70b596c 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala @@ -29,7 +29,7 @@ import dotty.tools.pc.AutoImports.AutoImport import dotty.tools.pc.AutoImports.AutoImportsGenerator import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.printer.ShortenedTypePrinter.IncludeDefaultParam -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/ScalaCliCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/ScalaCliCompletions.scala index fce35ab69ce3..e2a0a033ee6b 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/ScalaCliCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/ScalaCliCompletions.scala @@ -4,7 +4,7 @@ import scala.meta.internal.mtags.CoursierComplete import dotty.tools.dotc.ast.tpd.* import dotty.tools.dotc.util.SourcePosition -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* class ScalaCliCompletions( coursierComplete: CoursierComplete, diff --git a/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala b/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala index a7cf1a703a1f..559e199f3449 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala @@ -29,7 +29,7 @@ import dotty.tools.pc.AutoImports.ImportSel.Rename import dotty.tools.pc.IndexedContext import dotty.tools.pc.IndexedContext.Result import dotty.tools.pc.Params -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j.TextEdit diff --git a/presentation-compiler/src/main/dotty/tools/pc/utils/MtagsEnrichments.scala b/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala similarity index 96% rename from presentation-compiler/src/main/dotty/tools/pc/utils/MtagsEnrichments.scala rename to presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala index e4385392973f..c5b3f593ddc6 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/utils/MtagsEnrichments.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/utils/InteractiveEnrichments.scala @@ -20,8 +20,7 @@ import dotty.tools.dotc.core.Names.* import dotty.tools.dotc.core.StdNames.* import dotty.tools.dotc.core.SymDenotations.NoDenotation import dotty.tools.dotc.core.Symbols.* -import dotty.tools.dotc.core.Types.AppliedType -import dotty.tools.dotc.core.Types.Type +import dotty.tools.dotc.core.Types.* import dotty.tools.dotc.interactive.Interactive import dotty.tools.dotc.interactive.InteractiveDriver import dotty.tools.dotc.util.SourcePosition @@ -31,7 +30,7 @@ import dotty.tools.pc.SemanticdbSymbols import org.eclipse.lsp4j as l -object MtagsEnrichments extends CommonMtagsEnrichments: +object InteractiveEnrichments extends CommonMtagsEnrichments: extension (driver: InteractiveDriver) @@ -399,11 +398,17 @@ object MtagsEnrichments extends CommonMtagsEnrichments: end extension extension (tpe: Type) - def metalsDealias(using Context): Type = + def deepDealias(using Context): Type = tpe.dealias match case app @ AppliedType(tycon, params) => // we dealias applied type params by hand, because `dealias` doesn't do it - AppliedType(tycon, params.map(_.metalsDealias)) + AppliedType(tycon, params.map(_.deepDealias)) + case aliasingBounds: AliasingBounds => + aliasingBounds.derivedAlias(aliasingBounds.alias.dealias) + case TypeBounds(lo, hi) => + TypeBounds(lo.dealias, hi.dealias) + case RefinedType(parent, name, refinedInfo) => + RefinedType(parent.dealias, name, refinedInfo.deepDealias) case dealised => dealised -end MtagsEnrichments +end InteractiveEnrichments diff --git a/presentation-compiler/test/dotty/tools/pc/base/BaseCompletionSuite.scala b/presentation-compiler/test/dotty/tools/pc/base/BaseCompletionSuite.scala index 964f6a6894a2..978375fb3c66 100644 --- a/presentation-compiler/test/dotty/tools/pc/base/BaseCompletionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/base/BaseCompletionSuite.scala @@ -9,7 +9,7 @@ import scala.meta.pc.CancelToken import scala.language.unsafeNulls import dotty.tools.pc.completions.CompletionSource -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import dotty.tools.pc.utils.{TestCompletions, TextEdits} import org.eclipse.lsp4j.{CompletionItem, CompletionList} diff --git a/presentation-compiler/test/dotty/tools/pc/base/BaseHoverSuite.scala b/presentation-compiler/test/dotty/tools/pc/base/BaseHoverSuite.scala index 0b8d663f8b33..0f385631d9dc 100644 --- a/presentation-compiler/test/dotty/tools/pc/base/BaseHoverSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/base/BaseHoverSuite.scala @@ -5,7 +5,7 @@ import java.nio.file.Paths import scala.meta.internal.metals.{CompilerOffsetParams, CompilerRangeParams} import scala.language.unsafeNulls -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import dotty.tools.pc.utils.{RangeReplace, TestHovers} abstract class BaseHoverSuite diff --git a/presentation-compiler/test/dotty/tools/pc/base/BasePcDefinitionSuite.scala b/presentation-compiler/test/dotty/tools/pc/base/BasePcDefinitionSuite.scala index 8269d4ce1c44..58c2bcdb171c 100644 --- a/presentation-compiler/test/dotty/tools/pc/base/BasePcDefinitionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/base/BasePcDefinitionSuite.scala @@ -8,7 +8,7 @@ import scala.language.unsafeNulls import dotty.tools.dotc.util.Spans.Span import dotty.tools.dotc.util.{SourceFile, SourcePosition} -import dotty.tools.pc.utils.MtagsEnrichments.toLsp +import dotty.tools.pc.utils.InteractiveEnrichments.toLsp import dotty.tools.pc.utils.TextEdits import org.eclipse.lsp4j.TextEdit diff --git a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverDefnSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverDefnSuite.scala index 7a647fa40f5f..f4ce4473e60a 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverDefnSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverDefnSuite.scala @@ -223,13 +223,8 @@ class HoverDefnSuite extends BaseHoverSuite: | <> |} |""".stripMargin, - """|**Expression type**: - |```scala - |Option[Int] - |``` - |**Symbol signature**: - |```scala - |val x: Option[T] + """|```scala + |val x: Option[Int] |``` |""".stripMargin.hover ) 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 d1e90241e639..319f0941238f 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala @@ -653,3 +653,33 @@ class HoverTermSuite extends BaseHoverSuite: |``` |""".stripMargin ) + + @Test def `dealias-type-members-in-structural-types-1`: Unit = + check( + """object Obj { + | trait A extends Sup { self => + | type T + | def member : T + | } + | val x: A { type T = Int} = ??? + | + | <> + | + |}""".stripMargin, + """def member: Int""".stripMargin.hover + ) + + @Test def `dealias-type-members-in-structural-types-2`: Unit = + check( + """object Obj: + | trait A extends Sup { self => + | type T + | def fun(body: A { type T = self.T} => Unit) = () + | } + | val x: A { type T = Int} = ??? + | + | x.fun: <> => + | () + |""".stripMargin, + """yy: A{type T = Int}""".stripMargin.hover + ) diff --git a/presentation-compiler/test/dotty/tools/pc/utils/PcAssertions.scala b/presentation-compiler/test/dotty/tools/pc/utils/PcAssertions.scala index 6dfc8acec66c..ef15121c6702 100644 --- a/presentation-compiler/test/dotty/tools/pc/utils/PcAssertions.scala +++ b/presentation-compiler/test/dotty/tools/pc/utils/PcAssertions.scala @@ -4,7 +4,7 @@ import scala.language.unsafeNulls import dotty.tools.pc.completions.CompletionSource import dotty.tools.dotc.util.DiffUtil -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import org.hamcrest import org.hamcrest.* diff --git a/presentation-compiler/test/dotty/tools/pc/utils/TestInlayHints.scala b/presentation-compiler/test/dotty/tools/pc/utils/TestInlayHints.scala index 98ebb0852735..a923b76b955c 100644 --- a/presentation-compiler/test/dotty/tools/pc/utils/TestInlayHints.scala +++ b/presentation-compiler/test/dotty/tools/pc/utils/TestInlayHints.scala @@ -3,7 +3,7 @@ package dotty.tools.pc.utils import scala.collection.mutable.ListBuffer import scala.meta.internal.jdk.CollectionConverters._ -import dotty.tools.pc.utils.MtagsEnrichments.* +import dotty.tools.pc.utils.InteractiveEnrichments.* import dotty.tools.pc.utils.TextEdits import org.eclipse.lsp4j.InlayHint