@lvce-editor/problems-view 1.29.0 → 1.30.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.
@@ -1783,7 +1783,7 @@ const create = (id, uri, x, y, width, height, workspaceUri) => {
1783
1783
  };
1784
1784
 
1785
1785
  const isEqual$2 = (oldState, newState) => {
1786
- return oldState.collapsedUris === newState.collapsedUris && oldState.deltaY === newState.deltaY && oldState.filterValue === newState.filterValue && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.itemHeight === newState.itemHeight && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.problems === newState.problems && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.viewMode === newState.viewMode && oldState.width === newState.width;
1786
+ return oldState.collapsedUris === newState.collapsedUris && oldState.deltaY === newState.deltaY && oldState.filterValue === newState.filterValue && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.itemHeight === newState.itemHeight && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.problems === newState.problems && oldState.showErrors === newState.showErrors && oldState.showInfos === newState.showInfos && oldState.showWarnings === newState.showWarnings && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.viewMode === newState.viewMode && oldState.width === newState.width;
1787
1787
  };
1788
1788
 
1789
1789
  const isEqual$1 = (oldState, newState) => {
@@ -1802,7 +1802,7 @@ const haveSameCollapsedUris = (oldState, newState) => {
1802
1802
  return oldCollapsedUris.length === newCollapsedUris.length && oldCollapsedUris.every((uri, index) => uri === newCollapsedUris[index]);
1803
1803
  };
1804
1804
  const isEqual = (oldState, newState) => {
1805
- return oldState.activeUri === newState.activeUri && haveSameCollapsedUris(oldState, newState) && oldState.fileIconCache === newState.fileIconCache && oldState.focusedIndex === newState.focusedIndex && oldState.height === newState.height && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.problems === newState.problems && oldState.filterValue === newState.filterValue && oldState.message === newState.message && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.width === newState.width && oldState.viewMode === newState.viewMode;
1805
+ return oldState.activeUri === newState.activeUri && haveSameCollapsedUris(oldState, newState) && oldState.fileIconCache === newState.fileIconCache && oldState.focusedIndex === newState.focusedIndex && oldState.height === newState.height && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.problems === newState.problems && oldState.showErrors === newState.showErrors && oldState.showInfos === newState.showInfos && oldState.showWarnings === newState.showWarnings && oldState.filterValue === newState.filterValue && oldState.message === newState.message && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.width === newState.width && oldState.viewMode === newState.viewMode;
1806
1806
  };
1807
1807
 
1808
1808
  const RenderItems = 1;
@@ -1848,6 +1848,9 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1848
1848
  return Math.min(Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize), size);
1849
1849
  };
1850
1850
 
1851
+ const Error$1 = 'error';
1852
+ const Warning = 'warning';
1853
+
1851
1854
  const getListItemType = (listItemType, isCollapsed) => {
1852
1855
  if (listItemType === Item) {
1853
1856
  return Item;
@@ -1865,11 +1868,30 @@ const matchesFilterValue = (string, filterValueLower) => {
1865
1868
  return 0;
1866
1869
  };
1867
1870
 
1868
- const filterProblems = (problems, collapsedUris, filterValue) => {
1871
+ const matchesSeverity = (problem, showErrors, showWarnings, showInfos) => {
1872
+ switch (problem.type) {
1873
+ case Error$1:
1874
+ return showErrors;
1875
+ case Warning:
1876
+ return showWarnings;
1877
+ default:
1878
+ return showInfos;
1879
+ }
1880
+ };
1881
+ const filterProblems = (problems, collapsedUris, filterValue, showErrors = true, showWarnings = true, showInfos = true) => {
1869
1882
  const filterValueLower = filterValue.toLowerCase();
1870
1883
  const collapsedUriSet = new Set(collapsedUris);
1884
+ const hasSeverityFilter = !showErrors || !showWarnings || !showInfos;
1885
+ const visibleUris = new Set(problems.filter(problem => problem.listItemType === Item && matchesSeverity(problem, showErrors, showWarnings, showInfos)).map(problem => problem.uri));
1871
1886
  const filtered = [];
1872
1887
  for (const problem of problems) {
1888
+ if (problem.listItemType === Item) {
1889
+ if (!matchesSeverity(problem, showErrors, showWarnings, showInfos)) {
1890
+ continue;
1891
+ }
1892
+ } else if (hasSeverityFilter && !visibleUris.has(problem.uri)) {
1893
+ continue;
1894
+ }
1873
1895
  const uriMatchIndex = matchesFilterValue(problem.uri, filterValueLower);
1874
1896
  const sourceMatchIndex = matchesFilterValue(problem.source, filterValueLower);
1875
1897
  const messageMatchIndex = matchesFilterValue(problem.message, filterValueLower);
@@ -1892,8 +1914,8 @@ const filterProblems = (problems, collapsedUris, filterValue) => {
1892
1914
  return filtered;
1893
1915
  };
1894
1916
 
1895
- const getVisibleProblemCount = (problems, collapsedUris, filterValue, viewMode) => {
1896
- const filtered = filterProblems(problems, collapsedUris, filterValue);
1917
+ const getVisibleProblemCount = (problems, collapsedUris, filterValue, viewMode, showErrors = true, showWarnings = true, showInfos = true) => {
1918
+ const filtered = filterProblems(problems, collapsedUris, filterValue, showErrors, showWarnings, showInfos);
1897
1919
  if (viewMode !== Table) {
1898
1920
  return filtered.length;
1899
1921
  }
@@ -1915,11 +1937,14 @@ const updateVirtualList = (state, newDeltaY) => {
1915
1937
  itemHeight,
1916
1938
  minimumSliderSize,
1917
1939
  problems,
1940
+ showErrors,
1941
+ showInfos,
1942
+ showWarnings,
1918
1943
  smallWidthBreakPoint,
1919
1944
  viewMode,
1920
1945
  width
1921
1946
  } = state;
1922
- const itemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode);
1947
+ const itemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode, showErrors, showWarnings, showInfos);
1923
1948
  const listHeight = getListHeight(height, width, smallWidthBreakPoint, viewMode);
1924
1949
  const contentHeight = itemCount * itemHeight;
1925
1950
  const finalDeltaY = Math.max(contentHeight - listHeight, 0);
@@ -2119,17 +2144,17 @@ const getMenuEntriesFilter = state => {
2119
2144
  showWarnings: showWarnings$1
2120
2145
  } = state;
2121
2146
  return [{
2122
- command: '-1',
2147
+ command: 'Problems.toggleShowErrors',
2123
2148
  flags: showErrors$1 ? Checked : Unchecked,
2124
2149
  id: 'show-errors',
2125
2150
  label: showErrors()
2126
2151
  }, {
2127
- command: '-1',
2152
+ command: 'Problems.toggleShowWarnings',
2128
2153
  flags: showWarnings$1 ? Checked : Unchecked,
2129
2154
  id: 'show-warnings',
2130
2155
  label: showWarnings()
2131
2156
  }, {
2132
- command: '-1',
2157
+ command: 'Problems.toggleShowInfos',
2133
2158
  flags: showInfos$1 ? Checked : Unchecked,
2134
2159
  id: 'show-infos',
2135
2160
  label: showInfos()
@@ -2152,51 +2177,12 @@ const getMenuIds = () => {
2152
2177
  return [ProblemsFilter$1];
2153
2178
  };
2154
2179
 
2155
- const getMissingRequests = (problems, fileIconCache) => {
2156
- const missingRequests = [];
2157
- const pendingUris = new Set();
2158
- for (const problem of problems) {
2159
- const {
2160
- fileName,
2161
- uri
2162
- } = problem;
2163
- if (!uri || uri in fileIconCache || pendingUris.has(uri)) {
2164
- continue;
2165
- }
2166
- pendingUris.add(uri);
2167
- missingRequests.push({
2168
- name: fileName,
2169
- uri
2170
- });
2171
- }
2172
- return missingRequests;
2173
- };
2174
- const requestFileIcon = name => {
2175
- if (!name) {
2176
- return Promise.resolve('');
2177
- }
2178
- return getFileIcon({
2179
- name
2180
- });
2181
- };
2182
- const getFileIcons = async (problems, fileIconCache) => {
2183
- const missingRequests = getMissingRequests(problems, fileIconCache);
2184
- if (missingRequests.length === 0) {
2185
- return fileIconCache;
2186
- }
2187
- const icons = await Promise.all(missingRequests.map(request => requestFileIcon(request.name)));
2188
- const newFileIconCache = {
2189
- ...fileIconCache
2190
- };
2191
- for (let i = 0; i < missingRequests.length; i++) {
2192
- newFileIconCache[missingRequests[i].uri] = icons[i];
2193
- }
2194
- return newFileIconCache;
2195
- };
2196
-
2197
2180
  const {
2198
2181
  getProblems: getProblems$1,
2199
2182
  getUri} = EditorWorker;
2183
+ const getDiagnostics = editorId => {
2184
+ return invoke$1('Editor.getDiagnostics', editorId);
2185
+ };
2200
2186
 
2201
2187
  const leadingSlashesRegex = /^\/+/;
2202
2188
  const trailingSlashRegex = /\/$/;
@@ -2339,6 +2325,72 @@ const getProblems = async (workspaceUri, activeUri) => {
2339
2325
  }
2340
2326
  };
2341
2327
 
2328
+ const countByType = (diagnostics, type) => {
2329
+ return diagnostics.filter(diagnostic => diagnostic.type === type).length;
2330
+ };
2331
+ const getProblemsSummary = async () => {
2332
+ const editorId = await getActiveEditorId();
2333
+ if (editorId === -1) {
2334
+ return {
2335
+ errorCount: 0,
2336
+ hasEditor: false,
2337
+ problemCount: 0,
2338
+ warningCount: 0
2339
+ };
2340
+ }
2341
+ const [allDiagnostics, activeDiagnostics] = await Promise.all([getProblems$1(), getDiagnostics(editorId)]);
2342
+ const uniqueDiagnostics = getUniqueDiagnostics(allDiagnostics);
2343
+ const uniqueActiveDiagnostics = getUniqueDiagnostics(activeDiagnostics);
2344
+ return {
2345
+ errorCount: countByType(uniqueActiveDiagnostics, Error$1),
2346
+ hasEditor: true,
2347
+ problemCount: uniqueDiagnostics.length,
2348
+ warningCount: countByType(uniqueActiveDiagnostics, Warning)
2349
+ };
2350
+ };
2351
+
2352
+ const getMissingRequests = (problems, fileIconCache) => {
2353
+ const missingRequests = [];
2354
+ const pendingUris = new Set();
2355
+ for (const problem of problems) {
2356
+ const {
2357
+ fileName,
2358
+ uri
2359
+ } = problem;
2360
+ if (!uri || uri in fileIconCache || pendingUris.has(uri)) {
2361
+ continue;
2362
+ }
2363
+ pendingUris.add(uri);
2364
+ missingRequests.push({
2365
+ name: fileName,
2366
+ uri
2367
+ });
2368
+ }
2369
+ return missingRequests;
2370
+ };
2371
+ const requestFileIcon = name => {
2372
+ if (!name) {
2373
+ return Promise.resolve('');
2374
+ }
2375
+ return getFileIcon({
2376
+ name
2377
+ });
2378
+ };
2379
+ const getFileIcons = async (problems, fileIconCache) => {
2380
+ const missingRequests = getMissingRequests(problems, fileIconCache);
2381
+ if (missingRequests.length === 0) {
2382
+ return fileIconCache;
2383
+ }
2384
+ const icons = await Promise.all(missingRequests.map(request => requestFileIcon(request.name)));
2385
+ const newFileIconCache = {
2386
+ ...fileIconCache
2387
+ };
2388
+ for (let i = 0; i < missingRequests.length; i++) {
2389
+ newFileIconCache[missingRequests[i].uri] = icons[i];
2390
+ }
2391
+ return newFileIconCache;
2392
+ };
2393
+
2342
2394
  const refreshProblems = async (state, activeUri) => {
2343
2395
  const {
2344
2396
  fileIconCache,
@@ -2522,14 +2574,14 @@ const getIcon = (uri, fileIconCache) => {
2522
2574
  return fileIconCache[uri] || '';
2523
2575
  };
2524
2576
 
2525
- const getVisibleProblems = (problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY = 0, maxLineY = Infinity, viewMode = List) => {
2577
+ const getVisibleProblems = (problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY = 0, maxLineY = Infinity, viewMode = List, showErrors = true, showWarnings = true, showInfos = true) => {
2526
2578
  array(problems);
2527
2579
  array(collapsedUris);
2528
2580
  number(focusedIndex);
2529
2581
  string(filterValue);
2530
2582
  const visibleItems = [];
2531
2583
  const filterValueLength = filterValue.length;
2532
- const filtered = filterProblems(problems, collapsedUris, filterValue);
2584
+ const filtered = filterProblems(problems, collapsedUris, filterValue, showErrors, showWarnings, showInfos);
2533
2585
  const displayProblems = viewMode === Table ? filtered.filter(problem => problem.message) : filtered;
2534
2586
  const finalLineY = Math.min(maxLineY, displayProblems.length);
2535
2587
  for (let i = minLineY; i < finalLineY; i++) {
@@ -2558,6 +2610,9 @@ const handleClickAt = (state, eventX, eventY) => {
2558
2610
  filterValue,
2559
2611
  itemHeight,
2560
2612
  problems,
2613
+ showErrors,
2614
+ showInfos,
2615
+ showWarnings,
2561
2616
  smallWidthBreakPoint,
2562
2617
  viewMode,
2563
2618
  width,
@@ -2567,7 +2622,7 @@ const handleClickAt = (state, eventX, eventY) => {
2567
2622
 
2568
2623
  // TODO use functional focus rendering
2569
2624
  // Focus.setFocus(FocusKey.Problems)
2570
- const problemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode);
2625
+ const problemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode, showErrors, showWarnings, showInfos);
2571
2626
  if (problemCount === 0) {
2572
2627
  return focusIndex(state, -1);
2573
2628
  }
@@ -2595,9 +2650,12 @@ const handleProblemClick = async (state, eventX, eventY) => {
2595
2650
  fileIconCache,
2596
2651
  filterValue,
2597
2652
  problems,
2653
+ showErrors,
2654
+ showInfos,
2655
+ showWarnings,
2598
2656
  viewMode
2599
2657
  } = newState;
2600
- const visibleProblems = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, focusedIndex, focusedIndex + 1, viewMode);
2658
+ const visibleProblems = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, focusedIndex, focusedIndex + 1, viewMode, showErrors, showWarnings, showInfos);
2601
2659
  const problem = visibleProblems[0];
2602
2660
  if (!problem || problem.listItemType !== Item) {
2603
2661
  return newState;
@@ -2840,12 +2898,15 @@ const renderCss = (oldState, newState) => {
2840
2898
  minLineY,
2841
2899
  problems,
2842
2900
  scrollBarHeight,
2901
+ showErrors,
2902
+ showInfos,
2903
+ showWarnings,
2843
2904
  smallWidthBreakPoint,
2844
2905
  uid,
2845
2906
  viewMode,
2846
2907
  width
2847
2908
  } = newState;
2848
- const visibleProblems = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode);
2909
+ const visibleProblems = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode, showErrors, showWarnings, showInfos);
2849
2910
  const uniqueIndents = getUniqueIndents(visibleProblems);
2850
2911
  const listHeight = getListHeight(height, width, smallWidthBreakPoint, viewMode);
2851
2912
  const scrollBarTop = getScrollBarTop(listHeight, finalDeltaY, deltaY, scrollBarHeight);
@@ -3105,8 +3166,6 @@ const getFileIconVirtualDom = icon => {
3105
3166
  };
3106
3167
  };
3107
3168
 
3108
- const Warning = 'warning';
3109
-
3110
3169
  const warningIconNode = {
3111
3170
  childCount: 0,
3112
3171
  className: mergeClassNames(ProblemsIcon, ProblemsWarningIcon),
@@ -3419,12 +3478,15 @@ const renderItems = (oldState, newState) => {
3419
3478
  problems,
3420
3479
  scrollBarActive,
3421
3480
  scrollBarHeight,
3481
+ showErrors,
3482
+ showInfos,
3483
+ showWarnings,
3422
3484
  smallWidthBreakPoint,
3423
3485
  viewMode,
3424
3486
  width
3425
3487
  } = newState;
3426
- const problemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode);
3427
- const visible = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode);
3488
+ const problemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode, showErrors, showWarnings, showInfos);
3489
+ const visible = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode, showErrors, showWarnings, showInfos);
3428
3490
  const isSmall = width <= smallWidthBreakPoint;
3429
3491
  const dom = getProblemsVirtualDom(activeUri, viewMode, visible, filterValue, inputSource, isSmall, message, scrollBarHeight, scrollBarActive, problemCount);
3430
3492
  return ['Viewlet.setDom2', dom];
@@ -3490,11 +3552,14 @@ const getActions = state => {
3490
3552
  focusedIndex,
3491
3553
  inputSource,
3492
3554
  problems,
3555
+ showErrors,
3556
+ showInfos,
3557
+ showWarnings,
3493
3558
  smallWidthBreakPoint,
3494
3559
  viewMode,
3495
3560
  width
3496
3561
  } = state;
3497
- const visibleCount = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, 0, Infinity, viewMode).length;
3562
+ const visibleCount = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, 0, Infinity, viewMode, showErrors, showWarnings, showInfos).length;
3498
3563
  const problemsCount = problems.length;
3499
3564
  const isSmall = width <= smallWidthBreakPoint;
3500
3565
  const actions = [];
@@ -3627,6 +3692,36 @@ const toggleFileGroup = (state, uri) => {
3627
3692
  };
3628
3693
  };
3629
3694
 
3695
+ const toggleShowErrors = state => {
3696
+ const {
3697
+ showErrors
3698
+ } = state;
3699
+ return {
3700
+ ...state,
3701
+ showErrors: !showErrors
3702
+ };
3703
+ };
3704
+
3705
+ const toggleShowInfos = state => {
3706
+ const {
3707
+ showInfos
3708
+ } = state;
3709
+ return {
3710
+ ...state,
3711
+ showInfos: !showInfos
3712
+ };
3713
+ };
3714
+
3715
+ const toggleShowWarnings = state => {
3716
+ const {
3717
+ showWarnings
3718
+ } = state;
3719
+ return {
3720
+ ...state,
3721
+ showWarnings: !showWarnings
3722
+ };
3723
+ };
3724
+
3630
3725
  const commandMap = {
3631
3726
  'Problems.collapseAll': wrapCommand(collapseAll$1),
3632
3727
  'Problems.copyMessage': wrapCommand(copyMessage),
@@ -3637,6 +3732,7 @@ const commandMap = {
3637
3732
  'Problems.getKeyBindings': getKeyBindings,
3638
3733
  'Problems.getMenuEntries2': wrapGetter(getMenuEntries2),
3639
3734
  'Problems.getMenuIds': getMenuIds,
3735
+ 'Problems.getProblemsSummary': getProblemsSummary,
3640
3736
  'Problems.handleActiveEditorChange': wrapCommand(handleActiveEditorChange),
3641
3737
  'Problems.handleArrowLeft': wrapCommand(handleArrowLeft),
3642
3738
  'Problems.handleArrowRight': wrapCommand(handleArrowRight),
@@ -3661,6 +3757,9 @@ const commandMap = {
3661
3757
  'Problems.saveState': wrapGetter(saveState),
3662
3758
  'Problems.terminate': terminate,
3663
3759
  'Problems.toggleFileGroup': wrapCommand(toggleFileGroup),
3760
+ 'Problems.toggleShowErrors': wrapCommand(toggleShowErrors),
3761
+ 'Problems.toggleShowInfos': wrapCommand(toggleShowInfos),
3762
+ 'Problems.toggleShowWarnings': wrapCommand(toggleShowWarnings),
3664
3763
  'Problems.viewAsList': wrapCommand(viewAsList),
3665
3764
  'Problems.viewAsTable': wrapCommand(viewAsTable)
3666
3765
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",