|
| 1 | +import { ModelsAsDataLanguage } from "./models-as-data"; |
| 2 | +import { ModeledMethodType, Provenance } from "../modeled-method"; |
| 3 | +import { DataTuple } from "../model-extension-file"; |
| 4 | +import { sharedExtensiblePredicates, sharedKinds } from "./shared"; |
| 5 | + |
| 6 | +function readRowToMethod(row: DataTuple[]): string { |
| 7 | + return `${row[0]}.${row[1]}#${row[3]}${row[4]}`; |
| 8 | +} |
| 9 | + |
| 10 | +export const staticLanguage: ModelsAsDataLanguage = { |
| 11 | + source: { |
| 12 | + extensiblePredicate: sharedExtensiblePredicates.source, |
| 13 | + supportedKinds: sharedKinds.source, |
| 14 | + // extensible predicate sourceModel( |
| 15 | + // string package, string type, boolean subtypes, string name, string signature, string ext, |
| 16 | + // string output, string kind, string provenance |
| 17 | + // ); |
| 18 | + generateMethodDefinition: (method) => [ |
| 19 | + method.packageName, |
| 20 | + method.typeName, |
| 21 | + true, |
| 22 | + method.methodName, |
| 23 | + method.methodParameters, |
| 24 | + "", |
| 25 | + method.output, |
| 26 | + method.kind, |
| 27 | + method.provenance, |
| 28 | + ], |
| 29 | + readModeledMethod: (row) => ({ |
| 30 | + type: "source" as ModeledMethodType, |
| 31 | + input: "", |
| 32 | + output: row[6] as string, |
| 33 | + kind: row[7] as string, |
| 34 | + provenance: row[8] as Provenance, |
| 35 | + signature: readRowToMethod(row), |
| 36 | + packageName: row[0] as string, |
| 37 | + typeName: row[1] as string, |
| 38 | + methodName: row[3] as string, |
| 39 | + methodParameters: row[4] as string, |
| 40 | + }), |
| 41 | + }, |
| 42 | + sink: { |
| 43 | + extensiblePredicate: sharedExtensiblePredicates.sink, |
| 44 | + supportedKinds: sharedKinds.sink, |
| 45 | + // extensible predicate sinkModel( |
| 46 | + // string package, string type, boolean subtypes, string name, string signature, string ext, |
| 47 | + // string input, string kind, string provenance |
| 48 | + // ); |
| 49 | + generateMethodDefinition: (method) => [ |
| 50 | + method.packageName, |
| 51 | + method.typeName, |
| 52 | + true, |
| 53 | + method.methodName, |
| 54 | + method.methodParameters, |
| 55 | + "", |
| 56 | + method.input, |
| 57 | + method.kind, |
| 58 | + method.provenance, |
| 59 | + ], |
| 60 | + readModeledMethod: (row) => ({ |
| 61 | + type: "sink", |
| 62 | + input: row[6] as string, |
| 63 | + output: "", |
| 64 | + kind: row[7] as string, |
| 65 | + provenance: row[8] as Provenance, |
| 66 | + signature: readRowToMethod(row), |
| 67 | + packageName: row[0] as string, |
| 68 | + typeName: row[1] as string, |
| 69 | + methodName: row[3] as string, |
| 70 | + methodParameters: row[4] as string, |
| 71 | + }), |
| 72 | + }, |
| 73 | + summary: { |
| 74 | + extensiblePredicate: sharedExtensiblePredicates.summary, |
| 75 | + supportedKinds: sharedKinds.summary, |
| 76 | + // extensible predicate summaryModel( |
| 77 | + // string package, string type, boolean subtypes, string name, string signature, string ext, |
| 78 | + // string input, string output, string kind, string provenance |
| 79 | + // ); |
| 80 | + generateMethodDefinition: (method) => [ |
| 81 | + method.packageName, |
| 82 | + method.typeName, |
| 83 | + true, |
| 84 | + method.methodName, |
| 85 | + method.methodParameters, |
| 86 | + "", |
| 87 | + method.input, |
| 88 | + method.output, |
| 89 | + method.kind, |
| 90 | + method.provenance, |
| 91 | + ], |
| 92 | + readModeledMethod: (row) => ({ |
| 93 | + type: "summary", |
| 94 | + input: row[6] as string, |
| 95 | + output: row[7] as string, |
| 96 | + kind: row[8] as string, |
| 97 | + provenance: row[9] as Provenance, |
| 98 | + signature: readRowToMethod(row), |
| 99 | + packageName: row[0] as string, |
| 100 | + typeName: row[1] as string, |
| 101 | + methodName: row[3] as string, |
| 102 | + methodParameters: row[4] as string, |
| 103 | + }), |
| 104 | + }, |
| 105 | + neutral: { |
| 106 | + extensiblePredicate: sharedExtensiblePredicates.neutral, |
| 107 | + supportedKinds: sharedKinds.neutral, |
| 108 | + // extensible predicate neutralModel( |
| 109 | + // string package, string type, string name, string signature, string kind, string provenance |
| 110 | + // ); |
| 111 | + generateMethodDefinition: (method) => [ |
| 112 | + method.packageName, |
| 113 | + method.typeName, |
| 114 | + method.methodName, |
| 115 | + method.methodParameters, |
| 116 | + method.kind, |
| 117 | + method.provenance, |
| 118 | + ], |
| 119 | + readModeledMethod: (row) => ({ |
| 120 | + type: "neutral", |
| 121 | + input: "", |
| 122 | + output: "", |
| 123 | + kind: row[4] as string, |
| 124 | + provenance: row[5] as Provenance, |
| 125 | + signature: `${row[0]}.${row[1]}#${row[2]}${row[3]}`, |
| 126 | + packageName: row[0] as string, |
| 127 | + typeName: row[1] as string, |
| 128 | + methodName: row[2] as string, |
| 129 | + methodParameters: row[3] as string, |
| 130 | + }), |
| 131 | + }, |
| 132 | +}; |
0 commit comments