occam-verify-cli 0.0.1006 → 0.0.1007
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/bin/action/verify.js +15 -2
- package/bin/utilities/releaseContext.js +5 -7
- package/lib/combinator.js +7 -3
- package/lib/conclusion.js +6 -3
- package/lib/context/file.js +134 -57
- package/lib/context/release.js +91 -50
- package/lib/log.js +15 -25
- package/lib/metaType.js +6 -4
- package/lib/metavariable.js +9 -15
- package/lib/premise.js +6 -2
- package/lib/ruleNames.js +5 -1
- package/lib/utilities/node.js +22 -1
- package/lib/utilities/releaseContext.js +6 -8
- package/lib/utilities/tokens.js +8 -1
- package/lib/verify/declaration/metavariable.js +3 -10
- package/lib/verify/files.js +1 -1
- package/lib/verify/release.js +27 -18
- package/package.json +1 -1
- package/src/combinator.js +12 -2
- package/src/conclusion.js +10 -2
- package/src/context/file.js +84 -45
- package/src/context/release.js +120 -47
- package/src/log.js +16 -31
- package/src/metaType.js +5 -3
- package/src/metavariable.js +6 -12
- package/src/premise.js +11 -1
- package/src/ruleNames.js +1 -0
- package/src/utilities/node.js +27 -2
- package/src/utilities/releaseContext.js +6 -8
- package/src/utilities/tokens.js +7 -0
- package/src/verify/declaration/metavariable.js +2 -13
- package/src/verify/files.js +1 -1
- package/src/verify/release.js +30 -18
package/lib/verify/release.js
CHANGED
|
@@ -14,25 +14,34 @@ function _interop_require_default(obj) {
|
|
|
14
14
|
default: obj
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function verifyRelease(releaseName, releaseContextMap) {
|
|
17
|
+
function verifyRelease(releaseName, dependentName, dependentReleased, releaseContextMap) {
|
|
18
18
|
var releaseVerified = false;
|
|
19
19
|
var releaseContext = releaseContextMap[releaseName];
|
|
20
20
|
if (releaseContext !== null) {
|
|
21
|
-
var
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
var released = releaseContext.isReleased();
|
|
22
|
+
if (released) {
|
|
23
|
+
releaseVerified = true;
|
|
24
|
+
} else {
|
|
25
|
+
if (dependentReleased) {
|
|
26
|
+
releaseContext.warning("The '".concat(releaseName, "' project cannot be verified because its '").concat(dependentName, "' dependent is a package."));
|
|
26
27
|
} else {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
var _$dependentName = releaseName, _$dependentReleased = released, dependencyReleasesVVerified = verifyDependencyReleases(releaseContext, _$dependentName, _$dependentReleased, releaseContextMap);
|
|
29
|
+
if (dependencyReleasesVVerified) {
|
|
30
|
+
var verified = releaseContext.isVerified();
|
|
31
|
+
if (verified) {
|
|
32
|
+
releaseVerified = true;
|
|
33
|
+
} else {
|
|
34
|
+
releaseContext.info("Verifying the '".concat(releaseName, "' project..."));
|
|
35
|
+
var releaseFilesVerified = verifyReleaseFiles(releaseContext);
|
|
36
|
+
if (releaseFilesVerified) {
|
|
37
|
+
var verified1 = true;
|
|
38
|
+
releaseContext.setVerified(verified1);
|
|
39
|
+
releaseVerified = verified1; ///
|
|
40
|
+
}
|
|
41
|
+
if (releaseVerified) {
|
|
42
|
+
releaseContext.info("...verified the '".concat(releaseName, "' project."));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
47
|
}
|
|
@@ -43,9 +52,9 @@ function verifyReleaseFiles(releaseContext) {
|
|
|
43
52
|
var filesVerified = (0, _files.default)(releaseContext), releaseFilesVerified = filesVerified; ///
|
|
44
53
|
return releaseFilesVerified;
|
|
45
54
|
}
|
|
46
|
-
function verifyDependencyReleases(releaseContext, releaseContextMap) {
|
|
55
|
+
function verifyDependencyReleases(releaseContext, dependentName, dependentReleased, releaseContextMap) {
|
|
47
56
|
var dependencies = releaseContext.getDependencies(), dependencyReleasesVVerified = dependencies.everyDependency(function(dependency) {
|
|
48
|
-
var name = dependency.getName(), releaseName = name, releaseVerified = verifyRelease(releaseName, releaseContextMap);
|
|
57
|
+
var name = dependency.getName(), releaseName = name, releaseVerified = verifyRelease(releaseName, dependentName, dependentReleased, releaseContextMap);
|
|
49
58
|
if (releaseVerified) {
|
|
50
59
|
return true;
|
|
51
60
|
}
|
|
@@ -53,4 +62,4 @@ function verifyDependencyReleases(releaseContext, releaseContextMap) {
|
|
|
53
62
|
return dependencyReleasesVVerified;
|
|
54
63
|
}
|
|
55
64
|
|
|
56
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
65
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZnkvcmVsZWFzZS5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuaW1wb3J0IHZlcmlmeUZpbGVzIGZyb20gXCIuLi92ZXJpZnkvZmlsZXNcIjtcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gdmVyaWZ5UmVsZWFzZShyZWxlYXNlTmFtZSwgZGVwZW5kZW50TmFtZSwgZGVwZW5kZW50UmVsZWFzZWQsIHJlbGVhc2VDb250ZXh0TWFwKSB7XG4gIGxldCByZWxlYXNlVmVyaWZpZWQgPSBmYWxzZTtcblxuICBjb25zdCByZWxlYXNlQ29udGV4dCA9IHJlbGVhc2VDb250ZXh0TWFwW3JlbGVhc2VOYW1lXTtcblxuICBpZiAocmVsZWFzZUNvbnRleHQgIT09IG51bGwpIHtcbiAgICBjb25zdCByZWxlYXNlZCA9IHJlbGVhc2VDb250ZXh0LmlzUmVsZWFzZWQoKTtcblxuICAgIGlmIChyZWxlYXNlZCkge1xuICAgICAgcmVsZWFzZVZlcmlmaWVkID0gdHJ1ZTtcbiAgICB9IGVsc2Uge1xuICAgICAgaWYgKGRlcGVuZGVudFJlbGVhc2VkKSB7XG4gICAgICAgIHJlbGVhc2VDb250ZXh0Lndhcm5pbmcoYFRoZSAnJHtyZWxl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QUFTSix5QkFBeUJMLGNBQWMsRUFBRUosYUFBYSxFQUFFQyxpQkFBaUIsRUFBRUMsaUJBQWlCO0lBQ25HLElBQU1nQixlQUFlZCxlQUFlZSxlQUFlLElBQzdDWCw4QkFBOEJVLGFBQWFFLGVBQWUsQ0FBQyxTQUFDQztRQUMxRCxJQUFNQyxPQUFPRCxXQUFXRSxPQUFPLElBQ3pCeEIsY0FBY3VCLE1BQ2RuQixrQkFBa0JMLGNBQWNDLGFBQWFDLGVBQWVDLG1CQUFtQkM7UUFFckYsSUFBSUMsaUJBQWlCO1lBQ25CLE9BQU87UUFDVDtJQUNGO0lBRU4sT0FBT0s7QUFDVCJ9
|
package/package.json
CHANGED
package/src/combinator.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
+
import Statement from "./statement";
|
|
4
5
|
import LocalContext from "./context/local";
|
|
5
6
|
|
|
6
7
|
import { nodeQuery } from "./utilities/query";
|
|
8
|
+
import { statementNodeFromStatementString } from "./utilities/node";
|
|
7
9
|
|
|
8
10
|
const statementNodeQuery = nodeQuery("/combinatorDeclaration/statement");
|
|
9
11
|
|
|
@@ -43,9 +45,17 @@ export default class Combinator {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
static fromJSON(json, fileContext) {
|
|
46
|
-
let
|
|
48
|
+
let { statement } = json;
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
const lexer = fileContext.getLexer(),
|
|
51
|
+
parser = fileContext.getParser(),
|
|
52
|
+
statementString = statement, ///
|
|
53
|
+
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
54
|
+
localContext = LocalContext.fromFileContext(fileContext);
|
|
55
|
+
|
|
56
|
+
statement = Statement.fromStatementNode(statementNode, localContext);
|
|
57
|
+
|
|
58
|
+
const combinator = new Combinator(statement);
|
|
49
59
|
|
|
50
60
|
return combinator;
|
|
51
61
|
}
|
package/src/conclusion.js
CHANGED
|
@@ -6,6 +6,7 @@ import UnqualifiedStatement from "./statement/unqualified";
|
|
|
6
6
|
|
|
7
7
|
import { trim } from "./utilities/string";
|
|
8
8
|
import { nodeQuery } from "./utilities/query";
|
|
9
|
+
import { unqualifiedStatementNodeFromUnqualifiedStatementString } from "./utilities/node";
|
|
9
10
|
|
|
10
11
|
const unqualifiedStatementNodeQuery = nodeQuery("/conclusion/unqualifiedStatement");
|
|
11
12
|
|
|
@@ -89,9 +90,16 @@ export default class Conclusion {
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
static fromJSON(json, fileContext) {
|
|
92
|
-
let
|
|
93
|
+
let { unqualifiedStatement } = json;
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
const lexer = fileContext.getLexer(),
|
|
96
|
+
parser = fileContext.getParser(),
|
|
97
|
+
unqualifiedStatementString = unqualifiedStatement, ///
|
|
98
|
+
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, lexer, parser);
|
|
99
|
+
|
|
100
|
+
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext);
|
|
101
|
+
|
|
102
|
+
const conclusion = new Conclusion(fileContext, unqualifiedStatement);
|
|
95
103
|
|
|
96
104
|
return conclusion;
|
|
97
105
|
}
|
package/src/context/file.js
CHANGED
|
@@ -13,16 +13,14 @@ import Combinator from "../combinator";
|
|
|
13
13
|
import Constructor from "../constructor";
|
|
14
14
|
import Metatheorem from "../metatheorem";
|
|
15
15
|
import Metavariable from "../metavariable";
|
|
16
|
-
import topLevelVerifier from "../verifier/topLevel";
|
|
17
16
|
|
|
18
17
|
import { push } from "../utilities/array";
|
|
19
18
|
import { objectType } from "../type";
|
|
20
19
|
import { nodeAsString, nodesAsString } from "../utilities/string";
|
|
21
20
|
|
|
22
21
|
export default class FileContext {
|
|
23
|
-
constructor(releaseContext,
|
|
22
|
+
constructor(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, constructors, metatheorems, metavariables) {
|
|
24
23
|
this.releaseContext = releaseContext;
|
|
25
|
-
this.fileContent = fileContent;
|
|
26
24
|
this.filePath = filePath;
|
|
27
25
|
this.tokens = tokens;
|
|
28
26
|
this.node = node;
|
|
@@ -44,10 +42,6 @@ export default class FileContext {
|
|
|
44
42
|
return this.releaseContext;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
getFileContent() {
|
|
48
|
-
return this.fileContent;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
45
|
getFilePath() {
|
|
52
46
|
return this.filePath;
|
|
53
47
|
}
|
|
@@ -60,6 +54,8 @@ export default class FileContext {
|
|
|
60
54
|
return this.node;
|
|
61
55
|
}
|
|
62
56
|
|
|
57
|
+
getFile(filePath) { return this.releaseContext.getFile(filePath); }
|
|
58
|
+
|
|
63
59
|
getLexer() { return this.releaseContext.getLexer(); }
|
|
64
60
|
|
|
65
61
|
getParser() { return this.releaseContext.getParser(); }
|
|
@@ -288,6 +284,70 @@ export default class FileContext {
|
|
|
288
284
|
return this.metavariables;
|
|
289
285
|
}
|
|
290
286
|
|
|
287
|
+
setReleaseContext(releaseContext) {
|
|
288
|
+
this.releaseContext = releaseContext;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
setFilePath(filePath) {
|
|
292
|
+
this.filePath = filePath;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
setTokens(tokens) {
|
|
296
|
+
this.tokens = tokens;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
setNode(node) {
|
|
300
|
+
this.node = node;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
setTypes(types) {
|
|
304
|
+
this.types = types;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
setRules(rules) {
|
|
308
|
+
this.rules = rules;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
setAxioms(axioms) {
|
|
312
|
+
this.axioms = axioms;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
setLemmas(lemmas) {
|
|
316
|
+
this.lemmas = lemmas;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
setTheorems(theorems) {
|
|
320
|
+
this.theorems = theorems;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
setVariables(variables) {
|
|
324
|
+
this.variables = variables;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
setMetaLemmas(metaLemmas) {
|
|
328
|
+
this.metaLemmas = metaLemmas;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
setConjectures(conjectures) {
|
|
332
|
+
this.conjectures = conjectures;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
setCombinators(combinators) {
|
|
336
|
+
this.combinators = combinators;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
setConstructors(constructors) {
|
|
340
|
+
this.constructors = constructors;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
setMetatheorems(metatheorems) {
|
|
344
|
+
this.metatheorems = metatheorems;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
setMetavariables(metavariables) {
|
|
348
|
+
this.metavariables = metavariables;
|
|
349
|
+
}
|
|
350
|
+
|
|
291
351
|
findTypeByTypeName(typeName) {
|
|
292
352
|
let types = this.getTypes();
|
|
293
353
|
|
|
@@ -615,15 +675,15 @@ export default class FileContext {
|
|
|
615
675
|
return metavariableAdded;
|
|
616
676
|
}
|
|
617
677
|
|
|
618
|
-
trace(message
|
|
678
|
+
trace(message) { this.releaseContext.trace(message, this.filePath); }
|
|
619
679
|
|
|
620
|
-
debug(message
|
|
680
|
+
debug(message) { this.releaseContext.debug(message, this.filePath); }
|
|
621
681
|
|
|
622
|
-
info(message
|
|
682
|
+
info(message) { this.releaseContext.info(message, this.filePath); }
|
|
623
683
|
|
|
624
|
-
warning(message
|
|
684
|
+
warning(message) { this.releaseContext.warning(message, this.filePath); }
|
|
625
685
|
|
|
626
|
-
error(message
|
|
686
|
+
error(message) { this.releaseContext.error(message, this.filePath); }
|
|
627
687
|
|
|
628
688
|
reset() {
|
|
629
689
|
this.types = [];
|
|
@@ -640,30 +700,6 @@ export default class FileContext {
|
|
|
640
700
|
this.metavariables = [];
|
|
641
701
|
}
|
|
642
702
|
|
|
643
|
-
verify() {
|
|
644
|
-
let verified = false;
|
|
645
|
-
|
|
646
|
-
if (this.tokens === null) {
|
|
647
|
-
const lexer = this.getLexer(),
|
|
648
|
-
parser = this.getParser(),
|
|
649
|
-
content = this.fileContent; ///
|
|
650
|
-
|
|
651
|
-
this.tokens = lexer.tokenise(content);
|
|
652
|
-
|
|
653
|
-
this.node = parser.parse(this.tokens);
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
if (this.node !== null) {
|
|
657
|
-
this.reset();
|
|
658
|
-
|
|
659
|
-
const fileContext = this; ///
|
|
660
|
-
|
|
661
|
-
verified = topLevelVerifier.verify(this.node, fileContext);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
return verified;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
703
|
toJSON() {
|
|
668
704
|
const filePath = this.filePath,
|
|
669
705
|
types = this.types.map((type) => {
|
|
@@ -769,8 +805,8 @@ export default class FileContext {
|
|
|
769
805
|
return json;
|
|
770
806
|
}
|
|
771
807
|
|
|
772
|
-
|
|
773
|
-
const { types, rules, axioms, lemmas, theorems, metaLemmas, variables, conjectures, combinators, constructors, metatheorems, metavariables } =
|
|
808
|
+
initialise(fileContextJSON) {
|
|
809
|
+
const { types, rules, axioms, lemmas, theorems, metaLemmas, variables, conjectures, combinators, constructors, metatheorems, metavariables } = fileContextJSON,
|
|
774
810
|
fileContext = this, ///
|
|
775
811
|
typesJSON = types, ///
|
|
776
812
|
rulesJSON = rules, ///
|
|
@@ -871,10 +907,13 @@ export default class FileContext {
|
|
|
871
907
|
}
|
|
872
908
|
|
|
873
909
|
static fromFileAndReleaseContext(file, releaseContext) {
|
|
874
|
-
const
|
|
910
|
+
const lexer = releaseContext.getLexer(),
|
|
911
|
+
parser = releaseContext.getParser(),
|
|
875
912
|
filePath = file.getPath(),
|
|
876
|
-
|
|
877
|
-
|
|
913
|
+
fileContent = file.getContent(),
|
|
914
|
+
content = fileContent, ////
|
|
915
|
+
tokens = lexer.tokenise(content),
|
|
916
|
+
node = parser.parse(tokens),
|
|
878
917
|
types = [],
|
|
879
918
|
rules = [],
|
|
880
919
|
axioms = [],
|
|
@@ -887,7 +926,7 @@ export default class FileContext {
|
|
|
887
926
|
constructors = [],
|
|
888
927
|
metatheorems = [],
|
|
889
928
|
metavariables = [],
|
|
890
|
-
fileContext = new FileContext(releaseContext,
|
|
929
|
+
fileContext = new FileContext(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, variables, metaLemmas, theorems, conjectures, combinators, constructors, metatheorems, metavariables);
|
|
891
930
|
|
|
892
931
|
return fileContext;
|
|
893
932
|
}
|
|
@@ -897,7 +936,7 @@ export default class FileContext {
|
|
|
897
936
|
lexer = releaseContext.getLexer(),
|
|
898
937
|
parser = releaseContext.getParser(),
|
|
899
938
|
fileContent = file.getContent(),
|
|
900
|
-
content = fileContent,
|
|
939
|
+
content = fileContent, ////
|
|
901
940
|
tokens = lexer.tokenise(content),
|
|
902
941
|
node = parser.parse(tokens),
|
|
903
942
|
types = [],
|
|
@@ -912,8 +951,8 @@ export default class FileContext {
|
|
|
912
951
|
constructors = [],
|
|
913
952
|
metatheorems = [],
|
|
914
953
|
metavariables = [],
|
|
915
|
-
fileContext = new FileContext(releaseContext,
|
|
954
|
+
fileContext = new FileContext(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, variables, metaLemmas, theorems, conjectures, combinators, constructors, metatheorems, metavariables);
|
|
916
955
|
|
|
917
956
|
return fileContext;
|
|
918
957
|
}
|
|
919
|
-
}
|
|
958
|
+
}
|
package/src/context/release.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import FileContext from "./file";
|
|
4
|
+
import topLevelVerifier from "../verifier/topLevel";
|
|
5
|
+
|
|
3
6
|
import { filePathUtilities } from "occam-entities";
|
|
4
7
|
import { lexersUtilities, parsersUtilities } from "occam-custom-grammars";
|
|
5
8
|
|
|
6
|
-
import FileContext from "./file";
|
|
7
|
-
|
|
8
9
|
import { objectType } from "../type";
|
|
9
10
|
import { tail, push, leftDifference } from "../utilities/array";
|
|
10
11
|
import { customGrammarFromNameAndEntries, combinedCustomGrammarFromReleaseContexts } from "../utilities/customGrammar";
|
|
11
12
|
|
|
12
|
-
const {
|
|
13
|
+
const { isFilePathNominalFilePath } = filePathUtilities,
|
|
13
14
|
{ nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
14
15
|
{ nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
15
16
|
|
|
16
17
|
export default class ReleaseContext {
|
|
17
|
-
constructor(log, name, json, entries,
|
|
18
|
+
constructor(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts) {
|
|
18
19
|
this.log = log;
|
|
19
20
|
this.name = name;
|
|
20
21
|
this.json = json;
|
|
21
22
|
this.entries = entries;
|
|
22
|
-
this.released = released;
|
|
23
23
|
this.lexer = lexer;
|
|
24
24
|
this.parser = parser;
|
|
25
25
|
this.verified = verified;
|
|
@@ -45,10 +45,6 @@ export default class ReleaseContext {
|
|
|
45
45
|
return this.entries;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
isReleased() {
|
|
49
|
-
return this.released;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
48
|
getLexer() {
|
|
53
49
|
return this.lexer;
|
|
54
50
|
}
|
|
@@ -89,10 +85,6 @@ export default class ReleaseContext {
|
|
|
89
85
|
this.entries = entries;
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
setReleased(released) {
|
|
93
|
-
this.released = released;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
88
|
setLexer(lexer) {
|
|
97
89
|
this.lexer = lexer;
|
|
98
90
|
}
|
|
@@ -121,6 +113,24 @@ export default class ReleaseContext {
|
|
|
121
113
|
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
122
114
|
}
|
|
123
115
|
|
|
116
|
+
findFileContext(filePath) {
|
|
117
|
+
const fileContext = this.fileContexts.find((fileContext) => {
|
|
118
|
+
const fileContextFilePath = fileContext.getFilePath();
|
|
119
|
+
|
|
120
|
+
if (fileContextFilePath === filePath) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return fileContext;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
isReleased() {
|
|
129
|
+
const released = (this.json !== null);
|
|
130
|
+
|
|
131
|
+
return released;
|
|
132
|
+
}
|
|
133
|
+
|
|
124
134
|
getLabels(includeDependencies = true) {
|
|
125
135
|
const labels = [];
|
|
126
136
|
|
|
@@ -400,30 +410,32 @@ export default class ReleaseContext {
|
|
|
400
410
|
|
|
401
411
|
matchShortenedVersion(shortenedVersion) { return this.entries.matchShortenedVersion(shortenedVersion); }
|
|
402
412
|
|
|
403
|
-
trace(message,
|
|
413
|
+
trace(message, filePath = null) { this.log.trace(message, filePath); }
|
|
404
414
|
|
|
405
|
-
debug(message,
|
|
415
|
+
debug(message, filePath = null) { this.log.debug(message, filePath); }
|
|
406
416
|
|
|
407
|
-
info(message,
|
|
417
|
+
info(message, filePath = null) { this.log.info(message, filePath); }
|
|
408
418
|
|
|
409
|
-
warning(message,
|
|
419
|
+
warning(message, filePath = null) { this.log.warning(message, filePath); }
|
|
410
420
|
|
|
411
|
-
error(message,
|
|
421
|
+
error(message, filePath = null) { this.log.error(message, filePath); }
|
|
412
422
|
|
|
413
423
|
initialise(releaseContexts) {
|
|
414
424
|
const combinedCustomGrammar = combinedCustomGrammarFromReleaseContexts(releaseContexts),
|
|
425
|
+
nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
415
426
|
nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
416
|
-
|
|
427
|
+
releaseContext = this, ///
|
|
428
|
+
released = this.isReleased();
|
|
429
|
+
|
|
430
|
+
this.dependencyReleaseContexts = tail(releaseContexts); ///
|
|
417
431
|
|
|
418
432
|
this.lexer = nominalLexer; ///
|
|
419
433
|
|
|
420
434
|
this.parser = nominalParser; ///
|
|
421
435
|
|
|
422
|
-
this.
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
debugger
|
|
426
|
-
}
|
|
436
|
+
this.fileContexts = released ?
|
|
437
|
+
fileContextsFromJSONEntriesAndReleaseContext(this.json, this.entries, releaseContext) :
|
|
438
|
+
fileContextsFromEntriesAndReleaseContext(this.entries, releaseContext);
|
|
427
439
|
|
|
428
440
|
this.initialised = true;
|
|
429
441
|
}
|
|
@@ -431,13 +443,9 @@ export default class ReleaseContext {
|
|
|
431
443
|
verify() {
|
|
432
444
|
let verified = false;
|
|
433
445
|
|
|
434
|
-
const
|
|
435
|
-
fileContexts = fileContextsFromEntries(this.entries, releaseContext),
|
|
436
|
-
fileContextsVerified = verifyFileContexts(fileContexts, releaseContext);
|
|
446
|
+
const fileContextsVerified = verifyFileContexts(this.fileContexts);
|
|
437
447
|
|
|
438
448
|
if (fileContextsVerified) {
|
|
439
|
-
this.fileContexts = fileContexts;
|
|
440
|
-
|
|
441
449
|
this.verified = true;
|
|
442
450
|
|
|
443
451
|
verified = true;
|
|
@@ -457,21 +465,73 @@ export default class ReleaseContext {
|
|
|
457
465
|
return json;
|
|
458
466
|
}
|
|
459
467
|
|
|
460
|
-
static
|
|
468
|
+
static fromLogNameJSONAndEntries(log, name, json, entries) {
|
|
461
469
|
const lexer = null,
|
|
462
470
|
parser = null,
|
|
463
471
|
verified = false,
|
|
464
472
|
initialised = false,
|
|
465
|
-
fileContexts =
|
|
473
|
+
fileContexts = null,
|
|
466
474
|
customGrammar = customGrammarFromNameAndEntries(name, entries),
|
|
467
475
|
dependencyReleaseContexts = null,
|
|
468
|
-
releaseContext = new ReleaseContext(log, name, json, entries,
|
|
476
|
+
releaseContext = new ReleaseContext(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts);
|
|
469
477
|
|
|
470
478
|
return releaseContext;
|
|
471
479
|
}
|
|
472
480
|
}
|
|
473
481
|
|
|
474
|
-
function
|
|
482
|
+
function fileContextsFromJSONEntriesAndReleaseContext(json, entries, releaseContext) {
|
|
483
|
+
const fileContexts = [];
|
|
484
|
+
|
|
485
|
+
entries.forEachFile((file) => {
|
|
486
|
+
const filePath = file.getPath(),
|
|
487
|
+
filePathNominalFilePath = isFilePathNominalFilePath(filePath);
|
|
488
|
+
|
|
489
|
+
if (filePathNominalFilePath) {
|
|
490
|
+
const fileContext = FileContext.fromFileAndReleaseContext(file, releaseContext),
|
|
491
|
+
filePath = fileContext.getFilePath();
|
|
492
|
+
|
|
493
|
+
fileContexts.push(fileContext);
|
|
494
|
+
|
|
495
|
+
const fileContextJSON = findFileContextJSON(json, filePath);
|
|
496
|
+
|
|
497
|
+
fileContext.initialise(fileContextJSON);
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
return fileContexts;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function fileContextsFromEntriesAndReleaseContext(entries, releaseContext) {
|
|
505
|
+
const fileContexts = [];
|
|
506
|
+
|
|
507
|
+
entries.forEachFile((file) => {
|
|
508
|
+
const filePath = file.getPath(),
|
|
509
|
+
filePathNominalFilePath = isFilePathNominalFilePath(filePath);
|
|
510
|
+
|
|
511
|
+
if (filePathNominalFilePath) {
|
|
512
|
+
const fileContext = FileContext.fromFileAndReleaseContext(file, releaseContext);
|
|
513
|
+
|
|
514
|
+
fileContexts.push(fileContext);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
return fileContexts;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function findFileContextJSON(json, filePath) {
|
|
522
|
+
const fileContextsJSON = json, ///
|
|
523
|
+
fileContextJSON = fileContextsJSON.find((fileContextJSON) => {
|
|
524
|
+
const { filePath: fileContextFilePath } = fileContextJSON;
|
|
525
|
+
|
|
526
|
+
if (fileContextFilePath === filePath) {
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
return fileContextJSON;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function verifyFileContexts(fileContexts) {
|
|
475
535
|
let fileContextsVerified;
|
|
476
536
|
|
|
477
537
|
fileContexts = [ ///
|
|
@@ -488,9 +548,9 @@ function verifyFileContexts(fileContexts, releaseContext) {
|
|
|
488
548
|
const verifiedFileContexts = [];
|
|
489
549
|
|
|
490
550
|
fileContexts.forEach((fileContext) => {
|
|
491
|
-
const
|
|
551
|
+
const fileContextVerified = verifyFileContext(fileContext);
|
|
492
552
|
|
|
493
|
-
if (
|
|
553
|
+
if (fileContextVerified) {
|
|
494
554
|
const verifiedFileContext = fileContext; ///
|
|
495
555
|
|
|
496
556
|
verifiedFileContexts.push(verifiedFileContext);
|
|
@@ -498,7 +558,7 @@ function verifyFileContexts(fileContexts, releaseContext) {
|
|
|
498
558
|
});
|
|
499
559
|
|
|
500
560
|
const verifiedFileContextsLength = verifiedFileContexts.length,
|
|
501
|
-
|
|
561
|
+
fileVerified = (verifiedFileContextsLength > 0);
|
|
502
562
|
|
|
503
563
|
if (!fileVerified) {
|
|
504
564
|
break;
|
|
@@ -514,19 +574,32 @@ function verifyFileContexts(fileContexts, releaseContext) {
|
|
|
514
574
|
return fileContextsVerified;
|
|
515
575
|
}
|
|
516
576
|
|
|
517
|
-
function
|
|
518
|
-
|
|
577
|
+
function verifyFileContext(fileContext) {
|
|
578
|
+
let fileContextVerified = false;
|
|
519
579
|
|
|
520
|
-
|
|
521
|
-
const filePath = file.getPath(),
|
|
522
|
-
filePathFlorenceFilePath = isFilePathFlorenceFilePath(filePath);
|
|
580
|
+
const tokens = fileContext.getTokens();
|
|
523
581
|
|
|
524
|
-
|
|
525
|
-
|
|
582
|
+
if (tokens === null) {
|
|
583
|
+
const filePath = fileContext.getFilePath(),
|
|
584
|
+
file = fileContext.getFile(filePath),
|
|
585
|
+
lexer = fileContext.getLexer(),
|
|
586
|
+
parser = fileContext.getParser(),
|
|
587
|
+
content = file.getContent(),
|
|
588
|
+
tokens = lexer.tokenise(content),
|
|
589
|
+
node = parser.parse(tokens);
|
|
526
590
|
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
});
|
|
591
|
+
fileContext.setTokens(tokens);
|
|
530
592
|
|
|
531
|
-
|
|
593
|
+
fileContext.setNode(node);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
const node = fileContext.getNode();
|
|
597
|
+
|
|
598
|
+
if (node !== null) {
|
|
599
|
+
fileContext.reset();
|
|
600
|
+
|
|
601
|
+
fileContextVerified = topLevelVerifier.verify(node, fileContext);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return fileContextVerified;
|
|
532
605
|
}
|