Skip to content

Commit

Permalink
feat: 增加几个语言支持
Browse files Browse the repository at this point in the history
Co-authored-by: ygqygq2 <[email protected]>
  • Loading branch information
ygqygq2 committed Apr 28, 2024
1 parent fe03f80 commit 064f89a
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 21 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

All notable changes to the "turbo-console-log" extension will be documented in this file.

# [3.0.7]
# [3.0.9]

## 新增功能 🌱

- feat: 增加几个语言支持

# [3.0.8]

## 功能优化

Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,26 @@ Properties:

## Support languages

- javascript
- typescript
- php
- csharp
- c++
- rust
- csharp
- coffeescript
- dart
- go
- groovy
- java
- javascript
- kotlin
- scala
- lua
- perl
- php
- python
- r
- ruby
- perl
- go
- java
- swift
- rust
- scala
- shellscript
- lua
- coffeescript
- swift
- typescript

## License

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "turbo-print-log",
"displayName": "Turbo Console Log for more language",
"description": "选中变量,根据不同语言增加一行变量打印日志",
"version": "3.0.8",
"version": "3.0.9",
"publisher": "ygqygq2",
"engines": {
"vscode": "^1.88.0"
Expand Down
1 change: 1 addition & 0 deletions sampleWorkspace/default-settings/add-log/no-print-log.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var a = "a";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def a = 'a'
1 change: 1 addition & 0 deletions sampleWorkspace/default-settings/add-log/no-print-log.r
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a <- "a";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var a = "a";
print("🚀 ~ file: no-print-log.copy.dart:2 ~ a: " + a);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def a = 'a'
println "🚀 ~ file: no-print-log.copy.groovy:2 ~ a: " + a
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a <- "a";
print(paste("🚀 ~ file: no-print-log.copy.r:2 ~ a: ", a))
30 changes: 23 additions & 7 deletions src/debug-message/LanguageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export class GeneralLanguageProcessor implements LanguageProcessor {
case 'coffeescript':
return 'console.log';
case 'python':
case 'swift':
case 'perl':
case 'lua':
case 'r':
case 'dart':
return 'print';
case 'go':
return 'fmt.Println';
Expand All @@ -36,21 +41,17 @@ export class GeneralLanguageProcessor implements LanguageProcessor {
return 'echo';
case 'ruby':
return 'puts';
case 'swift':
return 'print';
case 'csharp':
return 'Console.WriteLine';
case 'shellscript':
return 'echo';
case 'perl':
case 'lua':
return 'print';
case 'cpp':
return 'std::cout';
case 'rust':
return 'println!';
case 'kotlin':
case 'scala':
case 'groovy':
return 'println';
default:
return 'console.log';
Expand All @@ -72,6 +73,8 @@ export class GeneralLanguageProcessor implements LanguageProcessor {
return `${printFunction}(${variableName})${semicolon}`;
case 'csharp':
case 'java':
case 'rust':
case 'dart':
return `${printFunction}(${variableName});`;
case 'python':
case 'go':
Expand All @@ -96,11 +99,12 @@ export class GeneralLanguageProcessor implements LanguageProcessor {
case 'ruby':
case 'shellscript':
case 'coffeescript':
case 'groovy':
return `${printFunction} ${variableName}`;
case 'cpp':
return `${printFunction} << ${variableName} << std::endl;`;
case 'rust':
return `${printFunction}(${variableName});`;
case 'r':
return `${printFunction}(paste(${variableName}))`;
default:
return `${printFunction}(${variableName})`;
}
Expand All @@ -118,13 +122,16 @@ export class GeneralLanguageProcessor implements LanguageProcessor {
case 'java':
case 'go':
case 'swift':
case 'dart':
case 'groovy':
return '//';
case 'python':
case 'ruby':
case 'perl':
case 'shellscript':
case 'coffeescript':
case 'php':
case 'r':
return '#';
case 'lua':
return '--';
Expand Down Expand Up @@ -152,6 +159,9 @@ export class GeneralLanguageProcessor implements LanguageProcessor {
case 'perl':
case 'php':
case 'cpp':
case 'dart':
case 'r':
case 'groovy':
return ' ';
case 'rust':
return ' {}';
Expand All @@ -169,13 +179,16 @@ export class GeneralLanguageProcessor implements LanguageProcessor {
case 'python':
case 'rust':
case 'lua':
case 'r':
return ', ';
case 'java':
case 'kotlin':
case 'scala':
case 'csharp':
case 'coffeescript':
case 'ruby':
case 'dart':
case 'groovy':
return ' + ';
case 'shellscript':
return ' ';
Expand Down Expand Up @@ -205,6 +218,9 @@ export class GeneralLanguageProcessor implements LanguageProcessor {
case 'scala':
case 'lua':
case 'coffeescript':
case 'dart':
case 'groovy':
case 'r':
return `${variableName}`;
case 'perl':
case 'php':
Expand Down
3 changes: 3 additions & 0 deletions src/test/suite/addLog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ const testInfo: TestInfo = [
{ fileName: 'no-print-log.coffee', cursorPosition: { line: 0, character: 0 } },
{ fileName: 'no-print-log.cpp', cursorPosition: { line: 0, character: 12 } },
{ fileName: 'no-print-log.cs', cursorPosition: { line: 0, character: 7 } },
{ fileName: 'no-print-log.dart', cursorPosition: { line: 0, character: 4 } },
{ fileName: 'no-print-log.go', cursorPosition: { line: 0, character: 0 } },
{ fileName: 'no-print-log.groovy', cursorPosition: { line: 0, character: 4 } },
{ fileName: 'no-print-log.java', cursorPosition: { line: 0, character: 7 } },
{ fileName: 'no-print-log.js', cursorPosition: { line: 0, character: 6 } },
// { fileName: 'no-print-log.kt', cursorPosition: { line: 0, character: 4 } },
{ fileName: 'no-print-log.lua', cursorPosition: { line: 0, character: 6 } },
// { fileName: 'no-print-log.php', cursorPosition: { line: 0, character: 6 } },
// { fileName: 'no-print-log.pl', cursorPosition: { line: 0, character: 3 } },
{ fileName: 'no-print-log.py', cursorPosition: { line: 0, character: 0 } },
{ fileName: 'no-print-log.r', cursorPosition: { line: 0, character: 0 } },
{ fileName: 'no-print-log.rb', cursorPosition: { line: 0, character: 0 } },
{ fileName: 'no-print-log.rs', cursorPosition: { line: 0, character: 4 } },
// { fileName: 'no-print-log.scala', cursorPosition: { line: 0, character: 4 } },
Expand Down

0 comments on commit 064f89a

Please sign in to comment.