Skip to content

Commit

Permalink
properly add parentheses to all java methods in PC
Browse files Browse the repository at this point in the history
  • Loading branch information
rochala committed Nov 6, 2023
1 parent 1e29a19 commit 8fb93bb
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object AutoImports:
def renameConfigMap(config: PresentationCompilerConfig)(using
Context
): Map[Symbol, String] =
config.symbolPrefixes.nn.asScala.flatMap { (from, to) =>
config.symbolPrefixes().nn.asScala.flatMap { (from, to) =>
val pkg = SemanticdbSymbols.inverseSemanticdbSymbol(from)
val rename = to.stripSuffix(".").stripSuffix("#")
List(pkg, pkg.map(_.moduleClass)).flatten
Expand Down Expand Up @@ -246,7 +246,7 @@ object AutoImports:
// see WorksheetProvider.worksheetScala3AdjustmentsForPC
val indent =
if pos.source.path.isWorksheet &&
editPos.getStart().nn.getCharacter == 0
editPos.getStart().nn.getCharacter() == 0
then indent0.drop(2)
else indent0
val topPadding =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ final class AutoImportsProvider(
)(using ReportContext):

def autoImports(isExtension: Boolean): List[AutoImportsResult] =
val uri = params.uri.nn
val text = params.text.nn
val uri = params.uri().nn
val text = params.text().nn
val filePath = Paths.get(uri)
driver.run(uri, SourceFile.virtual(filePath.toString, text))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object CompletionItemResolver extends ItemResolver:
.orElse(
search.symbolDocumentation(gsym.companion)
) match
case Some(info) if item.getDetail != null =>
case Some(info) if item.getDetail() != null =>
enrichDocs(
item,
info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ final class ConvertToNamedArgumentsProvider(
):

def convertToNamedArguments: Either[String, List[l.TextEdit]] =
val uri = params.uri.nn
val text = params.text.nn
val uri = params.uri().nn
val text = params.text().nn
val filePath = Paths.get(uri)
driver.run(uri, SourceFile.virtual(filePath.toString, text))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ final class ExtractMethodProvider(
extends ExtractMethodUtils:

def extractMethod(): List[TextEdit] =
val text = range.text.nn
val uri = range.uri.nn
val text = range.text().nn
val uri = range.uri().nn
val filePath = Paths.get(uri)
val source = SourceFile.virtual(filePath.toString, text)
driver.run(uri, source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ object HoverProvider:
driver: InteractiveDriver,
search: SymbolSearch
)(implicit reportContext: ReportContext): ju.Optional[HoverSignature] =
val uri = params.uri.nn
val text = params.text.nn
val uri = params.uri().nn
val text = params.text().nn
val sourceFile = SourceFile.virtual(uri, text)
driver.run(uri, sourceFile)

Expand Down Expand Up @@ -126,7 +126,7 @@ object HoverProvider:

val docString = symbolTpes
.flatMap(symTpe => search.symbolDocumentation(symTpe._1))
.map(_.docstring)
.map(_.docstring())
.mkString("\n")
printer.expressionType(exprTpw) match
case Some(expressionType) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ final class InferredTypeProvider(
adjustOpt: Option[AdjustTypeOpts] = None
): List[TextEdit] =
val retryType = adjustOpt.isEmpty
val uri = params.uri.nn
val uri = params.uri().nn
val filePath = Paths.get(uri).nn

val sourceText = adjustOpt.map(_.text).getOrElse(params.text.nn)
val sourceText = adjustOpt.map(_.text).getOrElse(params.text().nn)
val source =
SourceFile.virtual(filePath.toString(), sourceText)
driver.run(uri, source)
Expand Down Expand Up @@ -187,7 +187,7 @@ final class InferredTypeProvider(
Some(
AdjustTypeOpts(
removeType(vl.namePos.end, tpt.sourcePos.end - 1),
tpt.sourcePos.toLsp.getEnd.nn
tpt.sourcePos.toLsp.getEnd().nn
)
)
)
Expand Down Expand Up @@ -226,7 +226,7 @@ final class InferredTypeProvider(
Some(
AdjustTypeOpts(
removeType(lastColon, tpt.sourcePos.end - 1),
tpt.sourcePos.toLsp.getEnd.nn
tpt.sourcePos.toLsp.getEnd().nn
)
)
)
Expand Down Expand Up @@ -255,7 +255,7 @@ final class InferredTypeProvider(
val firstEnd = patterns(0).endPos.end
val secondStart = patterns(1).startPos.start
val hasDot = params
.text.nn
.text().nn
.substring(firstEnd, secondStart).nn
.exists(_ == ',')
if !hasDot then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ abstract class PcCollector[T](
params: VirtualFileParams
):
private val caseClassSynthetics: Set[Name] = Set(nme.apply, nme.copy)
val uri = params.uri.nn
val uri = params.uri().nn
val filePath = Paths.get(uri).nn
val sourceText = params.text.nn
val sourceText = params.text().nn
val source =
SourceFile.virtual(filePath.toString(), sourceText)
driver.run(uri, source)
Expand All @@ -49,7 +49,7 @@ abstract class PcCollector[T](
val offsetParams =
params match
case op: OffsetParams => op
case _ => CompilerOffsetParams(uri, sourceText, 0, params.token.nn)
case _ => CompilerOffsetParams(uri, sourceText, 0, params.token().nn)
val pos = driver.sourcePosition(offsetParams)
val rawPath =
Interactive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class PcDefinitionProvider(
definitions(findTypeDef = true)

private def definitions(findTypeDef: Boolean): DefinitionResult =
val uri = params.uri.nn
val text = params.text.nn
val uri = params.uri().nn
val text = params.text().nn
val filePath = Paths.get(uri)
driver.run(
uri,
Expand All @@ -54,7 +54,7 @@ class PcDefinitionProvider(
if findTypeDef then findTypeDefinitions(path, pos, indexedContext)
else findDefinitions(path, pos, indexedContext)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ final class PcInlineValueProviderImpl(
) extends PcCollector[Occurence](driver, params)
with InlineValueProvider:

val text = params.text.nn.toCharArray().nn
val text = params.text().nn.toCharArray().nn

val position: l.Position = pos.toLsp.getStart.nn
val position: l.Position = pos.toLsp.getStart().nn

override def collect(parent: Option[Tree])(
tree: Tree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ case class ScalaPresentationCompiler(
def complete(params: OffsetParams): CompletableFuture[l.CompletionList] =
compilerAccess.withInterruptableCompiler(Some(params))(
EmptyCompletionList(),
params.token
params.token()
) { access =>
val driver = access.compiler()
new CompletionProvider(
Expand All @@ -134,7 +134,7 @@ case class ScalaPresentationCompiler(
def definition(params: OffsetParams): CompletableFuture[DefinitionResult] =
compilerAccess.withInterruptableCompiler(Some(params))(
DefinitionResultImpl.empty,
params.token
params.token()
) { access =>
val driver = access.compiler()
PcDefinitionProvider(driver, params, search).definitions()
Expand All @@ -145,7 +145,7 @@ case class ScalaPresentationCompiler(
): CompletableFuture[DefinitionResult] =
compilerAccess.withInterruptableCompiler(Some(params))(
DefinitionResultImpl.empty,
params.token
params.token()
) { access =>
val driver = access.compiler()
PcDefinitionProvider(driver, params, search).typeDefinitions()
Expand All @@ -156,7 +156,7 @@ case class ScalaPresentationCompiler(
): CompletableFuture[ju.List[DocumentHighlight]] =
compilerAccess.withInterruptableCompiler(Some(params))(
List.empty[DocumentHighlight].asJava,
params.token
params.token()
) { access =>
val driver = access.compiler()
PcDocumentHighlightProvider(driver, params).highlights.asJava
Expand Down Expand Up @@ -208,7 +208,7 @@ case class ScalaPresentationCompiler(
] =
compilerAccess.withNonInterruptableCompiler(Some(params))(
List.empty[scala.meta.pc.AutoImportsResult].asJava,
params.token
params.token()
) { access =>
val driver = access.compiler()
new AutoImportsProvider(
Expand All @@ -229,7 +229,7 @@ case class ScalaPresentationCompiler(
val empty: ju.List[l.TextEdit] = new ju.ArrayList[l.TextEdit]()
compilerAccess.withNonInterruptableCompiler(Some(params))(
empty,
params.token
params.token()
) { pc =>
val driver = pc.compiler()
OverrideCompletions.implementAllAt(
Expand All @@ -247,7 +247,7 @@ case class ScalaPresentationCompiler(
val empty: ju.List[l.TextEdit] = new ju.ArrayList[l.TextEdit]()
compilerAccess.withNonInterruptableCompiler(Some(params))(
empty,
params.token
params.token()
) { pc =>
new InferredTypeProvider(params, pc.compiler(), config, search)
.inferredTypeEdits()
Expand All @@ -259,7 +259,7 @@ case class ScalaPresentationCompiler(
): CompletableFuture[ju.List[l.TextEdit]] =
val empty: Either[String, List[l.TextEdit]] = Right(List())
(compilerAccess
.withInterruptableCompiler(Some(params))(empty, params.token) { pc =>
.withInterruptableCompiler(Some(params))(empty, params.token()) { pc =>
new PcInlineValueProviderImpl(pc.compiler(), params)
.getInlineTextEdits()
})
Expand All @@ -274,7 +274,7 @@ case class ScalaPresentationCompiler(
extractionPos: OffsetParams
): CompletableFuture[ju.List[l.TextEdit]] =
val empty: ju.List[l.TextEdit] = new ju.ArrayList[l.TextEdit]()
compilerAccess.withInterruptableCompiler(Some(range))(empty, range.token) {
compilerAccess.withInterruptableCompiler(Some(range))(empty, range.token()) {
pc =>
new ExtractMethodProvider(
range,
Expand All @@ -294,7 +294,7 @@ case class ScalaPresentationCompiler(
): CompletableFuture[ju.List[l.TextEdit]] =
val empty: Either[String, List[l.TextEdit]] = Right(List())
(compilerAccess
.withNonInterruptableCompiler(Some(params))(empty, params.token) { pc =>
.withNonInterruptableCompiler(Some(params))(empty, params.token()) { pc =>
new ConvertToNamedArgumentsProvider(
pc.compiler(),
params,
Expand Down Expand Up @@ -326,7 +326,7 @@ case class ScalaPresentationCompiler(
): CompletableFuture[ju.Optional[HoverSignature]] =
compilerAccess.withNonInterruptableCompiler(Some(params))(
ju.Optional.empty[HoverSignature](),
params.token
params.token()
) { access =>
val driver = access.compiler()
HoverProvider.hover(params, driver, search)
Expand All @@ -338,7 +338,7 @@ case class ScalaPresentationCompiler(
): CompletableFuture[ju.Optional[l.Range]] =
compilerAccess.withNonInterruptableCompiler(Some(params))(
Optional.empty[l.Range](),
params.token
params.token()
) { access =>
val driver = access.compiler()
Optional.ofNullable(
Expand All @@ -352,7 +352,7 @@ case class ScalaPresentationCompiler(
): CompletableFuture[ju.List[l.TextEdit]] =
compilerAccess.withNonInterruptableCompiler(Some(params))(
List[l.TextEdit]().asJava,
params.token
params.token()
) { access =>
val driver = access.compiler()
PcRenameProvider(driver, params, Some(name)).rename().asJava
Expand All @@ -372,7 +372,7 @@ case class ScalaPresentationCompiler(
def signatureHelp(params: OffsetParams): CompletableFuture[l.SignatureHelp] =
compilerAccess.withNonInterruptableCompiler(Some(params))(
new l.SignatureHelp(),
params.token
params.token()
) { access =>
val driver = access.compiler()
SignatureHelpProvider.signatureHelp(driver, params, search)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class SelectionRangeProvider(

params.asScala.toList.map { param =>

val uri = param.uri.nn
val text = param.text.nn
val uri = param.uri().nn
val text = param.text().nn
val filePath = Paths.get(uri)
val source = SourceFile.virtual(filePath.toString, text)
driver.run(uri, source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ object SignatureHelpProvider:
params: OffsetParams,
search: SymbolSearch
) =
val uri = params.uri
val sourceFile = SourceFile.virtual(params.uri.nn, params.text.nn)
val uri = params.uri()
val sourceFile = SourceFile.virtual(params.uri().nn, params.text().nn)
driver.run(uri.nn, sourceFile)

given ctx: Context = driver.currentCtx
Expand Down Expand Up @@ -101,7 +101,7 @@ object SignatureHelpProvider:
signature: Signatures.Signature,
isJavaSymbol: Boolean
): Option[Signature] =
val allParams = info.parameters.nn.asScala
val allParams = info.parameters().nn.asScala
def updateParams(
params: List[Signatures.Param],
index: Int
Expand All @@ -114,7 +114,7 @@ object SignatureHelpProvider:
case Some(paramDoc) =>
val newName =
if isJavaSymbol && head.name.startsWith("x$") then
paramDoc.nn.displayName
paramDoc.nn.displayName()
else head.name
head.copy(
doc = Some(paramDoc.docstring.nn),
Expand All @@ -132,7 +132,7 @@ object SignatureHelpProvider:
val updated = updateParams(head, index)
updated :: updateParamss(tail, index + head.size)
val updatedParams = updateParamss(signature.paramss, 0)
Some(signature.copy(doc = Some(info.docstring.nn), paramss = updatedParams))
Some(signature.copy(doc = Some(info.docstring().nn), paramss = updatedParams))
end withDocumentation

private def signatureToSignatureInformation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object CompletionPos:
offsetParams: OffsetParams,
treePath: List[Tree]
)(using Context): CompletionPos =
infer(cursorPos, offsetParams.uri.nn, offsetParams.text.nn, treePath)
infer(cursorPos, offsetParams.uri().nn, offsetParams.text().nn, treePath)

def infer(
cursorPos: SourcePosition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class CompletionProvider(
folderPath: Option[Path]
)(using reports: ReportContext):
def completions(): CompletionList =
val uri = params.uri.nn
val text = params.text.nn
val uri = params.uri().nn
val text = params.text().nn

val code = applyCompletionCursor(params)
val sourceFile = SourceFile.virtual(uri, code)
Expand Down Expand Up @@ -125,8 +125,8 @@ class CompletionProvider(
* because scala parser trim end position to the last statement pos.
*/
private def applyCompletionCursor(params: OffsetParams): String =
val text = params.text.nn
val offset = params.offset.nn
val text = params.text().nn
val offset = params.offset().nn

val isStartMultilineComment =
val i = params.offset()
Expand Down Expand Up @@ -192,7 +192,7 @@ class CompletionProvider(

item.setTags(completion.lspTags.asJava)

if config.isCompletionSnippetsEnabled then
if config.isCompletionSnippetsEnabled() then
item.setInsertTextFormat(InsertTextFormat.Snippet)

completion.command.foreach { command =>
Expand Down Expand Up @@ -236,7 +236,7 @@ class CompletionProvider(
case Some(edits) =>
edits match
case AutoImportEdits(Some(nameEdit), other) =>
mkItem(nameEdit.getNewText.nn, other.toList, range = Some(nameEdit.getRange.nn))
mkItem(nameEdit.getNewText().nn, other.toList, range = Some(nameEdit.getRange().nn))
case _ =>
mkItem(
v.insertText.getOrElse( ident.backticked(backtickSoftKeyword) + completionTextSuffix),
Expand Down
Loading

0 comments on commit 8fb93bb

Please sign in to comment.