scancscode 1.0.11 → 1.0.12

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.
@@ -158,7 +158,7 @@ class CSCodeScanner {
158
158
  // if ((stringStartIndex == 0 || prefix == "+ ") && suffix != ".TR()") {
159
159
  // formattedStringLine = formattedStringLine + ".TR()"
160
160
  // }
161
- formattedStringLine = this.replaceStringsTR(stringMatch, stringLine, bodyLine);
161
+ formattedStringLine = this.replaceStringsTR(stringMatch, stringLine, bodyLine, trmethodname);
162
162
  literals.push(stringContent);
163
163
  }
164
164
  convertedString = formattedStringLine;
@@ -166,7 +166,7 @@ class CSCodeScanner {
166
166
  }
167
167
  else {
168
168
  literals.push(stringContent);
169
- convertedString = this.replaceStringsTR(stringMatch, stringLine, bodyLine);
169
+ convertedString = this.replaceStringsTR(stringMatch, stringLine, bodyLine, trmethodname);
170
170
  }
171
171
  // 串联字符串列表
172
172
  let prefix = bodyLine.substring(lastIndex, stringLineIndex);
@@ -195,17 +195,18 @@ class CSCodeScanner {
195
195
  }
196
196
  return snippets;
197
197
  }
198
- static replaceStringsTR(stringMatch, stringLine, bodyLine) {
198
+ static replaceStringsTR(stringMatch, stringLine, bodyLine, trmethodname) {
199
199
  if (this.isNativeString(stringLine)) {
200
200
  return stringLine;
201
201
  }
202
+ let trmethodcall = `.${trmethodname}()`;
202
203
  let formattedStringLine = stringLine;
203
204
  let stringStartIndex = stringMatch.index;
204
205
  let stringEndIndex = stringStartIndex + stringLine.length;
205
206
  let prefix = bodyLine.substring(stringStartIndex - 2, stringStartIndex);
206
- let suffix = bodyLine.substring(stringEndIndex, stringEndIndex + ".TR()".length);
207
- if ((stringStartIndex == 0 || prefix == "+ ") && suffix != ".TR()") {
208
- formattedStringLine = formattedStringLine + ".TR()";
207
+ let suffix = bodyLine.substring(stringEndIndex, stringEndIndex + trmethodcall.length);
208
+ if ((stringStartIndex == 0 || prefix == "+ ") && suffix != trmethodcall) {
209
+ formattedStringLine = formattedStringLine + trmethodcall;
209
210
  }
210
211
  return formattedStringLine;
211
212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scancscode",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {
@@ -167,14 +167,14 @@ export class CSCodeScanner {
167
167
  // if ((stringStartIndex == 0 || prefix == "+ ") && suffix != ".TR()") {
168
168
  // formattedStringLine = formattedStringLine + ".TR()"
169
169
  // }
170
- formattedStringLine = this.replaceStringsTR(stringMatch, stringLine, bodyLine);
170
+ formattedStringLine = this.replaceStringsTR(stringMatch, stringLine, bodyLine, trmethodname);
171
171
  literals.push(stringContent);
172
172
  }
173
173
  convertedString = formattedStringLine;
174
174
  }
175
175
  } else {
176
176
  literals.push(stringContent);
177
- convertedString = this.replaceStringsTR(stringMatch, stringLine, bodyLine);
177
+ convertedString = this.replaceStringsTR(stringMatch, stringLine, bodyLine, trmethodname);
178
178
  }
179
179
 
180
180
  // 串联字符串列表
@@ -207,18 +207,19 @@ export class CSCodeScanner {
207
207
  return snippets;
208
208
  }
209
209
 
210
- public static replaceStringsTR(stringMatch: RegExpExecArray, stringLine: string, bodyLine: string) {
210
+ public static replaceStringsTR(stringMatch: RegExpExecArray, stringLine: string, bodyLine: string, trmethodname: string): string {
211
211
  if (this.isNativeString(stringLine)) {
212
212
  return stringLine;
213
213
  }
214
214
 
215
+ let trmethodcall = `.${trmethodname}()`;
215
216
  let formattedStringLine = stringLine;
216
217
  let stringStartIndex = stringMatch.index;
217
218
  let stringEndIndex = stringStartIndex + stringLine.length;
218
219
  let prefix = bodyLine.substring(stringStartIndex - 2, stringStartIndex);
219
- let suffix = bodyLine.substring(stringEndIndex, stringEndIndex + ".TR()".length);
220
- if ((stringStartIndex == 0 || prefix == "+ ") && suffix != ".TR()") {
221
- formattedStringLine = formattedStringLine + ".TR()";
220
+ let suffix = bodyLine.substring(stringEndIndex, stringEndIndex + trmethodcall.length);
221
+ if ((stringStartIndex == 0 || prefix == "+ ") && suffix != trmethodcall) {
222
+ formattedStringLine = formattedStringLine + trmethodcall;
222
223
  }
223
224
  return formattedStringLine;
224
225
  }