Skip to content

Commit

Permalink
undo unnecessary changes, add -Wunsued:all, remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
rochala committed Jul 3, 2023
1 parent 5ee339d commit aa7542f
Show file tree
Hide file tree
Showing 22 changed files with 256 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dotty.tools.pc

import scala.annotation.tailrec
import scala.jdk.CollectionConverters.*
import scala.meta.internal.mtags.KeywordWrapper
import scala.meta.internal.pc.AutoImportPosition
import scala.meta.pc.PresentationCompilerConfig

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ final class ExtractMethodProvider(
val newctx = driver.currentCtx.fresh.setCompilationUnit(unit)
Interactive.contextOfPath(path)(using newctx)
val indexedCtx = IndexedContext(locatedCtx)
val printer = ShortenedTypePrinter(search, IncludeDefaultParam.Never)(using indexedCtx)
val printer =
ShortenedTypePrinter(search, IncludeDefaultParam.Never)(using indexedCtx)
def prettyPrint(tpe: Type) =
def prettyPrintReturnType(tpe: Type): String =
tpe match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ object HoverProvider:
ctx.fresh.setCompilationUnit(unit)
Interactive.contextOfPath(enclosing)(using newctx)
case None => ctx
val printer = ShortenedTypePrinter(search, IncludeDefaultParam.Include)(using IndexedContext(printerContext))
val printer = ShortenedTypePrinter(search, IncludeDefaultParam.Include)(
using IndexedContext(printerContext)
)
MetalsInteractive.enclosingSymbolsWithExpressionType(
enclosing,
pos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ abstract class PcCollector[T](
case _ => resultAllOccurences().toList

def resultAllOccurences(): Set[T] =
def noTreeFilter = (tree: Tree) => true
def noSoughtFilter = (f: Symbol => Boolean) => true
def noTreeFilter = (_: Tree) => true
def noSoughtFilter = (_: Symbol => Boolean) => true

traverseSought(noTreeFilter, noSoughtFilter)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import scala.meta.pc.DefinitionResult
import scala.meta.pc.OffsetParams
import scala.meta.pc.SymbolSearch

import dotty.tools.dotc.CompilationUnit
import dotty.tools.dotc.ast.NavigateAST
import dotty.tools.dotc.ast.tpd.*
import dotty.tools.dotc.ast.untpd
Expand Down Expand Up @@ -43,8 +42,6 @@ class PcDefinitionProvider(
uri,
SourceFile.virtual(filePath.toString, params.text)
)
val unit = driver.currentCtx.run.units.head
val tree = unit.tpdTree

val pos = driver.sourcePosition(params)
val path =
Expand All @@ -56,7 +53,7 @@ class PcDefinitionProvider(
if findTypeDef then findTypeDefinitions(path, pos, indexedContext)
else findDefinitions(path, pos, indexedContext)

if result.locations().isEmpty() then fallbackToUntyped(unit, pos)(using ctx)
if result.locations().isEmpty() then fallbackToUntyped(pos)(using ctx)
else result
end definitions

Expand All @@ -72,8 +69,8 @@ class PcDefinitionProvider(
* @param pos cursor position
* @return definition result
*/
private def fallbackToUntyped(unit: CompilationUnit, pos: SourcePosition)(
using ctx: Context
private def fallbackToUntyped(pos: SourcePosition)(using
ctx: Context
) =
lazy val untpdPath = NavigateAST
.untypedPath(pos.span)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ class CompletionProvider(
path: List[Tree],
indexedContext: IndexedContext
)(using ctx: Context): CompletionItem =
val printer = ShortenedTypePrinter(search, IncludeDefaultParam.ResolveLater)(using indexedContext)
val printer =
ShortenedTypePrinter(search, IncludeDefaultParam.ResolveLater)(using
indexedContext
)
val editRange = completionPos.toEditRange

// For overloaded signatures we get multiple symbols, so we need
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ sealed trait CompletionValue:
/**
* Label with potentially attached description.
*/
def labelWithDescription(printer: ShortenedTypePrinter)(using Context): String =
def labelWithDescription(printer: ShortenedTypePrinter)(using
Context
): String =
label
def lspTags(using Context): List[CompletionItemTag] = Nil
end CompletionValue
Expand Down Expand Up @@ -83,7 +85,9 @@ object CompletionValue:
else s"${label}${description(printer)}"
else s"${label}: ${description(printer)}"

override def description(printer: ShortenedTypePrinter)(using Context): String =
override def description(printer: ShortenedTypePrinter)(using
Context
): String =
printer.completionSymbol(symbol)
end Symbolic

Expand Down Expand Up @@ -111,7 +115,9 @@ object CompletionValue:
) extends Symbolic:
override def completionItemKind(using Context): CompletionItemKind =
CompletionItemKind.Method
override def description(printer: ShortenedTypePrinter)(using Context): String =
override def description(printer: ShortenedTypePrinter)(using
Context
): String =
s"${printer.completionSymbol(symbol)} (extension)"

/**
Expand Down Expand Up @@ -148,7 +154,9 @@ object CompletionValue:
override def insertText: Option[String] = Some(label.replace("$", "$$"))
override def completionItemKind(using Context): CompletionItemKind =
CompletionItemKind.Field
override def description(printer: ShortenedTypePrinter)(using Context): String =
override def description(printer: ShortenedTypePrinter)(using
Context
): String =
": " + printer.tpe(tpe)

override def labelWithDescription(printer: ShortenedTypePrinter)(using
Expand Down Expand Up @@ -199,7 +207,9 @@ object CompletionValue:
isWorkspace: Boolean = false,
isExtension: Boolean = false
) extends Symbolic:
override def description(printer: ShortenedTypePrinter)(using Context): String =
override def description(
printer: ShortenedTypePrinter
)(using Context): String =
if isExtension then s"${printer.completionSymbol(symbol)} (extension)"
else super.description(printer)
end Interpolator
Expand All @@ -212,7 +222,9 @@ object CompletionValue:
) extends CompletionValue:
override def completionItemKind(using Context): CompletionItemKind =
CompletionItemKind.Enum
override def description(printer: ShortenedTypePrinter)(using Context): String =
override def description(printer: ShortenedTypePrinter)(using
Context
): String =
desc

case class CaseKeyword(
Expand All @@ -239,7 +251,9 @@ object CompletionValue:
override def completionItemKind(using Context): CompletionItemKind =
CompletionItemKind.Snippet

override def description(printer: ShortenedTypePrinter)(using Context): String =
override def description(printer: ShortenedTypePrinter)(using
Context
): String =
description
override def insertMode: Option[InsertTextMode] = Some(InsertTextMode.AsIs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object KeywordsCompletions:
comments: List[Comment]
)(using ctx: Context): List[CompletionValue] =
lazy val notInComment =
checkIfNotInComment(completionPos.cursorPos, path, comments)
checkIfNotInComment(completionPos.cursorPos, comments)

path match
case Nil if completionPos.query.isEmpty =>
Expand Down Expand Up @@ -69,9 +69,8 @@ object KeywordsCompletions:

private def checkIfNotInComment(
pos: SourcePosition,
path: List[Tree],
comments: List[Comment]
)(using ctx: Context): Boolean =
): Boolean =
!comments.exists(_.span.contains(pos.span))

private def isPackage(enclosing: List[Tree]): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ object CaseKeywordCompletion:
completionPos,
clientSupportsSnippets
)
val result = ListBuffer.empty[CompletionValue]
val tpe = selector.tpe.widen.bounds.hi match
case tr @ TypeRef(_, _) => tr.underlying
case t => t
Expand Down
Loading

0 comments on commit aa7542f

Please sign in to comment.