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.
- package/lib/dom/declaration/complexType.js +61 -76
- package/lib/dom/property.js +19 -32
- package/lib/dom/propertyRelation.js +1 -9
- package/lib/dom/type.js +3 -3
- package/lib/node/declaration/property.js +19 -8
- package/lib/utilities/json.js +2 -2
- package/package.json +1 -1
- package/src/dom/declaration/complexType.js +67 -83
- package/src/dom/property.js +21 -31
- package/src/dom/propertyRelation.js +0 -6
- package/src/dom/type.js +7 -9
- package/src/node/declaration/property.js +19 -7
- package/src/utilities/json.js +3 -1
|
@@ -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
|
|
61
|
-
|
|
62
|
-
if (propertyTypesVerify) {
|
|
63
|
-
const typePrefix = this.context.getTypePrefix();
|
|
58
|
+
const typePrefix = this.context.getTypePrefix();
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
if (typePrefix !== null) {
|
|
61
|
+
const typePrefixName = typePrefix.getName(),
|
|
62
|
+
prefixName = typePrefixName; ///
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
this.type.setPrefixName(prefixName);
|
|
65
|
+
}
|
|
71
66
|
|
|
72
|
-
|
|
67
|
+
this.context.addType(this.type);
|
|
73
68
|
|
|
74
|
-
|
|
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
|
|
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
|
-
|
|
204
|
-
|
|
191
|
+
if (propertyNameVerifies) {
|
|
192
|
+
const propertyNominalTypeNameVerifies = this.verifyPropertyNominalTypeName(property, properties);
|
|
205
193
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
264
|
-
let
|
|
231
|
+
verifyPropertyName(property, properties) {
|
|
232
|
+
let propertyNameVerifies = false;
|
|
265
233
|
|
|
266
|
-
|
|
234
|
+
const propertyString = property.getString();
|
|
267
235
|
|
|
268
|
-
|
|
236
|
+
this.context.trace(`Verifying the '${propertyString}' property's name...`, this.node);
|
|
269
237
|
|
|
270
|
-
|
|
238
|
+
const propertyName = property.getName(),
|
|
239
|
+
count = properties.reduce((count, property) => {
|
|
240
|
+
const propertyNameMatches = property.matchPropertyName(propertyName);
|
|
271
241
|
|
|
272
|
-
|
|
273
|
-
|
|
242
|
+
if (propertyNameMatches) {
|
|
243
|
+
count++;
|
|
244
|
+
}
|
|
274
245
|
|
|
275
|
-
|
|
276
|
-
|
|
246
|
+
return count;
|
|
247
|
+
}, 0);
|
|
277
248
|
|
|
278
|
-
|
|
249
|
+
if (count > 1) {
|
|
250
|
+
this.context.debug(`The '${propertyString}' property appears more than once.`, this.node);
|
|
279
251
|
} else {
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
|
|
268
|
+
if (superType !== null) {
|
|
269
|
+
const superTypeString = superType.getString();
|
|
290
270
|
|
|
291
|
-
|
|
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 (
|
|
296
|
-
this.context.debug(`...verified the '${
|
|
277
|
+
if (propertyNameVerifies) {
|
|
278
|
+
this.context.debug(`...verified the '${propertyString}' property's name.`, this.node);
|
|
297
279
|
}
|
|
298
280
|
|
|
299
|
-
return
|
|
281
|
+
return propertyNameVerifies;
|
|
300
282
|
}
|
|
301
283
|
|
|
302
|
-
|
|
303
|
-
let
|
|
284
|
+
verifyPropertyNominalTypeName(property) {
|
|
285
|
+
let propertyNominalTypeNameVerifies = false;
|
|
304
286
|
|
|
305
|
-
const
|
|
287
|
+
const propertyString = property.getString(),
|
|
288
|
+
nominalTypeName = property.getNominalTypeName();
|
|
306
289
|
|
|
307
|
-
this.context.trace(`Verifying the '${
|
|
290
|
+
this.context.trace(`Verifying the '${propertyString}' property's '${nominalTypeName}' nominal type name...`, this.node);
|
|
308
291
|
|
|
309
|
-
const
|
|
310
|
-
properties = this.type.getProperties(includeSuperTypes);
|
|
292
|
+
const nominalTypeNameMatches = this.type.matchNominalTypeName(nominalTypeName);
|
|
311
293
|
|
|
312
|
-
|
|
313
|
-
|
|
294
|
+
if (nominalTypeNameMatches) {
|
|
295
|
+
propertyNominalTypeNameVerifies = true;
|
|
296
|
+
} else {
|
|
297
|
+
const typePresent = this.context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
314
298
|
|
|
315
|
-
if (
|
|
316
|
-
|
|
299
|
+
if (typePresent) {
|
|
300
|
+
propertyNominalTypeNameVerifies = true;
|
|
317
301
|
}
|
|
318
|
-
}
|
|
302
|
+
}
|
|
319
303
|
|
|
320
|
-
if (
|
|
321
|
-
this.context.debug(`...
|
|
304
|
+
if (propertyNominalTypeNameVerifies) {
|
|
305
|
+
this.context.debug(`...verifies the '${propertyString}' property's '${nominalTypeName}' nominal type name.`, this.node);
|
|
322
306
|
}
|
|
323
307
|
|
|
324
|
-
return
|
|
308
|
+
return propertyNominalTypeNameVerifies;
|
|
325
309
|
}
|
|
326
310
|
|
|
327
311
|
static name = "ComplexTypeDeclaration";
|
package/src/dom/property.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
28
|
-
this.
|
|
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
|
|
41
|
-
|
|
42
|
-
type = typeJSON, ///
|
|
39
|
+
const name = this.name, ///
|
|
40
|
+
nominalTypeName = this.nominalTypeName, ///
|
|
43
41
|
json = {
|
|
44
|
-
|
|
45
|
-
|
|
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,
|
|
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
|
|
77
|
-
|
|
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,
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
|
377
|
-
|
|
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
|
}
|
package/src/utilities/json.js
CHANGED