Skip to content

Commit 1f63dee

Browse files
committed
properly add parentheses to all java methods in PC
1 parent dd0683a commit 1f63dee

21 files changed

+68
-68
lines changed

presentation-compiler/src/main/dotty/tools/pc/AutoImports.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object AutoImports:
2323
def renameConfigMap(config: PresentationCompilerConfig)(using
2424
Context
2525
): Map[Symbol, String] =
26-
config.symbolPrefixes.nn.asScala.flatMap { (from, to) =>
26+
config.symbolPrefixes().nn.asScala.flatMap { (from, to) =>
2727
val pkg = SemanticdbSymbols.inverseSemanticdbSymbol(from)
2828
val rename = to.stripSuffix(".").stripSuffix("#")
2929
List(pkg, pkg.map(_.moduleClass)).flatten
@@ -246,7 +246,7 @@ object AutoImports:
246246
// see WorksheetProvider.worksheetScala3AdjustmentsForPC
247247
val indent =
248248
if pos.source.path.isWorksheet &&
249-
editPos.getStart().nn.getCharacter == 0
249+
editPos.getStart().nn.getCharacter() == 0
250250
then indent0.drop(2)
251251
else indent0
252252
val topPadding =

presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ final class AutoImportsProvider(
2929
)(using ReportContext):
3030

3131
def autoImports(isExtension: Boolean): List[AutoImportsResult] =
32-
val uri = params.uri.nn
33-
val text = params.text.nn
32+
val uri = params.uri().nn
33+
val text = params.text().nn
3434
val filePath = Paths.get(uri)
3535
driver.run(uri, SourceFile.virtual(filePath.toString, text))
3636

presentation-compiler/src/main/dotty/tools/pc/CompletionItemResolver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object CompletionItemResolver extends ItemResolver:
3030
.orElse(
3131
search.symbolDocumentation(gsym.companion)
3232
) match
33-
case Some(info) if item.getDetail != null =>
33+
case Some(info) if item.getDetail() != null =>
3434
enrichDocs(
3535
item,
3636
info,

presentation-compiler/src/main/dotty/tools/pc/ConvertToNamedArgumentsProvider.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ final class ConvertToNamedArgumentsProvider(
2323
):
2424

2525
def convertToNamedArguments: Either[String, List[l.TextEdit]] =
26-
val uri = params.uri.nn
27-
val text = params.text.nn
26+
val uri = params.uri().nn
27+
val text = params.text().nn
2828
val filePath = Paths.get(uri)
2929
driver.run(uri, SourceFile.virtual(filePath.toString, text))
3030

presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ final class ExtractMethodProvider(
3838
extends ExtractMethodUtils:
3939

4040
def extractMethod(): List[TextEdit] =
41-
val text = range.text.nn
42-
val uri = range.uri.nn
41+
val text = range.text().nn
42+
val uri = range.uri().nn
4343
val filePath = Paths.get(uri)
4444
val source = SourceFile.virtual(filePath.toString, text)
4545
driver.run(uri, source)

presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ object HoverProvider:
3232
driver: InteractiveDriver,
3333
search: SymbolSearch
3434
)(implicit reportContext: ReportContext): ju.Optional[HoverSignature] =
35-
val uri = params.uri.nn
36-
val text = params.text.nn
35+
val uri = params.uri().nn
36+
val text = params.text().nn
3737
val sourceFile = SourceFile.virtual(uri, text)
3838
driver.run(uri, sourceFile)
3939

@@ -126,7 +126,7 @@ object HoverProvider:
126126

127127
val docString = symbolTpes
128128
.flatMap(symTpe => search.symbolDocumentation(symTpe._1))
129-
.map(_.docstring)
129+
.map(_.docstring())
130130
.mkString("\n")
131131
printer.expressionType(exprTpw) match
132132
case Some(expressionType) =>

presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ final class InferredTypeProvider(
6262
adjustOpt: Option[AdjustTypeOpts] = None
6363
): List[TextEdit] =
6464
val retryType = adjustOpt.isEmpty
65-
val uri = params.uri.nn
65+
val uri = params.uri().nn
6666
val filePath = Paths.get(uri).nn
6767

68-
val sourceText = adjustOpt.map(_.text).getOrElse(params.text.nn)
68+
val sourceText = adjustOpt.map(_.text).getOrElse(params.text().nn)
6969
val source =
7070
SourceFile.virtual(filePath.toString(), sourceText)
7171
driver.run(uri, source)
@@ -187,7 +187,7 @@ final class InferredTypeProvider(
187187
Some(
188188
AdjustTypeOpts(
189189
removeType(vl.namePos.end, tpt.sourcePos.end - 1),
190-
tpt.sourcePos.toLsp.getEnd.nn
190+
tpt.sourcePos.toLsp.getEnd().nn
191191
)
192192
)
193193
)
@@ -226,7 +226,7 @@ final class InferredTypeProvider(
226226
Some(
227227
AdjustTypeOpts(
228228
removeType(lastColon, tpt.sourcePos.end - 1),
229-
tpt.sourcePos.toLsp.getEnd.nn
229+
tpt.sourcePos.toLsp.getEnd().nn
230230
)
231231
)
232232
)
@@ -255,7 +255,7 @@ final class InferredTypeProvider(
255255
val firstEnd = patterns(0).endPos.end
256256
val secondStart = patterns(1).startPos.start
257257
val hasDot = params
258-
.text.nn
258+
.text().nn
259259
.substring(firstEnd, secondStart).nn
260260
.exists(_ == ',')
261261
if !hasDot then

presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ abstract class PcCollector[T](
3333
params: VirtualFileParams
3434
):
3535
private val caseClassSynthetics: Set[Name] = Set(nme.apply, nme.copy)
36-
val uri = params.uri.nn
36+
val uri = params.uri().nn
3737
val filePath = Paths.get(uri).nn
38-
val sourceText = params.text.nn
38+
val sourceText = params.text().nn
3939
val source =
4040
SourceFile.virtual(filePath.toString(), sourceText)
4141
driver.run(uri, source)
@@ -49,7 +49,7 @@ abstract class PcCollector[T](
4949
val offsetParams =
5050
params match
5151
case op: OffsetParams => op
52-
case _ => CompilerOffsetParams(uri, sourceText, 0, params.token.nn)
52+
case _ => CompilerOffsetParams(uri, sourceText, 0, params.token().nn)
5353
val pos = driver.sourcePosition(offsetParams)
5454
val rawPath =
5555
Interactive

presentation-compiler/src/main/dotty/tools/pc/PcDefinitionProvider.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class PcDefinitionProvider(
3636
definitions(findTypeDef = true)
3737

3838
private def definitions(findTypeDef: Boolean): DefinitionResult =
39-
val uri = params.uri.nn
40-
val text = params.text.nn
39+
val uri = params.uri().nn
40+
val text = params.text().nn
4141
val filePath = Paths.get(uri)
4242
driver.run(
4343
uri,
@@ -54,7 +54,7 @@ class PcDefinitionProvider(
5454
if findTypeDef then findTypeDefinitions(path, pos, indexedContext)
5555
else findDefinitions(path, pos, indexedContext)
5656

57-
if result.locations.nn.isEmpty() then fallbackToUntyped(pos)(using ctx)
57+
if result.locations().nn.isEmpty() then fallbackToUntyped(pos)(using ctx)
5858
else result
5959
end definitions
6060

presentation-compiler/src/main/dotty/tools/pc/PcInlineValueProviderImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ final class PcInlineValueProviderImpl(
2727
) extends PcCollector[Option[Occurence]](driver, params)
2828
with InlineValueProvider:
2929

30-
val text = params.text.nn.toCharArray().nn
30+
val text = params.text().nn.toCharArray().nn
3131

32-
val position: l.Position = pos.toLsp.getStart.nn
32+
val position: l.Position = pos.toLsp.getStart().nn
3333

3434
override def collect(parent: Option[Tree])(
3535
tree: Tree | EndMarker,

presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ case class ScalaPresentationCompiler(
117117
def complete(params: OffsetParams): CompletableFuture[l.CompletionList] =
118118
compilerAccess.withInterruptableCompiler(Some(params))(
119119
EmptyCompletionList(),
120-
params.token
120+
params.token()
121121
) { access =>
122122
val driver = access.compiler()
123123
new CompletionProvider(
@@ -134,7 +134,7 @@ case class ScalaPresentationCompiler(
134134
def definition(params: OffsetParams): CompletableFuture[DefinitionResult] =
135135
compilerAccess.withInterruptableCompiler(Some(params))(
136136
DefinitionResultImpl.empty,
137-
params.token
137+
params.token()
138138
) { access =>
139139
val driver = access.compiler()
140140
PcDefinitionProvider(driver, params, search).definitions()
@@ -145,7 +145,7 @@ case class ScalaPresentationCompiler(
145145
): CompletableFuture[DefinitionResult] =
146146
compilerAccess.withInterruptableCompiler(Some(params))(
147147
DefinitionResultImpl.empty,
148-
params.token
148+
params.token()
149149
) { access =>
150150
val driver = access.compiler()
151151
PcDefinitionProvider(driver, params, search).typeDefinitions()
@@ -156,7 +156,7 @@ case class ScalaPresentationCompiler(
156156
): CompletableFuture[ju.List[DocumentHighlight]] =
157157
compilerAccess.withInterruptableCompiler(Some(params))(
158158
List.empty[DocumentHighlight].asJava,
159-
params.token
159+
params.token()
160160
) { access =>
161161
val driver = access.compiler()
162162
PcDocumentHighlightProvider(driver, params).highlights.asJava
@@ -208,7 +208,7 @@ case class ScalaPresentationCompiler(
208208
] =
209209
compilerAccess.withNonInterruptableCompiler(Some(params))(
210210
List.empty[scala.meta.pc.AutoImportsResult].asJava,
211-
params.token
211+
params.token()
212212
) { access =>
213213
val driver = access.compiler()
214214
new AutoImportsProvider(
@@ -229,7 +229,7 @@ case class ScalaPresentationCompiler(
229229
val empty: ju.List[l.TextEdit] = new ju.ArrayList[l.TextEdit]()
230230
compilerAccess.withNonInterruptableCompiler(Some(params))(
231231
empty,
232-
params.token
232+
params.token()
233233
) { pc =>
234234
val driver = pc.compiler()
235235
OverrideCompletions.implementAllAt(
@@ -247,7 +247,7 @@ case class ScalaPresentationCompiler(
247247
val empty: ju.List[l.TextEdit] = new ju.ArrayList[l.TextEdit]()
248248
compilerAccess.withNonInterruptableCompiler(Some(params))(
249249
empty,
250-
params.token
250+
params.token()
251251
) { pc =>
252252
new InferredTypeProvider(params, pc.compiler(), config, search)
253253
.inferredTypeEdits()
@@ -259,7 +259,7 @@ case class ScalaPresentationCompiler(
259259
): CompletableFuture[ju.List[l.TextEdit]] =
260260
val empty: Either[String, List[l.TextEdit]] = Right(List())
261261
(compilerAccess
262-
.withInterruptableCompiler(Some(params))(empty, params.token) { pc =>
262+
.withInterruptableCompiler(Some(params))(empty, params.token()) { pc =>
263263
new PcInlineValueProviderImpl(pc.compiler(), params)
264264
.getInlineTextEdits()
265265
})
@@ -274,7 +274,7 @@ case class ScalaPresentationCompiler(
274274
extractionPos: OffsetParams
275275
): CompletableFuture[ju.List[l.TextEdit]] =
276276
val empty: ju.List[l.TextEdit] = new ju.ArrayList[l.TextEdit]()
277-
compilerAccess.withInterruptableCompiler(Some(range))(empty, range.token) {
277+
compilerAccess.withInterruptableCompiler(Some(range))(empty, range.token()) {
278278
pc =>
279279
new ExtractMethodProvider(
280280
range,
@@ -294,7 +294,7 @@ case class ScalaPresentationCompiler(
294294
): CompletableFuture[ju.List[l.TextEdit]] =
295295
val empty: Either[String, List[l.TextEdit]] = Right(List())
296296
(compilerAccess
297-
.withNonInterruptableCompiler(Some(params))(empty, params.token) { pc =>
297+
.withNonInterruptableCompiler(Some(params))(empty, params.token()) { pc =>
298298
new ConvertToNamedArgumentsProvider(
299299
pc.compiler(),
300300
params,
@@ -326,7 +326,7 @@ case class ScalaPresentationCompiler(
326326
): CompletableFuture[ju.Optional[HoverSignature]] =
327327
compilerAccess.withNonInterruptableCompiler(Some(params))(
328328
ju.Optional.empty[HoverSignature](),
329-
params.token
329+
params.token()
330330
) { access =>
331331
val driver = access.compiler()
332332
HoverProvider.hover(params, driver, search)
@@ -338,7 +338,7 @@ case class ScalaPresentationCompiler(
338338
): CompletableFuture[ju.Optional[l.Range]] =
339339
compilerAccess.withNonInterruptableCompiler(Some(params))(
340340
Optional.empty[l.Range](),
341-
params.token
341+
params.token()
342342
) { access =>
343343
val driver = access.compiler()
344344
Optional.ofNullable(
@@ -352,7 +352,7 @@ case class ScalaPresentationCompiler(
352352
): CompletableFuture[ju.List[l.TextEdit]] =
353353
compilerAccess.withNonInterruptableCompiler(Some(params))(
354354
List[l.TextEdit]().asJava,
355-
params.token
355+
params.token()
356356
) { access =>
357357
val driver = access.compiler()
358358
PcRenameProvider(driver, params, Some(name)).rename().asJava
@@ -372,7 +372,7 @@ case class ScalaPresentationCompiler(
372372
def signatureHelp(params: OffsetParams): CompletableFuture[l.SignatureHelp] =
373373
compilerAccess.withNonInterruptableCompiler(Some(params))(
374374
new l.SignatureHelp(),
375-
params.token
375+
params.token()
376376
) { access =>
377377
val driver = access.compiler()
378378
SignatureHelpProvider.signatureHelp(driver, params, search)

presentation-compiler/src/main/dotty/tools/pc/SelectionRangeProvider.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class SelectionRangeProvider(
3636

3737
params.asScala.toList.map { param =>
3838

39-
val uri = param.uri.nn
40-
val text = param.text.nn
39+
val uri = param.uri().nn
40+
val text = param.text().nn
4141
val filePath = Paths.get(uri)
4242
val source = SourceFile.virtual(filePath.toString, text)
4343
driver.run(uri, source)

presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ object SignatureHelpProvider:
2828
params: OffsetParams,
2929
search: SymbolSearch
3030
) =
31-
val uri = params.uri
32-
val sourceFile = SourceFile.virtual(params.uri.nn, params.text.nn)
31+
val uri = params.uri()
32+
val sourceFile = SourceFile.virtual(params.uri().nn, params.text().nn)
3333
driver.run(uri.nn, sourceFile)
3434

3535
given ctx: Context = driver.currentCtx
@@ -101,7 +101,7 @@ object SignatureHelpProvider:
101101
signature: Signatures.Signature,
102102
isJavaSymbol: Boolean
103103
): Option[Signature] =
104-
val allParams = info.parameters.nn.asScala
104+
val allParams = info.parameters().nn.asScala
105105
def updateParams(
106106
params: List[Signatures.Param],
107107
index: Int
@@ -114,7 +114,7 @@ object SignatureHelpProvider:
114114
case Some(paramDoc) =>
115115
val newName =
116116
if isJavaSymbol && head.name.startsWith("x$") then
117-
paramDoc.nn.displayName
117+
paramDoc.nn.displayName()
118118
else head.name
119119
head.copy(
120120
doc = Some(paramDoc.docstring.nn),
@@ -132,7 +132,7 @@ object SignatureHelpProvider:
132132
val updated = updateParams(head, index)
133133
updated :: updateParamss(tail, index + head.size)
134134
val updatedParams = updateParamss(signature.paramss, 0)
135-
Some(signature.copy(doc = Some(info.docstring.nn), paramss = updatedParams))
135+
Some(signature.copy(doc = Some(info.docstring().nn), paramss = updatedParams))
136136
end withDocumentation
137137

138138
private def signatureToSignatureInformation(

presentation-compiler/src/main/dotty/tools/pc/completions/CompletionPos.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object CompletionPos:
4141
offsetParams: OffsetParams,
4242
treePath: List[Tree]
4343
)(using Context): CompletionPos =
44-
infer(cursorPos, offsetParams.uri.nn, offsetParams.text.nn, treePath)
44+
infer(cursorPos, offsetParams.uri().nn, offsetParams.text().nn, treePath)
4545

4646
def infer(
4747
cursorPos: SourcePosition,

presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class CompletionProvider(
4141
folderPath: Option[Path]
4242
)(using reports: ReportContext):
4343
def completions(): CompletionList =
44-
val uri = params.uri.nn
45-
val text = params.text.nn
44+
val uri = params.uri().nn
45+
val text = params.text().nn
4646

4747
val code = applyCompletionCursor(params)
4848
val sourceFile = SourceFile.virtual(uri, code)
@@ -125,8 +125,8 @@ class CompletionProvider(
125125
* because scala parser trim end position to the last statement pos.
126126
*/
127127
private def applyCompletionCursor(params: OffsetParams): String =
128-
val text = params.text.nn
129-
val offset = params.offset.nn
128+
val text = params.text().nn
129+
val offset = params.offset().nn
130130

131131
val isStartMultilineComment =
132132
val i = params.offset()
@@ -187,7 +187,7 @@ class CompletionProvider(
187187

188188
item.setTags(completion.lspTags.asJava)
189189

190-
if config.isCompletionSnippetsEnabled then
190+
if config.isCompletionSnippetsEnabled() then
191191
item.setInsertTextFormat(InsertTextFormat.Snippet)
192192

193193
completion.command.foreach { command =>
@@ -231,7 +231,7 @@ class CompletionProvider(
231231
case Some(edits) =>
232232
edits match
233233
case AutoImportEdits(Some(nameEdit), other) =>
234-
mkItem(nameEdit.getNewText.nn, other.toList, range = Some(nameEdit.getRange.nn))
234+
mkItem(nameEdit.getNewText().nn, other.toList, range = Some(nameEdit.getRange().nn))
235235
case _ =>
236236
mkItem(
237237
v.insertText.getOrElse( ident.backticked(backtickSoftKeyword) + completionTextSuffix),

0 commit comments

Comments
 (0)