diff --git a/sampleWorkspace/default-settings/no-print-log.result.coffee b/sampleWorkspace/default-settings/no-print-log.result.coffee index c928c69..37a6171 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.coffee +++ b/sampleWorkspace/default-settings/no-print-log.result.coffee @@ -1,2 +1,2 @@ a = "a" -console.log "🚀 ~ file: no-print-log.copy.coffee:2 ~ a:" + " " + a +console.log "🚀 ~ file: no-print-log.copy.coffee:2 ~ a: " + a diff --git a/sampleWorkspace/default-settings/no-print-log.result.cpp b/sampleWorkspace/default-settings/no-print-log.result.cpp index 289ab22..3e237ca 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.cpp +++ b/sampleWorkspace/default-settings/no-print-log.result.cpp @@ -1,2 +1,2 @@ std::string a = "a"; -std::cout << "🚀 ~ file: no-print-log.copy.cpp:2 ~ a:" << " " << a << std::endl; +std::cout << "🚀 ~ file: no-print-log.copy.cpp:2 ~ a: " << a << std::endl; diff --git a/sampleWorkspace/default-settings/no-print-log.result.cs b/sampleWorkspace/default-settings/no-print-log.result.cs index 1121759..fcdf699 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.cs +++ b/sampleWorkspace/default-settings/no-print-log.result.cs @@ -1,2 +1,2 @@ string a = "a"; -Console.WriteLine("🚀 ~ file: no-print-log.copy.cs:2 ~ a:" + " " + a); +Console.WriteLine("🚀 ~ file: no-print-log.copy.cs:2 ~ a: " + a); diff --git a/sampleWorkspace/default-settings/no-print-log.result.java b/sampleWorkspace/default-settings/no-print-log.result.java index c08ae64..ebb117f 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.java +++ b/sampleWorkspace/default-settings/no-print-log.result.java @@ -1,2 +1,2 @@ String a = "a"; -System.out.println("🚀 ~ file: no-print-log.copy.java:2 ~ a:" + " " + a); +System.out.println("🚀 ~ file: no-print-log.copy.java:2 ~ a: " + a); diff --git a/sampleWorkspace/default-settings/no-print-log.result.kt b/sampleWorkspace/default-settings/no-print-log.result.kt index 1bcd3f7..773c6cc 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.kt +++ b/sampleWorkspace/default-settings/no-print-log.result.kt @@ -1,2 +1,2 @@ val a = "a" -println("🚀 ~ file: no-print-log.copy.kt:2 ~ a:" + " " + a) +println("🚀 ~ file: no-print-log.copy.kt:2 ~ a: " + a) diff --git a/sampleWorkspace/default-settings/no-print-log.result.php b/sampleWorkspace/default-settings/no-print-log.result.php index 6e46b76..225ac70 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.php +++ b/sampleWorkspace/default-settings/no-print-log.result.php @@ -1,2 +1,2 @@ $a = "a"; -echo "🚀 ~ file: no-print-log.result.php:2 ~ \$a:" . " " . $a; +echo "🚀 ~ file: no-print-log.copy.php:2 ~ \$a: " . $a; diff --git a/sampleWorkspace/default-settings/no-print-log.result.pl b/sampleWorkspace/default-settings/no-print-log.result.pl index b0f7e62..5951b3b 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.pl +++ b/sampleWorkspace/default-settings/no-print-log.result.pl @@ -1,2 +1,2 @@ my $a = "a"; -print "🚀 ~ file: no-print-log.copy.pl:2 ~ \$a:" . " " . $a; +print "🚀 ~ file: no-print-log.copy.pl:2 ~ \$a: " . $a; diff --git a/sampleWorkspace/default-settings/no-print-log.result.rb b/sampleWorkspace/default-settings/no-print-log.result.rb index 4a1d9cd..0ae0ffa 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.rb +++ b/sampleWorkspace/default-settings/no-print-log.result.rb @@ -1,2 +1,2 @@ a = "a" -puts "🚀 ~ file: no-print-log.copy.rb:2 ~ a:" + " " + a +puts "🚀 ~ file: no-print-log.copy.rb:2 ~ a: " + a diff --git a/sampleWorkspace/default-settings/no-print-log.result.scala b/sampleWorkspace/default-settings/no-print-log.result.scala index f44b88d..0a18a86 100644 --- a/sampleWorkspace/default-settings/no-print-log.result.scala +++ b/sampleWorkspace/default-settings/no-print-log.result.scala @@ -1,2 +1,2 @@ val a = "a" -println("🚀 ~ file: no-print-log.copy.scala:2 ~ a: " + " " + a) +println("🚀 ~ file: no-print-log.copy.scala:2 ~ a: " + a) diff --git a/src/debug-message/GeneralDebugMessage.ts b/src/debug-message/GeneralDebugMessage.ts index 619535a..d108b0a 100644 --- a/src/debug-message/GeneralDebugMessage.ts +++ b/src/debug-message/GeneralDebugMessage.ts @@ -116,9 +116,11 @@ export class GeneralDebugMessage extends DebugMessage { ? `file: ${fileName}:${lineOfLogMsg} ${delimiterInsideMessage} ` : ''; // 处理 Rust 特殊情况 - const rustSpecial = lp?.getLanguageId() === 'rust' ? ' {}' : ''; + const extraSpace = lp?.getExtraSpace(); + const concatString = lp?.getConcatenatedString(); + const variable = lp?.variableToString(selectedVar); // 构建 content - const content = `${quote}${logMessagePrefix}${prefix}${fileNameAndLineNum}${selectedVar}${logMessageSuffix}${rustSpecial}${quote}${lp?.getConcatenatedString()}${lp?.variableToString(selectedVar)}`; + const content = `${quote}${logMessagePrefix}${prefix}${fileNameAndLineNum}${selectedVar}${logMessageSuffix}${extraSpace}${quote}${concatString}${variable}`; return lp?.getPrintStatement(content, logFunctionByLanguageId, semicolon); } diff --git a/src/debug-message/LanguageProcessor.ts b/src/debug-message/LanguageProcessor.ts index 4b1b8ba..ee4940a 100644 --- a/src/debug-message/LanguageProcessor.ts +++ b/src/debug-message/LanguageProcessor.ts @@ -133,6 +133,33 @@ export class GeneralLanguageProcessor implements LanguageProcessor { } } + public getExtraSpace(): string { + switch (this.languageId) { + case 'javascript': + case 'typescript': + case 'go': + case 'swift': + case 'python': + case 'lua': + case 'shellscript': + return ''; + case 'java': + case 'kotlin': + case 'scala': + case 'csharp': + case 'coffeescript': + case 'ruby': + case 'perl': + case 'php': + case 'cpp': + return ' '; + case 'rust': + return ' {}'; + default: + return ''; + } + } + public getConcatenatedString(): string { switch (this.languageId) { case 'javascript': @@ -149,14 +176,14 @@ export class GeneralLanguageProcessor implements LanguageProcessor { case 'csharp': case 'coffeescript': case 'ruby': - return ' + " " + '; + return ' + '; case 'shellscript': return ' '; case 'perl': case 'php': - return ' . " " . '; + return ' . '; case 'cpp': - return ' << " " << '; + return ' << '; default: return ', '; } diff --git a/src/debug-message/types.ts b/src/debug-message/types.ts index c6a0b68..d464464 100644 --- a/src/debug-message/types.ts +++ b/src/debug-message/types.ts @@ -6,6 +6,7 @@ export interface LanguageProcessor { getPrintString(): string; getPrintStatement(variableName: string, logFunctionByLanguageId?: string, semicolon?: string): string; getSingleLineCommentSymbol(): string; + getExtraSpace(): string; getConcatenatedString(): string; variableToString(variableName: string): string; }