Skip to content

Commit 0b71e50

Browse files
committed
Remove unneeded .nn in presentation compiler
1 parent f4e0fe2 commit 0b71e50

31 files changed

+129
-130
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().asScala.flatMap { (from, to) =>
2727
val pkg = SemanticdbSymbols.inverseSemanticdbSymbol(from)
2828
val rename = to.stripSuffix(".").stripSuffix("#")
2929
List(pkg, pkg.map(_.moduleClass)).flatten
@@ -253,7 +253,7 @@ object AutoImports:
253253
// see WorksheetProvider.worksheetScala3AdjustmentsForPC
254254
val indent =
255255
if pos.source.path.isWorksheet &&
256-
editPos.getStart().nn.getCharacter() == 0
256+
editPos.getStart().getCharacter() == 0
257257
then indent0.drop(2)
258258
else indent0
259259
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
@@ -30,8 +30,8 @@ final class AutoImportsProvider(
3030
)(using ReportContext):
3131

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CompilerSearchVisitor(
1919
)(using ctx: Context, reports: ReportContext)
2020
extends SymbolSearchVisitor:
2121

22-
val logger: Logger = Logger.getLogger(classOf[CompilerSearchVisitor].getName()).nn
22+
val logger: Logger = Logger.getLogger(classOf[CompilerSearchVisitor].getName())
2323

2424
private def isAccessibleImplicitClass(sym: Symbol) =
2525
val owner = sym.maybeOwner
@@ -77,7 +77,7 @@ class CompilerSearchVisitor(
7777
.split("\\$")
7878

7979
val added =
80-
try toSymbols(pkg, innerPath.nn.toList.map(_.nn)).filter(visitSymbol)
80+
try toSymbols(pkg, innerPath.toList).filter(visitSymbol)
8181
catch
8282
case NonFatal(e) =>
8383
logger.log(Level.WARNING, e.getMessage(), e)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object CompletionItemResolver extends ItemResolver:
5050
Context
5151
): String =
5252
def docs(gsym: Symbol): String =
53-
search.symbolDocumentation(gsym).fold("")(_.docstring().nn)
53+
search.symbolDocumentation(gsym).fold("")(_.docstring())
5454
val gsymDoc = docs(gsym)
5555
def keyword(gsym: Symbol): String =
5656
if gsym.isClass then "class"

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()
27+
val text = params.text()
2828
val filePath = Paths.get(uri)
2929
driver.run(uri, SourceFile.virtual(filePath.toString, text))
3030

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DiagnosticProvider(driver: InteractiveDriver, params: VirtualFileParams):
1818

1919
def diagnostics(): List[lsp4j.Diagnostic] =
2020
if params.shouldReturnDiagnostics then
21-
val diags = driver.run(params.uri().nn, params.text().nn)
21+
val diags = driver.run(params.uri(), params.text())
2222
given Context = driver.currentCtx
2323
diags.flatMap(toLsp)
2424
else Nil

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

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

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

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ object HoverProvider:
3737
search: SymbolSearch,
3838
contentType: ContentType
3939
)(implicit reportContext: ReportContext): ju.Optional[HoverSignature] =
40-
val uri = params.uri().nn
41-
val text = params.text().nn
40+
val uri = params.uri()
41+
val text = params.text()
4242
val sourceFile = SourceFile.virtual(uri, text)
4343
driver.run(uri, sourceFile)
4444
val unit = driver.compilationUnits.get(uri)
@@ -90,7 +90,7 @@ object HoverProvider:
9090
)
9191
end report
9292
reportContext.unsanitized.create(() => report, /*ifVerbose =*/ true)
93-
ju.Optional.empty().nn
93+
ju.Optional.empty()
9494
else
9595
val skipCheckOnName =
9696
!pos.isPoint // don't check isHoveringOnName for RangeHover
@@ -158,9 +158,9 @@ object HoverProvider:
158158
contextInfo = printer.getUsedRenamesInfo,
159159
contentType = contentType
160160
)
161-
).nn
161+
)
162162
case _ =>
163-
ju.Optional.empty().nn
163+
ju.Optional.empty()
164164
end match
165165
case (_, tpe, Some(namedTupleArg)) :: _ =>
166166
val exprTpw = tpe.widenTermRefExpr.deepDealiasAndSimplify
@@ -175,8 +175,8 @@ object HoverProvider:
175175
contextInfo = printer.getUsedRenamesInfo,
176176
contentType = contentType
177177
)
178-
).nn
179-
case _ => ju.Optional.empty().nn
178+
)
179+
case _ => ju.Optional.empty()
180180
end match
181181
end if
182182
end hover
@@ -238,7 +238,7 @@ object HoverProvider:
238238

239239
refTpe.flatMap(findRefinement).headOption.asJava
240240
case _ =>
241-
ju.Optional.empty().nn
241+
ju.Optional.empty()
242242

243243
end HoverProvider
244244

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

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ final class InferredMethodProvider(
5454
def inferredMethodEdits(
5555
adjustOpt: Option[AdjustTypeOpts] = None
5656
): List[TextEdit] =
57-
val uri = params.uri().nn
58-
val filePath = Paths.get(uri).nn
57+
val uri = params.uri()
58+
val filePath = Paths.get(uri)
5959

60-
val sourceText = adjustOpt.map(_.text).getOrElse(params.text().nn)
60+
val sourceText = adjustOpt.map(_.text).getOrElse(params.text())
6161
val source =
6262
SourceFile.virtual(filePath.toString(), sourceText)
6363
driver.run(uri, source)
@@ -101,8 +101,8 @@ final class InferredMethodProvider(
101101
.mkString(", ")
102102

103103
def printSignature(
104-
methodName: Name,
105-
params: List[List[Type]],
104+
methodName: Name,
105+
params: List[List[Type]],
106106
retTypeOpt: Option[Type]
107107
): String =
108108
val retTypeString = retTypeOpt match
@@ -145,15 +145,15 @@ final class InferredMethodProvider(
145145
/**
146146
* Returns the position to insert the method signature for a container.
147147
* If the container has an empty body, the position is the end of the container.
148-
* If the container has a non-empty body, the position is the end of the last element in the body.
149-
*
148+
* If the container has a non-empty body, the position is the end of the last element in the body.
149+
*
150150
* @param container the container to insert the method signature for
151151
* @return the position to insert the method signature for the container and a boolean indicating if the container has an empty body
152152
*/
153153
def insertPositionFor(container: Tree): Option[(SourcePosition, Boolean)] =
154154
val typeSymbol = container.tpe.widenDealias.typeSymbol
155155
if typeSymbol.exists then
156-
val trees = driver.openedTrees(params.uri().nn)
156+
val trees = driver.openedTrees(params.uri())
157157
val include = Interactive.Include.definitions | Interactive.Include.local
158158
Interactive.findTreesMatching(trees, include, typeSymbol).headOption match
159159
case Some(srcTree) =>
@@ -170,9 +170,9 @@ final class InferredMethodProvider(
170170

171171
/**
172172
* Extracts type information for a specific parameter in a method signature.
173-
* If the parameter is a function type, extracts both the function's argument types
173+
* If the parameter is a function type, extracts both the function's argument types
174174
* and return type. Otherwise, extracts just the parameter type.
175-
*
175+
*
176176
* @param methodType the method type to analyze
177177
* @param argIndex the index of the parameter to extract information for
178178
* @return a tuple of (argument types, return type) where:
@@ -192,7 +192,7 @@ final class InferredMethodProvider(
192192
else
193193
(None, Some(m.paramInfos(argIndex)))
194194
case _ => (None, None)
195-
195+
196196
def signatureEdits(signature: String): List[TextEdit] =
197197
val pos = insertPosition()
198198
val indent = indentation(params.text(), pos.start - 1)
@@ -234,17 +234,17 @@ final class InferredMethodProvider(
234234
* outerArgs
235235
* ---------------------------
236236
* method(..., errorMethod(args), ...)
237-
*
237+
*
238238
*/
239-
case (id @ Ident(errorMethod)) ::
240-
(apply @ Apply(func, args)) ::
241-
Apply(method, outerArgs) ::
239+
case (id @ Ident(errorMethod)) ::
240+
(apply @ Apply(func, args)) ::
241+
Apply(method, outerArgs) ::
242242
_ if id.symbol == NoSymbol && func == id && method != apply =>
243-
243+
244244
val argTypes = args.map(_.typeOpt.widenDealias)
245245

246246
val argIndex = outerArgs.indexOf(apply)
247-
val (allArgTypes, retTypeOpt) =
247+
val (allArgTypes, retTypeOpt) =
248248
extractParameterTypeInfo(method.tpe.widenDealias, argIndex) match
249249
case (Some(argTypes2), retTypeOpt) => (List(argTypes, argTypes2), retTypeOpt)
250250
case (None, retTypeOpt) => (List(argTypes), retTypeOpt)
@@ -257,12 +257,12 @@ final class InferredMethodProvider(
257257
* outerArgs
258258
* ---------------------
259259
* method(..., errorMethod, ...)
260-
*
260+
*
261261
*/
262-
case (id @ Ident(errorMethod)) ::
263-
Apply(method, outerArgs) ::
262+
case (id @ Ident(errorMethod)) ::
263+
Apply(method, outerArgs) ::
264264
_ if id.symbol == NoSymbol && method != id =>
265-
265+
266266
val argIndex = outerArgs.indexOf(id)
267267

268268
val (argTypes, retTypeOpt) = extractParameterTypeInfo(method.tpe.widenDealias, argIndex)
@@ -272,20 +272,20 @@ final class InferredMethodProvider(
272272
case None => Nil
273273

274274
val signature = printSignature(errorMethod, allArgTypes, retTypeOpt)
275-
275+
276276
signatureEdits(signature)
277277

278278
/**
279279
* tpt body
280280
* ----------- ----------------
281281
* val value: DefinedType = errorMethod(args)
282-
*
282+
*
283283
*/
284-
case (id @ Ident(errorMethod)) ::
285-
(apply @ Apply(func, args)) ::
286-
ValDef(_, tpt, body) ::
284+
case (id @ Ident(errorMethod)) ::
285+
(apply @ Apply(func, args)) ::
286+
ValDef(_, tpt, body) ::
287287
_ if id.symbol == NoSymbol && func == id && apply == body =>
288-
288+
289289
val retType = tpt.tpe.widenDealias
290290
val argTypes = args.map(_.typeOpt.widenDealias)
291291

@@ -296,24 +296,24 @@ final class InferredMethodProvider(
296296
* tpt body
297297
* ----------- -----------
298298
* val value: DefinedType = errorMethod
299-
*
299+
*
300300
*/
301-
case (id @ Ident(errorMethod)) ::
302-
ValDef(_, tpt, body) ::
301+
case (id @ Ident(errorMethod)) ::
302+
ValDef(_, tpt, body) ::
303303
_ if id.symbol == NoSymbol && id == body =>
304-
304+
305305
val retType = tpt.tpe.widenDealias
306306

307307
val signature = printSignature(errorMethod, Nil, Some(retType))
308308
signatureEdits(signature)
309309

310310
/**
311-
*
311+
*
312312
* errorMethod(args)
313-
*
313+
*
314314
*/
315-
case (id @ Ident(errorMethod)) ::
316-
(apply @ Apply(func, args)) ::
315+
case (id @ Ident(errorMethod)) ::
316+
(apply @ Apply(func, args)) ::
317317
_ if id.symbol == NoSymbol && func == id =>
318318

319319
val argTypes = args.map(_.typeOpt.widenDealias)
@@ -322,37 +322,37 @@ final class InferredMethodProvider(
322322
signatureEdits(signature)
323323

324324
/**
325-
*
325+
*
326326
* errorMethod
327-
*
327+
*
328328
*/
329-
case (id @ Ident(errorMethod)) ::
329+
case (id @ Ident(errorMethod)) ::
330330
_ if id.symbol == NoSymbol =>
331331

332332
val signature = printSignature(errorMethod, Nil, None)
333333
signatureEdits(signature)
334334

335335
/**
336-
*
336+
*
337337
* container.errorMethod(args)
338-
*
338+
*
339339
*/
340-
case (select @ Select(container, errorMethod)) ::
341-
(apply @ Apply(func, args)) ::
340+
case (select @ Select(container, errorMethod)) ::
341+
(apply @ Apply(func, args)) ::
342342
_ if select.symbol == NoSymbol && func == select =>
343-
343+
344344
val argTypes = args.map(_.typeOpt.widenDealias)
345345
val signature = printSignature(errorMethod, List(argTypes), None)
346346
signatureEditsForContainer(signature, container)
347347

348348
/**
349-
*
349+
*
350350
* container.errorMethod
351-
*
351+
*
352352
*/
353-
case (select @ Select(container, errorMethod)) ::
353+
case (select @ Select(container, errorMethod)) ::
354354
_ if select.symbol == NoSymbol =>
355-
355+
356356
val signature = printSignature(errorMethod, Nil, None)
357357
signatureEditsForContainer(signature, container)
358358

0 commit comments

Comments
 (0)