Skip to content

Commit

Permalink
add parentheses to all non-arg java methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rochala committed Nov 6, 2023
1 parent a48a3af commit 1e29a19
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CompilerSearchVisitor(
)(using ctx: Context, reports: ReportContext)
extends SymbolSearchVisitor:

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

private def isAccessible(sym: Symbol): Boolean = try
sym != NoSymbol && sym.isPublic && sym.isStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object CompletionItemResolver extends ItemResolver:
else ""
val companion = gsym.companion
if companion == NoSymbol || gsym.is(JavaDefined) then
if gsymDoc.isEmpty then
if gsymDoc.isEmpty() then
if gsym.isAliasType then
fullDocstring(gsym.info.metalsDealias.typeSymbol, search)
else if gsym.is(Method) then
Expand All @@ -73,8 +73,8 @@ object CompletionItemResolver extends ItemResolver:
else gsymDoc
else
val companionDoc = docs(companion)
if companionDoc.isEmpty then gsymDoc
else if gsymDoc.isEmpty then companionDoc
if companionDoc.isEmpty() then gsymDoc
else if gsymDoc.isEmpty() then companionDoc
else
List(
s"""|### ${keyword(companion)} ${companion.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object HoverProvider:
)
end report
reportContext.unsanitized.create(report, ifVerbose = true)
ju.Optional.empty.nn
ju.Optional.empty().nn
else
val skipCheckOnName =
!pos.isPoint // don't check isHoveringOnName for RangeHover
Expand Down Expand Up @@ -146,7 +146,7 @@ object HoverProvider:
)
).nn
case _ =>
ju.Optional.empty.nn
ju.Optional.empty().nn
end match
end match
end if
Expand Down Expand Up @@ -189,7 +189,7 @@ object HoverProvider:

refTpe.flatMap(findRefinement).asJava
case _ =>
ju.Optional.empty.nn
ju.Optional.empty().nn

end HoverProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final class InferredTypeProvider(

val sourceText = adjustOpt.map(_.text).getOrElse(params.text.nn)
val source =
SourceFile.virtual(filePath.toString, sourceText)
SourceFile.virtual(filePath.toString(), sourceText)
driver.run(uri, source)
val unit = driver.currentCtx.run.nn.units.head
val pos = driver.sourcePosition(params)
Expand Down Expand Up @@ -308,7 +308,7 @@ final class InferredTypeProvider(
val end = if withBacktick then idx + 1 else idx
val pos = tree.source.atSpan(Span(start, end, start))
Some(pos)
case None if idx < text.length =>
case None if idx < text.length() =>
val ch = text.charAt(idx)
if ch == realName.head then
lookup(idx + 1, Some((idx, realName.tail)), withBacktick)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MetalsDriver(

override def run(uri: URI, sourceCode: String): List[Diagnostic] =
val diags =
if alreadyCompiled(uri, sourceCode.toCharArray.nn) then Nil
if alreadyCompiled(uri, sourceCode.toCharArray().nn) then Nil
else super.run(uri, sourceCode)
lastCompiledURI = uri
diags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class PcCollector[T](
val filePath = Paths.get(uri).nn
val sourceText = params.text.nn
val source =
SourceFile.virtual(filePath.toString, sourceText)
SourceFile.virtual(filePath.toString(), sourceText)
driver.run(uri, source)
given ctx: Context = driver.currentCtx

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,7 +27,7 @@ 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SemanticdbTextDocumentProvider(
val validCode = removeMagicImports(sourceCode, filePath)
driver.run(
uri,
SourceFile.virtual(filePath.toString, validCode)
SourceFile.virtual(filePath.toString(), validCode)
)
val tree = driver.currentCtx.run.nn.units.head.tpdTree
val extractor = ExtractSemanticDB.Extractor()
Expand All @@ -42,7 +42,7 @@ class SemanticdbTextDocumentProvider(
if Properties.isWin then relativeUri.toString().replace("\\", "/")
else relativeUri.toString()
}
.getOrElse(filePath.toString)
.getOrElse(filePath.toString())

val document = TextDocument(
schema = Schema.SEMANTICDB4,
Expand All @@ -57,7 +57,7 @@ class SemanticdbTextDocumentProvider(
val out = SemanticdbOutputStream.newInstance(byteStream)
document.writeTo(out)
out.flush()
byteStream.toByteArray.nn
byteStream.toByteArray().nn
end textDocument

end SemanticdbTextDocumentProvider
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ object SignatureHelpProvider:
info

private def markupContent(content: String): l.MarkupContent | Null =
if content.isEmpty then null
if content.isEmpty() then null
else
val markup = new l.MarkupContent
markup.setKind("markdown")
markup.setValue(content.trim)
markup.setValue(content.trim())
markup

end SignatureHelpProvider
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object TastyUtils:
end htmlTasty

private def tastyHtmlPageTitle(file: URI) =
val filename = Paths.get(file).nn.getFileName.toString
val filename = Paths.get(file).nn.getFileName().toString
s"TASTy for $filename"

private val standaloneHtmlStyles =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,32 @@ object AmmoniteFileCompletions:
)

def matches(file: Path): Boolean =
(Files.isDirectory(file) || file.toAbsolutePath.toString.isAmmoniteScript) &&
query.exists(q => CompletionFuzzy.matches(q.nn, file.getFileName.toString))
(Files.isDirectory(file) || file.toAbsolutePath().toString.isAmmoniteScript) &&
query.exists(q => CompletionFuzzy.matches(q.nn, file.getFileName().toString))

(split, workspace) match
case (_ :: script :: Nil, Some(workspace)) =>
// drop / or \
val current = workspace.resolve(script.drop(1))
val importPath = translateImportToPath(select).drop(1)
val currentPath = current.nn.getParent.nn.resolve(importPath).nn.toAbsolutePath
val currentPath = current.nn.getParent().nn.resolve(importPath).nn.toAbsolutePath()
val parentTextEdit =
if query.exists(_.nn.isEmpty()) &&
Files.exists(currentPath.nn.getParent) && Files.isDirectory(
Files.exists(currentPath.nn.getParent()) && Files.isDirectory(
currentPath
)
then List(parent)
else Nil
Files
.list(currentPath).nn
.iterator.nn
.iterator().nn
.asScala
.toList
.filter(path => !fileName.contains(path.nn.getFileName.toString.stripSuffix(".sc")))
.filter(path => !fileName.contains(path.nn.getFileName().toString.stripSuffix(".sc")))
.collect {
case file if matches(file) =>
CompletionValue.FileSystemMember(
file.getFileName.toString,
file.getFileName().toString,
editRange,
isDirectory = Files.isDirectory(file)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object AmmoniteIvyCompletions:
case None => Nil
case Some(dependency) =>
val isInitialCompletion =
pos.lineContent.trim == "import $ivy."
pos.lineContent.trim() == "import $ivy."
val ivyEditRange =
if isInitialCompletion then completionPos.toEditRange
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object CompletionPos:
val prevIsDot =
if start - 1 >= 0 then text.charAt(start - 1) == '.' else false
val kind =
if query.nn.isEmpty && !prevIsDot then CompletionKind.Empty
if query.nn.isEmpty() && !prevIsDot then CompletionKind.Empty
else if prevIsDot then CompletionKind.Members
else CompletionKind.Scope

Expand All @@ -74,7 +74,7 @@ object CompletionPos:
): (Int, Boolean) =
var i = 0
var tabIndented = false
while lineOffset + i < text.length && {
while lineOffset + i < text.length() && {
val char = text.charAt(lineOffset + i)
if char == '\t' then
tabIndented = true
Expand Down Expand Up @@ -126,7 +126,7 @@ object CompletionPos:
*/
private def inferIdentEnd(pos: SourcePosition, text: String): Int =
var i = pos.point
while i < text.length && Chars.isIdentifierPart(text.charAt(i)) do i += 1
while i < text.length() && Chars.isIdentifierPart(text.charAt(i)) do i += 1
i

end CompletionPos
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Completions(
def hasSyntheticCursorSuffix: Boolean =
if !sym.name.endsWith(Cursor.value) then false
else
val realNameLength = sym.decodedName.length - Cursor.value.length
val realNameLength = sym.decodedName.length() - Cursor.value.length()
sym.source == pos.source &&
sym.span.start + realNameLength == pos.span.end

Expand Down Expand Up @@ -571,7 +571,7 @@ class Completions(
val nameId =
if sym.isClass || sym.is(Module) then
// drop #|. at the end to avoid duplication
name.substring(0, name.length - 1).nn
name.substring(0, name.length() - 1).nn
else name
val suffix =
if symOnly.snippetSuffix.addLabelSnippet then "[]" else ""
Expand Down Expand Up @@ -693,7 +693,7 @@ class Completions(
if !ov.symbol.is(Deferred) then penalty |= MemberOrdering.IsNotAbstract
penalty
case CompletionValue.Workspace(_, sym, _, _) =>
symbolRelevance(sym) | (IsWorkspaceSymbol + sym.name.show.length)
symbolRelevance(sym) | (IsWorkspaceSymbol + sym.name.show.length())
case sym: CompletionValue.Symbolic =>
symbolRelevance(sym.symbol)
case _ =>
Expand Down Expand Up @@ -782,7 +782,7 @@ class Completions(
def fuzzyScore(o: CompletionValue.Symbolic): Int =
fuzzyCache.getOrElseUpdate(
o, {
val name = o.label.toLowerCase.nn
val name = o.label.toLowerCase().nn
if name.startsWith(queryLower) then 0
else if name.contains(queryLower) then 1
else 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object InterpolatorCompletions:
config: PresentationCompilerConfig,
buildTargetIdentifier: String
)(using Context, ReportContext) =
InterpolationSplice(pos.span.point, text.toCharArray.nn, text) match
InterpolationSplice(pos.span.point, text.toCharArray().nn, text) match
case Some(interpolator) =>
InterpolatorCompletions.contributeScope(
text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object KeywordsCompletions:
checkIfNotInComment(completionPos.cursorPos, comments)

path match
case Nil if completionPos.query.isEmpty =>
case Nil if completionPos.query.isEmpty() =>
Keyword.all.collect {
// topelevel definitions are allowed in Scala 3
case kw if (kw.isPackage || kw.isTemplate) && notInComment =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ object OverrideCompletions:

val uri = params.uri.nn
val text = params.text.nn
driver.run(uri, SourceFile.virtual(uri.toASCIIString.nn, text))
driver.run(uri, SourceFile.virtual(uri.toASCIIString().nn, text))

val unit = driver.currentCtx.run.nn.units.headOption
unit match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ class ShortenedTypePrinter(
if includeDefaultParam == ShortenedTypePrinter.IncludeDefaultParam.Include && isDefaultParam
then
val defaultValue = docInfo match
case Some(value) if !value.defaultValue.nn.isEmpty =>
case Some(value) if !value.defaultValue.nn.isEmpty() =>
value.defaultValue()
case _ => "..."
s" = $defaultValue"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ object MtagsEnrichments extends CommonMtagsEnrichments:
for
uri <- InteractiveDriver.toUriOption(pos.source)
range <- if pos.exists then Some(pos.toLsp) else None
yield new l.Location(uri.toString, range)
yield new l.Location(uri.toString(), range)

def encloses(other: SourcePosition): Boolean =
pos.start <= other.start && pos.end >= other.end
Expand Down

0 comments on commit 1e29a19

Please sign in to comment.