mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
@@ -3,12 +3,33 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { coalesce } from './arrays';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
function splitUriList(str: string): string[] {
|
||||
return str.split('\r\n');
|
||||
}
|
||||
|
||||
export function parseUriList(str: string): string[] {
|
||||
function parseUriList(str: string): string[] {
|
||||
return splitUriList(str)
|
||||
.filter(value => !value.startsWith('#')) // Remove comments
|
||||
.map(value => value.trim());
|
||||
}
|
||||
|
||||
export class UriList {
|
||||
|
||||
static from(str: string): UriList {
|
||||
return new UriList(coalesce(parseUriList(str).map(line => {
|
||||
try {
|
||||
return { uri: vscode.Uri.parse(line), str: line };
|
||||
} catch {
|
||||
// Uri parse failure
|
||||
return undefined;
|
||||
}
|
||||
})));
|
||||
}
|
||||
|
||||
private constructor(
|
||||
public readonly entries: ReadonlyArray<{ readonly uri: vscode.Uri; readonly str: string }>
|
||||
) { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user