@microsoft/compose-language-service
Version:
Language service for Docker Compose documents
28 lines • 1.74 kB
JavaScript
;
/*!--------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompletionCollection = void 0;
class CompletionCollection extends Array {
constructor(name, locationRequirements, ...items) {
super(...items);
this.name = name;
this.locationRequirements = locationRequirements;
}
getActiveCompletionItems(params) {
if (this.locationRequirements.logicalPaths !== undefined && !this.locationRequirements.logicalPaths.some(p => { var _a; return p.test((_a = params.positionInfo.path) !== null && _a !== void 0 ? _a : ''); })) {
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));
}
}
exports.CompletionCollection = CompletionCollection;
//# sourceMappingURL=CompletionCollection.js.map