diff --git a/platform/completion/common/src/LookupElementLogging.kt b/platform/completion/common/src/LookupElementLogging.kt new file mode 100644 index 000000000000..1b71991f6459 --- /dev/null +++ b/platform/completion/common/src/LookupElementLogging.kt @@ -0,0 +1,15 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.platform.completion.common + +import com.intellij.codeInsight.lookup.LookupElement + +/** + * Identifies a [LookupElement] in a log message **without** disclosing its text. + * + * `LookupElement.toString()` is the element's `lookupString`, which is user-derived — in a terminal or a scratch buffer + * it can be a secret the user just typed (IJPL-252788). Levels that are enabled by default (`INFO`, `WARN`, `ERROR`, + * including the `details` of [com.intellij.openapi.diagnostic.errorWithWarnDetails], which are logged at `WARN`) must + * use this instead. The full element still belongs in a paired `debug { }` line, which is off unless someone is + * investigating. + */ +fun LookupElement.logId(): String = "${javaClass.name}@${Integer.toHexString(System.identityHashCode(this))}" diff --git a/platform/completion/common/src/protocol/modCommand/ModCommandDeserializer.kt b/platform/completion/common/src/protocol/modCommand/ModCommandDeserializer.kt index 87fa2b980587..baf9e703e045 100644 --- a/platform/completion/common/src/protocol/modCommand/ModCommandDeserializer.kt +++ b/platform/completion/common/src/protocol/modCommand/ModCommandDeserializer.kt @@ -16,6 +16,7 @@ import com.intellij.modcommand.ModRegisterTabOut import com.intellij.modcommand.ModStartRename import com.intellij.modcommand.ModUpdateFileText import com.intellij.modcommand.ModUpdateReferences +import com.intellij.openapi.diagnostic.debug import com.intellij.openapi.editor.colors.TextAttributesKey import com.intellij.openapi.util.TextRange import com.intellij.openapi.vfs.VirtualFile @@ -147,6 +148,7 @@ private fun findFile(path: String): VirtualFile? = private fun RpcTextRange.toTextRange(): TextRange = TextRange(startOffset, endOffset) private fun logFileNotFound(commandType: String, path: String): Nothing? { - ccLogger.warn("ModCommandDeserializer: file not found for $commandType: $path") + ccLogger.debug { "ModCommandDeserializer: file not found for $commandType: $path" } + ccLogger.warn("ModCommandDeserializer: file not found for $commandType") return null }