UNPKG

@microsoft/compose-language-service

Version:
26 lines 1.55 kB
/*!-------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------*/ export class CompletionCollection extends Array { name; locationRequirements; constructor(name, locationRequirements, ...items) { super(...items); this.name = name; this.locationRequirements = locationRequirements; } getActiveCompletionItems(params) { if (this.locationRequirements.logicalPaths !== undefined && !this.locationRequirements.logicalPaths.some(p => p.test(params.positionInfo.path ?? ''))) { return undefined; // Reject this collection: the logical path requirement is not satisfied } if (this.locationRequirements.indentationDepth !== undefined && this.locationRequirements.indentationDepth !== params.positionInfo.indentDepth) { return undefined; // Reject this collection: the indentation depth requirement is not satisfied } const line = params.document.lineAt(params.position); return this .filter(eci => (params.basicCompletions && !eci.isAdvancedComposeCompletion) || (params.advancedCompletions && eci.isAdvancedComposeCompletion)) .filter(eci => !eci.matcher || eci.matcher.test(line)); } } //# sourceMappingURL=CompletionCollection.js.map