scancscode 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,9 @@ class CSCodeScanner {
9
9
  static assignmentPattern = /([\w\.\u4e00-\u9fff]+\.text\s*=(?![=>])\s*)([^;]+)\s*;/mg;
10
10
  // 正则表达式匹配 匹配每个字符串
11
11
  static stringPattern = /\$?"([^"]*)"/mg;
12
+ // 正则表达式匹配 匹配获取成员值的表达式
13
+ static getMemberValuePattern = /^(\s*)([\w\.\u4e00-\u9fff\[\]]+)(\.TR\(\))?(\s*)$/m;
14
+ static memberSplit = /^[\s\+;]/;
12
15
  // 正则表达式匹配插值表达式 {...}
13
16
  static interpolationPattern = /\{([^}]+?)(\:[a-zA-Z\d-\.\#(?:\\\\:)\u4e00-\u9fff]+)?\}/mg;
14
17
  static stringFormatPattern = /(?<![a-zA-Z_\u4e00-\u9fff])([sS]tring\.Format)(?=\(.*?\))/mg;
@@ -182,7 +185,20 @@ class CSCodeScanner {
182
185
  }
183
186
  }
184
187
  else {
185
- convertedAssignLine = assignLine;
188
+ let memberLines = bodyLine.split("+");
189
+ if (memberLines.length > 0) {
190
+ for (let i = 0; i < memberLines.length; i++) {
191
+ let memberLine = memberLines[i];
192
+ let match = memberLine.match(this.getMemberValuePattern);
193
+ if (match != null) {
194
+ memberLines[i] = match[1] + match[2] + ".TR()" + match[4];
195
+ }
196
+ }
197
+ convertedAssignLine = assignHead + memberLines.join("+") + ";";
198
+ }
199
+ else {
200
+ convertedAssignLine = assignLine;
201
+ }
186
202
  }
187
203
  let convertedAssignLine2 = convertedAssignLine.replaceAll(this.stringFormatPattern, `${trclassname}.Format`);
188
204
  snippets.push({
@@ -46,8 +46,8 @@ class LiteralCollector {
46
46
  return;
47
47
  }
48
48
  let files = glob_1.glob.sync("**/*.cs", { cwd: folder });
49
- let testFullPath = "@";
50
- // let testFullPath = "E:/DATA/Projects/ZhiYou/ProjectFClient/GameClient/Assets/Bundles/FGUI/ShopCommon/ShopCommonDialog.cs";
49
+ // let testFullPath = "@";
50
+ let testFullPath = "E:/DATA/Projects/ZhiYou/ProjectFClient/GameClient/Assets/Bundles/FGUI/TopRank/Comp/SubTopRankSelfComp.cs";
51
51
  for (const filePath of files) {
52
52
  let fullPath = folder + filePath;
53
53
  if (testFullPath != "@") {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const CmdExecutor_1 = require("./CmdExecutor");
4
- CmdExecutor_1.CmdExecutor.runConvertWithCmdOptions();
4
+ CmdExecutor_1.CmdExecutor.testConvert();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scancscode",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {
@@ -10,6 +10,9 @@ export class CSCodeScanner {
10
10
 
11
11
  // 正则表达式匹配 匹配每个字符串
12
12
  private static readonly stringPattern = /\$?"([^"]*)"/mg;
13
+ // 正则表达式匹配 匹配获取成员值的表达式
14
+ private static readonly getMemberValuePattern = /^(\s*)([\w\.\u4e00-\u9fff\[\]]+)(\.TR\(\))?(\s*)$/m;
15
+ private static readonly memberSplit = /^[\s\+;]/;
13
16
  // 正则表达式匹配插值表达式 {...}
14
17
  private static readonly interpolationPattern = /\{([^}]+?)(\:[a-zA-Z\d-\.\#(?:\\\\:)\u4e00-\u9fff]+)?\}/mg;
15
18
 
@@ -190,7 +193,19 @@ export class CSCodeScanner {
190
193
  convertedAssignLine = stringLines.join("");
191
194
  }
192
195
  } else {
193
- convertedAssignLine = assignLine;
196
+ let memberLines = bodyLine.split("+");
197
+ if (memberLines.length > 0) {
198
+ for (let i = 0; i < memberLines.length; i++) {
199
+ let memberLine = memberLines[i];
200
+ let match = memberLine.match(this.getMemberValuePattern);
201
+ if (match != null) {
202
+ memberLines[i] = match[1] + match[2] + ".TR()" + match[4];
203
+ }
204
+ }
205
+ convertedAssignLine = assignHead + memberLines.join("+") + ";";
206
+ } else {
207
+ convertedAssignLine = assignLine;
208
+ }
194
209
  }
195
210
 
196
211
  let convertedAssignLine2 = convertedAssignLine.replaceAll(this.stringFormatPattern, `${trclassname}.Format`);
@@ -14,8 +14,8 @@ export class LiteralCollector {
14
14
  }
15
15
 
16
16
  let files = glob.sync("**/*.cs", { cwd: folder });
17
- let testFullPath = "@";
18
- // let testFullPath = "E:/DATA/Projects/ZhiYou/ProjectFClient/GameClient/Assets/Bundles/FGUI/ShopCommon/ShopCommonDialog.cs";
17
+ // let testFullPath = "@";
18
+ let testFullPath = "E:/DATA/Projects/ZhiYou/ProjectFClient/GameClient/Assets/Bundles/FGUI/TopRank/Comp/SubTopRankSelfComp.cs";
19
19
  for (const filePath of files) {
20
20
  let fullPath = folder + filePath;
21
21
  if (testFullPath != "@") {
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { CmdExecutor } from "./CmdExecutor";
2
2
 
3
- CmdExecutor.runConvertWithCmdOptions()
3
+ CmdExecutor.testConvert()