@lvce-editor/problems-view 1.9.0 → 1.11.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/problemsViewWorkerMain.js +128 -30
- package/package.json +1 -1
|
@@ -1169,10 +1169,9 @@ const None$1 = 0;
|
|
|
1169
1169
|
const Table = 1;
|
|
1170
1170
|
const List = 2;
|
|
1171
1171
|
|
|
1172
|
-
const create = (id, uri, x, y, width, height,
|
|
1172
|
+
const create = (id, uri, x, y, width, height, workspaceUri) => {
|
|
1173
1173
|
const state = {
|
|
1174
1174
|
uid: id,
|
|
1175
|
-
parentUid,
|
|
1176
1175
|
problems: [],
|
|
1177
1176
|
focusedIndex: -2,
|
|
1178
1177
|
message: '',
|
|
@@ -1189,7 +1188,8 @@ const create = (id, uri, x, y, width, height, args, parentUid) => {
|
|
|
1189
1188
|
listItems: [],
|
|
1190
1189
|
collapsedUris: [],
|
|
1191
1190
|
smallWidthBreakPoint: 650,
|
|
1192
|
-
filteredProblems: []
|
|
1191
|
+
filteredProblems: [],
|
|
1192
|
+
workspaceUri
|
|
1193
1193
|
};
|
|
1194
1194
|
set$1(id, state, state);
|
|
1195
1195
|
};
|
|
@@ -1199,7 +1199,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1199
1199
|
};
|
|
1200
1200
|
|
|
1201
1201
|
const isEqual = (oldState, newState) => {
|
|
1202
|
-
return oldState.problems === newState.problems && oldState.filterValue === newState.filterValue && oldState.message === newState.message;
|
|
1202
|
+
return oldState.problems === newState.problems && oldState.filterValue === newState.filterValue && oldState.message === newState.message && oldState.viewMode === newState.viewMode;
|
|
1203
1203
|
};
|
|
1204
1204
|
|
|
1205
1205
|
const RenderItems = 1;
|
|
@@ -1453,6 +1453,10 @@ const handleClickAt = (state, eventX, eventY) => {
|
|
|
1453
1453
|
};
|
|
1454
1454
|
};
|
|
1455
1455
|
|
|
1456
|
+
const handleClickButton = async (state, name) => {
|
|
1457
|
+
return state;
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1456
1460
|
const handleContextMenu = async (state, eventX, eventY) => {
|
|
1457
1461
|
// @ts-ignore
|
|
1458
1462
|
// await ContextMenu.show(eventX, eventY, MenuEntryId.Problems)
|
|
@@ -1498,14 +1502,107 @@ const initialize = async () => {
|
|
|
1498
1502
|
set(rpc);
|
|
1499
1503
|
};
|
|
1500
1504
|
|
|
1501
|
-
const
|
|
1505
|
+
const toProblem = (diagnostic, index) => {
|
|
1506
|
+
const {
|
|
1507
|
+
message,
|
|
1508
|
+
rowIndex,
|
|
1509
|
+
columnIndex,
|
|
1510
|
+
source,
|
|
1511
|
+
code,
|
|
1512
|
+
type,
|
|
1513
|
+
uri
|
|
1514
|
+
} = diagnostic;
|
|
1515
|
+
return {
|
|
1516
|
+
message: message || '',
|
|
1517
|
+
rowIndex: rowIndex || 0,
|
|
1518
|
+
columnIndex: columnIndex || 0,
|
|
1519
|
+
uri,
|
|
1520
|
+
relativePath: '',
|
|
1521
|
+
count: 0,
|
|
1522
|
+
source: source || '',
|
|
1523
|
+
code: code || '',
|
|
1524
|
+
type: type || 'error',
|
|
1525
|
+
listItemType: Item,
|
|
1526
|
+
posInSet: index,
|
|
1527
|
+
setSize: 1,
|
|
1528
|
+
level: 2,
|
|
1529
|
+
fileName: ''
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
const getRelativeParentUri = (uri, workspaceUri) => {
|
|
1533
|
+
const slashIndex = uri.lastIndexOf('/');
|
|
1534
|
+
return uri.slice(0, slashIndex).slice(workspaceUri.length);
|
|
1535
|
+
};
|
|
1536
|
+
const getFileName = uri => {
|
|
1537
|
+
const slashIndex = uri.lastIndexOf('/');
|
|
1538
|
+
return uri.slice(slashIndex + 1);
|
|
1539
|
+
};
|
|
1540
|
+
const toProblems = (diagnostics, workspaceUri = '') => {
|
|
1541
|
+
const problems = [];
|
|
1542
|
+
let problem = {
|
|
1543
|
+
message: '',
|
|
1544
|
+
rowIndex: 0,
|
|
1545
|
+
columnIndex: 0,
|
|
1546
|
+
uri: '',
|
|
1547
|
+
relativePath: '',
|
|
1548
|
+
count: 0,
|
|
1549
|
+
source: '',
|
|
1550
|
+
code: '',
|
|
1551
|
+
level: 0,
|
|
1552
|
+
listItemType: 0,
|
|
1553
|
+
posInSet: 0,
|
|
1554
|
+
setSize: 0,
|
|
1555
|
+
type: '',
|
|
1556
|
+
fileName: ''
|
|
1557
|
+
};
|
|
1558
|
+
let relativeIndex = 0;
|
|
1559
|
+
for (const diagnostic of diagnostics) {
|
|
1560
|
+
if (diagnostic.uri === problem.uri) {
|
|
1561
|
+
relativeIndex++;
|
|
1562
|
+
problem.count++;
|
|
1563
|
+
} else {
|
|
1564
|
+
relativeIndex = 1;
|
|
1565
|
+
problem = {
|
|
1566
|
+
message: '',
|
|
1567
|
+
rowIndex: 0,
|
|
1568
|
+
columnIndex: 0,
|
|
1569
|
+
uri: diagnostic.uri,
|
|
1570
|
+
relativePath: '',
|
|
1571
|
+
count: 1,
|
|
1572
|
+
source: '',
|
|
1573
|
+
type: '',
|
|
1574
|
+
listItemType: Expanded,
|
|
1575
|
+
posInSet: relativeIndex,
|
|
1576
|
+
setSize: 123,
|
|
1577
|
+
level: 1,
|
|
1578
|
+
code: '',
|
|
1579
|
+
fileName: ''
|
|
1580
|
+
};
|
|
1581
|
+
problems.push(problem);
|
|
1582
|
+
}
|
|
1583
|
+
problems.push(toProblem(diagnostic, relativeIndex));
|
|
1584
|
+
}
|
|
1585
|
+
for (const problem of problems) {
|
|
1586
|
+
// TODO maybe rename property, this should be the relative path of the parent folder of the file
|
|
1587
|
+
// @ts-ignore
|
|
1588
|
+
problem.relativePath = getRelativeParentUri(problem.uri, workspaceUri);
|
|
1589
|
+
// @ts-ignore
|
|
1590
|
+
problem.fileName = getFileName(problem.uri);
|
|
1591
|
+
// problem.uri = problem.uri // TODO
|
|
1592
|
+
}
|
|
1593
|
+
return problems;
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1596
|
+
// TODO send event listener to editor, asking to send problem updates to this worker
|
|
1597
|
+
|
|
1598
|
+
const getProblems = async workspaceUri => {
|
|
1502
1599
|
try {
|
|
1503
|
-
// TODO send event listener to editor, asking to send problem updates to this worker
|
|
1504
1600
|
// @ts-ignore
|
|
1505
|
-
await invoke('Editor.getProblems');
|
|
1506
|
-
//
|
|
1601
|
+
const diagnostics = await invoke('Editor.getProblems');
|
|
1602
|
+
// @ts-ignore
|
|
1603
|
+
const problems = toProblems(diagnostics, workspaceUri);
|
|
1507
1604
|
return {
|
|
1508
|
-
problems
|
|
1605
|
+
problems,
|
|
1509
1606
|
error: ''
|
|
1510
1607
|
};
|
|
1511
1608
|
} catch (error) {
|
|
@@ -1620,7 +1717,7 @@ const loadContent = async (state, savedState) => {
|
|
|
1620
1717
|
const {
|
|
1621
1718
|
problems,
|
|
1622
1719
|
error
|
|
1623
|
-
} = await getProblems();
|
|
1720
|
+
} = await getProblems(state.workspaceUri);
|
|
1624
1721
|
if (error) {
|
|
1625
1722
|
return {
|
|
1626
1723
|
...state,
|
|
@@ -1849,23 +1946,23 @@ const getTreeItemIndent = depth => {
|
|
|
1849
1946
|
|
|
1850
1947
|
const getProblemVirtualDom = problem => {
|
|
1851
1948
|
const {
|
|
1852
|
-
|
|
1853
|
-
rowIndex,
|
|
1949
|
+
code,
|
|
1854
1950
|
columnIndex,
|
|
1855
|
-
|
|
1856
|
-
uri,
|
|
1951
|
+
filterValueLength,
|
|
1857
1952
|
icon,
|
|
1858
|
-
|
|
1859
|
-
|
|
1953
|
+
isActive,
|
|
1954
|
+
isCollapsed,
|
|
1955
|
+
level,
|
|
1956
|
+
listItemType,
|
|
1957
|
+
message,
|
|
1860
1958
|
messageMatchIndex,
|
|
1861
|
-
filterValueLength,
|
|
1862
|
-
code,
|
|
1863
|
-
type,
|
|
1864
1959
|
posInSet,
|
|
1960
|
+
relativePath,
|
|
1961
|
+
rowIndex,
|
|
1865
1962
|
setSize,
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1963
|
+
source,
|
|
1964
|
+
type,
|
|
1965
|
+
fileName
|
|
1869
1966
|
} = problem;
|
|
1870
1967
|
let className = Problem;
|
|
1871
1968
|
if (isActive) {
|
|
@@ -1883,7 +1980,7 @@ const getProblemVirtualDom = problem => {
|
|
|
1883
1980
|
ariaExpanded: !isCollapsed,
|
|
1884
1981
|
ariaSelected: isActive,
|
|
1885
1982
|
role: AriaRoles.TreeItem
|
|
1886
|
-
}, listItemType === Collapsed ? getChevronRightVirtualDom() : getChevronDownVirtualDom(), getFileIconVirtualDom(icon), text(
|
|
1983
|
+
}, listItemType === Collapsed ? getChevronRightVirtualDom() : getChevronDownVirtualDom(), getFileIconVirtualDom(icon), text(fileName), {
|
|
1887
1984
|
type: VirtualDomElements.Div,
|
|
1888
1985
|
className: LabelDetail,
|
|
1889
1986
|
childCount: 1
|
|
@@ -2053,7 +2150,7 @@ const getProblemsTableVirtualDom = problems => {
|
|
|
2053
2150
|
};
|
|
2054
2151
|
|
|
2055
2152
|
const getProblemsVirtualDom$1 = (viewMode, problems, filterValue, message) => {
|
|
2056
|
-
if (message) {
|
|
2153
|
+
if (problems.length === 0 && message) {
|
|
2057
2154
|
return [{
|
|
2058
2155
|
type: VirtualDomElements.Div,
|
|
2059
2156
|
className: Message,
|
|
@@ -2347,18 +2444,19 @@ const viewAsTable = state => {
|
|
|
2347
2444
|
};
|
|
2348
2445
|
|
|
2349
2446
|
const commandMap = {
|
|
2350
|
-
'Problems.copyMessage': copyMessage,
|
|
2447
|
+
'Problems.copyMessage': wrapCommand(copyMessage),
|
|
2351
2448
|
'Problems.create': create,
|
|
2352
2449
|
'Problems.diff2': diff2,
|
|
2353
|
-
'Problems.focusIndex': focusIndex,
|
|
2450
|
+
'Problems.focusIndex': wrapCommand(focusIndex),
|
|
2354
2451
|
'Problems.getCommandIds': getCommandIds,
|
|
2355
2452
|
'Problems.getKeyBindings': getKeyBindings,
|
|
2356
2453
|
'Problems.handleArrowLeft': wrapCommand(handleArrowLeft),
|
|
2357
2454
|
'Problems.handleArrowRight': wrapCommand(handleArrowRight),
|
|
2358
2455
|
'Problems.handleClickAt': wrapCommand(handleClickAt),
|
|
2359
|
-
'Problems.handleContextMenu': handleContextMenu,
|
|
2456
|
+
'Problems.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2457
|
+
'Problems.handleClickButton': wrapCommand(handleClickButton),
|
|
2360
2458
|
'Problems.handleFilterInput': wrapCommand(handleFilterInput),
|
|
2361
|
-
'Problems.handleIconThemeChange': handleIconThemeChange,
|
|
2459
|
+
'Problems.handleIconThemeChange': wrapCommand(handleIconThemeChange),
|
|
2362
2460
|
'Problems.initialize': initialize,
|
|
2363
2461
|
'Problems.loadContent': wrapCommand(loadContent),
|
|
2364
2462
|
'Problems.render2': render2,
|
|
@@ -2367,8 +2465,8 @@ const commandMap = {
|
|
|
2367
2465
|
'Problems.resize': resize,
|
|
2368
2466
|
'Problems.saveState': saveState,
|
|
2369
2467
|
'Problems.terminate': terminate,
|
|
2370
|
-
'Problems.viewAsList': viewAsList,
|
|
2371
|
-
'Problems.viewAsTable': viewAsTable
|
|
2468
|
+
'Problems.viewAsList': wrapCommand(viewAsList),
|
|
2469
|
+
'Problems.viewAsTable': wrapCommand(viewAsTable)
|
|
2372
2470
|
};
|
|
2373
2471
|
|
|
2374
2472
|
const listen = async () => {
|