cleanup (appendLine)

GitOrigin-RevId: 536d22bb04c82ad43b8904139bb1e04abeaaa7a8
This commit is contained in:
Vladimir Krivosheev
2023-08-27 11:03:00 +03:00
committed by intellij-monorepo-bot
parent 8e68c3d352
commit 51ab4a5479
22 changed files with 96 additions and 94 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.internal.performance
import com.intellij.execution.filters.TextConsoleBuilderFactory
@@ -171,21 +171,21 @@ internal class TypingLatencyReportDialog(
private fun formatReportAsText(): String {
return buildString {
appendln(formatHeader(false))
appendln()
appendLine(formatHeader(false))
appendLine()
for (row in latencyMap.values.sortedBy { it.key.name }) {
appendln(formatLatency(row.key.name, row.totalLatency, row.key.details))
appendln("Actions:")
appendLine(formatLatency(row.key.name, row.totalLatency, row.key.details))
appendLine("Actions:")
for (actionLatencyRecord in row.actionLatencyRecords.entries.sortedByDescending { it.value.averageLatency }) {
appendln(" ${formatLatency(actionLatencyRecord.key, actionLatencyRecord.value)}")
appendLine(" ${formatLatency(actionLatencyRecord.key, actionLatencyRecord.value)}")
}
}
appendln()
appendLine()
if (threadDumps.isNotEmpty()) {
appendln("Thread dumps:")
appendLine("Thread dumps:")
for (threadDump in threadDumps) {
appendln(threadDump)
appendln("-".repeat(40))
appendLine(threadDump)
appendLine("-".repeat(40))
}
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.build.output
import com.intellij.build.BuildProgressListener
@@ -75,8 +75,8 @@ class BuildOutputInstantReaderImplTest {
listOf(parser, createParser("[error]", ERROR)), pushBackBufferSize)
val inputData = buildString {
appendln("[warning] this is a warning\n".repeat(80))
appendln("[error] error1\n")
appendLine("[warning] this is a warning\n".repeat(80))
appendLine("[error] error1\n")
}
outputReader.append(inputData).closeAndGetFuture().get()
@@ -185,14 +185,14 @@ class BuildOutputInstantReaderImplTest {
""".trimIndent()
val inputData = buildString {
trashOut.joinTo(this, "\n", postfix = "\n")
appendln(errLines)
appendln()
appendln(infoLines)
appendln()
appendln(infoLines) /* checks that duplicate messages are not sent */
appendln()
appendLine(errLines)
appendLine()
appendLine(infoLines)
appendLine()
appendLine(infoLines) /* checks that duplicate messages are not sent */
appendLine()
trashOut.joinTo(this, "\n", postfix = "\n")
appendln(warnLines)
appendLine(warnLines)
}
outputReader.append(inputData).closeAndGetFuture().get()
@@ -217,7 +217,7 @@ class BuildOutputInstantReaderImplTest {
val buf = StringBuilder()
var nextLine: String? = line.dropWhile { !it.isWhitespace() }.trimStart()
while (!nextLine.isNullOrBlank() && !nextLine.startsWith('[')) {
buf.appendln(nextLine)
buf.appendLine(nextLine)
nextLine = reader.readLine()
}
messageConsumer.accept(MessageEventImpl(reader.parentEventId, kind, null, buf.toString().dropLast(1), null))

View File

@@ -299,7 +299,7 @@ class GCRootPathsTree(
fun createHotPathReport(treeDisplayOptions: AnalysisConfig.TreeDisplayOptions, rootReasonGetter: (Int) -> String): String {
val rootList = mutableListOf<Triple<Int, RegularNode, Edge>>()
val result = StringBuilder()
val printFunc = { s: String -> result.appendln(s); Unit }
val printFunc = { s: String -> result.appendLine(s); Unit }
for (entry in edges.int2ObjectEntrySet().fastIterator()) {
rootList.add(Triple(entry.intKey, entry.value.first, entry.value.second))

View File

@@ -106,7 +106,7 @@ class HProfAnalysis(private val hprofFileChannel: FileChannel,
// Currently, there is a maximum count of supported instances. Produce simplified report
// (histogram only), if the count exceeds maximum.
if (!isSupported(histogram.instanceCount)) {
result.appendln(histogram.prepareReport("All", 50))
result.appendLine(histogram.prepareReport("All", 50))
return result.toString()
}
@@ -155,23 +155,23 @@ class HProfAnalysis(private val hprofFileChannel: FileChannel,
val analysisReport = analysisCallback(analysisContext, fileBackedListProvider, PartialProgressIndicator(progress, 0.4, 0.4))
if (analysisReport.isNotBlank()) {
result.appendln(analysisReport)
result.appendLine(analysisReport)
}
analysisStopwatch.stop()
if (includeMetaInfo) {
result.appendln(sectionHeader("Analysis information"))
result.appendln("Prepare files duration: $prepareFilesStopwatch")
result.appendln("Analysis duration: $analysisStopwatch")
result.appendln("TOTAL DURATION: $totalStopwatch")
result.appendln("Temp files:")
result.appendln(" heapdump = ${toShortStringAsCount(hprofFileChannel.size())}")
result.appendLine(sectionHeader("Analysis information"))
result.appendLine("Prepare files duration: $prepareFilesStopwatch")
result.appendLine("Analysis duration: $analysisStopwatch")
result.appendLine("TOTAL DURATION: $totalStopwatch")
result.appendLine("Temp files:")
result.appendLine(" heapdump = ${toShortStringAsCount(hprofFileChannel.size())}")
tempFiles.forEach { temp ->
val channel = temp.channel
if (channel.isOpen) {
result.appendln(" ${temp.type} = ${toShortStringAsCount(channel.size())}")
result.appendLine(" ${temp.type} = ${toShortStringAsCount(channel.size())}")
}
}
}

View File

@@ -27,20 +27,20 @@ internal class LiveInstanceStats {
val openProjects = ProjectManager.getInstance().openProjects
val projectsOpenCount = openProjects.size
result.appendln("Projects open: $projectsOpenCount")
result.appendLine("Projects open: $projectsOpenCount")
openProjects.forEachIndexed { projectIndex, project ->
result.appendln("Project ${projectIndex + 1}:")
result.appendLine("Project ${projectIndex + 1}:")
val modulesCount = ModuleManager.getInstance(project).modules.count()
result.appendln(" Module count: $modulesCount")
result.appendLine(" Module count: $modulesCount")
val allEditors = FileEditorManager.getInstance(project).allEditors
val typeToCount = allEditors.groupingBy { "${it.javaClass.name}[${it.file?.fileType?.javaClass?.name}]" }.eachCount()
result.appendln(" Editors opened: ${allEditors.size}. Counts by type:")
result.appendLine(" Editors opened: ${allEditors.size}. Counts by type:")
typeToCount.entries.sortedByDescending { it.value }.forEach { (typeString, count) ->
result.appendln(" * $count $typeString")
result.appendLine(" * $count $typeString")
}
result.appendln()
result.appendLine()
}
return result.toString()
}

View File

@@ -40,8 +40,8 @@ class Histogram(val entries: List<HistogramEntry>, val instanceCount: Long) {
fun prepareReport(name: String, topClassCount: Int): String {
val result = StringBuilder()
result.appendln("Histogram. Top $topClassCount by instance count:")
val appendToResult = { s: String -> result.appendln(s); Unit }
result.appendLine("Histogram. Top $topClassCount by instance count:")
val appendToResult = { s: String -> result.appendLine(s); Unit }
var counter = 1
TruncatingPrintBuffer(topClassCount, 0, appendToResult).use { buffer ->
@@ -50,13 +50,13 @@ class Histogram(val entries: List<HistogramEntry>, val instanceCount: Long) {
counter++
}
}
result.appendln(getSummaryLine(this, name))
result.appendln()
result.appendln("Top 10 by bytes count:")
result.appendLine(getSummaryLine(this, name))
result.appendLine()
result.appendLine("Top 10 by bytes count:")
val entriesByBytes = entries.sortedByDescending { it.totalBytes }
for (i in 0 until 10) {
val entry = entriesByBytes[i]
result.appendln(formatEntryLine(i + 1, entry))
result.appendLine(formatEntryLine(i + 1, entry))
}
return result.toString()
}
@@ -72,7 +72,7 @@ class Histogram(val entries: List<HistogramEntry>, val instanceCount: Long) {
secondaryHistogram: Histogram, secondaryHistogramName: String,
options: AnalysisConfig.HistogramOptions): String {
val result = StringBuilder()
val appendToResult = { s: String -> result.appendln(s); Unit }
val appendToResult = { s: String -> result.appendLine(s); Unit }
val mapClassNameToEntrySecondary = HashMap<String, HistogramEntry>()
secondaryHistogram.entries.forEach {
@@ -83,7 +83,7 @@ class Histogram(val entries: List<HistogramEntry>, val instanceCount: Long) {
"${getSummaryLine(mainHistogram, mainHistogramName)}\n${getSummaryLine(secondaryHistogram, secondaryHistogramName)}"
if (options.includeByCount) {
result.appendln("Histogram. Top ${options.classByCountLimit} by instance count [All-objects] [Only-strong-ref]:")
result.appendLine("Histogram. Top ${options.classByCountLimit} by instance count [All-objects] [Only-strong-ref]:")
var counter = 1
TruncatingPrintBuffer(options.classByCountLimit, 0, appendToResult).use { buffer ->
@@ -93,24 +93,24 @@ class Histogram(val entries: List<HistogramEntry>, val instanceCount: Long) {
counter++
}
}
result.appendln(summary)
result.appendLine(summary)
}
if (options.includeBySize && options.includeByCount) {
result.appendln()
result.appendLine()
}
if (options.includeBySize) {
val classCountInByBytesSection = min(mainHistogram.entries.size, options.classBySizeLimit)
result.appendln("Top $classCountInByBytesSection by size:")
result.appendLine("Top $classCountInByBytesSection by size:")
val entriesByBytes = mainHistogram.entries.sortedByDescending { it.totalBytes }
for (i in 0 until classCountInByBytesSection) {
val entry = entriesByBytes[i]
val entry2 = mapClassNameToEntrySecondary[entry.classDefinition.name]
result.appendln(formatEntryLineMerged(i + 1, entry, entry2))
result.appendLine(formatEntryLineMerged(i + 1, entry, entry2))
}
if (!options.includeByCount) {
result.appendln(summary)
result.appendLine(summary)
}
}
return result.toString()

View File

@@ -111,7 +111,8 @@ public final class DebugAttachDetector {
return true;
}
Properties properties = ApplicationManager.getApplication().getService(DebugAttachDetector.class).myAgentProperties;
if (properties == null) { // For now return true if can not detect
// for now, return true if you can not detect
if (properties == null) {
return true;
}
return isAttached(properties);

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.internal
import com.intellij.openapi.actionSystem.ActionUpdateThread
@@ -50,7 +50,7 @@ internal class KeymapToCsvAction : AnAction() {
}
val result = buildString {
appendln("key," + columns.joinToString(","))
appendLine("key," + columns.joinToString(","))
for ((key, shortcutsForKey) in allShortcuts) {
append(key)
for (column in columns) {
@@ -58,7 +58,7 @@ internal class KeymapToCsvAction : AnAction() {
val actionsForShortcut = shortcutsForKey[column] ?: emptyList()
append(actionsForShortcut.joinToString("|"))
}
appendln()
appendLine()
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.testFramework.fixtures
import com.intellij.build.*
@@ -205,7 +205,7 @@ class BuildViewTestFixture(private val myProject: Project) : IdeaTestFixture {
list.add(buffer.toString())
buffer.clear()
}
buffer.appendln(line)
buffer.appendLine(line)
}
if (buffer.isNotEmpty()) {
list.add(buffer.toString())

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.gradle.execution.build.output
import com.intellij.build.FilePosition
@@ -46,7 +46,7 @@ class GradleBuildScriptErrorParser : BuildOutputParser {
val description = StringBuilder()
if (location != null) {
description.appendln(location).appendln()
description.appendLine(location).appendLine()
}
@NlsSafe var reason = reader.readLine() ?: return false
val parentId: Any
@@ -57,11 +57,11 @@ class GradleBuildScriptErrorParser : BuildOutputParser {
parentId = reader.parentEventId
}
description.appendln(reason)
description.appendLine(reason)
loop@ while (true) {
val nextLine = reader.readLine() ?: return false
if (nextLine.isBlank()) break
description.appendln(nextLine)
description.appendLine(nextLine)
val trimStart = nextLine.trimStart()
if (trimStart.startsWith("> ")) {
reason = trimStart.substringAfter("> ").trimEnd('.') //NON-NLS
@@ -79,7 +79,8 @@ class GradleBuildScriptErrorParser : BuildOutputParser {
var exception: StringBuilder? = null
while (true) {
val nextLine = reader.readLine() ?: break
if (nextLine == "BUILD FAILED" || nextLine == "* Get more help at https://help.gradle.org" || nextLine.startsWith("CONFIGURE FAILED")) break
if (nextLine == "BUILD FAILED" || nextLine == "* Get more help at https://help.gradle.org" || nextLine.startsWith(
"CONFIGURE FAILED")) break
if (nextLine == "* Exception is:") {
exception = StringBuilder()
}
@@ -88,10 +89,10 @@ class GradleBuildScriptErrorParser : BuildOutputParser {
}
else {
if (exception != null) {
exception.appendln(nextLine)
exception.appendLine(nextLine)
}
else if (trySuggestions != null && nextLine.isNotBlank()) {
trySuggestions.appendln(nextLine)
trySuggestions.appendLine(nextLine)
}
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.maven.testFramework.xml
open class XmlBuilder {
@@ -37,7 +37,7 @@ open class XmlBuilder {
}
fun text(text: String) {
state.appendln(" ".repeat(indent) + text)
state.appendLine(" ".repeat(indent) + text)
}
open fun generate(): String {

View File

@@ -60,7 +60,7 @@ interface TypesTestBase {
builder.append(psiType)
}
}
builder.appendln()
builder.appendLine()
level++
return false
}

View File

@@ -63,7 +63,7 @@ interface ValuesTestBase {
}
builder.append(" = ").append(value ?: "NON-EVALUATED")
}
builder.appendln()
builder.appendLine()
level++
return false
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast
import org.jetbrains.uast.internal.acceptList
@@ -45,7 +45,7 @@ interface UDoWhileExpression : ULoopExpression {
override fun asRenderString(): String = buildString {
append("do ")
append(body.asRenderString())
appendln("while (${condition.asRenderString()})")
appendLine("while (${condition.asRenderString()})")
}
override fun asLogString(): String = log()

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast
import org.jetbrains.uast.internal.acceptList
@@ -50,8 +50,8 @@ interface USwitchExpression : UExpression {
override fun asRenderString(): String = buildString {
val expr = expression?.let { "(" + it.asRenderString() + ") " } ?: ""
appendln("switch $expr")
appendln(body.asRenderString())
appendLine("switch $expr")
appendLine(body.asRenderString())
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast
import com.intellij.psi.PsiType
@@ -83,8 +83,8 @@ interface UTryExpression : UExpression {
append(resourceVariables.joinToString("\n") { it.asRenderString() })
append(")")
}
appendln(tryClause.asRenderString().trim('\n', '\r'))
catchClauses.forEach { appendln(it.asRenderString().trim('\n', '\r')) }
appendLine(tryClause.asRenderString().trim('\n', '\r'))
catchClauses.forEach { appendLine(it.asRenderString().trim('\n', '\r')) }
finallyClause?.let { append("finally ").append(it.asRenderString().trim('\n', '\r')) }
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast
import com.intellij.psi.PsiAnonymousClass
@@ -79,9 +79,9 @@ interface UClass : UDeclaration, PsiClass {
append(" : ")
append(superTypes.joinToString { it.asRenderString() })
}
appendln(" {")
appendLine(" {")
uastDeclarations.forEachIndexed { _, declaration ->
appendln(declaration.asRenderString().withMargin)
appendLine(declaration.asRenderString().withMargin)
}
append("}")
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast
import com.intellij.psi.PsiClassInitializer
@@ -30,7 +30,7 @@ interface UClassInitializer : UDeclaration, PsiClassInitializer {
override fun asRenderString(): String = buildString {
append(modifierList)
appendln(uastBody.asRenderString().withMargin)
appendLine(uastBody.asRenderString().withMargin)
}
override fun <D, R> accept(visitor: UastTypedVisitor<D, R>, data: D): R =

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast
import com.intellij.psi.PsiFile
@@ -62,17 +62,17 @@ interface UFile : UElement, UAnnotated {
}
val packageName = this@UFile.packageName
if (packageName.isNotEmpty()) appendln("package $packageName").appendln()
if (packageName.isNotEmpty()) appendLine("package $packageName").appendLine()
val imports = this@UFile.imports
if (imports.isNotEmpty()) {
imports.forEach { appendln(it.asRenderString()) }
appendln()
imports.forEach { appendLine(it.asRenderString()) }
appendLine()
}
classes.forEachIndexed { index, clazz ->
if (index > 0) appendln()
appendln(clazz.asRenderString())
if (index > 0) appendLine()
appendLine(clazz.asRenderString())
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast
import com.intellij.psi.*
@@ -163,9 +163,9 @@ interface UEnumConstant : UField, UCallExpression, PsiEnumConstant {
valueArguments.joinTo(this, prefix = "(", postfix = ")", transform = UExpression::asRenderString)
}
initializingClass?.let {
appendln(" {")
appendLine(" {")
it.uastDeclarations.forEach { declaration ->
appendln(declaration.asRenderString().withMargin)
appendLine(declaration.asRenderString().withMargin)
}
append("}")
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast
import org.jetbrains.uast.internal.acceptList
@@ -28,8 +28,8 @@ interface UBlockExpression : UExpression {
override fun asLogString(): String = log()
override fun asRenderString(): String = buildString {
appendln("{")
expressions.forEach { appendln(it.asRenderString().withMargin) }
appendLine("{")
expressions.forEach { appendLine(it.asRenderString().withMargin) }
append("}")
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.util
import com.intellij.psi.PsiElement
@@ -18,7 +18,7 @@ abstract class IndentedPrintingVisitor(val shouldIndent: (PsiElement) -> Boolean
if (charSequence != null) {
builder.append(" ".repeat(level))
builder.append(charSequence)
builder.appendln()
builder.appendLine()
}
val shouldIndent = shouldIndent(element)