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 8563404
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 30 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 @@ -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,7 +69,7 @@ class PcDefinitionProvider(
* @param pos cursor position
* @return definition result
*/
private def fallbackToUntyped(unit: CompilationUnit, pos: SourcePosition)(
private def fallbackToUntyped(pos: SourcePosition)(
using ctx: Context
) =
lazy val untpdPath = NavigateAST
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ package dotty.tools.pc.printer

import scala.collection.mutable
import scala.meta.internal.jdk.CollectionConverters.*
import scala.meta.internal.metals.Report
import scala.meta.internal.metals.ReportContext
import scala.meta.pc.SymbolDocumentation
import scala.meta.pc.SymbolSearch
import scala.util.Failure
import scala.util.Success
import scala.util.Try

import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Flags
Expand All @@ -24,13 +20,8 @@ import dotty.tools.dotc.core.Types.Type
import dotty.tools.pc.IndexedContext
import dotty.tools.pc.Params
import dotty.tools.pc.utils.MtagsEnrichments.*
import dotty.tools.dotc.printing.PlainPrinter
import dotty.tools.dotc.printing.Texts.Text
import dotty.tools.dotc.core.Decorators.show
import dotty.tools.dotc.printing.RefinedPrinter
import dotty.tools.dotc.printing.Formatting.ShownDef.ctxShow
import dotty.tools.dotc.typer.ImportInfo
import dotty.tools.dotc.core.Annotations.Annotation
import dotty.tools.pc.IndexedContext.Result
import dotty.tools.pc.AutoImports.AutoImportsGenerator
import org.eclipse.lsp4j.TextEdit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dotty.tools.pc.base

import java.net.URI
import java.nio.file.Paths

import scala.meta.internal.metals.CompilerOffsetParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dotty.tools.pc.tests
import java.nio.file.Path

import dotty.tools.pc.base.{BaseCompletionSuite, BaseExtractMethodSuite}
import dotty.tools.pc.utils.MockEntries

import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ class CompletionOverrideSuite extends BaseCompletionSuite:
topLines = Some(3)
)

@Test def `pathdependent` =
@Test def `path-dependent` =
checkEdit(
"""|trait Over {
| object Outer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ class AutoImplementAbstractMembersSuite extends BaseCodeActionSuite:
|""".stripMargin
)

@Test def `testtest` =
@Test def `path-dependent-type-arg` =
checkEdit(
"""|package a
|import scala.deriving.Mirror
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.meta.pc.SymbolDocumentation
import dotty.tools.pc.base.BaseHoverSuite
import dotty.tools.pc.utils.MockEntries

import org.junit.{Ignore, Test}
import org.junit.Test

class HoverNamedArgSuite extends BaseHoverSuite:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class HoverRangeSuite extends BaseHoverSuite:
|inline transparent def foo(i: Int): Foo""".stripMargin.hoverRange
)

@Test def `deptypes` =
@Test def `dep-types` =
check(
"""|trait A
|object A1 extends A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ class HoverTermSuite extends BaseHoverSuite:

@Test def `annot` =
check(
"""|
"""|import scala.annotation.tailrec
|
|object O {
| @<<scala.annotation.tail@@rec>>
| @<<tail@@rec>>
| def hello(n: Int): Int = {
| if (i == 0) 0
| else hello( n - 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.interactive.InteractiveDriver
import dotty.tools.dotc.semanticdb.SemanticSymbolBuilder
import dotty.tools.pc.CompilerSearchVisitor
import java.nio.file.Files

object TestingWorkspaceSearch:
def empty: TestingWorkspaceSearch = new TestingWorkspaceSearch(Nil)
Expand Down
1 change: 1 addition & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ object Build {
val mtagsVersion = "0.11.12+45-45df705d-SNAPSHOT" // Will be set to stable release after 0.11.13 is published

Seq(
scalacOptions += "-Wunused:all",
libraryDependencies ++= Seq(
"org.lz4" % "lz4-java" % "1.8.0",
"io.get-coursier" % "interface" % "1.0.13",
Expand Down

0 comments on commit 8563404

Please sign in to comment.