UNPKG

@finos/legend-application-pure-ide

Version:
185 lines 5.01 kB
/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { uuid } from '@finos/legend-shared'; import { createModelSchema, deserialize, list, object, optional, primitive, } from 'serializr'; export class ExecutionResult { text; // compiler!: string; reinit; } export class ExecutionSuccessResult extends ExecutionResult { cache; modifiedFiles = []; } createModelSchema(ExecutionSuccessResult, { text: primitive(), cache: primitive(), modifiedFiles: list(primitive()), reinit: primitive(), }); export class ExecutionFailureResult extends ExecutionResult { RO; line; column; source; error; sessionError; } createModelSchema(ExecutionFailureResult, { text: primitive(), RO: primitive(), line: optional(primitive()), column: optional(primitive()), source: optional(primitive()), error: primitive(), sessionError: primitive(), }); class GetConceptJumpTo { RO; line; column; source; } createModelSchema(GetConceptJumpTo, { RO: primitive(), line: primitive(), column: primitive(), source: primitive(), }); export class GetConceptResult extends ExecutionResult { jumpTo; } createModelSchema(GetConceptResult, { text: primitive(), jumpTo: object(GetConceptJumpTo), }); export class CandidateWithPackageImported { uuid = uuid(); sourceID; line; column; foundName; } createModelSchema(CandidateWithPackageImported, { sourceID: primitive(), line: primitive(), column: primitive(), foundName: primitive(), }); export class CandidateWithPackageNotImported { uuid = uuid(); sourceID; line; column; foundName; add; messageToBeModified; fileToBeModified; lineToBeModified; columnToBeModified; } createModelSchema(CandidateWithPackageNotImported, { sourceID: primitive(), line: primitive(), column: primitive(), foundName: primitive(), add: primitive(), messageToBeModified: primitive(), fileToBeModified: primitive(), lineToBeModified: primitive(), columnToBeModified: primitive(), }); export class UnmatchedFunctionResult extends ExecutionFailureResult { candidateName; candidatesWithPackageImported = []; candidatesWithPackageNotImported = []; } createModelSchema(UnmatchedFunctionResult, { candidateName: primitive(), candidatesWithPackageImported: list(object(CandidateWithPackageImported)), candidatesWithPackageNotImported: list(object(CandidateWithPackageNotImported)), }); export class UnknownSymbolResult extends ExecutionFailureResult { candidateName; candidates = []; } createModelSchema(UnknownSymbolResult, { candidateName: primitive(), candidates: list(object(CandidateWithPackageNotImported)), }); export class TestAttribute { id; parentId; file; line; // number column; // number } createModelSchema(TestAttribute, { id: primitive(), parentId: primitive(), file: primitive(), line: primitive(), column: primitive(), }); export class TestInfo { children = []; li_attr; text; type; // presence indicate this is the leaf } createModelSchema(TestInfo, { children: list(object(TestInfo)), li_attr: object(TestAttribute), text: primitive(), type: primitive(), }); export class TestExecutionResult extends ExecutionResult { count; filterPaths = []; path; pctAdapter; relevantTestsOnly; runnerId; tests = []; } createModelSchema(TestExecutionResult, { count: primitive(), filterPaths: list(primitive()), path: primitive(), pctAdapter: optional(primitive()), relevantTestsOnly: primitive(), runnerId: primitive(), tests: list(object(TestInfo)), }); export const deserializeExecutionResult = (value) => { if (value.error) { if (value.candidateName && value.PureUnmatchedFunctionException) { return deserialize(UnmatchedFunctionResult, value); } else if (value.candidateName && value.candidates) { return deserialize(UnknownSymbolResult, value); } return deserialize(ExecutionFailureResult, value); } else if (value.jumpTo) { return deserialize(GetConceptResult, value); } else if (value.tests) { return deserialize(TestExecutionResult, value); } return deserialize(ExecutionSuccessResult, value); }; //# sourceMappingURL=Execution.js.map