@likec4/language-server 0.47.0 → 0.49.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/ast.js CHANGED
@@ -47,11 +47,10 @@ export function cleanParsedModel(doc) {
47
47
  c4Relations: [],
48
48
  c4Views: []
49
49
  };
50
- Object.assign(doc, props);
51
- return doc;
50
+ return Object.assign(doc, props);
52
51
  }
53
52
  export function isFqnIndexedDocument(doc) {
54
- return isLikeC4LangiumDocument(doc) && doc.state >= DocumentState.IndexedContent && !isNil(doc.c4fqns);
53
+ return isLikeC4LangiumDocument(doc) && doc.state >= DocumentState.IndexedContent && !!doc.c4fqns;
55
54
  }
56
55
  export function isLikeC4LangiumDocument(doc) {
57
56
  return doc.textDocument.languageId === LikeC4LanguageMetaData.languageId;
@@ -1,6 +1,6 @@
1
1
  import { AbstractSemanticTokenProvider, type AstNode, type SemanticTokenAcceptor } from 'langium';
2
2
  export declare class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
3
- protected highlightElement(node: AstNode, acceptor: SemanticTokenAcceptor): void;
3
+ protected highlightElement(node: AstNode, acceptor: SemanticTokenAcceptor): void | undefined | 'prune';
4
4
  private highlightAstElement;
5
5
  private highlightView;
6
6
  }
@@ -2,6 +2,7 @@ import { AbstractSemanticTokenProvider } from "langium";
2
2
  import { SemanticTokenModifiers, SemanticTokenTypes } from "vscode-languageserver-protocol";
3
3
  import { ast } from "../ast.js";
4
4
  export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
5
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
5
6
  highlightElement(node, acceptor) {
6
7
  if (ast.isRelation(node) && "kind" in node) {
7
8
  acceptor({
@@ -23,6 +24,7 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
23
24
  cst: node.$cstNode,
24
25
  type: SemanticTokenTypes.variable
25
26
  });
27
+ return "prune";
26
28
  }
27
29
  if (ast.isWildcardExpr(node) && node.$cstNode) {
28
30
  acceptor({
@@ -1,6 +1,6 @@
1
1
  import { type c4 } from '@likec4/core';
2
2
  import type { LangiumDocument } from 'langium';
3
- import type { LikeC4LangiumDocument, ParsedLikeC4LangiumDocument } from '../ast';
3
+ import type { FqnIndexedDocument, ParsedLikeC4LangiumDocument } from '../ast';
4
4
  import { ast } from '../ast';
5
5
  import type { LikeC4Services } from '../module';
6
6
  export type ModelParsedListener = () => void;
@@ -9,7 +9,7 @@ export declare class LikeC4ModelParser {
9
9
  private fqnIndex;
10
10
  constructor(services: LikeC4Services);
11
11
  parse(doc: LangiumDocument | LangiumDocument[]): ParsedLikeC4LangiumDocument[];
12
- protected parseLikeC4Document(_doc: LikeC4LangiumDocument): ParsedLikeC4LangiumDocument;
12
+ protected parseLikeC4Document(_doc: FqnIndexedDocument): ParsedLikeC4LangiumDocument;
13
13
  private parseSpecification;
14
14
  private parseModel;
15
15
  private parseElement;
@@ -1,18 +1,13 @@
1
- import {
2
- InvalidModelError,
3
- invariant,
4
- isNonEmptyArray,
5
- nonexhaustive
6
- } from "@likec4/core";
1
+ import { InvalidModelError, invariant, isNonEmptyArray, nonexhaustive } from "@likec4/core";
7
2
  import { getDocument } from "langium";
8
3
  import objectHash from "object-hash";
4
+ import { isTruthy } from "remeda";
9
5
  import stripIndent from "strip-indent";
10
6
  import {
11
7
  ElementViewOps,
12
8
  ast,
13
9
  cleanParsedModel,
14
10
  isFqnIndexedDocument,
15
- isLikeC4LangiumDocument,
16
11
  resolveRelationPoints,
17
12
  streamModel,
18
13
  toAutoLayout,
@@ -22,7 +17,6 @@ import {
22
17
  } from "../ast.js";
23
18
  import { elementRef, getFqnElementRef } from "../elementRef.js";
24
19
  import { logError, logWarnError, logger } from "../logger.js";
25
- import { isTruthy } from "remeda";
26
20
  function toSingleLine(str) {
27
21
  return str?.split("\n").join(" ").trim();
28
22
  }
@@ -40,7 +34,8 @@ export class LikeC4ModelParser {
40
34
  const docs = Array.isArray(doc) ? doc : [doc];
41
35
  const result = [];
42
36
  for (const doc2 of docs) {
43
- if (!isLikeC4LangiumDocument(doc2)) {
37
+ if (!isFqnIndexedDocument(doc2)) {
38
+ logger.warn(`Not a FqnIndexedDocument: ${doc2.uri.toString(true)}`);
44
39
  continue;
45
40
  }
46
41
  try {
@@ -52,7 +47,6 @@ export class LikeC4ModelParser {
52
47
  return result;
53
48
  }
54
49
  parseLikeC4Document(_doc) {
55
- invariant(isFqnIndexedDocument(_doc), "Not a FqnIndexedDocument");
56
50
  const doc = cleanParsedModel(_doc);
57
51
  this.parseSpecification(doc);
58
52
  this.parseModel(doc);
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- export const printDocs = (docs) => docs.map((d) => " - " + d.uri).join("\n");
1
+ export const printDocs = (docs) => docs.map((d) => " - " + d.uri.toString(true)).join("\n");
2
2
  export function queueMicrotask(cb) {
3
3
  return Promise.resolve().then(cb);
4
4
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
3
  "description": "LikeC4 Language Server",
4
- "version": "0.47.0",
4
+ "version": "0.49.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -50,8 +50,8 @@
50
50
  "test": "vitest run"
51
51
  },
52
52
  "dependencies": {
53
- "@likec4/core": "0.47.0",
54
- "@likec4/graph": "0.47.0",
53
+ "@likec4/core": "0.49.0",
54
+ "@likec4/graph": "0.49.0",
55
55
  "langium": "^2.1.2",
56
56
  "object-hash": "^3.0.0",
57
57
  "p-debounce": "^4.0.0",