Skip to content

Commit e7fda08

Browse files
committed
refactor: change package from scala.meta to dotty.tools.pc
1 parent 6913a22 commit e7fda08

File tree

61 files changed

+662
-768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+662
-768
lines changed

.scalafmt.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version = "3.7.3"
2+
runner.dialect = scala3
3+
4+
maxColumn = 80
5+
align.preset = none
6+
docstrings.style = Asterisk
7+
docstrings.wrap = no
8+
assumeStandardLibraryStripMargin = true
9+
align.stripMargin = true
10+
newlines.inInterpolation = avoid
11+
trailingCommas = multiple
12+
13+
rewrite.scala3.removeOptionalBraces = yes
14+
15+
project.includePaths = [
16+
"glob:**/presentation-compiler/**"
17+
]
18+
19+
project.excludePaths = [
20+
"glob:**/target/**"
21+
"glob:**/out/**"
22+
]

presentation-compiler/src/main/scala/meta/internal/pc/AutoImports.scala renamed to presentation-compiler/src/main/dotty/tools/pc/AutoImports.scala

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
package scala.meta.internal.pc
1+
package dotty.tools.pc
22

33
import scala.annotation.tailrec
44
import scala.jdk.CollectionConverters.*
55

66
import scala.meta.internal.mtags.KeywordWrapper
7-
import scala.meta.internal.mtags.MtagsEnrichments.*
8-
import scala.meta.internal.pc.printer.ShortenedNames.ShortName
7+
import dotty.tools.pc.utils.MtagsEnrichments.*
8+
import dotty.tools.pc.printer.ShortenedNames.ShortName
99
import scala.meta.pc.PresentationCompilerConfig
10+
import scala.meta.internal.pc.AutoImportPosition
1011

1112
import dotty.tools.dotc.ast.tpd.*
1213
import dotty.tools.dotc.core.Contexts.*
@@ -68,7 +69,7 @@ object AutoImports extends AutoImportsBackticks:
6869
case class SymbolImport(
6970
sym: Symbol,
7071
ident: SymbolIdent,
71-
importSel: Option[ImportSel],
72+
importSel: Option[ImportSel]
7273
):
7374

7475
def name: String = ident.value
@@ -93,7 +94,7 @@ object AutoImports extends AutoImportsBackticks:
9394
tree: Tree,
9495
comments: List[Comment],
9596
indexedContext: IndexedContext,
96-
config: PresentationCompilerConfig,
97+
config: PresentationCompilerConfig
9798
): AutoImportsGenerator =
9899

99100
import indexedContext.ctx
@@ -111,13 +112,13 @@ object AutoImports extends AutoImportsBackticks:
111112
pos,
112113
importPos,
113114
indexedContext,
114-
renames,
115+
renames
115116
)
116117
end generator
117118

118119
case class AutoImportEdits(
119120
nameEdit: Option[l.TextEdit],
120-
importEdit: Option[l.TextEdit],
121+
importEdit: Option[l.TextEdit]
121122
):
122123

123124
def edits: List[l.TextEdit] = List(nameEdit, importEdit).flatten
@@ -144,7 +145,7 @@ object AutoImports extends AutoImportsBackticks:
144145
val pos: SourcePosition,
145146
importPosition: AutoImportPosition,
146147
indexedContext: IndexedContext,
147-
renames: Symbol => Option[String],
148+
renames: Symbol => Option[String]
148149
):
149150

150151
import indexedContext.ctx
@@ -177,8 +178,7 @@ object AutoImports extends AutoImportsBackticks:
177178

178179
val importEdit =
179180
symbolImport.importSel.flatMap(sel => renderImports(List(sel)))
180-
if nameEdit.isDefined || importEdit.isDefined then
181-
Some(AutoImportEdits(nameEdit, importEdit))
181+
if nameEdit.isDefined || importEdit.isDefined then Some(AutoImportEdits(nameEdit, importEdit))
182182
else None
183183
end editsForSymbol
184184

@@ -198,7 +198,7 @@ object AutoImports extends AutoImportsBackticks:
198198
(
199199
SymbolIdent.Select(
200200
ownerImport.ident,
201-
symbol.nameBacktickedImport,
201+
symbol.nameBacktickedImport
202202
),
203203
ownerImport.importSel,
204204
)
@@ -212,7 +212,7 @@ object AutoImports extends AutoImportsBackticks:
212212
SymbolImport(
213213
symbol,
214214
name,
215-
sel,
215+
sel
216216
)
217217
case IndexedContext.Result.Conflict =>
218218
val owner = symbol.owner
@@ -224,23 +224,21 @@ object AutoImports extends AutoImportsBackticks:
224224
!indexedContext.hasRename(owner, rename)
225225
)
226226
else
227-
Some(ImportSel.Direct(owner)).filter(_ =>
228-
!indexedContext.lookupSym(owner).exists
229-
)
227+
Some(ImportSel.Direct(owner)).filter(_ => !indexedContext.lookupSym(owner).exists)
230228

231229
SymbolImport(
232230
symbol,
233231
SymbolIdent.Select(
234232
SymbolIdent.direct(rename),
235-
symbol.nameBacktickedImport,
233+
symbol.nameBacktickedImport
236234
),
237-
importSel,
235+
importSel
238236
)
239237
case None =>
240238
SymbolImport(
241239
symbol,
242240
SymbolIdent.direct(symbol.fullNameBackticked),
243-
None,
241+
None
244242
)
245243
end match
246244
case IndexedContext.Result.InScope =>
@@ -290,17 +288,16 @@ object AutoImports extends AutoImportsBackticks:
290288
pos: SourcePosition,
291289
text: String,
292290
tree: Tree,
293-
comments: List[Comment],
291+
comments: List[Comment]
294292
)(using Context): AutoImportPosition =
295293

296294
@tailrec
297295
def lastPackageDef(
298296
prev: Option[PackageDef],
299-
tree: Tree,
297+
tree: Tree
300298
): Option[PackageDef] =
301299
tree match
302-
case curr @ PackageDef(_, (next: PackageDef) :: Nil)
303-
if !curr.symbol.isPackageObject =>
300+
case curr @ PackageDef(_, (next: PackageDef) :: Nil) if !curr.symbol.isPackageObject =>
304301
lastPackageDef(Some(curr), next)
305302
case pkg: PackageDef if !pkg.symbol.isPackageObject => Some(pkg)
306303
case _ => prev
@@ -310,8 +307,7 @@ object AutoImports extends AutoImportsBackticks:
310307
case PackageDef(_, stats) =>
311308
stats.flatMap {
312309
case s: PackageDef => firstObjectBody(s)
313-
case TypeDef(_, t @ Template(defDef, _, _, _))
314-
if defDef.symbol.showName == "<init>" =>
310+
case TypeDef(_, t @ Template(defDef, _, _, _)) if defDef.symbol.showName == "<init>" =>
315311
Some(t)
316312
case _ => None
317313
}.headOption
@@ -320,8 +316,7 @@ object AutoImports extends AutoImportsBackticks:
320316
def skipUsingDirectivesOffset =
321317
comments
322318
.takeWhile(comment =>
323-
!comment.isDocComment && comment.span.end < firstObjectBody(tree)
324-
.fold(0)(_.span.start)
319+
!comment.isDocComment && comment.span.end < firstObjectBody(tree).fold(0)(_.span.start)
325320
)
326321
.lastOption
327322
.fold(0)(_.span.end + 1)
@@ -355,10 +350,8 @@ object AutoImports extends AutoImportsBackticks:
355350
offset
356351
case None =>
357352
val scriptOffset =
358-
if isAmmonite then
359-
ScriptFirstImportPosition.ammoniteScStartOffset(text, comments)
360-
else
361-
ScriptFirstImportPosition.scalaCliScStartOffset(text, comments)
353+
if isAmmonite then ScriptFirstImportPosition.ammoniteScStartOffset(text, comments)
354+
else ScriptFirstImportPosition.scalaCliScStartOffset(text, comments)
362355

363356
scriptOffset.getOrElse(
364357
pos.source.lineToOffset(tmpl.self.srcPos.line)
@@ -373,7 +366,7 @@ object AutoImports extends AutoImportsBackticks:
373366
AutoImportPosition(
374367
skipUsingDirectivesOffset,
375368
0,
376-
padTop = false,
369+
padTop = false
377370
)
378371

379372
val scriptPos =

presentation-compiler/src/main/scala/meta/internal/pc/AutoImportsProvider.scala renamed to presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
package scala.meta.internal.pc
1+
package dotty.tools.pc
22

33
import java.nio.file.Paths
44

55
import scala.collection.mutable
66
import scala.jdk.CollectionConverters.*
77

88
import scala.meta.internal.metals.ReportContext
9-
import scala.meta.internal.mtags.MtagsEnrichments.*
10-
import scala.meta.internal.pc.AutoImports.*
11-
import scala.meta.internal.pc.completions.CompletionPos
9+
import scala.meta.internal.pc.AutoImportsResultImpl
10+
import dotty.tools.pc.utils.MtagsEnrichments.*
11+
import dotty.tools.pc.AutoImports.*
12+
import dotty.tools.pc.completions.CompletionPos
1213
import scala.meta.pc.*
1314

1415
import dotty.tools.dotc.ast.tpd.*
@@ -24,15 +25,15 @@ final class AutoImportsProvider(
2425
name: String,
2526
params: OffsetParams,
2627
config: PresentationCompilerConfig,
27-
buildTargetIdentifier: String,
28+
buildTargetIdentifier: String
2829
)(using ReportContext):
2930

3031
def autoImports(isExtension: Boolean): List[AutoImportsResult] =
3132
val uri = params.uri
3233
val filePath = Paths.get(uri)
3334
driver.run(
3435
uri,
35-
SourceFile.virtual(filePath.toString, params.text),
36+
SourceFile.virtual(filePath.toString, params.text)
3637
)
3738
val unit = driver.currentCtx.run.units.head
3839
val tree = unit.tpdTree
@@ -61,8 +62,7 @@ final class AutoImportsProvider(
6162
sym.name.show == query
6263

6364
val visitor = new CompilerSearchVisitor(visit)
64-
if isExtension then
65-
search.searchMethods(name, buildTargetIdentifier, visitor)
65+
if isExtension then search.searchMethods(name, buildTargetIdentifier, visitor)
6666
else search.search(name, buildTargetIdentifier, visitor)
6767
val results = symbols.result.filter(isExactMatch(_, name))
6868

@@ -84,7 +84,7 @@ final class AutoImportsProvider(
8484
tree,
8585
unit.comments,
8686
indexedContext.importContext,
87-
config,
87+
config
8888
)
8989
(sym: Symbol) => generator.forSymbol(sym)
9090
end match
@@ -95,7 +95,7 @@ final class AutoImportsProvider(
9595
edits <- mkEdit(sym)
9696
yield AutoImportsResultImpl(
9797
sym.owner.showFullName,
98-
edits.asJava,
98+
edits.asJava
9999
)
100100
else List.empty
101101
end if

presentation-compiler/src/main/scala/meta/internal/pc/CompilerInterfaces.scala renamed to presentation-compiler/src/main/dotty/tools/pc/CompilerInterfaces.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package scala.meta.internal.pc
1+
package dotty.tools.pc
22

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

presentation-compiler/src/main/scala/meta/internal/pc/CompilerSearchVisitor.scala renamed to presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package scala.meta.internal.pc
1+
package dotty.tools.pc
22

33
import java.util.logging.Level
44
import java.util.logging.Logger
@@ -20,23 +20,22 @@ class CompilerSearchVisitor(
2020

2121
val logger: Logger = Logger.getLogger(classOf[CompilerSearchVisitor].getName)
2222

23-
private def isAccessible(sym: Symbol): Boolean = try
24-
sym != NoSymbol && sym.isPublic
23+
private def isAccessible(sym: Symbol): Boolean = try sym != NoSymbol && sym.isPublic
2524
catch
2625
case NonFatal(e) =>
2726
reports.incognito.create(
2827
Report(
2928
"is_public",
3029
s"""Symbol: $sym""".stripMargin,
31-
e,
30+
e
3231
)
3332
)
3433
logger.log(Level.SEVERE, e.getMessage(), e)
3534
false
3635

3736
private def toSymbols(
3837
pkg: String,
39-
parts: List[String],
38+
parts: List[String]
4039
): List[Symbol] =
4140
def loop(owners: List[Symbol], parts: List[String]): List[Symbol] =
4241
parts match
@@ -72,7 +71,7 @@ class CompilerSearchVisitor(
7271
path: java.nio.file.Path,
7372
symbol: String,
7473
kind: org.eclipse.lsp4j.SymbolKind,
75-
range: org.eclipse.lsp4j.Range,
74+
range: org.eclipse.lsp4j.Range
7675
): Int =
7776
val gsym = SemanticdbSymbols.inverseSemanticdbSymbol(symbol).headOption
7877
gsym

presentation-compiler/src/main/scala/meta/internal/pc/CompletionItemResolver.scala renamed to presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package scala.meta.internal.pc
1+
package dotty.tools.pc
22

3-
import scala.meta.internal.mtags.MtagsEnrichments.*
3+
import dotty.tools.pc.utils.MtagsEnrichments.*
44
import scala.meta.pc.PresentationCompilerConfig
55
import scala.meta.pc.SymbolDocumentation
66
import scala.meta.pc.SymbolSearch
7+
import scala.meta.internal.pc.ItemResolver
78

89
import dotty.tools.dotc.core.Contexts.Context
910
import dotty.tools.dotc.core.Flags.*
@@ -19,7 +20,7 @@ object CompletionItemResolver extends ItemResolver:
1920
item: CompletionItem,
2021
msym: String,
2122
search: SymbolSearch,
22-
metalsConfig: PresentationCompilerConfig,
23+
metalsConfig: PresentationCompilerConfig
2324
)(using Context): CompletionItem =
2425
SemanticdbSymbols.inverseSemanticdbSymbol(msym) match
2526
case gsym :: _ if gsym != NoSymbol =>
@@ -34,7 +35,7 @@ object CompletionItemResolver extends ItemResolver:
3435
info,
3536
metalsConfig,
3637
fullDocstring(gsym, search),
37-
gsym.is(JavaDefined),
38+
gsym.is(JavaDefined)
3839
)
3940
case _ =>
4041
item
@@ -59,8 +60,7 @@ object CompletionItemResolver extends ItemResolver:
5960
val companion = gsym.companion
6061
if companion == NoSymbol || gsym.is(JavaDefined) then
6162
if gsymDoc.isEmpty then
62-
if gsym.isAliasType then
63-
fullDocstring(gsym.info.metalsDealias.typeSymbol, search)
63+
if gsym.isAliasType then fullDocstring(gsym.info.metalsDealias.typeSymbol, search)
6464
else if gsym.is(Method) then
6565
gsym.info.finalResultType match
6666
case tr @ TermRef(_, sym) =>
@@ -80,7 +80,7 @@ object CompletionItemResolver extends ItemResolver:
8080
|""".stripMargin,
8181
s"""|### ${keyword(gsym)} ${gsym.name}
8282
|${gsymDoc}
83-
|""".stripMargin,
83+
|""".stripMargin
8484
).sorted.mkString("\n")
8585
end if
8686
end fullDocstring

presentation-compiler/src/main/scala/meta/internal/pc/ConvertToNamedArgumentsProvider.scala renamed to presentation-compiler/src/main/dotty/tools/pc/ConvertToNamedArgumentsProvider.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package scala.meta.internal.pc
1+
package dotty.tools.pc
22

33
import java.nio.file.Paths
44

5-
import scala.meta.internal.mtags.MtagsEnrichments.*
5+
import dotty.tools.pc.utils.MtagsEnrichments.*
66
import scala.meta.pc.OffsetParams
7+
import scala.meta.internal.pc.CodeActionErrorMessages
78

89
import dotty.tools.dotc.ast.tpd
910
import dotty.tools.dotc.core.Contexts.Context
@@ -17,15 +18,15 @@ import org.eclipse.{lsp4j as l}
1718
final class ConvertToNamedArgumentsProvider(
1819
driver: InteractiveDriver,
1920
params: OffsetParams,
20-
argIndices: Set[Int],
21+
argIndices: Set[Int]
2122
):
2223

2324
def convertToNamedArguments: Either[String, List[l.TextEdit]] =
2425
val uri = params.uri
2526
val filePath = Paths.get(uri)
2627
driver.run(
2728
uri,
28-
SourceFile.virtual(filePath.toString, params.text),
29+
SourceFile.virtual(filePath.toString, params.text)
2930
)
3031
val unit = driver.currentCtx.run.units.head
3132
val newctx = driver.currentCtx.fresh.setCompilationUnit(unit)

0 commit comments

Comments
 (0)