@wrongstack/tools 0.7.7 → 0.8.0

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.
package/dist/index.js CHANGED
@@ -8,8 +8,8 @@ import * as os from 'node:os';
8
8
  import * as dns from 'node:dns/promises';
9
9
  import * as net from 'node:net';
10
10
  import * as fs13 from 'node:fs';
11
- import { statSync, mkdirSync, writeFileSync, unlinkSync } from 'node:fs';
12
- import { DatabaseSync } from 'node:sqlite';
11
+ import { statSync, mkdirSync, writeFileSync } from 'node:fs';
12
+ import { createRequire } from 'node:module';
13
13
  import * as ts from 'typescript';
14
14
 
15
15
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -2758,8 +2758,8 @@ var jsonTool = {
2758
2758
  };
2759
2759
  }
2760
2760
  };
2761
- function query(data, path17) {
2762
- const parts = path17.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
2761
+ function query(data, path18) {
2762
+ const parts = path18.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
2763
2763
  let current = data;
2764
2764
  for (const part of parts) {
2765
2765
  if (current === null || current === void 0) return void 0;
@@ -4033,7 +4033,7 @@ async function dockerLogs(service, lines, filterRe, cwd, signal, since) {
4033
4033
  });
4034
4034
  }
4035
4035
  var MAX_TAIL_LINES = 1e5;
4036
- async function fileLogs(path17, lines, filterRe, stream) {
4036
+ async function fileLogs(path18, lines, filterRe, stream) {
4037
4037
  const { createInterface } = await import('node:readline');
4038
4038
  const { createReadStream } = await import('node:fs');
4039
4039
  const entries = [];
@@ -4042,7 +4042,7 @@ async function fileLogs(path17, lines, filterRe, stream) {
4042
4042
  let writeIdx = 0;
4043
4043
  let totalLines = 0;
4044
4044
  const rl = createInterface({
4045
- input: createReadStream(path17),
4045
+ input: createReadStream(path18),
4046
4046
  crlfDelay: Number.POSITIVE_INFINITY
4047
4047
  });
4048
4048
  for await (const line of rl) {
@@ -4063,7 +4063,7 @@ async function fileLogs(path17, lines, filterRe, stream) {
4063
4063
  if (parsed) entries.push(parsed);
4064
4064
  }
4065
4065
  return {
4066
- source: path17,
4066
+ source: path18,
4067
4067
  entries,
4068
4068
  total: entries.length,
4069
4069
  truncated: totalLines > effLines,
@@ -4980,12 +4980,39 @@ function lspKindToInternalKind(k) {
4980
4980
  // src/codebase-index/writer.ts
4981
4981
  var INDEX_DIR = ".codebase-index";
4982
4982
  var DB_FILE = "index.db";
4983
+ var warningSilenced = false;
4984
+ function silenceSqliteExperimentalWarning() {
4985
+ if (warningSilenced) return;
4986
+ warningSilenced = true;
4987
+ const original = process.emitWarning.bind(process);
4988
+ process.emitWarning = ((warning, ...rest) => {
4989
+ const msg = typeof warning === "string" ? warning : warning?.message ?? "";
4990
+ const name = typeof warning === "string" ? String(rest[0] ?? "") : warning?.name ?? "";
4991
+ if (/sqlite/i.test(msg) && /experimental/i.test(`${name} ${msg}`)) return;
4992
+ original(warning, ...rest);
4993
+ });
4994
+ }
4995
+ var DatabaseSyncCtor;
4996
+ function loadDatabaseSync() {
4997
+ if (DatabaseSyncCtor) return DatabaseSyncCtor;
4998
+ silenceSqliteExperimentalWarning();
4999
+ try {
5000
+ const req = createRequire(import.meta.url);
5001
+ DatabaseSyncCtor = req("node:sqlite").DatabaseSync;
5002
+ } catch (err) {
5003
+ throw new Error(
5004
+ `The codebase index needs Node's built-in SQLite (node:sqlite), available since Node 22.5. This runtime doesn't provide it: ${err instanceof Error ? err.message : String(err)}`
5005
+ );
5006
+ }
5007
+ return DatabaseSyncCtor;
5008
+ }
4983
5009
  var IndexStore = class {
4984
5010
  constructor(projectRoot) {
4985
5011
  this.projectRoot = projectRoot;
4986
5012
  const dir = path.join(projectRoot, INDEX_DIR);
4987
5013
  fs13.mkdirSync(dir, { recursive: true });
4988
- this.db = new DatabaseSync(path.join(dir, DB_FILE));
5014
+ const Database = loadDatabaseSync();
5015
+ this.db = new Database(path.join(dir, DB_FILE));
4989
5016
  this.initSchema();
4990
5017
  }
4991
5018
  projectRoot;
@@ -5488,6 +5515,7 @@ import (
5488
5515
  "go/ast"
5489
5516
  "go/parser"
5490
5517
  "go/token"
5518
+ "io"
5491
5519
  "os"
5492
5520
  "strings"
5493
5521
  )
@@ -5502,17 +5530,13 @@ type Sym struct {
5502
5530
  }
5503
5531
 
5504
5532
  func main() {
5505
- if len(os.Args) < 2 {
5506
- fmt.Print("[]")
5507
- return
5508
- }
5509
- src, err := os.ReadFile(os.Args[1])
5533
+ src, err := io.ReadAll(os.Stdin)
5510
5534
  if err != nil {
5511
5535
  fmt.Print("[]")
5512
5536
  return
5513
5537
  }
5514
5538
  fset := token.NewFileSet()
5515
- node, err := parser.ParseFile(fset, os.Args[1], src, 0)
5539
+ node, err := parser.ParseFile(fset, "src.go", src, 0)
5516
5540
  if err != nil {
5517
5541
  fmt.Print("[]")
5518
5542
  return
@@ -5656,7 +5680,7 @@ func formatMethods(fields []*ast.Field) string {
5656
5680
  return formatFields(fields)
5657
5681
  }
5658
5682
 
5659
- func formatTypeParams(tp *ast.TypeParams) string {
5683
+ func formatTypeParams(tp *ast.FieldList) string {
5660
5684
  if tp == nil || len(tp.List) == 0 {
5661
5685
  return ""
5662
5686
  }
@@ -5699,30 +5723,33 @@ func formatType(t ast.Expr) string {
5699
5723
  return "chan " + formatType(v.Value)
5700
5724
  case *ast.BasicLit:
5701
5725
  return v.Value
5726
+ case *ast.IndexExpr:
5727
+ // Generic instantiation with one type arg, e.g. Logger[int].
5728
+ return formatType(v.X) + "[" + formatType(v.Index) + "]"
5729
+ case *ast.IndexListExpr:
5730
+ // Generic instantiation with multiple type args, e.g. Map[K, V].
5731
+ args := make([]string, len(v.Indices))
5732
+ for i, idx := range v.Indices {
5733
+ args[i] = formatType(idx)
5734
+ }
5735
+ return formatType(v.X) + "[" + strings.Join(args, ", ") + "]"
5702
5736
  default:
5703
5737
  return "?"
5704
5738
  }
5705
5739
  }
5706
5740
  `;
5707
- function syncGoParse(filePath, _content, lang) {
5708
- const tmpDir = path.join(process.env.TEMP ?? "/tmp", "ws-go-parse");
5741
+ function syncGoParse(filePath, content, lang) {
5742
+ const tmpDir = path.join(os.tmpdir(), "ws-go-parse");
5709
5743
  try {
5710
5744
  mkdirSync(tmpDir, { recursive: true });
5711
5745
  const scriptPath = path.join(tmpDir, "parse.go");
5712
5746
  writeFileSync(scriptPath, GO_PARSE_SCRIPT, "utf8");
5713
- let stdout;
5714
- try {
5715
- stdout = execSync(`go run "${scriptPath}" "${filePath}"`, {
5716
- timeout: 15e3,
5717
- encoding: "utf8",
5718
- windowsHide: true
5719
- });
5720
- } finally {
5721
- try {
5722
- unlinkSync(scriptPath);
5723
- } catch {
5724
- }
5725
- }
5747
+ const stdout = execSync(`go run "${scriptPath}"`, {
5748
+ input: content,
5749
+ timeout: 15e3,
5750
+ encoding: "utf8",
5751
+ windowsHide: true
5752
+ });
5726
5753
  if (!stdout.trim()) {
5727
5754
  return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
5728
5755
  }
@@ -5959,7 +5986,11 @@ print(json.dumps([s.to_dict() for s in syms]))
5959
5986
  `;
5960
5987
  function syncPyParse(filePath, lang) {
5961
5988
  try {
5962
- const stdout = execSync(`python -c "${PY_PARSE_SCRIPT.replace(/"/g, '\\"')}" "${filePath}"`, {
5989
+ const tmpDir = path.join(os.tmpdir(), "ws-py-parse");
5990
+ mkdirSync(tmpDir, { recursive: true });
5991
+ const scriptPath = path.join(tmpDir, "parse.py");
5992
+ writeFileSync(scriptPath, PY_PARSE_SCRIPT, "utf8");
5993
+ const stdout = execSync(`python "${scriptPath}" "${filePath}"`, {
5963
5994
  timeout: 15e3,
5964
5995
  encoding: "utf8",
5965
5996
  windowsHide: true
@@ -6000,7 +6031,10 @@ function checkNativeParser() {
6000
6031
  execSync("rustc --version", { stdio: "pipe" });
6001
6032
  const toolsDir = path.join(process.cwd(), "tools");
6002
6033
  try {
6003
- execSync("cargo metadata --no-deps --format-version 1 --manifest-path " + path.join(toolsDir, "Cargo.toml"), { stdio: "pipe" });
6034
+ execSync(
6035
+ "cargo metadata --no-deps --format-version 1 --manifest-path " + path.join(toolsDir, "Cargo.toml"),
6036
+ { stdio: "pipe" }
6037
+ );
6004
6038
  return true;
6005
6039
  } catch {
6006
6040
  return false;
@@ -6014,14 +6048,18 @@ function tryNativeParse(file, content) {
6014
6048
  const toolsDir = path.join(process.cwd(), "tools");
6015
6049
  const crateDir = path.join(toolsDir, "syn-parser");
6016
6050
  const tmpFile = path.join(crateDir, "src", "input.rs");
6017
- const { writeFileSync: writeFileSync2 } = __require("node:fs");
6018
- writeFileSync2(tmpFile, content, "utf8");
6019
- const result = spawnSync("cargo", ["run", "--manifest-path", path.join(toolsDir, "Cargo.toml")], {
6020
- cwd: process.cwd(),
6021
- encoding: "utf8",
6022
- timeout: 15e3,
6023
- stdio: ["pipe", "pipe", "pipe"]
6024
- });
6051
+ const { writeFileSync: writeFileSync3 } = __require("node:fs");
6052
+ writeFileSync3(tmpFile, content, "utf8");
6053
+ const result = spawnSync(
6054
+ "cargo",
6055
+ ["run", "--manifest-path", path.join(toolsDir, "Cargo.toml")],
6056
+ {
6057
+ cwd: process.cwd(),
6058
+ encoding: "utf8",
6059
+ timeout: 15e3,
6060
+ stdio: ["pipe", "pipe", "pipe"]
6061
+ }
6062
+ );
6025
6063
  if (result.status === 0 && result.stdout) {
6026
6064
  const symbols = JSON.parse(result.stdout);
6027
6065
  return {
@@ -6055,7 +6093,8 @@ function regexParse(opts) {
6055
6093
  lineOffsets.push(lineOffsets[i] + lines[i].length + 1);
6056
6094
  }
6057
6095
  function lineFromOffset(offset) {
6058
- let lo = 0, hi = lineOffsets.length - 1;
6096
+ let lo = 0;
6097
+ let hi = lineOffsets.length - 1;
6059
6098
  while (lo < hi) {
6060
6099
  const mid = lo + hi + 1 >>> 1;
6061
6100
  if (lineOffsets[mid] <= offset) lo = mid;
@@ -6069,8 +6108,7 @@ function regexParse(opts) {
6069
6108
  }
6070
6109
  for (const pattern of RS_PATTERNS) {
6071
6110
  pattern.regex.lastIndex = 0;
6072
- let match;
6073
- while ((match = pattern.regex.exec(content)) !== null) {
6111
+ for (let match = pattern.regex.exec(content); match !== null; match = pattern.regex.exec(content)) {
6074
6112
  const name = match[1];
6075
6113
  const offset = match.index;
6076
6114
  const line = lineFromOffset(offset);
@@ -6123,7 +6161,8 @@ function regexParse2(opts) {
6123
6161
  lineOffsets.push(lineOffsets[i] + lines[i].length + 1);
6124
6162
  }
6125
6163
  function lineFromOffset(offset) {
6126
- let lo = 0, hi = lineOffsets.length - 1;
6164
+ let lo = 0;
6165
+ let hi = lineOffsets.length - 1;
6127
6166
  while (lo < hi) {
6128
6167
  const mid = lo + hi + 1 >>> 1;
6129
6168
  if (lineOffsets[mid] <= offset) lo = mid;
@@ -6135,19 +6174,20 @@ function regexParse2(opts) {
6135
6174
  if (rootMatch) {
6136
6175
  const offset = rootMatch.index;
6137
6176
  const line = lineFromOffset(offset);
6138
- symbols.push(makeSymbol({
6139
- name: path.basename(file),
6140
- kind: "object",
6141
- line,
6142
- col: 0,
6143
- signature: `"${path.basename(file)}" = { ... }`,
6144
- file,
6145
- lang
6146
- }));
6177
+ symbols.push(
6178
+ makeSymbol({
6179
+ name: path.basename(file),
6180
+ kind: "object",
6181
+ line,
6182
+ col: 0,
6183
+ signature: `"${path.basename(file)}" = { ... }`,
6184
+ file,
6185
+ lang
6186
+ })
6187
+ );
6147
6188
  }
6148
6189
  const topLevelKeyRegex = /^\s*"([^"]+)"\s*:/gm;
6149
- let match;
6150
- while ((match = topLevelKeyRegex.exec(content)) !== null) {
6190
+ for (let match = topLevelKeyRegex.exec(content); match !== null; match = topLevelKeyRegex.exec(content)) {
6151
6191
  const key = match[1];
6152
6192
  const offset = match.index;
6153
6193
  const line = lineFromOffset(offset);
@@ -6174,15 +6214,17 @@ function regexParse2(opts) {
6174
6214
  signature = `"$ref": "..."`;
6175
6215
  }
6176
6216
  }
6177
- symbols.push(makeSymbol({
6178
- name: key,
6179
- kind,
6180
- line,
6181
- col,
6182
- signature,
6183
- file,
6184
- lang
6185
- }));
6217
+ symbols.push(
6218
+ makeSymbol({
6219
+ name: key,
6220
+ kind,
6221
+ line,
6222
+ col,
6223
+ signature,
6224
+ file,
6225
+ lang
6226
+ })
6227
+ );
6186
6228
  if (isPackageJson && key === "scripts") {
6187
6229
  extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset);
6188
6230
  }
@@ -6191,20 +6233,21 @@ function regexParse2(opts) {
6191
6233
  }
6192
6234
  }
6193
6235
  const defsRegex = /"\$defs"\s*:|"\$defs"\s*:/g;
6194
- let defsMatch;
6195
- while ((defsMatch = defsRegex.exec(content)) !== null) {
6236
+ const defsMatch = defsRegex.exec(content);
6237
+ if (defsMatch !== null) {
6196
6238
  const offset = defsMatch.index;
6197
6239
  const line = lineFromOffset(offset);
6198
- symbols.push(makeSymbol({
6199
- name: "$defs",
6200
- kind: "property",
6201
- line,
6202
- col: offset - (lineOffsets[line - 1] ?? 0),
6203
- signature: '"$defs": { ... }',
6204
- file,
6205
- lang
6206
- }));
6207
- break;
6240
+ symbols.push(
6241
+ makeSymbol({
6242
+ name: "$defs",
6243
+ kind: "property",
6244
+ line,
6245
+ col: offset - (lineOffsets[line - 1] ?? 0),
6246
+ signature: '"$defs": { ... }',
6247
+ file,
6248
+ lang
6249
+ })
6250
+ );
6208
6251
  }
6209
6252
  const defsPatterns = [
6210
6253
  /"\$defs"\s*:/g,
@@ -6214,69 +6257,71 @@ function regexParse2(opts) {
6214
6257
  ];
6215
6258
  for (const pat of defsPatterns) {
6216
6259
  pat.lastIndex = 0;
6217
- while ((match = pat.exec(content)) !== null) {
6260
+ for (let match = pat.exec(content); match !== null; match = pat.exec(content)) {
6218
6261
  const offset = match.index;
6219
6262
  const line = lineFromOffset(offset);
6220
6263
  const key = match[0].match(/"([^"]+)"/)?.[1] ?? match[0];
6221
- symbols.push(makeSymbol({
6222
- name: key,
6223
- kind: "property",
6224
- line,
6225
- col: offset - (lineOffsets[line - 1] ?? 0),
6226
- signature: `"${key}": { ... }`,
6227
- file,
6228
- lang
6229
- }));
6264
+ symbols.push(
6265
+ makeSymbol({
6266
+ name: key,
6267
+ kind: "property",
6268
+ line,
6269
+ col: offset - (lineOffsets[line - 1] ?? 0),
6270
+ signature: `"${key}": { ... }`,
6271
+ file,
6272
+ lang
6273
+ })
6274
+ );
6230
6275
  }
6231
6276
  }
6232
6277
  return { file, lang, symbols, mtimeMs: Date.now() };
6233
6278
  }
6234
6279
  function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset) {
6235
6280
  const scriptsBlockRegex = /"scripts"\s*:\s*\{([^}]+)\}/g;
6236
- let match;
6237
- while ((match = scriptsBlockRegex.exec(content)) !== null) {
6281
+ for (let match = scriptsBlockRegex.exec(content); match !== null; match = scriptsBlockRegex.exec(content)) {
6238
6282
  const blockContent = match[0];
6239
6283
  const blockOffset = match.index;
6240
6284
  const scriptKeyRegex = /"(\w[\w-]*)"\s*:/g;
6241
- let scriptMatch;
6242
- while ((scriptMatch = scriptKeyRegex.exec(blockContent)) !== null) {
6285
+ for (let scriptMatch = scriptKeyRegex.exec(blockContent); scriptMatch !== null; scriptMatch = scriptKeyRegex.exec(blockContent)) {
6243
6286
  const key = scriptMatch[1];
6244
6287
  const keyOffset = blockOffset + scriptMatch.index;
6245
6288
  const line = lineFromOffset(keyOffset);
6246
- symbols.push(makeSymbol({
6247
- name: key,
6248
- kind: "function",
6249
- line,
6250
- col: keyOffset - (lineOffsets[line - 1] ?? 0),
6251
- signature: `"${key}": "..."`,
6252
- file,
6253
- lang
6254
- }));
6289
+ symbols.push(
6290
+ makeSymbol({
6291
+ name: key,
6292
+ kind: "function",
6293
+ line,
6294
+ col: keyOffset - (lineOffsets[line - 1] ?? 0),
6295
+ signature: `"${key}": "..."`,
6296
+ file,
6297
+ lang
6298
+ })
6299
+ );
6255
6300
  }
6256
6301
  }
6257
6302
  }
6258
6303
  function extractCompilerOptions(content, symbols, file, lang, lineOffsets, parentLine, lineFromOffset) {
6259
6304
  const optsBlockRegex = /"compilerOptions"\s*:\s*\{([^}]+)\}/g;
6260
- let match;
6261
- while ((match = optsBlockRegex.exec(content)) !== null) {
6305
+ for (let match = optsBlockRegex.exec(content); match !== null; match = optsBlockRegex.exec(content)) {
6262
6306
  const blockContent = match[0];
6263
6307
  const blockOffset = match.index;
6264
6308
  const optKeyRegex = /"(\w[\w]*)"\s*:/g;
6265
- let optMatch;
6266
- while ((optMatch = optKeyRegex.exec(blockContent)) !== null) {
6309
+ for (let optMatch = optKeyRegex.exec(blockContent); optMatch !== null; optMatch = optKeyRegex.exec(blockContent)) {
6267
6310
  const key = optMatch[1];
6268
6311
  const keyOffset = blockOffset + optMatch.index;
6269
6312
  const line = lineFromOffset(keyOffset);
6270
6313
  if (line <= parentLine) continue;
6271
- symbols.push(makeSymbol({
6272
- name: key,
6273
- kind: "property",
6274
- line,
6275
- col: keyOffset - (lineOffsets[line - 1] ?? 0),
6276
- signature: `"${key}": ...`,
6277
- file,
6278
- lang
6279
- }));
6314
+ symbols.push(
6315
+ makeSymbol({
6316
+ name: key,
6317
+ kind: "property",
6318
+ line,
6319
+ col: keyOffset - (lineOffsets[line - 1] ?? 0),
6320
+ signature: `"${key}": ...`,
6321
+ file,
6322
+ lang
6323
+ })
6324
+ );
6280
6325
  }
6281
6326
  }
6282
6327
  }
@@ -6314,7 +6359,8 @@ function regexParse3(opts) {
6314
6359
  lineOffsets.push(lineOffsets[i] + lines[i].length + 1);
6315
6360
  }
6316
6361
  function lineFromOffset(offset) {
6317
- let lo = 0, hi = lineOffsets.length - 1;
6362
+ let lo = 0;
6363
+ let hi = lineOffsets.length - 1;
6318
6364
  while (lo < hi) {
6319
6365
  const mid = lo + hi + 1 >>> 1;
6320
6366
  if (lineOffsets[mid] <= offset) lo = mid;
@@ -6323,40 +6369,43 @@ function regexParse3(opts) {
6323
6369
  return lo + 1;
6324
6370
  }
6325
6371
  const anchorRegex = /&(\w[\w-]*)/g;
6326
- let match;
6327
- while ((match = anchorRegex.exec(content)) !== null) {
6372
+ for (let match = anchorRegex.exec(content); match !== null; match = anchorRegex.exec(content)) {
6328
6373
  const name = match[1];
6329
6374
  const offset = match.index;
6330
6375
  const line = lineFromOffset(offset);
6331
6376
  const col = offset - (lineOffsets[line - 1] ?? 0);
6332
- symbols.push(makeSymbol2({
6333
- name,
6334
- kind: "const",
6335
- line,
6336
- col,
6337
- signature: `&${name}`,
6338
- file,
6339
- lang
6340
- }));
6377
+ symbols.push(
6378
+ makeSymbol2({
6379
+ name,
6380
+ kind: "const",
6381
+ line,
6382
+ col,
6383
+ signature: `&${name}`,
6384
+ file,
6385
+ lang
6386
+ })
6387
+ );
6341
6388
  }
6342
6389
  const aliasRegex = /\*(\w[\w-]*)/g;
6343
- while ((match = aliasRegex.exec(content)) !== null) {
6390
+ for (let match = aliasRegex.exec(content); match !== null; match = aliasRegex.exec(content)) {
6344
6391
  const name = match[1];
6345
6392
  const offset = match.index;
6346
6393
  const line = lineFromOffset(offset);
6347
6394
  const col = offset - (lineOffsets[line - 1] ?? 0);
6348
- symbols.push(makeSymbol2({
6349
- name,
6350
- kind: "const",
6351
- line,
6352
- col,
6353
- signature: `*${name}`,
6354
- file,
6355
- lang
6356
- }));
6395
+ symbols.push(
6396
+ makeSymbol2({
6397
+ name,
6398
+ kind: "const",
6399
+ line,
6400
+ col,
6401
+ signature: `*${name}`,
6402
+ file,
6403
+ lang
6404
+ })
6405
+ );
6357
6406
  }
6358
6407
  const kvRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:/gm;
6359
- while ((match = kvRegex.exec(content)) !== null) {
6408
+ for (let match = kvRegex.exec(content); match !== null; match = kvRegex.exec(content)) {
6360
6409
  const indent = match[1].length;
6361
6410
  const key = match[2];
6362
6411
  const offset = match.index;
@@ -6372,38 +6421,42 @@ function regexParse3(opts) {
6372
6421
  symbols.push(makeSymbol2({ name: key, kind, line, col, signature, file, lang }));
6373
6422
  }
6374
6423
  const listItemRegex = /^-(\s+)([^:#\s][^:#\s]*)\s*:/gm;
6375
- while ((match = listItemRegex.exec(content)) !== null) {
6424
+ for (let match = listItemRegex.exec(content); match !== null; match = listItemRegex.exec(content)) {
6376
6425
  const key = match[2];
6377
6426
  const offset = match.index;
6378
6427
  const line = lineFromOffset(offset);
6379
6428
  const col = offset - (lineOffsets[line - 1] ?? 0);
6380
6429
  const value = extractValue(content, offset + match[0].length);
6381
6430
  const kind = isScalar(value) ? "literal" : "property";
6382
- symbols.push(makeSymbol2({
6383
- name: key,
6384
- kind,
6385
- line,
6386
- col,
6387
- signature: `- ${key}: ${truncate(value, 60)}`,
6388
- file,
6389
- lang
6390
- }));
6431
+ symbols.push(
6432
+ makeSymbol2({
6433
+ name: key,
6434
+ kind,
6435
+ line,
6436
+ col,
6437
+ signature: `- ${key}: ${truncate(value, 60)}`,
6438
+ file,
6439
+ lang
6440
+ })
6441
+ );
6391
6442
  }
6392
6443
  const blockScalarRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:\s*[|>](\s|$)/gm;
6393
- while ((match = blockScalarRegex.exec(content)) !== null) {
6444
+ for (let match = blockScalarRegex.exec(content); match !== null; match = blockScalarRegex.exec(content)) {
6394
6445
  const key = match[2];
6395
6446
  const offset = match.index;
6396
6447
  const line = lineFromOffset(offset);
6397
6448
  const col = offset - (lineOffsets[line - 1] ?? 0);
6398
- symbols.push(makeSymbol2({
6399
- name: key,
6400
- kind: "property",
6401
- line,
6402
- col,
6403
- signature: `${key}: | ...`,
6404
- file,
6405
- lang
6406
- }));
6449
+ symbols.push(
6450
+ makeSymbol2({
6451
+ name: key,
6452
+ kind: "property",
6453
+ line,
6454
+ col,
6455
+ signature: `${key}: | ...`,
6456
+ file,
6457
+ lang
6458
+ })
6459
+ );
6407
6460
  }
6408
6461
  return { file, lang, symbols, mtimeMs: Date.now() };
6409
6462
  }