occam-verify-cli 0.0.1005 → 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 +10 -5
- package/lib/combinator.js +7 -3
- package/lib/conclusion.js +10 -6
- package/lib/context/file.js +134 -57
- package/lib/context/release.js +97 -119
- package/lib/log.js +15 -25
- package/lib/metaType.js +6 -4
- package/lib/metavariable.js +9 -15
- package/lib/premise.js +9 -4
- package/lib/ruleNames.js +5 -1
- package/lib/supposition.js +6 -7
- package/lib/utilities/node.js +22 -1
- package/lib/utilities/releaseContext.js +7 -10
- 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 +15 -5
- package/src/context/file.js +84 -45
- package/src/context/release.js +120 -134
- package/src/log.js +16 -31
- package/src/metaType.js +5 -3
- package/src/metavariable.js +6 -12
- package/src/premise.js +15 -3
- package/src/ruleNames.js +1 -0
- package/src/supposition.js +6 -11
- package/src/utilities/node.js +27 -2
- package/src/utilities/releaseContext.js +8 -13
- 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/context/release.other.js +0 -605
- package/src/context/release.other.js +0 -547
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,31 +1,31 @@
|
|
|
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,
|
|
18
|
+
constructor(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts) {
|
|
18
19
|
this.log = log;
|
|
19
20
|
this.name = name;
|
|
21
|
+
this.json = json;
|
|
20
22
|
this.entries = entries;
|
|
21
|
-
this.released = released;
|
|
22
23
|
this.lexer = lexer;
|
|
23
24
|
this.parser = parser;
|
|
24
25
|
this.verified = verified;
|
|
25
26
|
this.initialised = initialised;
|
|
26
27
|
this.fileContexts = fileContexts;
|
|
27
28
|
this.customGrammar = customGrammar;
|
|
28
|
-
this.loggingDisabled = loggingDisabled;
|
|
29
29
|
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -37,12 +37,12 @@ export default class ReleaseContext {
|
|
|
37
37
|
return this.name;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
return this.
|
|
40
|
+
getJSON() {
|
|
41
|
+
return this.json;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
return this.
|
|
44
|
+
getEntries() {
|
|
45
|
+
return this.entries;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
getLexer() {
|
|
@@ -69,10 +69,6 @@ export default class ReleaseContext {
|
|
|
69
69
|
return this.customGrammar;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
isLoggingDisabled() {
|
|
73
|
-
return this.loggingDisabled;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
72
|
getDependencyReleaseContexts() {
|
|
77
73
|
return this.dependencyReleaseContexts;
|
|
78
74
|
}
|
|
@@ -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
|
}
|
|
@@ -117,14 +109,28 @@ export default class ReleaseContext {
|
|
|
117
109
|
this.customGrammar = customGrammar;
|
|
118
110
|
}
|
|
119
111
|
|
|
120
|
-
setLoggingDisabled(loggingDisabled) {
|
|
121
|
-
this.loggingDisabled = loggingDisabled;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
112
|
setDependencyReleaseContexts(dependencyReleaseContexts) {
|
|
125
113
|
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
126
114
|
}
|
|
127
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
|
+
|
|
128
134
|
getLabels(includeDependencies = true) {
|
|
129
135
|
const labels = [];
|
|
130
136
|
|
|
@@ -404,77 +410,32 @@ export default class ReleaseContext {
|
|
|
404
410
|
|
|
405
411
|
matchShortenedVersion(shortenedVersion) { return this.entries.matchShortenedVersion(shortenedVersion); }
|
|
406
412
|
|
|
407
|
-
|
|
408
|
-
const loggingDisabled = true;
|
|
409
|
-
|
|
410
|
-
this.setLoggingDisabled(loggingDisabled);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
enableLogging() {
|
|
414
|
-
const loggingDisabled = false;
|
|
413
|
+
trace(message, filePath = null) { this.log.trace(message, filePath); }
|
|
415
414
|
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
trace(message, node = null, tokens = null, filePath = null) {
|
|
420
|
-
if (this.loggingDisabled) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
this.log.trace(message, node, tokens, filePath);
|
|
425
|
-
}
|
|
415
|
+
debug(message, filePath = null) { this.log.debug(message, filePath); }
|
|
426
416
|
|
|
427
|
-
|
|
428
|
-
if (this.loggingDisabled) {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
417
|
+
info(message, filePath = null) { this.log.info(message, filePath); }
|
|
431
418
|
|
|
432
|
-
|
|
433
|
-
}
|
|
419
|
+
warning(message, filePath = null) { this.log.warning(message, filePath); }
|
|
434
420
|
|
|
435
|
-
|
|
436
|
-
if (this.loggingDisabled) {
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
this.log.info(message, node, tokens, filePath);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
warning(message, node = null, tokens = null, filePath = null) {
|
|
444
|
-
if (this.loggingDisabled) {
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
this.log.warning(message, node, tokens, filePath);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
error(message, node = null, tokens = null, filePath = null) {
|
|
452
|
-
if (this.loggingDisabled) {
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
this.log.error(message, node, tokens, filePath);
|
|
457
|
-
}
|
|
421
|
+
error(message, filePath = null) { this.log.error(message, filePath); }
|
|
458
422
|
|
|
459
423
|
initialise(releaseContexts) {
|
|
460
424
|
const combinedCustomGrammar = combinedCustomGrammarFromReleaseContexts(releaseContexts),
|
|
425
|
+
nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
461
426
|
nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
462
|
-
|
|
427
|
+
releaseContext = this, ///
|
|
428
|
+
released = this.isReleased();
|
|
429
|
+
|
|
430
|
+
this.dependencyReleaseContexts = tail(releaseContexts); ///
|
|
463
431
|
|
|
464
432
|
this.lexer = nominalLexer; ///
|
|
465
433
|
|
|
466
434
|
this.parser = nominalParser; ///
|
|
467
435
|
|
|
468
|
-
this.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const releaseContext = this, ///
|
|
472
|
-
fileContexts = fileContextsFromEntries(this.entries, releaseContext);
|
|
473
|
-
|
|
474
|
-
initialiseFileContexts(fileContexts, releaseContext);
|
|
475
|
-
|
|
476
|
-
this.fileContexts = fileContexts;
|
|
477
|
-
}
|
|
436
|
+
this.fileContexts = released ?
|
|
437
|
+
fileContextsFromJSONEntriesAndReleaseContext(this.json, this.entries, releaseContext) :
|
|
438
|
+
fileContextsFromEntriesAndReleaseContext(this.entries, releaseContext);
|
|
478
439
|
|
|
479
440
|
this.initialised = true;
|
|
480
441
|
}
|
|
@@ -482,13 +443,9 @@ export default class ReleaseContext {
|
|
|
482
443
|
verify() {
|
|
483
444
|
let verified = false;
|
|
484
445
|
|
|
485
|
-
const
|
|
486
|
-
fileContexts = fileContextsFromEntries(this.entries, releaseContext),
|
|
487
|
-
fileContextsVerified = verifyFileContexts(fileContexts, releaseContext);
|
|
446
|
+
const fileContextsVerified = verifyFileContexts(this.fileContexts);
|
|
488
447
|
|
|
489
448
|
if (fileContextsVerified) {
|
|
490
|
-
this.fileContexts = fileContexts;
|
|
491
|
-
|
|
492
449
|
this.verified = true;
|
|
493
450
|
|
|
494
451
|
verified = true;
|
|
@@ -508,22 +465,73 @@ export default class ReleaseContext {
|
|
|
508
465
|
return json;
|
|
509
466
|
}
|
|
510
467
|
|
|
511
|
-
static
|
|
468
|
+
static fromLogNameJSONAndEntries(log, name, json, entries) {
|
|
512
469
|
const lexer = null,
|
|
513
470
|
parser = null,
|
|
514
471
|
verified = false,
|
|
515
472
|
initialised = false,
|
|
516
|
-
fileContexts =
|
|
473
|
+
fileContexts = null,
|
|
517
474
|
customGrammar = customGrammarFromNameAndEntries(name, entries),
|
|
518
|
-
loggingDisabled = false,
|
|
519
475
|
dependencyReleaseContexts = null,
|
|
520
|
-
releaseContext = new ReleaseContext(log, name,
|
|
476
|
+
releaseContext = new ReleaseContext(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts);
|
|
521
477
|
|
|
522
478
|
return releaseContext;
|
|
523
479
|
}
|
|
524
480
|
}
|
|
525
481
|
|
|
526
|
-
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) {
|
|
527
535
|
let fileContextsVerified;
|
|
528
536
|
|
|
529
537
|
fileContexts = [ ///
|
|
@@ -540,9 +548,9 @@ function verifyFileContexts(fileContexts, releaseContext) {
|
|
|
540
548
|
const verifiedFileContexts = [];
|
|
541
549
|
|
|
542
550
|
fileContexts.forEach((fileContext) => {
|
|
543
|
-
const
|
|
551
|
+
const fileContextVerified = verifyFileContext(fileContext);
|
|
544
552
|
|
|
545
|
-
if (
|
|
553
|
+
if (fileContextVerified) {
|
|
546
554
|
const verifiedFileContext = fileContext; ///
|
|
547
555
|
|
|
548
556
|
verifiedFileContexts.push(verifiedFileContext);
|
|
@@ -550,7 +558,7 @@ function verifyFileContexts(fileContexts, releaseContext) {
|
|
|
550
558
|
});
|
|
551
559
|
|
|
552
560
|
const verifiedFileContextsLength = verifiedFileContexts.length,
|
|
553
|
-
|
|
561
|
+
fileVerified = (verifiedFileContextsLength > 0);
|
|
554
562
|
|
|
555
563
|
if (!fileVerified) {
|
|
556
564
|
break;
|
|
@@ -566,54 +574,32 @@ function verifyFileContexts(fileContexts, releaseContext) {
|
|
|
566
574
|
return fileContextsVerified;
|
|
567
575
|
}
|
|
568
576
|
|
|
569
|
-
function
|
|
570
|
-
|
|
571
|
-
...fileContexts
|
|
572
|
-
];
|
|
573
|
-
|
|
574
|
-
for (;;) {
|
|
575
|
-
const fileContextsLength = fileContexts.length;
|
|
576
|
-
|
|
577
|
-
if (fileContextsLength === 0) {
|
|
578
|
-
break;
|
|
579
|
-
}
|
|
577
|
+
function verifyFileContext(fileContext) {
|
|
578
|
+
let fileContextVerified = false;
|
|
580
579
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
fileContexts.forEach((fileContext) => {
|
|
584
|
-
const initialised = fileContext.initialise(releaseContext);
|
|
585
|
-
|
|
586
|
-
if (initialised) {
|
|
587
|
-
const initialisedFileContext = fileContext; ///
|
|
588
|
-
|
|
589
|
-
initialisedFileContexts.push(initialisedFileContext);
|
|
590
|
-
}
|
|
591
|
-
});
|
|
580
|
+
const tokens = fileContext.getTokens();
|
|
592
581
|
|
|
593
|
-
|
|
594
|
-
|
|
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);
|
|
595
590
|
|
|
596
|
-
|
|
597
|
-
break;
|
|
598
|
-
}
|
|
591
|
+
fileContext.setTokens(tokens);
|
|
599
592
|
|
|
600
|
-
|
|
593
|
+
fileContext.setNode(node);
|
|
601
594
|
}
|
|
602
|
-
}
|
|
603
595
|
|
|
604
|
-
|
|
605
|
-
const fileContexts = [];
|
|
606
|
-
|
|
607
|
-
entries.forEachFile((file) => {
|
|
608
|
-
const filePath = file.getPath(),
|
|
609
|
-
filePathFlorenceFilePath = isFilePathFlorenceFilePath(filePath);
|
|
596
|
+
const node = fileContext.getNode();
|
|
610
597
|
|
|
611
|
-
|
|
612
|
-
|
|
598
|
+
if (node !== null) {
|
|
599
|
+
fileContext.reset();
|
|
613
600
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
});
|
|
601
|
+
fileContextVerified = topLevelVerifier.verify(node, fileContext);
|
|
602
|
+
}
|
|
617
603
|
|
|
618
|
-
return
|
|
604
|
+
return fileContextVerified;
|
|
619
605
|
}
|
package/src/log.js
CHANGED
|
@@ -25,37 +25,37 @@ export default class Log {
|
|
|
25
25
|
return this.follow;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
trace(message,
|
|
28
|
+
trace(message, filePath) {
|
|
29
29
|
const level = TRACE_LEVEL;
|
|
30
30
|
|
|
31
|
-
this.write(level, message,
|
|
31
|
+
this.write(level, message, filePath);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
debug(message,
|
|
34
|
+
debug(message, filePath) {
|
|
35
35
|
const level = DEBUG_LEVEL;
|
|
36
36
|
|
|
37
|
-
this.write(level, message,
|
|
37
|
+
this.write(level, message, filePath);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
info(message,
|
|
40
|
+
info(message, filePath) {
|
|
41
41
|
const level = INFO_LEVEL;
|
|
42
42
|
|
|
43
|
-
this.write(level, message,
|
|
43
|
+
this.write(level, message, filePath);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
warning(message,
|
|
46
|
+
warning(message, filePath) {
|
|
47
47
|
const level = WARNING_LEVEL;
|
|
48
48
|
|
|
49
|
-
this.write(level, message,
|
|
49
|
+
this.write(level, message, filePath);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
error(message,
|
|
52
|
+
error(message, filePath) {
|
|
53
53
|
const level = ERROR_LEVEL;
|
|
54
54
|
|
|
55
|
-
this.write(level, message,
|
|
55
|
+
this.write(level, message, filePath);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
write(level, message,
|
|
58
|
+
write(level, message, filePath) {
|
|
59
59
|
const levels = [
|
|
60
60
|
TRACE_LEVEL,
|
|
61
61
|
DEBUG_LEVEL,
|
|
@@ -70,7 +70,7 @@ export default class Log {
|
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
message = formatMessage(level, message,
|
|
73
|
+
message = formatMessage(level, message, filePath); ///
|
|
74
74
|
|
|
75
75
|
this.follow ?
|
|
76
76
|
console.log(message) :
|
|
@@ -96,27 +96,12 @@ export default class Log {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
function formatMessage(level, message,
|
|
99
|
+
function formatMessage(level, message, filePath = null) {
|
|
100
100
|
const upperCaseLevel = level.toUpperCase();
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
`${upperCaseLevel}: ${
|
|
105
|
-
`${upperCaseLevel}: ${message}`;
|
|
106
|
-
} else {
|
|
107
|
-
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, tokens),
|
|
108
|
-
leastLineNumber = leastLineIndex, ///
|
|
109
|
-
greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, tokens),
|
|
110
|
-
greatestLineNumber = greatestLineIndex; ///
|
|
111
|
-
|
|
112
|
-
if (leastLineNumber === greatestLineNumber) {
|
|
113
|
-
const lineNumber = leastLineNumber; ///
|
|
114
|
-
|
|
115
|
-
message = `${upperCaseLevel}: ${filePath} (${lineNumber}) - ${message}`;
|
|
116
|
-
} else {
|
|
117
|
-
message = `${upperCaseLevel}: ${filePath} (${leastLineNumber}-${greatestLineNumber}) - ${message}`;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
102
|
+
message = (filePath !== null) ?
|
|
103
|
+
`${upperCaseLevel}: ${filePath} - ${message}`:
|
|
104
|
+
`${upperCaseLevel}: ${message}`;
|
|
120
105
|
|
|
121
106
|
return message;
|
|
122
107
|
}
|