occam-verify-cli 1.0.340 → 1.0.342

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.
@@ -34,8 +34,6 @@ export default domAssigned(class ComplexTypeDeclaration {
34
34
  return this.prefixed;
35
35
  }
36
36
 
37
- getReleaseContext() { return this.context.getReleaseContext(); }
38
-
39
37
  verify() {
40
38
  let verifies = false;
41
39
 
@@ -57,22 +55,18 @@ export default domAssigned(class ComplexTypeDeclaration {
57
55
  const propertiesVerify = this.verifyProperties();
58
56
 
59
57
  if (propertiesVerify) {
60
- const propertyTypesVerify = this.verifyPropertyTypes();
61
-
62
- if (propertyTypesVerify) {
63
- const typePrefix = this.context.getTypePrefix();
58
+ const typePrefix = this.context.getTypePrefix();
64
59
 
65
- if (typePrefix !== null) {
66
- const typePrefixName = typePrefix.getName(),
67
- prefixName = typePrefixName; ///
60
+ if (typePrefix !== null) {
61
+ const typePrefixName = typePrefix.getName(),
62
+ prefixName = typePrefixName; ///
68
63
 
69
- this.type.setPrefixName(prefixName);
70
- }
64
+ this.type.setPrefixName(prefixName);
65
+ }
71
66
 
72
- this.context.addType(this.type);
67
+ this.context.addType(this.type);
73
68
 
74
- verifies = true;
75
- }
69
+ verifies = true;
76
70
  }
77
71
  }
78
72
  }
@@ -192,40 +186,14 @@ export default domAssigned(class ComplexTypeDeclaration {
192
186
 
193
187
  this.context.trace(`Verifying the '${propertyString}' property...`, this.node);
194
188
 
195
- const propertyName = property.getName(),
196
- count = properties.reduce((count, property) => {
197
- const propertyNameMatches = property.matchPropertyName(propertyName);
198
-
199
- if (propertyNameMatches) {
200
- count++;
201
- }
189
+ const propertyNameVerifies = this.verifyPropertyName(property, properties);
202
190
 
203
- return count;
204
- }, 0);
191
+ if (propertyNameVerifies) {
192
+ const propertyNominalTypeNameVerifies = this.verifyPropertyNominalTypeName(property, properties);
205
193
 
206
- if (count > 1) {
207
- this.context.debug(`The '${propertyString}' property appears more than once.`, this.node);
208
- } else {
209
- const superTypes = this.type.getSuperTypes();
210
-
211
- propertyVerifies = superTypes.every((superType) => {
212
- const superTypeProperties = superType.getProperties(),
213
- superTypeProperty = superTypeProperties.find((superTypeProperty) => {
214
- const propertyNameMatches = superTypeProperty.matchPropertyName(propertyName);
215
-
216
- if (propertyNameMatches) {
217
- return true;
218
- }
219
- }) || null;
220
-
221
- if (superTypeProperty !== null) {
222
- const superTypePropertyString = superTypeProperty.getString();
223
-
224
- this.context.debug(`The '${propertyString}' property matches the super-type's '${superTypePropertyString}' property.`, this.node);
225
- } else {
226
- return true;
227
- }
228
- });
194
+ if (propertyNominalTypeNameVerifies) {
195
+ propertyVerifies = true;
196
+ }
229
197
  }
230
198
 
231
199
  if (propertyVerifies) {
@@ -260,68 +228,84 @@ export default domAssigned(class ComplexTypeDeclaration {
260
228
  return propertiesVerify;
261
229
  }
262
230
 
263
- verifyPropertyType(property) {
264
- let propertyTypeVerifies = false;
231
+ verifyPropertyName(property, properties) {
232
+ let propertyNameVerifies = false;
265
233
 
266
- let propertyType = property.getType();
234
+ const propertyString = property.getString();
267
235
 
268
- const propertyTypeString = propertyType.getString();
236
+ this.context.trace(`Verifying the '${propertyString}' property's name...`, this.node);
269
237
 
270
- this.context.trace(`Verifying the '${propertyTypeString}' property type...`, this.node);
238
+ const propertyName = property.getName(),
239
+ count = properties.reduce((count, property) => {
240
+ const propertyNameMatches = property.matchPropertyName(propertyName);
271
241
 
272
- const typeName = this.type.getName(),
273
- typeNameMatches = propertyType.matchTypeName(typeName);
242
+ if (propertyNameMatches) {
243
+ count++;
244
+ }
274
245
 
275
- if (typeNameMatches) {
276
- propertyTypeVerifies = true;
246
+ return count;
247
+ }, 0);
277
248
 
278
- property.setType(this.type);
249
+ if (count > 1) {
250
+ this.context.debug(`The '${propertyString}' property appears more than once.`, this.node);
279
251
  } else {
280
- const nominalTypeName = propertyType.getNominalTypeName();
281
-
282
- propertyType = this.context.findTypeByNominalTypeName(nominalTypeName);
283
-
284
- const propertyTypePresent = (propertyType !== null);
285
-
286
- if (propertyTypePresent) {
287
- const type = propertyType; ///
252
+ const superTypes = this.type.getSuperTypes(),
253
+ superType = superTypes.find((superType) => {
254
+ const superTypeProperties = superType.getProperties(),
255
+ propertyNameMatches = superTypeProperties.some((superTypeProperty) => {
256
+ const propertyNameMatches = superTypeProperty.matchPropertyName(propertyName);
257
+
258
+ if (propertyNameMatches) {
259
+ return true;
260
+ }
261
+ });
262
+
263
+ if (propertyNameMatches) {
264
+ return true;
265
+ }
266
+ }) || null;
288
267
 
289
- property.setType(type);
268
+ if (superType !== null) {
269
+ const superTypeString = superType.getString();
290
270
 
291
- propertyTypeVerifies = true;
271
+ this.context.debug(`The '${superTypeString}' super-type has the same property.`, this.node);
272
+ } else {
273
+ propertyNameVerifies = true;
292
274
  }
293
275
  }
294
276
 
295
- if (propertyTypeVerifies) {
296
- this.context.debug(`...verified the '${propertyTypeString}' property type.`, this.node);
277
+ if (propertyNameVerifies) {
278
+ this.context.debug(`...verified the '${propertyString}' property's name.`, this.node);
297
279
  }
298
280
 
299
- return propertyTypeVerifies;
281
+ return propertyNameVerifies;
300
282
  }
301
283
 
302
- verifyPropertyTypes() {
303
- let propertyTypesVerify;
284
+ verifyPropertyNominalTypeName(property) {
285
+ let propertyNominalTypeNameVerifies = false;
304
286
 
305
- const typeString = this.type.getString();
287
+ const propertyString = property.getString(),
288
+ nominalTypeName = property.getNominalTypeName();
306
289
 
307
- this.context.trace(`Verifying the '${typeString}' complex type's property types...`, this.node);
290
+ this.context.trace(`Verifying the '${propertyString}' property's '${nominalTypeName}' nominal type name...`, this.node);
308
291
 
309
- const includeSuperTypes = false,
310
- properties = this.type.getProperties(includeSuperTypes);
292
+ const nominalTypeNameMatches = this.type.matchNominalTypeName(nominalTypeName);
311
293
 
312
- propertyTypesVerify = properties.every((property) => {
313
- const propertyVerifies = this.verifyPropertyType(property);
294
+ if (nominalTypeNameMatches) {
295
+ propertyNominalTypeNameVerifies = true;
296
+ } else {
297
+ const typePresent = this.context.isTypePresentByNominalTypeName(nominalTypeName);
314
298
 
315
- if (propertyVerifies) {
316
- return true;
299
+ if (typePresent) {
300
+ propertyNominalTypeNameVerifies = true;
317
301
  }
318
- });
302
+ }
319
303
 
320
- if (propertyTypesVerify) {
321
- this.context.debug(`...verified the '${typeString}' complex type's property types.`, this.node);
304
+ if (propertyNominalTypeNameVerifies) {
305
+ this.context.debug(`...verifies the '${propertyString}' property's '${nominalTypeName}' nominal type name.`, this.node);
322
306
  }
323
307
 
324
- return propertyTypesVerify;
308
+ return propertyNominalTypeNameVerifies;
325
309
  }
326
310
 
327
311
  static name = "ComplexTypeDeclaration";
@@ -3,46 +3,44 @@
3
3
  import dom from "../dom";
4
4
 
5
5
  import { domAssigned } from "../dom";
6
- import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
7
6
 
8
7
  export default domAssigned(class Property {
9
- constructor(string, type, name) {
8
+ constructor(string, name, nominalTypeName) {
10
9
  this.string = string;
11
- this.type = type;
12
10
  this.name = name;
11
+ this.nominalTypeName = nominalTypeName;
13
12
  }
14
13
 
15
14
  getString() {
16
15
  return this.string;
17
16
  }
18
17
 
19
- getType() {
20
- return this.type;
21
- }
22
-
23
18
  getName() {
24
19
  return this.name;
25
20
  }
26
21
 
27
- setType(type) {
28
- this.type = type;
22
+ getNominalTypeName() {
23
+ return this.nominalTypeName;
29
24
  }
30
25
 
31
- matchNominalTypeName(nominalTypeName) { return this.type.matchNominalTypeName(nominalTypeName); }
32
-
33
26
  matchPropertyName(propertyName) {
34
27
  const propertyNameMatches = (this.name === propertyName);
35
28
 
36
29
  return propertyNameMatches;
37
30
  }
38
31
 
32
+ matchNominalTypeName(nominalTypeName) {
33
+ const nominalTypeNameMatches = (this.nominalTypeName === nominalTypeName);
34
+
35
+ return nominalTypeNameMatches;
36
+ }
37
+
39
38
  toJSON() {
40
- const typeJSON = typeToTypeJSON(this.type),
41
- name = this.name, ///
42
- type = typeJSON, ///
39
+ const name = this.name, ///
40
+ nominalTypeName = this.nominalTypeName, ///
43
41
  json = {
44
- type,
45
- name
42
+ name,
43
+ nominalTypeName
46
44
  };
47
45
 
48
46
  return json;
@@ -51,16 +49,9 @@ export default domAssigned(class Property {
51
49
  static name = "Property";
52
50
 
53
51
  static fromJSON(json, context) {
54
- const { name } = json,
55
- type = typeFromJSON(json, context),
52
+ const { name, nominalTypeName } = json,
56
53
  string = name, ///
57
- property = new Property(string, type, name);
58
-
59
- return property;
60
- }
61
-
62
- static fromPropertyNode(propertyNode, context) {
63
- const property = propertyFromPropertyNode(propertyNode, context)
54
+ property = new Property(string, name, nominalTypeName);
64
55
 
65
56
  return property;
66
57
  }
@@ -73,12 +64,11 @@ export default domAssigned(class Property {
73
64
  }
74
65
 
75
66
  static fromPropertyDeclarationNode(propertyDeclarationNode, context) {
76
- const { Type } = dom,
77
- type = Type.fromPropertyDeclarationNode(propertyDeclarationNode),
78
- propertyName = propertyDeclarationNode.getPropertyName(),
67
+ const propertyName = propertyDeclarationNode.getPropertyName(),
68
+ nominalTypeName = propertyDeclarationNode.getNominalTypeName(),
79
69
  name = propertyName, ///
80
70
  string = name, ///
81
- property = new Property(string, type, name);
71
+ property = new Property(string, name, nominalTypeName);
82
72
 
83
73
  return property;
84
74
  }
@@ -87,10 +77,10 @@ export default domAssigned(class Property {
87
77
  function propertyFromPropertyNode(propertyNode, context) {
88
78
  const { Property } = dom,
89
79
  propertyName = propertyNode.getPropertyName(),
80
+ nominalTypeName = null,
90
81
  name = propertyName, ///
91
- type = null,
92
82
  string = name, ///
93
- property = new Property(string, type, name);
83
+ property = new Property(string, name, nominalTypeName);
94
84
 
95
85
  return property;
96
86
  }
@@ -33,8 +33,6 @@ export default domAssigned(class PropertyRelation {
33
33
  return this.term;
34
34
  }
35
35
 
36
- getType() { return this.property.getType(); }
37
-
38
36
  isEqualTo(propertyRelation) {
39
37
  const propertyRelationString = propertyRelation.getString(),
40
38
  equalTo = (propertyRelationString === this.string);
@@ -108,10 +106,6 @@ export default domAssigned(class PropertyRelation {
108
106
 
109
107
  context.debug(`The '${propertyName}' property is not a property of the '${variableString}' variable's '${variableTypeString}' type.`);
110
108
  } else {
111
- const type = termType;
112
-
113
- this.property.setType(type);
114
-
115
109
  propertyVerifies = true;
116
110
  }
117
111
 
package/src/dom/type.js CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import dom from "../dom";
6
-
7
- import { domAssigned } from "../dom";
5
+ import dom, { domAssigned } from "../dom";
8
6
  import { OBJECT_TYPE_NAME } from "../constants";
9
7
  import { typeFromTypeNode } from "../utilities/node";
10
8
  import { stringFromTypeNameTypePrefixNameAndSuperTypes } from "../utilities/type";
@@ -359,13 +357,13 @@ class Type {
359
357
  }
360
358
 
361
359
  static fromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
362
- const properties = [],
360
+ const typeName = simpleTypeDeclarationNode.getTypeName(),
363
361
  provisional = simpleTypeDeclarationNode.isProvisional(),
364
- typeName = simpleTypeDeclarationNode.getTypeName(),
365
362
  typePrefixName = simpleTypeDeclarationNode.getTypePrefixName(),
363
+ superTypes = superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context),
366
364
  name = typeName, ///
367
365
  prefixName = typePrefixName, ///
368
- superTypes = superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context),
366
+ properties = [],
369
367
  string = stringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
370
368
  type = new Type(string, name, prefixName, superTypes, properties, provisional);
371
369
 
@@ -373,12 +371,12 @@ class Type {
373
371
  }
374
372
 
375
373
  static fromComplexTypeDeclarationNode(complexTypeDeclarationNode, context) {
376
- const provisional = complexTypeDeclarationNode.isProvisional(),
377
- typeName = complexTypeDeclarationNode.getTypeName(),
374
+ const typeName = complexTypeDeclarationNode.getTypeName(),
375
+ provisional = complexTypeDeclarationNode.isProvisional(),
378
376
  typePrefixName = complexTypeDeclarationNode.getTypePrefixName(),
377
+ superTypes = superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
379
378
  name = typeName, ///
380
379
  prefixName = typePrefixName, ///
381
- superTypes = superTypesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
382
380
  properties = propertiesFromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
383
381
  string = stringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
384
382
  type = new Type(string, name, prefixName, superTypes, properties, provisional);
@@ -5,13 +5,6 @@ import NonTerminalNode from "../../node/nonTerminal";
5
5
  import { TYPE_RULE_NAME, PROPERTY_RULE_NAME } from "../../ruleNames";
6
6
 
7
7
  export default class PropertyDeclarationNode extends NonTerminalNode {
8
- getPropertyName() {
9
- const propertyNode = this.getPropertyNode(),
10
- propertyName = propertyNode.getPropertyName();
11
-
12
- return propertyName;
13
- }
14
-
15
8
  getTypeNode() {
16
9
  const ruleName = TYPE_RULE_NAME,
17
10
  typeNode = this.getNodeByRuleName(ruleName);
@@ -26,5 +19,24 @@ export default class PropertyDeclarationNode extends NonTerminalNode {
26
19
  return propertyNode;
27
20
  }
28
21
 
22
+ getPropertyName() {
23
+ const propertyNode = this.getPropertyNode(),
24
+ propertyName = propertyNode.getPropertyName();
25
+
26
+ return propertyName;
27
+ }
28
+
29
+ getNominalTypeName() {
30
+ let nominalTypeName = null;
31
+
32
+ const typeNode = this.getTypeNode();
33
+
34
+ if (typeNode !== null) {
35
+ nominalTypeName = typeNode.getNominalTypeName();
36
+ }
37
+
38
+ return nominalTypeName;
39
+ }
40
+
29
41
  static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(PropertyDeclarationNode, ruleName, childNodes, opacity, precedence); }
30
42
  }
@@ -496,7 +496,9 @@ export function termToTermJSON(term) {
496
496
  }
497
497
 
498
498
  export function typeToTypeJSON(type) {
499
- const typeJSON = type.toJSON();
499
+ const typeJSON = (type !== null) ?
500
+ type.toJSON() :
501
+ null;
500
502
 
501
503
  return typeJSON;
502
504
  }