dot-language-support 4.1.0 → 4.1.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +30 -59
  2. package/package.json +24 -22
package/dist/index.mjs CHANGED
@@ -1,13 +1,11 @@
1
1
  import * as lst from "vscode-languageserver-types";
2
2
  import { Range, TextEdit } from "vscode-languageserver-types";
3
-
4
3
  //#region src/core.ts
5
4
  function createMapFromTemplate(template) {
6
5
  const map = /* @__PURE__ */ new Map();
7
6
  for (const key in template) if (key in template) map.set(key, template[key]);
8
7
  return map;
9
8
  }
10
-
11
9
  //#endregion
12
10
  //#region src/types.ts
13
11
  const errorSource = {
@@ -295,7 +293,6 @@ const characterCodes = {
295
293
  tab: 9,
296
294
  verticalTab: 11
297
295
  };
298
-
299
296
  //#endregion
300
297
  //#region src/service/util.ts
301
298
  function getStart(sourceFile, node) {
@@ -328,7 +325,6 @@ const quote = (s) => `"${s}"`;
328
325
  function assertNever(v) {
329
326
  throw new Error(`Should not have reached this. Value: ${v ?? ""}`);
330
327
  }
331
-
332
328
  //#endregion
333
329
  //#region src/scanner.ts
334
330
  const textToToken = createMapFromTemplate({
@@ -403,7 +399,7 @@ var DefaultScanner = class {
403
399
  this.tokenValue = void 0;
404
400
  this.tokenFlags = tokenFlags.None;
405
401
  }
406
- scan(skipTrivia$1 = true) {
402
+ scan(skipTrivia = true) {
407
403
  this.startPos = this.pos;
408
404
  this.tokenFlags = tokenFlags.None;
409
405
  this.isUnterminated = false;
@@ -415,7 +411,7 @@ var DefaultScanner = class {
415
411
  case characterCodes.lineFeed:
416
412
  case characterCodes.carriageReturn:
417
413
  this.tokenFlags |= tokenFlags.PrecedingLineBreak;
418
- if (skipTrivia$1) {
414
+ if (skipTrivia) {
419
415
  this.pos++;
420
416
  continue;
421
417
  }
@@ -426,29 +422,29 @@ var DefaultScanner = class {
426
422
  case characterCodes.verticalTab:
427
423
  case characterCodes.formFeed:
428
424
  case characterCodes.space:
429
- if (skipTrivia$1) {
425
+ if (skipTrivia) {
430
426
  this.pos++;
431
427
  continue;
432
428
  }
433
429
  while (this.pos < this.end && this.#isWhiteSpaceSingleLine(this.text.charCodeAt(this.pos))) this.pos++;
434
430
  return this.token = syntaxKind.WhitespaceTrivia;
435
431
  case characterCodes.hash: {
436
- const content = this.#scanHashCommentTrivia(skipTrivia$1);
437
- if (skipTrivia$1) continue;
432
+ const content = this.#scanHashCommentTrivia(skipTrivia);
433
+ if (skipTrivia) continue;
438
434
  this.tokenValue = content;
439
435
  return this.token = syntaxKind.HashCommentTrivia;
440
436
  }
441
437
  case characterCodes.slash:
442
438
  if (this.pos + 1 < this.end) switch (this.text.charCodeAt(this.pos + 1)) {
443
439
  case characterCodes.slash: {
444
- const commentContent = this.#scanSingleLineCommentTrivia(skipTrivia$1);
445
- if (skipTrivia$1) continue;
440
+ const commentContent = this.#scanSingleLineCommentTrivia(skipTrivia);
441
+ if (skipTrivia) continue;
446
442
  this.tokenValue = commentContent;
447
443
  return this.token = syntaxKind.SingleLineCommentTrivia;
448
444
  }
449
445
  case characterCodes.asterisk: {
450
- const commentContent = this.#scanMultiLineCommentTrivia(skipTrivia$1);
451
- if (skipTrivia$1) continue;
446
+ const commentContent = this.#scanMultiLineCommentTrivia(skipTrivia);
447
+ if (skipTrivia) continue;
452
448
  this.tokenValue = commentContent;
453
449
  return this.token = syntaxKind.MultiLineCommentTrivia;
454
450
  }
@@ -620,7 +616,7 @@ var DefaultScanner = class {
620
616
  return result;
621
617
  }
622
618
  #scanString(allowEscapes = true) {
623
- const quote$1 = this.text.charCodeAt(this.pos);
619
+ const quote = this.text.charCodeAt(this.pos);
624
620
  this.pos++;
625
621
  let result = "";
626
622
  const start = this.pos;
@@ -637,7 +633,7 @@ var DefaultScanner = class {
637
633
  if (ch === characterCodes.backslash) hasBackslash = true;
638
634
  else if (hasBackslash) hasBackslash = false;
639
635
  else {
640
- if (ch === quote$1) {
636
+ if (ch === quote) {
641
637
  result += this.text.substring(start, this.pos);
642
638
  this.pos++;
643
639
  break;
@@ -787,7 +783,6 @@ function skipTrivia(text, pos) {
787
783
  function isLineBreak(ch) {
788
784
  return ch === characterCodes.lineFeed || ch === characterCodes.carriageReturn;
789
785
  }
790
-
791
786
  //#endregion
792
787
  //#region src/parser.ts
793
788
  const parsingContext = {
@@ -949,10 +944,10 @@ var Parser = class {
949
944
  case syntaxKind.SubgraphKeyword: {
950
945
  const subgraph = this.#parseSubGraph();
951
946
  if (this.#token() === syntaxKind.SemicolonToken) {
952
- const subgraphStatement$1 = this.#createNode(syntaxKind.SubGraphStatement, subgraph.pos);
953
- subgraphStatement$1.subgraph = subgraph;
954
- subgraphStatement$1.terminator = this.#parseExpectedToken(syntaxKind.SemicolonToken);
955
- return this.#finishNode(subgraphStatement$1);
947
+ const subgraphStatement = this.#createNode(syntaxKind.SubGraphStatement, subgraph.pos);
948
+ subgraphStatement.subgraph = subgraph;
949
+ subgraphStatement.terminator = this.#parseExpectedToken(syntaxKind.SemicolonToken);
950
+ return this.#finishNode(subgraphStatement);
956
951
  }
957
952
  if (this.#isEdgeOp()) return this.#parseEdgeStatement(subgraph);
958
953
  const subgraphStatement = this.#createNode(syntaxKind.SubGraphStatement, subgraph.pos);
@@ -1374,7 +1369,6 @@ function isIdentifier(kind) {
1374
1369
  function isIdentifierNode(node) {
1375
1370
  return isIdentifier(node.kind);
1376
1371
  }
1377
-
1378
1372
  //#endregion
1379
1373
  //#region src/service/languageFacts.ts
1380
1374
  const shapes = Object.freeze([
@@ -2377,7 +2371,6 @@ const colors = Object.freeze({
2377
2371
  yellow4: "#8b8b00",
2378
2372
  yellowgreen: "#9acd32"
2379
2373
  });
2380
-
2381
2374
  //#endregion
2382
2375
  //#region src/visitor.ts
2383
2376
  function visitNode(cbNode, node) {
@@ -2413,7 +2406,6 @@ function forEachChild(node, cbNode, cbNodes) {
2413
2406
  default: return;
2414
2407
  }
2415
2408
  }
2416
-
2417
2409
  //#endregion
2418
2410
  //#region src/checker.ts
2419
2411
  const validShapesLowerCase = new Set(shapes.map((s) => s.toLowerCase()));
@@ -2554,7 +2546,6 @@ function createCheckerError(sub) {
2554
2546
  function nodeContainsErrors(node) {
2555
2547
  return (node.flags & syntaxNodeFlags.ContainsErrors) === syntaxNodeFlags.ContainsErrors;
2556
2548
  }
2557
-
2558
2549
  //#endregion
2559
2550
  //#region src/binder.ts
2560
2551
  const binder = createBinder();
@@ -2746,12 +2737,12 @@ function createBinder() {
2746
2737
  }
2747
2738
  function ensureGlobalColor(node) {
2748
2739
  if (node && isIdentifierNode(node)) {
2749
- const colors$1 = colorTable;
2740
+ const colors = colorTable;
2750
2741
  const name = getIdentifierText(node);
2751
2742
  if (name === void 0) return;
2752
- if (colors$1 === void 0) throw "symbolTable is undefined";
2743
+ if (colors === void 0) throw "symbolTable is undefined";
2753
2744
  const color = createColor(node);
2754
- colors$1.set(name, color);
2745
+ colors.set(name, color);
2755
2746
  return;
2756
2747
  }
2757
2748
  console.warn("ensureSymbol called on non-identifier node");
@@ -2784,7 +2775,6 @@ function createBinder() {
2784
2775
  file.colors = colorTable;
2785
2776
  } };
2786
2777
  }
2787
-
2788
2778
  //#endregion
2789
2779
  //#region src/service/command/common.ts
2790
2780
  function createChangeToEdit(start, end, changeTo) {
@@ -2805,7 +2795,6 @@ function getOppositeEdgeOp(g) {
2805
2795
  function getAllowedOp(g) {
2806
2796
  return g === syntaxKind.DigraphKeyword ? syntaxKind.DirectedEdgeOp : syntaxKind.UndirectedEdgeOp;
2807
2797
  }
2808
-
2809
2798
  //#endregion
2810
2799
  //#region src/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.ts
2811
2800
  function create$3(edgeOffsets, changeEdgesTo, graphOffset, changeFromGraph, changeGraphTo) {
@@ -2840,7 +2829,6 @@ function execute$3(doc, _sourceFile, cmd) {
2840
2829
  function isChangeAllOtherEdgeOpsAndFixGraphCommand(cmd) {
2841
2830
  return cmd.command === commandIds.ConvertGraphType && !!cmd.arguments && cmd.arguments.length === 4;
2842
2831
  }
2843
-
2844
2832
  //#endregion
2845
2833
  //#region src/service/command/ChangeEdgeOpCommand.ts
2846
2834
  function create$2(startOffset, endOffset, changeTo, changeFrom) {
@@ -2869,7 +2857,6 @@ function execute$2(doc, _sourceFile, cmd) {
2869
2857
  function isChangeEdgeOpCommand(cmd) {
2870
2858
  return cmd.command === commandIds.ChangeEdgeOp && !!cmd.arguments && cmd.arguments.length === 3;
2871
2859
  }
2872
-
2873
2860
  //#endregion
2874
2861
  //#region src/service/command/ConsolidateDescendantsCommand.ts
2875
2862
  function create$1(statements, below) {
@@ -2937,7 +2924,6 @@ function execute$1(doc, sourceFile, cmd) {
2937
2924
  function isConsolidateDescendantsCommand(cmd) {
2938
2925
  return cmd.command === commandIds.ConsolidateDescendants && !!cmd.arguments && cmd.arguments.length > 1;
2939
2926
  }
2940
-
2941
2927
  //#endregion
2942
2928
  //#region src/service/command/RemoveSemicolons.ts
2943
2929
  function create() {
@@ -2964,7 +2950,6 @@ function execute(doc, sourceFile, cmd) {
2964
2950
  function isRemoveSemicolonsCommand(cmd) {
2965
2951
  return cmd.command === commandIds.RemoveSemicolons && (!cmd.arguments || cmd.arguments.length === 0 || cmd.arguments.every((e) => e === void 0));
2966
2952
  }
2967
-
2968
2953
  //#endregion
2969
2954
  //#region src/service/codeAction.ts
2970
2955
  function getCodeActions(doc, sourceFile, range, _context) {
@@ -3085,15 +3070,13 @@ function getCheckerErrorCommand(_doc, file, d, code) {
3085
3070
  }
3086
3071
  function convertGraphTypeCommand(file, graph, changeToGraphType) {
3087
3072
  const changeToEdgeOp = getAllowedOp(changeToGraphType);
3088
- const edgeOffsets = findAllEdges(graph).filter((e) => e.operation.kind !== changeToEdgeOp).map((e) => ({
3073
+ return create$3(findAllEdges(graph).filter((e) => e.operation.kind !== changeToEdgeOp).map((e) => ({
3089
3074
  start: getStart(file, e.operation),
3090
3075
  end: e.operation.end
3091
- }));
3092
- const graphTypeOffset = {
3076
+ })), changeToEdgeOp, {
3093
3077
  start: getStart(file, graph.keyword),
3094
3078
  end: graph.keyword.end
3095
- };
3096
- return create$3(edgeOffsets, changeToEdgeOp, graphTypeOffset, graph.keyword.kind, changeToGraphType);
3079
+ }, graph.keyword.kind, changeToGraphType);
3097
3080
  }
3098
3081
  function isInRange(rangeStartOffset, rangeEndOffset, startOffset, endOffset) {
3099
3082
  if (rangeStartOffset === rangeEndOffset) return startOffset <= rangeStartOffset && rangeEndOffset <= endOffset;
@@ -3128,7 +3111,6 @@ function subtreeContainsErrors(node) {
3128
3111
  });
3129
3112
  return hasError;
3130
3113
  }
3131
-
3132
3114
  //#endregion
3133
3115
  //#region src/service/colorProvider.ts
3134
3116
  const colorMap = colors;
@@ -3139,10 +3121,10 @@ function getDocumentColors(doc, sourceFile) {
3139
3121
  function getColorRepresentations(_doc, _sourceFile, color, range) {
3140
3122
  return !color || !range ? void 0 : [{ label: `"${getColorStringFromColor(color)}"` }];
3141
3123
  }
3142
- function colorTableToColorInformation(doc, sf, colors$1) {
3143
- if (!colors$1 || colors$1.size === 0) return [];
3124
+ function colorTableToColorInformation(doc, sf, colors) {
3125
+ if (!colors || colors.size === 0) return [];
3144
3126
  const res = [];
3145
- for (const [name, value] of colors$1) {
3127
+ for (const [name, value] of colors) {
3146
3128
  if (!name || !value) continue;
3147
3129
  const color = getColorFromName(name);
3148
3130
  if (color) res.push({
@@ -3177,7 +3159,6 @@ function numberToPaddedString(n) {
3177
3159
  const s = n.toString(16);
3178
3160
  return (s.length === 1 ? `0${s}` : s).toLowerCase();
3179
3161
  }
3180
-
3181
3162
  //#endregion
3182
3163
  //#region src/service/completion.ts
3183
3164
  function getCompletions(doc, sourceFile, position) {
@@ -3210,8 +3191,8 @@ function getCompletions(doc, sourceFile, position) {
3210
3191
  const attribute = prevNode;
3211
3192
  if (!attribute) return [];
3212
3193
  if (!attribute.parent) throw "sourceFile is not bound";
3213
- const parent$1 = attribute.parent;
3214
- if (parent$1.kind === syntaxKind.Assignment) return getAssignmentCompletion(parent$1);
3194
+ const parent = attribute.parent;
3195
+ if (parent.kind === syntaxKind.Assignment) return getAssignmentCompletion(parent);
3215
3196
  }
3216
3197
  return [];
3217
3198
  }
@@ -3274,7 +3255,6 @@ function getNodeCompletions(symbols, exlucdedSymbols) {
3274
3255
  }
3275
3256
  return res;
3276
3257
  }
3277
-
3278
3258
  //#endregion
3279
3259
  //#region src/service/hover.ts
3280
3260
  function hover(doc, sourceFile, position) {
@@ -3370,7 +3350,6 @@ function getEdgeHover(n) {
3370
3350
  function getEdgeSourceOrTargetText(n) {
3371
3351
  return n.kind === syntaxKind.NodeId ? getIdentifierText(n.id) : n.id !== void 0 ? `${getIdentifierText(n.id)}` : "sub graph";
3372
3352
  }
3373
-
3374
3353
  //#endregion
3375
3354
  //#region src/service/reference.ts
3376
3355
  function findReferences(doc, sourceFile, position, context) {
@@ -3418,7 +3397,6 @@ function findDefinition(doc, sourceFile, position) {
3418
3397
  }
3419
3398
  debugger;
3420
3399
  }
3421
-
3422
3400
  //#endregion
3423
3401
  //#region src/service/rename.ts
3424
3402
  function renameSymbol(doc, sourceFile, position, newName) {
@@ -3434,7 +3412,7 @@ function renameSymbol(doc, sourceFile, position, newName) {
3434
3412
  if (!nodeSymbol) throw "node.symbol is not bound";
3435
3413
  const r = nodeSymbol.references;
3436
3414
  const ranges = syntaxNodesToRanges(doc, sourceFile, r ? [nodeSymbol.firstMention, ...r] : [nodeSymbol.firstMention]);
3437
- return { changes: { [doc.uri]: ranges.map((r$1) => TextEdit.replace(r$1, newName)) } };
3415
+ return { changes: { [doc.uri]: ranges.map((r) => TextEdit.replace(r, newName)) } };
3438
3416
  }
3439
3417
  debugger;
3440
3418
  }
@@ -3444,16 +3422,11 @@ function isRenameableNode(node) {
3444
3422
  function isRenamableIdentifier(node) {
3445
3423
  return node.kind !== syntaxKind.QuotedTextIdentifier;
3446
3424
  }
3447
-
3448
- //#endregion
3449
- //#region src/error.ts
3450
- const diagnosicSource = "DOT";
3451
3425
  const subErrorCodeLength = 3;
3452
3426
  function formatError(error) {
3453
3427
  const subCode = (error.sub | 0).toString().padStart(subErrorCodeLength, "0");
3454
- return diagnosicSource + error.source + subCode;
3428
+ return "DOT" + error.source + subCode;
3455
3429
  }
3456
-
3457
3430
  //#endregion
3458
3431
  //#region src/service/validation.ts
3459
3432
  function convertDiagnostic(document, source) {
@@ -3464,7 +3437,7 @@ function convertDiagnostic(document, source) {
3464
3437
  },
3465
3438
  severity: source.category,
3466
3439
  code: formatError(source.code),
3467
- source: diagnosicSource,
3440
+ source: "DOT",
3468
3441
  message: source.message
3469
3442
  };
3470
3443
  }
@@ -3473,7 +3446,6 @@ function validateDocument(doc, sourceFile) {
3473
3446
  if (!diagnostics || diagnostics.length <= 0) return [];
3474
3447
  return diagnostics.map((d) => convertDiagnostic(doc, d));
3475
3448
  }
3476
-
3477
3449
  //#endregion
3478
3450
  //#region src/service/service.ts
3479
3451
  function parseDocument(doc) {
@@ -3500,6 +3472,5 @@ function createService() {
3500
3472
  getAvailableCommands
3501
3473
  };
3502
3474
  }
3503
-
3504
3475
  //#endregion
3505
- export { DefaultScanner, Parser, characterCodes, checkError, createService, diagnosticCategory, errorSource, forEachChild, getTextAsToken, getTokenAsText, graphContext, isIdentifier, isIdentifierNode, isIdentifierStart, isLineBreak, parseError, parsingContext, scanError, skipTrivia, syntaxKind, syntaxKindNames, syntaxNodeFlags, tokenFlags };
3476
+ export { DefaultScanner, Parser, characterCodes, checkError, createService, diagnosticCategory, errorSource, forEachChild, getTextAsToken, getTokenAsText, graphContext, isIdentifier, isIdentifierNode, isIdentifierStart, isLineBreak, parseError, parsingContext, scanError, skipTrivia, syntaxKind, syntaxKindNames, syntaxNodeFlags, tokenFlags };
package/package.json CHANGED
@@ -1,43 +1,45 @@
1
1
  {
2
2
  "name": "dot-language-support",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "Parser and language service for graphviz (dot) files",
5
- "author": "Niklas Mollenhauer",
6
- "license": "MIT",
7
- "main": "./dist/index.mjs",
8
- "module": "./dist/index.mjs",
9
- "types": "./dist/index.d.mts",
10
- "type": "module",
11
- "scripts": {
12
- "ci": "biome ci ./src",
13
- "test": "tsc && node --test '**/*.spec.ts'",
14
- "test:coverage": "node --test --experimental-test-coverage '**/*.spec.ts'",
15
- "format": "biome format --write ./src",
16
- "lint": "biome lint ./src",
17
- "lint:fix": "biome lint --write ./src",
18
- "build": "tsdown",
19
- "prepare": "npm run build"
20
- },
21
5
  "keywords": [
22
- "graphviz",
23
6
  "dot",
7
+ "graphviz",
24
8
  "gv",
25
- "parser",
26
9
  "language",
10
+ "parser",
27
11
  "service"
28
12
  ],
13
+ "license": "MIT",
14
+ "author": "Niklas Mollenhauer",
29
15
  "repository": {
30
16
  "type": "git",
31
17
  "url": "https://github.com/nikeee/dot-language-support.git"
32
18
  },
19
+ "type": "module",
20
+ "main": "./dist/index.mjs",
21
+ "module": "./dist/index.mjs",
22
+ "types": "./dist/index.d.mts",
23
+ "scripts": {
24
+ "ci": "oxlint -f github",
25
+ "test": "tsc && node --test '**/*.spec.ts'",
26
+ "test:coverage": "node --test --experimental-test-coverage '**/*.spec.ts'",
27
+ "format": "oxfmt",
28
+ "lint": "oxlint --type-aware",
29
+ "lint:fix": "oxlint --type-aware --fix",
30
+ "build": "tsdown",
31
+ "prepare": "npm run build"
32
+ },
33
33
  "dependencies": {
34
34
  "vscode-languageserver-textdocument": "^1.0.12",
35
35
  "vscode-languageserver-types": "^3.17.5"
36
36
  },
37
37
  "devDependencies": {
38
- "@biomejs/biome": "^2.3.11",
39
- "expect": "^30.2.0",
40
- "tsdown": "^0.19.0",
38
+ "expect": "^30.3.0",
39
+ "oxfmt": "^0.41.0",
40
+ "oxlint": "^1.49.0",
41
+ "oxlint-tsgolint": "^0.17.1",
42
+ "tsdown": "^0.21.4",
41
43
  "typescript": "^5.9.3"
42
44
  },
43
45
  "engines": {