@lvce-editor/problems-view 1.35.0 → 1.36.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 +83 -63
- package/package.json +1 -1
|
@@ -1437,7 +1437,7 @@ const create$1 = rpcId => {
|
|
|
1437
1437
|
};
|
|
1438
1438
|
};
|
|
1439
1439
|
|
|
1440
|
-
const None$
|
|
1440
|
+
const None$2 = 'none';
|
|
1441
1441
|
const ToolBar = 'toolbar';
|
|
1442
1442
|
const Tree = 'tree';
|
|
1443
1443
|
const TreeItem = 'treeitem';
|
|
@@ -1749,7 +1749,7 @@ const {
|
|
|
1749
1749
|
wrapGetter
|
|
1750
1750
|
} = create$a();
|
|
1751
1751
|
|
|
1752
|
-
const None = 0;
|
|
1752
|
+
const None$1 = 0;
|
|
1753
1753
|
const Table = 1;
|
|
1754
1754
|
const List = 2;
|
|
1755
1755
|
|
|
@@ -1780,7 +1780,7 @@ const create = (id, uri, x, y, width, height, workspaceUri) => {
|
|
|
1780
1780
|
showWarnings: true,
|
|
1781
1781
|
smallWidthBreakPoint: 650,
|
|
1782
1782
|
uid: id,
|
|
1783
|
-
viewMode: None,
|
|
1783
|
+
viewMode: None$1,
|
|
1784
1784
|
width,
|
|
1785
1785
|
workspaceUri,
|
|
1786
1786
|
x,
|
|
@@ -1833,7 +1833,7 @@ const diff = (oldState, newState) => {
|
|
|
1833
1833
|
const FilterHeight = 24;
|
|
1834
1834
|
const TableHeaderHeight = 22;
|
|
1835
1835
|
const getListTopOffset = (width, smallWidthBreakPoint, viewMode) => {
|
|
1836
|
-
const filterHeight = viewMode !== None && width <= smallWidthBreakPoint ? FilterHeight : 0;
|
|
1836
|
+
const filterHeight = viewMode !== None$1 && width <= smallWidthBreakPoint ? FilterHeight : 0;
|
|
1837
1837
|
const tableHeaderHeight = viewMode === Table ? TableHeaderHeight : 0;
|
|
1838
1838
|
return filterHeight + tableHeaderHeight;
|
|
1839
1839
|
};
|
|
@@ -1855,9 +1855,6 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
|
1855
1855
|
return Math.min(Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize), size);
|
|
1856
1856
|
};
|
|
1857
1857
|
|
|
1858
|
-
const Error$1 = 'error';
|
|
1859
|
-
const Warning = 'warning';
|
|
1860
|
-
|
|
1861
1858
|
const getListItemType = (listItemType, isCollapsed) => {
|
|
1862
1859
|
if (listItemType === Item) {
|
|
1863
1860
|
return Item;
|
|
@@ -1875,11 +1872,18 @@ const matchesFilterValue = (string, filterValueLower) => {
|
|
|
1875
1872
|
return 0;
|
|
1876
1873
|
};
|
|
1877
1874
|
|
|
1875
|
+
const None = 0;
|
|
1876
|
+
const Error$2 = 1;
|
|
1877
|
+
const Warning$1 = 2;
|
|
1878
|
+
const Spelling = 3;
|
|
1879
|
+
const Info = 4;
|
|
1880
|
+
const Other = 5;
|
|
1881
|
+
|
|
1878
1882
|
const matchesSeverity = (problem, showErrors, showWarnings, showInfos) => {
|
|
1879
1883
|
switch (problem.type) {
|
|
1880
|
-
case Error$
|
|
1884
|
+
case Error$2:
|
|
1881
1885
|
return showErrors;
|
|
1882
|
-
case Warning:
|
|
1886
|
+
case Warning$1:
|
|
1883
1887
|
return showWarnings;
|
|
1884
1888
|
default:
|
|
1885
1889
|
return showInfos;
|
|
@@ -2189,6 +2193,9 @@ const getMenuIds = () => {
|
|
|
2189
2193
|
return [ProblemsFilter$1];
|
|
2190
2194
|
};
|
|
2191
2195
|
|
|
2196
|
+
const Error$1 = 'error';
|
|
2197
|
+
const Warning = 'warning';
|
|
2198
|
+
|
|
2192
2199
|
const {
|
|
2193
2200
|
getProblems: getProblems$1,
|
|
2194
2201
|
getUri} = EditorWorker;
|
|
@@ -2196,9 +2203,21 @@ const getDiagnostics = editorId => {
|
|
|
2196
2203
|
return invoke$3('Editor.getDiagnostics', editorId);
|
|
2197
2204
|
};
|
|
2198
2205
|
|
|
2199
|
-
const
|
|
2200
|
-
|
|
2201
|
-
|
|
2206
|
+
const getProblemType = type => {
|
|
2207
|
+
switch (type) {
|
|
2208
|
+
case Error$1:
|
|
2209
|
+
return Error$2;
|
|
2210
|
+
case Warning:
|
|
2211
|
+
return Warning$1;
|
|
2212
|
+
case 'info':
|
|
2213
|
+
return Info;
|
|
2214
|
+
case 'spelling':
|
|
2215
|
+
return Spelling;
|
|
2216
|
+
default:
|
|
2217
|
+
return type ? Other : Error$2;
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
|
|
2202
2221
|
const toProblem = (diagnostic, index) => {
|
|
2203
2222
|
const {
|
|
2204
2223
|
code,
|
|
@@ -2218,31 +2237,13 @@ const toProblem = (diagnostic, index) => {
|
|
|
2218
2237
|
listItemType: Item,
|
|
2219
2238
|
message: message || '',
|
|
2220
2239
|
posInSet: index,
|
|
2221
|
-
relativePath: '',
|
|
2222
2240
|
rowIndex: rowIndex || 0,
|
|
2223
2241
|
setSize: 1,
|
|
2224
2242
|
source: source || '',
|
|
2225
|
-
type: type
|
|
2243
|
+
type: getProblemType(type),
|
|
2226
2244
|
uri
|
|
2227
2245
|
};
|
|
2228
2246
|
};
|
|
2229
|
-
const normalizeFileUri = uri => {
|
|
2230
|
-
const normalizedUri = uri.startsWith('file://') ? uri.slice('file://'.length) : uri;
|
|
2231
|
-
return windowsDrivePathRegex.test(normalizedUri) ? normalizedUri.slice(1) : normalizedUri;
|
|
2232
|
-
};
|
|
2233
|
-
const getRelativeParentUri = (uri, workspaceUri) => {
|
|
2234
|
-
const normalizedUri = normalizeFileUri(uri);
|
|
2235
|
-
const normalizedWorkspaceUri = normalizeFileUri(workspaceUri).replace(trailingSlashRegex, '');
|
|
2236
|
-
const slashIndex = normalizedUri.lastIndexOf('/');
|
|
2237
|
-
const parentUri = normalizedUri.slice(0, slashIndex);
|
|
2238
|
-
if (parentUri === normalizedWorkspaceUri) {
|
|
2239
|
-
return '';
|
|
2240
|
-
}
|
|
2241
|
-
if (normalizedWorkspaceUri && parentUri.startsWith(`${normalizedWorkspaceUri}/`)) {
|
|
2242
|
-
return parentUri.slice(normalizedWorkspaceUri.length + 1);
|
|
2243
|
-
}
|
|
2244
|
-
return parentUri.replace(leadingSlashesRegex, '');
|
|
2245
|
-
};
|
|
2246
2247
|
const getFileName = uri => {
|
|
2247
2248
|
const slashIndex = uri.lastIndexOf('/');
|
|
2248
2249
|
return uri.slice(slashIndex + 1);
|
|
@@ -2257,16 +2258,15 @@ const toRelatedProblem = (relatedInformation, diagnostic, index, setSize) => {
|
|
|
2257
2258
|
listItemType: Item,
|
|
2258
2259
|
message: relatedInformation.message || '',
|
|
2259
2260
|
posInSet: index,
|
|
2260
|
-
relativePath: '',
|
|
2261
2261
|
rowIndex: relatedInformation.rowIndex || 0,
|
|
2262
2262
|
setSize,
|
|
2263
2263
|
source: getFileName(relatedInformation.uri),
|
|
2264
2264
|
targetUri: relatedInformation.uri,
|
|
2265
|
-
type: diagnostic.type
|
|
2265
|
+
type: getProblemType(diagnostic.type),
|
|
2266
2266
|
uri: diagnostic.uri
|
|
2267
2267
|
};
|
|
2268
2268
|
};
|
|
2269
|
-
const toProblems =
|
|
2269
|
+
const toProblems = diagnostics => {
|
|
2270
2270
|
const problems = [];
|
|
2271
2271
|
let problem = {
|
|
2272
2272
|
code: '',
|
|
@@ -2277,11 +2277,10 @@ const toProblems = (diagnostics, workspaceUri = '') => {
|
|
|
2277
2277
|
listItemType: 0,
|
|
2278
2278
|
message: '',
|
|
2279
2279
|
posInSet: 0,
|
|
2280
|
-
relativePath: '',
|
|
2281
2280
|
rowIndex: 0,
|
|
2282
2281
|
setSize: 0,
|
|
2283
2282
|
source: '',
|
|
2284
|
-
type:
|
|
2283
|
+
type: None,
|
|
2285
2284
|
uri: ''
|
|
2286
2285
|
};
|
|
2287
2286
|
let relativeIndex = 0;
|
|
@@ -2300,11 +2299,10 @@ const toProblems = (diagnostics, workspaceUri = '') => {
|
|
|
2300
2299
|
listItemType: Expanded,
|
|
2301
2300
|
message: '',
|
|
2302
2301
|
posInSet: relativeIndex,
|
|
2303
|
-
relativePath: '',
|
|
2304
2302
|
rowIndex: 0,
|
|
2305
2303
|
setSize: 123,
|
|
2306
2304
|
source: '',
|
|
2307
|
-
type:
|
|
2305
|
+
type: None,
|
|
2308
2306
|
uri: diagnostic.uri
|
|
2309
2307
|
};
|
|
2310
2308
|
problems.push(problem);
|
|
@@ -2316,13 +2314,8 @@ const toProblems = (diagnostics, workspaceUri = '') => {
|
|
|
2316
2314
|
}
|
|
2317
2315
|
}
|
|
2318
2316
|
for (const problem of problems) {
|
|
2319
|
-
// TODO maybe rename property, this should be the relative path of the parent folder of the file
|
|
2320
|
-
// @ts-ignore
|
|
2321
2317
|
const displayUri = problem.targetUri || problem.uri;
|
|
2322
|
-
problem.relativePath = getRelativeParentUri(displayUri, workspaceUri);
|
|
2323
|
-
// @ts-ignore
|
|
2324
2318
|
problem.fileName = getFileName(displayUri);
|
|
2325
|
-
// problem.uri = problem.uri // TODO
|
|
2326
2319
|
}
|
|
2327
2320
|
return problems;
|
|
2328
2321
|
};
|
|
@@ -2339,7 +2332,7 @@ const getUniqueDiagnostics = diagnostics => {
|
|
|
2339
2332
|
return true;
|
|
2340
2333
|
});
|
|
2341
2334
|
};
|
|
2342
|
-
const getProblems = async
|
|
2335
|
+
const getProblems = async activeUri => {
|
|
2343
2336
|
if (!activeUri) {
|
|
2344
2337
|
return {
|
|
2345
2338
|
error: '',
|
|
@@ -2348,7 +2341,7 @@ const getProblems = async (workspaceUri, activeUri) => {
|
|
|
2348
2341
|
}
|
|
2349
2342
|
try {
|
|
2350
2343
|
const diagnostics = getUniqueDiagnostics(await getProblems$1());
|
|
2351
|
-
const problems = toProblems(diagnostics
|
|
2344
|
+
const problems = toProblems(diagnostics);
|
|
2352
2345
|
return {
|
|
2353
2346
|
error: '',
|
|
2354
2347
|
problems
|
|
@@ -2436,13 +2429,12 @@ const getFileIcons = async (problems, fileIconCache) => {
|
|
|
2436
2429
|
|
|
2437
2430
|
const refreshProblems = async (state, activeUri) => {
|
|
2438
2431
|
const {
|
|
2439
|
-
fileIconCache
|
|
2440
|
-
workspaceUri
|
|
2432
|
+
fileIconCache
|
|
2441
2433
|
} = state;
|
|
2442
2434
|
const {
|
|
2443
2435
|
error,
|
|
2444
2436
|
problems
|
|
2445
|
-
} = await getProblems(
|
|
2437
|
+
} = await getProblems(activeUri);
|
|
2446
2438
|
const newFileIconCache = await getFileIcons(problems, fileIconCache);
|
|
2447
2439
|
return {
|
|
2448
2440
|
...state,
|
|
@@ -2938,7 +2930,7 @@ const loadContent = async (state, savedState) => {
|
|
|
2938
2930
|
const {
|
|
2939
2931
|
error,
|
|
2940
2932
|
problems
|
|
2941
|
-
} = await getProblems(
|
|
2933
|
+
} = await getProblems(activeUri);
|
|
2942
2934
|
if (error) {
|
|
2943
2935
|
return {
|
|
2944
2936
|
...state,
|
|
@@ -3136,7 +3128,7 @@ const getIconVirtualDom = (icon, type = Div) => {
|
|
|
3136
3128
|
return {
|
|
3137
3129
|
childCount: 0,
|
|
3138
3130
|
className: mergeClassNames('MaskIcon', `MaskIcon${icon}`),
|
|
3139
|
-
role: None$
|
|
3131
|
+
role: None$2,
|
|
3140
3132
|
type
|
|
3141
3133
|
};
|
|
3142
3134
|
};
|
|
@@ -3274,7 +3266,7 @@ const getFileIconVirtualDom = icon => {
|
|
|
3274
3266
|
alt: '',
|
|
3275
3267
|
childCount: 0,
|
|
3276
3268
|
className: FileIcon,
|
|
3277
|
-
role: None$
|
|
3269
|
+
role: None$2,
|
|
3278
3270
|
src: icon,
|
|
3279
3271
|
type: Img
|
|
3280
3272
|
};
|
|
@@ -3291,7 +3283,7 @@ const errorIconNode = {
|
|
|
3291
3283
|
type: Div
|
|
3292
3284
|
};
|
|
3293
3285
|
const getProblemsIconVirtualDom = type => {
|
|
3294
|
-
if (type === Warning) {
|
|
3286
|
+
if (type === Warning$1) {
|
|
3295
3287
|
return warningIconNode;
|
|
3296
3288
|
}
|
|
3297
3289
|
return errorIconNode;
|
|
@@ -3310,6 +3302,34 @@ const getProblemSourceDetail = (source, code) => {
|
|
|
3310
3302
|
return message;
|
|
3311
3303
|
};
|
|
3312
3304
|
|
|
3305
|
+
const leadingSlashesRegex = /^\/+/;
|
|
3306
|
+
const trailingSlashRegex = /\/$/;
|
|
3307
|
+
const schemeRootRegex = /^[a-z][a-z\d+.-]*:\/\/$/i;
|
|
3308
|
+
const windowsDrivePathRegex = /^\/[a-z]:\//i;
|
|
3309
|
+
const normalizeFileUri = uri => {
|
|
3310
|
+
const normalizedUri = uri.startsWith('file://') ? uri.slice('file://'.length) : uri;
|
|
3311
|
+
return windowsDrivePathRegex.test(normalizedUri) ? normalizedUri.slice(1) : normalizedUri;
|
|
3312
|
+
};
|
|
3313
|
+
const getRelativeParentUri = (uri, workspaceUri) => {
|
|
3314
|
+
const normalizedUri = normalizeFileUri(uri);
|
|
3315
|
+
const normalizedWorkspaceUri = normalizeFileUri(workspaceUri).replace(trailingSlashRegex, '');
|
|
3316
|
+
const slashIndex = normalizedUri.lastIndexOf('/');
|
|
3317
|
+
if (slashIndex === -1) {
|
|
3318
|
+
return '';
|
|
3319
|
+
}
|
|
3320
|
+
const parentUri = normalizedUri.slice(0, slashIndex);
|
|
3321
|
+
if (schemeRootRegex.test(parentUri)) {
|
|
3322
|
+
return '';
|
|
3323
|
+
}
|
|
3324
|
+
if (parentUri === normalizedWorkspaceUri) {
|
|
3325
|
+
return '';
|
|
3326
|
+
}
|
|
3327
|
+
if (normalizedWorkspaceUri && parentUri.startsWith(`${normalizedWorkspaceUri}/`)) {
|
|
3328
|
+
return parentUri.slice(normalizedWorkspaceUri.length + 1);
|
|
3329
|
+
}
|
|
3330
|
+
return parentUri.replace(leadingSlashesRegex, '');
|
|
3331
|
+
};
|
|
3332
|
+
|
|
3313
3333
|
const labelNode = {
|
|
3314
3334
|
childCount: 1,
|
|
3315
3335
|
className: Label,
|
|
@@ -3330,7 +3350,7 @@ const problemAtNode = {
|
|
|
3330
3350
|
className: ProblemAt,
|
|
3331
3351
|
type: Span
|
|
3332
3352
|
};
|
|
3333
|
-
const getProblemVirtualDom = problem => {
|
|
3353
|
+
const getProblemVirtualDom = (problem, workspaceUri = '') => {
|
|
3334
3354
|
const {
|
|
3335
3355
|
code,
|
|
3336
3356
|
columnIndex,
|
|
@@ -3344,7 +3364,6 @@ const getProblemVirtualDom = problem => {
|
|
|
3344
3364
|
message,
|
|
3345
3365
|
messageMatchIndex,
|
|
3346
3366
|
posInSet,
|
|
3347
|
-
relativePath,
|
|
3348
3367
|
rowIndex,
|
|
3349
3368
|
setSize,
|
|
3350
3369
|
source,
|
|
@@ -3373,7 +3392,7 @@ const getProblemVirtualDom = problem => {
|
|
|
3373
3392
|
...labelNode,
|
|
3374
3393
|
'data-uri': uri,
|
|
3375
3394
|
onClick: HandleFileNameClick
|
|
3376
|
-
}, text(fileName), labelDetailNode, text(
|
|
3395
|
+
}, text(fileName), labelDetailNode, text(getRelativeParentUri(uri, workspaceUri)), ...getBadgeVirtualDom(ProblemBadge, problem.count)];
|
|
3377
3396
|
}
|
|
3378
3397
|
const lineColumn = atLineColumn(rowIndex + 1, columnIndex + 1);
|
|
3379
3398
|
const label = {
|
|
@@ -3407,7 +3426,7 @@ const getProblemVirtualDom = problem => {
|
|
|
3407
3426
|
return dom;
|
|
3408
3427
|
};
|
|
3409
3428
|
|
|
3410
|
-
const getProblemsListVirtualDom = problems => {
|
|
3429
|
+
const getProblemsListVirtualDom = (problems, workspaceUri = '') => {
|
|
3411
3430
|
const dom = [{
|
|
3412
3431
|
ariaLabel: 'Problems Tree',
|
|
3413
3432
|
// TODO use i18n string
|
|
@@ -3415,7 +3434,7 @@ const getProblemsListVirtualDom = problems => {
|
|
|
3415
3434
|
className: ProblemsList,
|
|
3416
3435
|
role: Tree,
|
|
3417
3436
|
type: Div
|
|
3418
|
-
}, ...problems.flatMap(getProblemVirtualDom)];
|
|
3437
|
+
}, ...problems.flatMap(problem => getProblemVirtualDom(problem, workspaceUri))];
|
|
3419
3438
|
return dom;
|
|
3420
3439
|
};
|
|
3421
3440
|
|
|
@@ -3514,7 +3533,7 @@ const messageNode = {
|
|
|
3514
3533
|
className: Message,
|
|
3515
3534
|
type: Div
|
|
3516
3535
|
};
|
|
3517
|
-
const getProblemsVirtualDom$1 = (viewMode, problems, filterValue, message, problemCount = problems.length) => {
|
|
3536
|
+
const getProblemsVirtualDom$1 = (viewMode, problems, filterValue, message, problemCount = problems.length, workspaceUri = '') => {
|
|
3518
3537
|
if (problemCount === 0 && message) {
|
|
3519
3538
|
return [messageNode, text(message)];
|
|
3520
3539
|
}
|
|
@@ -3527,7 +3546,7 @@ const getProblemsVirtualDom$1 = (viewMode, problems, filterValue, message, probl
|
|
|
3527
3546
|
if (viewMode === Table) {
|
|
3528
3547
|
return getProblemsTableVirtualDom(problems);
|
|
3529
3548
|
}
|
|
3530
|
-
return getProblemsListVirtualDom(problems);
|
|
3549
|
+
return getProblemsListVirtualDom(problems, workspaceUri);
|
|
3531
3550
|
};
|
|
3532
3551
|
|
|
3533
3552
|
const scrollBarNode = {
|
|
@@ -3549,7 +3568,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarActive) => {
|
|
|
3549
3568
|
|
|
3550
3569
|
const Focusable = 0;
|
|
3551
3570
|
|
|
3552
|
-
const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, inputSource, isSmall, message, scrollBarHeight = 0, scrollBarActive = false, problemCount = problems.length) => {
|
|
3571
|
+
const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, inputSource, isSmall, message, scrollBarHeight = 0, scrollBarActive = false, problemCount = problems.length, workspaceUri = '') => {
|
|
3553
3572
|
const baseDom = {
|
|
3554
3573
|
childCount: isSmall ? 2 : 1,
|
|
3555
3574
|
className: mergeClassNames(Viewlet, Problems),
|
|
@@ -3568,7 +3587,7 @@ const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, input
|
|
|
3568
3587
|
placeholder: filter(),
|
|
3569
3588
|
value: filterValue
|
|
3570
3589
|
}) : [];
|
|
3571
|
-
const itemsDom = getProblemsVirtualDom$1(viewMode, problems, filterValue, message, problemCount);
|
|
3590
|
+
const itemsDom = getProblemsVirtualDom$1(viewMode, problems, filterValue, message, problemCount, workspaceUri);
|
|
3572
3591
|
const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarActive);
|
|
3573
3592
|
const contentClassName = viewMode === Table ? mergeClassNames(ProblemsContent, ProblemsContentTable) : ProblemsContent;
|
|
3574
3593
|
const contentDom = {
|
|
@@ -3598,12 +3617,13 @@ const renderItems = (oldState, newState) => {
|
|
|
3598
3617
|
showWarnings,
|
|
3599
3618
|
smallWidthBreakPoint,
|
|
3600
3619
|
viewMode,
|
|
3601
|
-
width
|
|
3620
|
+
width,
|
|
3621
|
+
workspaceUri
|
|
3602
3622
|
} = newState;
|
|
3603
3623
|
const problemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode, showErrors, showWarnings, showInfos);
|
|
3604
3624
|
const visible = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode, showErrors, showWarnings, showInfos);
|
|
3605
3625
|
const isSmall = width <= smallWidthBreakPoint;
|
|
3606
|
-
const dom = getProblemsVirtualDom(activeUri, viewMode, visible, filterValue, inputSource, isSmall, message, scrollBarHeight, scrollBarActive, problemCount);
|
|
3626
|
+
const dom = getProblemsVirtualDom(activeUri, viewMode, visible, filterValue, inputSource, isSmall, message, scrollBarHeight, scrollBarActive, problemCount, workspaceUri);
|
|
3607
3627
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3608
3628
|
};
|
|
3609
3629
|
|