occam-verify-cli 1.0.318 → 1.0.325

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/lib/context/file.js +108 -126
  2. package/lib/context/local.js +21 -8
  3. package/lib/context/release.js +58 -7
  4. package/lib/dom/assertion/type.js +3 -3
  5. package/lib/dom/declaration/complexType.js +125 -101
  6. package/lib/dom/declaration/constructor.js +5 -5
  7. package/lib/dom/declaration/metavariable.js +3 -3
  8. package/lib/dom/declaration/simpleType.js +58 -52
  9. package/lib/dom/declaration/typePrefix.js +18 -7
  10. package/lib/dom/declaration/variable.js +5 -5
  11. package/lib/dom/metavariable.js +3 -3
  12. package/lib/dom/property.js +4 -4
  13. package/lib/dom/topLevelAssertion.js +1 -43
  14. package/lib/dom/type.js +107 -21
  15. package/lib/dom/variable.js +4 -4
  16. package/lib/node/declaration/complexType.js +22 -1
  17. package/lib/node/declaration/simpleType.js +22 -1
  18. package/lib/node/type.js +35 -9
  19. package/lib/unifier/metavariable.js +2 -2
  20. package/lib/unifier/statementWithCombinator.js +3 -3
  21. package/lib/unifier/termWithConstructor.js +2 -2
  22. package/lib/utilities/json.js +8 -6
  23. package/lib/utilities/node.js +4 -4
  24. package/lib/utilities/type.js +10 -5
  25. package/lib/verifier/combinator.js +2 -2
  26. package/lib/verifier/constructor.js +3 -3
  27. package/package.json +1 -1
  28. package/src/context/file.js +137 -171
  29. package/src/context/local.js +7 -3
  30. package/src/context/release.js +54 -8
  31. package/src/dom/assertion/type.js +3 -3
  32. package/src/dom/declaration/complexType.js +159 -132
  33. package/src/dom/declaration/constructor.js +6 -6
  34. package/src/dom/declaration/metavariable.js +3 -3
  35. package/src/dom/declaration/simpleType.js +74 -68
  36. package/src/dom/declaration/typePrefix.js +24 -6
  37. package/src/dom/declaration/variable.js +6 -6
  38. package/src/dom/metavariable.js +2 -2
  39. package/src/dom/property.js +1 -1
  40. package/src/dom/topLevelAssertion.js +3 -15
  41. package/src/dom/type.js +132 -22
  42. package/src/dom/variable.js +4 -4
  43. package/src/node/declaration/complexType.js +21 -0
  44. package/src/node/declaration/simpleType.js +21 -0
  45. package/src/node/type.js +42 -9
  46. package/src/unifier/metavariable.js +2 -2
  47. package/src/unifier/statementWithCombinator.js +2 -2
  48. package/src/unifier/termWithConstructor.js +2 -2
  49. package/src/utilities/json.js +18 -10
  50. package/src/utilities/node.js +6 -3
  51. package/src/utilities/type.js +12 -5
  52. package/src/verifier/combinator.js +2 -2
  53. package/src/verifier/constructor.js +3 -3
@@ -2,16 +2,16 @@
2
2
 
3
3
  import dom from "../../dom";
4
4
 
5
- import { objectType } from "../type";
6
5
  import { domAssigned } from "../../dom";
7
- import { stringFromTypeNameNameAndSuperTypes } from "../../utilities/type";
6
+ import { stringFromTypeNameTypePrefixNameAndSuperTypes } from "../../utilities/type";
8
7
 
9
8
  export default domAssigned(class ComplexTypeDeclaration {
10
- constructor(context, node, string, type) {
9
+ constructor(context, node, string, type, prefixed) {
11
10
  this.context = context;
12
11
  this.node = node;
13
12
  this.string = string;
14
13
  this.type = type;
14
+ this.prefixed = prefixed;
15
15
  }
16
16
 
17
17
  getContext() {
@@ -30,6 +30,10 @@ export default domAssigned(class ComplexTypeDeclaration {
30
30
  return this.type;
31
31
  }
32
32
 
33
+ isPrefixed() {
34
+ return this.prefixed;
35
+ }
36
+
33
37
  getReleaseContext() { return this.context.getReleaseContext(); }
34
38
 
35
39
  verify() {
@@ -39,18 +43,37 @@ export default domAssigned(class ComplexTypeDeclaration {
39
43
 
40
44
  this.context.trace(`Verifying the '${complexTypeDeclarationString}' complex type declaration...`, this.node);
41
45
 
42
- const typeVerifies = this.verifyType();
46
+ if (this.prefixed) {
47
+ const typeString = this.type.getString();
43
48
 
44
- if (typeVerifies) {
45
- const superTypesVerify = this.verifySuperTypes();
49
+ this.context.trace(`The '${typeString}' type is prefixed.`);
50
+ } else {
51
+ const typeVerifies = this.verifyType();
52
+
53
+ if (typeVerifies) {
54
+ const superTypesVerify = this.verifySuperTypes();
55
+
56
+ if (superTypesVerify) {
57
+ const propertiesVerify = this.verifyProperties();
58
+
59
+ if (propertiesVerify) {
60
+ const propertyTypesVerify = this.verifyPropertyTypes();
61
+
62
+ if (propertyTypesVerify) {
63
+ const typePrefix = this.context.getTypePrefix();
46
64
 
47
- if (superTypesVerify) {
48
- const propertiesVerify = this.verifyProperties();
65
+ if (typePrefix !== null) {
66
+ const typePrefixName = typePrefix.getName(),
67
+ prefixName = typePrefixName; ///
49
68
 
50
- if (propertiesVerify) {
51
- this.context.addType(this.type);
69
+ this.type.setPrefixName(prefixName);
70
+ }
71
+
72
+ this.context.addType(this.type);
52
73
 
53
- verifies = true;
74
+ verifies = true;
75
+ }
76
+ }
54
77
  }
55
78
  }
56
79
  }
@@ -70,16 +93,25 @@ export default domAssigned(class ComplexTypeDeclaration {
70
93
  this.context.trace(`Verifying the '${typeString}' complex type...`, this.node);
71
94
 
72
95
  const typeName = this.type.getName(),
73
- typePresent = this.context.isTypePresentByTypeName(typeName);
96
+ includeRelease = true,
97
+ includeDependencies = false,
98
+ typePresent = this.context.isTypePresentByTypeName(typeName, includeRelease, includeDependencies);
74
99
 
75
100
  if (typePresent) {
76
- this.context.debug(`The '${typeString}' type is already present in the package.`, this.node);
101
+ this.context.trace(`The '${typeString}' type is already present.`, this.node);
77
102
  } else {
78
- typeVerifies = true;
103
+ const prefixedTypeName = typeName, ///
104
+ typePresent = this.context.isTypePresentByPrefixedTypeName(prefixedTypeName);
105
+
106
+ if (typePresent) {
107
+ this.context.trace(`The '${typeString}' type is already present.`, this.node);
108
+ } else {
109
+ typeVerifies = true;
110
+ }
79
111
  }
80
112
 
81
113
  if (typeVerifies) {
82
- this.context.debug(`...verified the '${typeString}' complex type.`, this.node);
114
+ this.context.trace(`...verified the '${typeString}' complex type.`, this.node);
83
115
  }
84
116
 
85
117
  return typeVerifies;
@@ -92,11 +124,26 @@ export default domAssigned(class ComplexTypeDeclaration {
92
124
 
93
125
  this.context.trace(`Verifying the '${superTypeString}' super-type...`, this.node);
94
126
 
95
- const superTypeName = superType.getName(),
96
- superTypePresent = this.context.isTypePresentByTypeName(superTypeName);
127
+ const nominalTypeName = superType.getNominalTypeName(),
128
+ typeName = nominalTypeName, ///
129
+ typeNameMatches = this.type.matchTypeName(typeName);
130
+
131
+ if (typeNameMatches) {
132
+ this.context.trace(`The super-type's name matches the ${typeName}' complex type's name.`, this.node);
133
+ } else {
134
+ const oldSuperType = superType;
97
135
 
98
- if (superTypePresent) {
99
- superTypeVerifies = true;
136
+ superType = this.context.findTypeByNominalTypeName(nominalTypeName);
137
+
138
+ const superTypePresent = (superType !== null);
139
+
140
+ if (superTypePresent) {
141
+ const newSuperType = superType; ///
142
+
143
+ this.type.replaceSuperType(oldSuperType, newSuperType);
144
+
145
+ superTypeVerifies = true;
146
+ }
100
147
  }
101
148
 
102
149
  if (superTypeVerifies) {
@@ -107,75 +154,38 @@ export default domAssigned(class ComplexTypeDeclaration {
107
154
  }
108
155
 
109
156
  verifySuperTypes() {
110
- let superTypesVerify = false;
157
+ let superTypesVerify;
111
158
 
112
- this.context.trace(`Verifying the super-types...`, this.node);
113
-
114
- let superTypes;
115
-
116
- superTypes = this.type.getSuperTypes();
117
-
118
- const superTypesLength = superTypes.length;
119
-
120
- if (superTypesLength === 0) {
121
- const superType = objectType; ///
159
+ const typeString = this.type.getString();
122
160
 
123
- superTypes.push(superType);
124
- }
161
+ this.context.trace(`Verifying the '${typeString}' complex type's super-types...`, this.node);
125
162
 
126
- const typeName = this.type.getName(),
127
- typeBasic = this.type.isBasic(),
128
- typeString = this.type.getString();
163
+ const typeBasic = this.type.isBasic();
129
164
 
130
165
  if (typeBasic) {
131
166
  superTypesVerify = true;
132
167
 
133
168
  this.context.trace(`The '${typeString}' complex type is basic.`, this.node)
134
169
  } else {
135
- const superTypeNames = superTypes.map((superType) => {
136
- const superTypeName = superType.getName();
137
-
138
- return superTypeName;
139
- }),
140
- superTypeNamesIncludesTypeName = superTypeNames.includes(typeName);
141
-
142
- if (superTypeNamesIncludesTypeName) {
143
- this.context.trace(`The '${typeName}' complex type cannot be a super-type `, this.node);
144
- } else {
145
- superTypesVerify = superTypes.every((superType) => {
146
- const superTypeVerifies = this.verifySuperType(superType);
170
+ const superTypes = this.type.getSuperTypes();
147
171
 
148
- if (superTypeVerifies) {
149
- return true;
150
- }
151
- });
172
+ superTypesVerify = superTypes.every((superType) => {
173
+ const superTypeVerifies = this.verifySuperType(superType);
152
174
 
153
- if (superTypesVerify) {
154
- superTypes = superTypes.map((superType) => {
155
- const superTypeName = superType.getName();
156
-
157
- superType = this.context.findTypeByTypeName(superTypeName);
158
-
159
- return superType;
160
- });
161
-
162
- const string = stringFromTypeNameNameAndSuperTypes(typeName, superTypes);
163
-
164
- this.type.setString(string);
165
-
166
- this.type.setSuperTypes(superTypes);
175
+ if (superTypeVerifies) {
176
+ return true;
167
177
  }
168
- }
178
+ });
169
179
  }
170
180
 
171
181
  if (superTypesVerify) {
172
- this.context.debug(`...verified the super-types.`, this.node);
182
+ this.context.debug(`...verified the '${typeString}' complex type's super-types.`, this.node);
173
183
  }
174
184
 
175
185
  return superTypesVerify;
176
186
  }
177
187
 
178
- verifyProperty(property, properties, superTypeProperties) {
188
+ verifyProperty(property, properties) {
179
189
  let propertyVerifies = false;
180
190
 
181
191
  const propertyString = property.getString();
@@ -196,48 +206,30 @@ export default domAssigned(class ComplexTypeDeclaration {
196
206
  if (count > 1) {
197
207
  this.context.debug(`The '${propertyString}' property appears more than once.`, this.node);
198
208
  } else {
199
- const superTypeProperty = superTypeProperties.find((superTypeProperty) => {
200
- const propertyNameMatches = superTypeProperty.matchPropertyName(propertyName);
209
+ const superTypes = this.type.getSuperTypes();
201
210
 
202
- if (propertyNameMatches) {
203
- return true;
204
- }
205
- }) || null;
211
+ propertyVerifies = superTypes.every((superType) => {
212
+ const superTypeProperties = superType.getProperties(),
213
+ superTypeProperty = superTypeProperties.find((superTypeProperty) => {
214
+ const propertyNameMatches = superTypeProperty.matchPropertyName(propertyName);
206
215
 
207
- if (superTypeProperty !== null) {
208
- const superTypePropertyString = superTypeProperty.getString();
209
-
210
- this.context.debug(`The '${propertyString}' property matches the super-type's '${superTypePropertyString}' property.`, this.node);
211
- } else {
212
- let propertyType;
216
+ if (propertyNameMatches) {
217
+ return true;
218
+ }
219
+ }) || null;
213
220
 
214
- propertyType = property.getType();
221
+ if (superTypeProperty !== null) {
222
+ const superTypePropertyString = superTypeProperty.getString();
215
223
 
216
- const propertyTypeVerifies = this.verifyPropertyType(propertyType);
217
-
218
- if (propertyTypeVerifies) {
219
- const propertyTypeName = propertyType.getName();
220
-
221
- propertyType = this.context.findTypeByTypeName(propertyTypeName);
222
-
223
- const type = propertyType; ///
224
-
225
- property.setType(type);
226
-
227
- propertyVerifies = true;
224
+ this.context.debug(`The '${propertyString}' property matches the super-type's '${superTypePropertyString}' property.`, this.node);
225
+ } else {
226
+ return true;
228
227
  }
229
- }
228
+ });
230
229
  }
231
230
 
232
231
  if (propertyVerifies) {
233
- const typeName = this.type.getName(),
234
- typeNameMatches = property.matchTypeName(typeName);
235
-
236
- if (typeNameMatches) {
237
- property.setType(this.type);
238
- }
239
-
240
- this.context.debug(`verifies the '${propertyString}' property.`, this.node);
232
+ this.context.debug(`...verified the '${propertyString}' property.`, this.node);
241
233
  }
242
234
 
243
235
  return propertyVerifies;
@@ -246,69 +238,104 @@ export default domAssigned(class ComplexTypeDeclaration {
246
238
  verifyProperties() {
247
239
  let propertiesVerify;
248
240
 
249
- const includeSuperTypes = false,
250
- properties = this.type.getProperties(includeSuperTypes),
251
- superTypes = this.type.getSuperTypes()
241
+ const typeString = this.type.getString();
252
242
 
253
- propertiesVerify = superTypes.every((superType) => {
254
- const superTypeProperties = superType.getProperties(),
255
- propertiesVerify = properties.every((property) => {
256
- const propertyVerifies = this.verifyProperty(property, properties, superTypeProperties);
243
+ this.context.trace(`Verifying the '${typeString}' complex type's properties...`, this.node);
257
244
 
258
- if (propertyVerifies) {
259
- return true;
260
- }
261
- });
245
+ const includeSuperTypes = false,
246
+ properties = this.type.getProperties(includeSuperTypes);
247
+
248
+ propertiesVerify = properties.every((property) => {
249
+ const propertyVerifies = this.verifyProperty(property, properties);
262
250
 
263
- if (propertiesVerify) {
251
+ if (propertyVerifies) {
264
252
  return true;
265
253
  }
266
254
  });
267
255
 
256
+ if (propertiesVerify) {
257
+ this.context.debug(`...verified the '${typeString}' complex type's properties.`, this.node);
258
+ }
259
+
268
260
  return propertiesVerify;
269
261
  }
270
262
 
271
- verifyPropertyType(propertyType) {
263
+ verifyPropertyType(property) {
272
264
  let propertyTypeVerifies = false;
273
265
 
274
- const typeEqualToPropertyType = this.type.isEqualTo(propertyType);
266
+ let propertyType = property.getType();
267
+
268
+ const propertyTypeString = propertyType.getString();
275
269
 
276
- if (typeEqualToPropertyType) {
270
+ this.context.trace(`Verifying the '${propertyTypeString}' property type...`, this.node);
271
+
272
+ const typeName = this.type.getName(),
273
+ typeNameMatches = propertyType.matchTypeName(typeName);
274
+
275
+ if (typeNameMatches) {
277
276
  propertyTypeVerifies = true;
278
- } else {
279
- const propertyTypeString = propertyType.getString(); ///
280
277
 
281
- this.context.trace(`Verifying the '${propertyTypeString}' property type...`, this.node);
278
+ property.setType(this.type);
279
+ } else {
280
+ const nominalTypeName = propertyType.getNominalTypeName();
282
281
 
283
- const propertyTypeName = propertyType.getName(),
284
- propertyTypePresent = this.context.isTypePresentByTypeName(propertyTypeName);
282
+ propertyType = this.context.findTypeByNominalTypeName(nominalTypeName);
285
283
 
286
- if (!propertyTypePresent) {
287
- const propertyTypeString = propertyType.getString();
284
+ const propertyTypePresent = (propertyType !== null);
285
+
286
+ if (propertyTypePresent) {
287
+ const type = propertyType; ///
288
+
289
+ property.setType(type);
288
290
 
289
- this.context.debug(`The '${propertyTypeString}' property type is not present.`, this.node);
290
- } else {
291
291
  propertyTypeVerifies = true;
292
292
  }
293
+ }
293
294
 
294
- if (propertyTypeVerifies) {
295
- this.context.debug(`...verified the '${propertyTypeString}' property type.`, this.node);
296
- }
295
+ if (propertyTypeVerifies) {
296
+ this.context.debug(`...verified the '${propertyTypeString}' property type.`, this.node);
297
297
  }
298
298
 
299
299
  return propertyTypeVerifies;
300
300
  }
301
301
 
302
+ verifyPropertyTypes() {
303
+ let propertyTypesVerify;
304
+
305
+ const typeString = this.type.getString();
306
+
307
+ this.context.trace(`Verifying the '${typeString}' complex type's property types...`, this.node);
308
+
309
+ const includeSuperTypes = false,
310
+ properties = this.type.getProperties(includeSuperTypes);
311
+
312
+ propertyTypesVerify = properties.every((property) => {
313
+ const propertyVerifies = this.verifyPropertyType(property);
314
+
315
+ if (propertyVerifies) {
316
+ return true;
317
+ }
318
+ });
319
+
320
+ if (propertyTypesVerify) {
321
+ this.context.debug(`...verified the '${typeString}' complex type's property types.`, this.node);
322
+ }
323
+
324
+ return propertyTypesVerify;
325
+ }
326
+
302
327
  static name = "ComplexTypeDeclaration";
303
328
 
304
329
  static fromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
305
330
  const { Type } = dom,
306
- node = complexTypeDeclarationNode, ///
307
331
  type = Type.fromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
332
+ node = complexTypeDeclarationNode, ///
333
+ prefixed = complexTypeDeclarationNode.isPrefixed(),
334
+ typePrefixName = complexTypeDeclarationNode.getTypePrefixName(),
308
335
  typeName = type.getName(),
309
336
  superTypes = type.getSuperTypes(),
310
- string = stringFromTypeNameNameAndSuperTypes(typeName, superTypes),
311
- complexTypeDeclaration = new ComplexTypeDeclaration(context, node, string, type);
337
+ string = stringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
338
+ complexTypeDeclaration = new ComplexTypeDeclaration(context, node, string, type, prefixed);
312
339
 
313
340
  return complexTypeDeclaration;
314
341
  }
@@ -82,22 +82,22 @@ export default domAssigned(class ConstructorDeclaration {
82
82
 
83
83
  type = this.constructor.getType();
84
84
 
85
- const typeName = type.getName(),
86
- typeString = type.getString();
85
+ const typeString = type.getString();
87
86
 
88
87
  this.context.trace(`Verifying the '${typeString}' type...`, this.node);
89
88
 
90
- const includeSupertypes = false,
91
- provisional = type.isProvisional(includeSupertypes);
89
+ const nominalTypeName = type.getNominalTypeName();
92
90
 
93
- type = this.context.findTypeByTypeName(typeName);
91
+ type = this.context.findTypeByNominalTypeName(nominalTypeName);
94
92
 
95
93
  const typePresent = (type !== null)
96
94
 
97
95
  if (!typePresent) {
98
96
  this.context.debug(`The '${typeString}' type is not present.`, this.node);
99
97
  } else {
100
- const provisionalMatches = type.matchProvisional(provisional);
98
+ const includeSupertypes = false,
99
+ provisional = type.isProvisional(includeSupertypes),
100
+ provisionalMatches = type.matchProvisional(provisional);
101
101
 
102
102
  if (!provisionalMatches) {
103
103
  provisional ?
@@ -56,12 +56,12 @@ export default domAssigned(class MetavariableDeclaration {
56
56
  if (type === null) {
57
57
  typeVerifies = true;
58
58
  } else {
59
- const typeName = type.getName(),
60
- typeString = type.getString();
59
+ const typeString = type.getString();
61
60
 
62
61
  this.context.trace(`Verifying the '${typeString}' type...`, this.node);
63
62
 
64
- const typePresent = this.context.isTypePresentByTypeName(typeName);
63
+ const nominalTypeName = type.getNominalTypeName(),
64
+ typePresent = this.context.isTypePresentByNominalTypeName(nominalTypeName);
65
65
 
66
66
  if (!typePresent) {
67
67
  this.context.debug(`The '${typeString}' type is not present.`, this.node);