Path: blob/main/extensions/css-language-features/client/src/dropOrPaste/uriList.ts
3321 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as vscode from 'vscode';67function splitUriList(str: string): string[] {8return str.split('\r\n');9}1011function parseUriList(str: string): string[] {12return splitUriList(str)13.filter(value => !value.startsWith('#')) // Remove comments14.map(value => value.trim());15}1617export class UriList {1819static from(str: string): UriList {20return new UriList(coalesce(parseUriList(str).map(line => {21try {22return { uri: vscode.Uri.parse(line), str: line };23} catch {24// Uri parse failure25return undefined;26}27})));28}2930constructor(31public readonly entries: ReadonlyArray<{ readonly uri: vscode.Uri; readonly str: string }>32) { }33}3435function coalesce<T>(array: ReadonlyArray<T | undefined | null>): T[] {36return <T[]>array.filter(e => !!e);37}383940