UNPKG

@eclipse-glsp/protocol

Version:

The protocol definition for client-server communication in GLSP

88 lines 3.87 kB
"use strict"; /******************************************************************************** * Copyright (c) 2021-2023 STMicroelectronics and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ Object.defineProperty(exports, "__esModule", { value: true }); exports.DeleteElementOperation = exports.CreateEdgeOperation = exports.CreateNodeOperation = exports.CreateOperation = void 0; const type_util_1 = require("../utils/type-util"); const base_protocol_1 = require("./base-protocol"); var CreateOperation; (function (CreateOperation) { function is(object) { return base_protocol_1.Operation.is(object) && (0, type_util_1.hasStringProp)(object, 'elementTypeId'); } CreateOperation.is = is; /** * Typeguard function to check wether the given object is a {@link CreateOperation} with the given `kind`. * @param object The object to check. * @param kind The expected operation kind. * @returns A type literal indicating wether the given object is a create operation with the given kind. */ function hasKind(object, kind) { return CreateOperation.is(object) && object.kind === kind; } CreateOperation.hasKind = hasKind; })(CreateOperation || (exports.CreateOperation = CreateOperation = {})); var CreateNodeOperation; (function (CreateNodeOperation) { CreateNodeOperation.KIND = 'createNode'; function is(object) { return CreateOperation.hasKind(object, CreateNodeOperation.KIND); } CreateNodeOperation.is = is; function create(elementTypeId, options = {}) { return { kind: CreateNodeOperation.KIND, isOperation: true, elementTypeId, ...options }; } CreateNodeOperation.create = create; })(CreateNodeOperation || (exports.CreateNodeOperation = CreateNodeOperation = {})); var CreateEdgeOperation; (function (CreateEdgeOperation) { CreateEdgeOperation.KIND = 'createEdge'; function is(object) { return (CreateOperation.hasKind(object, CreateEdgeOperation.KIND) && (0, type_util_1.hasStringProp)(object, 'sourceElementId') && (0, type_util_1.hasStringProp)(object, 'targetElementId')); } CreateEdgeOperation.is = is; function create(options) { return { kind: CreateEdgeOperation.KIND, isOperation: true, ...options }; } CreateEdgeOperation.create = create; })(CreateEdgeOperation || (exports.CreateEdgeOperation = CreateEdgeOperation = {})); var DeleteElementOperation; (function (DeleteElementOperation) { DeleteElementOperation.KIND = 'deleteElement'; function is(object) { return base_protocol_1.Operation.hasKind(object, DeleteElementOperation.KIND) && (0, type_util_1.hasArrayProp)(object, 'elementIds'); } DeleteElementOperation.is = is; function create(elementIds, options = {}) { return { kind: DeleteElementOperation.KIND, isOperation: true, elementIds, ...options }; } DeleteElementOperation.create = create; })(DeleteElementOperation || (exports.DeleteElementOperation = DeleteElementOperation = {})); //# sourceMappingURL=element-creation.js.map