@lvce-editor/problems-view 1.32.0 → 1.34.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.
@@ -2243,6 +2243,25 @@ const getFileName = uri => {
2243
2243
  const slashIndex = uri.lastIndexOf('/');
2244
2244
  return uri.slice(slashIndex + 1);
2245
2245
  };
2246
+ const toRelatedProblem = (relatedInformation, diagnostic, index, setSize) => {
2247
+ return {
2248
+ code: '',
2249
+ columnIndex: relatedInformation.columnIndex || 0,
2250
+ count: 0,
2251
+ fileName: '',
2252
+ level: 3,
2253
+ listItemType: Item,
2254
+ message: relatedInformation.message || '',
2255
+ posInSet: index,
2256
+ relativePath: '',
2257
+ rowIndex: relatedInformation.rowIndex || 0,
2258
+ setSize,
2259
+ source: getFileName(relatedInformation.uri),
2260
+ targetUri: relatedInformation.uri,
2261
+ type: diagnostic.type || 'error',
2262
+ uri: diagnostic.uri
2263
+ };
2264
+ };
2246
2265
  const toProblems = (diagnostics, workspaceUri = '') => {
2247
2266
  const problems = [];
2248
2267
  let problem = {
@@ -2287,13 +2306,18 @@ const toProblems = (diagnostics, workspaceUri = '') => {
2287
2306
  problems.push(problem);
2288
2307
  }
2289
2308
  problems.push(toProblem(diagnostic, relativeIndex));
2309
+ const relatedInformation = diagnostic.relatedInformation || [];
2310
+ for (let i = 0; i < relatedInformation.length; i++) {
2311
+ problems.push(toRelatedProblem(relatedInformation[i], diagnostic, i + 1, relatedInformation.length));
2312
+ }
2290
2313
  }
2291
2314
  for (const problem of problems) {
2292
2315
  // TODO maybe rename property, this should be the relative path of the parent folder of the file
2293
2316
  // @ts-ignore
2294
- problem.relativePath = getRelativeParentUri(problem.uri, workspaceUri);
2317
+ const displayUri = problem.targetUri || problem.uri;
2318
+ problem.relativePath = getRelativeParentUri(displayUri, workspaceUri);
2295
2319
  // @ts-ignore
2296
- problem.fileName = getFileName(problem.uri);
2320
+ problem.fileName = getFileName(displayUri);
2297
2321
  // problem.uri = problem.uri // TODO
2298
2322
  }
2299
2323
  return problems;
@@ -2599,7 +2623,7 @@ const set = rpc => {
2599
2623
  state.connected = true;
2600
2624
  };
2601
2625
 
2602
- const handleMessagePort = async (port, viewletCommandMap) => {
2626
+ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
2603
2627
  const executeViewletCommand = async (uid, command, ...args) => {
2604
2628
  const fn = viewletCommandMap[`Problems.${command}`];
2605
2629
  if (typeof fn !== 'function') {
@@ -2614,7 +2638,9 @@ const handleMessagePort = async (port, viewletCommandMap) => {
2614
2638
  },
2615
2639
  messagePort: port
2616
2640
  });
2617
- set(rpc);
2641
+ if (setAsRendererProcess) {
2642
+ set(rpc);
2643
+ }
2618
2644
  };
2619
2645
 
2620
2646
  const getIcon = (uri, fileIconCache) => {
@@ -2714,9 +2740,10 @@ const handleProblemClick = async (state, eventX, eventY) => {
2714
2740
  const {
2715
2741
  columnIndex,
2716
2742
  rowIndex,
2743
+ targetUri,
2717
2744
  uri
2718
2745
  } = problem;
2719
- await openUri(uri, true);
2746
+ await openUri(targetUri || uri, true);
2720
2747
  await focusEditor();
2721
2748
  await setEditorCursor(rowIndex, columnIndex);
2722
2749
  return newState;
@@ -2922,16 +2949,16 @@ const getTreeItemIndent = depth => {
2922
2949
  return `${depth * defaultIndent}rem`;
2923
2950
  };
2924
2951
 
2925
- const getProblemIndent = listItemType => {
2952
+ const getProblemIndent = (listItemType, level) => {
2926
2953
  const isGroup = listItemType === Expanded || listItemType === Collapsed;
2927
- const depth = isGroup ? 1 : 2;
2954
+ const depth = isGroup ? 1 : Math.max(2, level || 2);
2928
2955
  return getTreeItemIndent(depth);
2929
2956
  };
2930
2957
 
2931
2958
  const getUniqueIndents = problems => {
2932
2959
  const uniqueIndents = [];
2933
2960
  for (const problem of problems) {
2934
- const indent = getProblemIndent(problem.listItemType);
2961
+ const indent = getProblemIndent(problem.listItemType, problem.level);
2935
2962
  if (!uniqueIndents.includes(indent)) {
2936
2963
  uniqueIndents.push(indent);
2937
2964
  }
@@ -3293,7 +3320,7 @@ const getProblemVirtualDom = problem => {
3293
3320
  uri
3294
3321
  } = problem;
3295
3322
  let className = Problem;
3296
- const indent = getProblemIndent(listItemType);
3323
+ const indent = getProblemIndent(listItemType, level);
3297
3324
  className = mergeClassNames(className, `Indent-${indent}`);
3298
3325
  if (isActive) {
3299
3326
  className = mergeClassNames(className, ProblemSelected);
@@ -3786,7 +3813,7 @@ const toggleShowWarnings = state => {
3786
3813
  };
3787
3814
  };
3788
3815
 
3789
- const handleDirectMessagePort = port => handleMessagePort(port, commandMap);
3816
+ const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
3790
3817
  const commandMap = {
3791
3818
  'Problems.collapseAll': wrapCommand(collapseAll$1),
3792
3819
  'Problems.copyMessage': wrapCommand(copyMessage),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.32.0",
3
+ "version": "1.34.0",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",