@eagleoutice/flowr 2.10.10 → 2.11.0
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/README.md +37 -29
- package/cli/common/options.d.ts +2 -108
- package/cli/common/options.js +3 -27
- package/cli/common/scripts-info.d.ts +2 -123
- package/cli/common/scripts-info.js +0 -17
- package/cli/flowr-main-options.d.ts +5 -0
- package/cli/flowr-main-options.js +10 -0
- package/cli/flowr.js +1 -1
- package/cli/repl/print-version.d.ts +3 -1
- package/cli/repl/print-version.js +21 -2
- package/cli/repl/server/connection.d.ts +2 -0
- package/cli/repl/server/connection.js +40 -31
- package/cli/script-core/summarizer-core.js +13 -32
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +2 -0
- package/config.d.ts +13 -0
- package/config.js +8 -0
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/dataflow/environments/append.d.ts +1 -2
- package/dataflow/environments/append.js +3 -10
- package/dataflow/environments/apply-kill.d.ts +21 -0
- package/dataflow/environments/apply-kill.js +155 -0
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +63 -3
- package/dataflow/environments/default-builtin-config.js +40 -8
- package/dataflow/environments/environment.d.ts +49 -32
- package/dataflow/environments/environment.js +133 -18
- package/dataflow/environments/identifier.d.ts +10 -0
- package/dataflow/environments/identifier.js +23 -0
- package/dataflow/environments/overwrite.js +2 -10
- package/dataflow/environments/resolve-by-name.d.ts +1 -1
- package/dataflow/environments/resolve-by-name.js +10 -2
- package/dataflow/environments/scoping.d.ts +9 -2
- package/dataflow/environments/scoping.js +15 -2
- package/dataflow/extractor.js +23 -2
- package/dataflow/graph/df-helper.d.ts +8 -0
- package/dataflow/graph/df-helper.js +8 -0
- package/dataflow/graph/graph.d.ts +4 -1
- package/dataflow/graph/graph.js +5 -1
- package/dataflow/info.d.ts +26 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +131 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +10 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +17 -0
- package/documentation/data/faq/faqs.js +3 -0
- package/documentation/data/interface/doc-writing-code.js +4 -80
- package/documentation/doc-util/doc-structure.js +1 -2
- package/documentation/wiki-core.js +2 -1
- package/documentation/wiki-dataflow-graph.js +35 -1
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.js +2 -0
- package/documentation/wiki-overview.js +1 -14
- package/documentation/wiki-package-database.d.ts +9 -0
- package/documentation/wiki-package-database.js +63 -0
- package/documentation/wiki-query.js +1 -0
- package/linter/linter-rules.d.ts +23 -0
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.js +2 -1
- package/linter/rules/undefined-symbol.d.ts +39 -0
- package/linter/rules/undefined-symbol.js +80 -0
- package/package.json +3 -4
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +9 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
- package/project/context/flowr-analyzer-dependencies-context.js +36 -4
- package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
- package/project/context/flowr-analyzer-environment-context.js +3 -4
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-file.d.ts +2 -0
- package/project/context/flowr-file.js +2 -0
- package/project/flowr-analyzer-builder.js +3 -0
- package/project/flowr-analyzer.d.ts +2 -1
- package/project/flowr-analyzer.js +3 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
- package/project/plugins/package-version-plugins/package.d.ts +3 -0
- package/project/plugins/package-version-plugins/package.js +12 -0
- package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
- package/project/plugins/package-version-plugins/pkgdb.js +370 -0
- package/project/plugins/plugin-registry.d.ts +4 -1
- package/project/plugins/plugin-registry.js +7 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +8 -0
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
- package/queries/catalog/linter-query/linter-query-executor.js +1 -0
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
- package/search/search-executor/search-enrichers.d.ts +1 -1
- package/search/search-executor/search-enrichers.js +7 -4
- package/util/mermaid/mermaid.d.ts +4 -0
- package/util/mermaid/mermaid.js +8 -1
- package/util/version.js +10 -2
- package/cli/common/features.d.ts +0 -9
- package/cli/common/features.js +0 -35
- package/cli/script-core/statistics-core.d.ts +0 -6
- package/cli/script-core/statistics-core.js +0 -104
- package/cli/script-core/statistics-helper-core.d.ts +0 -6
- package/cli/script-core/statistics-helper-core.js +0 -86
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -16
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -14
- package/statistics/features/common-syntax-probability.d.ts +0 -38
- package/statistics/features/common-syntax-probability.js +0 -169
- package/statistics/features/feature.d.ts +0 -179
- package/statistics/features/feature.js +0 -38
- package/statistics/features/post-processing.d.ts +0 -18
- package/statistics/features/post-processing.js +0 -26
- package/statistics/features/supported/assignments/assignments.d.ts +0 -12
- package/statistics/features/supported/assignments/assignments.js +0 -56
- package/statistics/features/supported/assignments/post-process.d.ts +0 -6
- package/statistics/features/supported/assignments/post-process.js +0 -126
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -143
- package/statistics/features/supported/comments/post-process.d.ts +0 -6
- package/statistics/features/supported/comments/post-process.js +0 -51
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -69
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
- package/statistics/features/supported/control-flow/post-process.js +0 -66
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -122
- package/statistics/features/supported/data-access/post-process.d.ts +0 -6
- package/statistics/features/supported/data-access/post-process.js +0 -108
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -168
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
- package/statistics/features/supported/expression-list/post-process.js +0 -45
- package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -81
- package/statistics/features/supported/loops/post-process.d.ts +0 -6
- package/statistics/features/supported/loops/post-process.js +0 -73
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -176
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -99
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
- package/statistics/features/supported/used-packages/post-process.js +0 -122
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -140
- package/statistics/features/supported/values/post-process.d.ts +0 -6
- package/statistics/features/supported/values/post-process.js +0 -73
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -111
- package/statistics/features/supported/variables/post-process.d.ts +0 -15
- package/statistics/features/supported/variables/post-process.js +0 -126
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -62
- package/statistics/meta-statistics.d.ts +0 -32
- package/statistics/meta-statistics.js +0 -16
- package/statistics/output/file-provider.d.ts +0 -36
- package/statistics/output/file-provider.js +0 -96
- package/statistics/output/print-stats.d.ts +0 -29
- package/statistics/output/print-stats.js +0 -81
- package/statistics/output/statistics-file.d.ts +0 -36
- package/statistics/output/statistics-file.js +0 -68
- package/statistics/statistics.d.ts +0 -29
- package/statistics/statistics.js +0 -108
- package/statistics/summarizer/auto-detect.d.ts +0 -5
- package/statistics/summarizer/auto-detect.js +0 -34
- package/statistics/summarizer/first-phase/process.d.ts +0 -6
- package/statistics/summarizer/first-phase/process.js +0 -81
- package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
- package/statistics/summarizer/post-process/clusterer.js +0 -40
- package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
- package/statistics/summarizer/post-process/file-based-count.js +0 -47
- package/statistics/summarizer/post-process/histogram.d.ts +0 -57
- package/statistics/summarizer/post-process/histogram.js +0 -126
- package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
- package/statistics/summarizer/post-process/post-process-output.js +0 -102
- package/statistics/summarizer/second-phase/process.d.ts +0 -15
- package/statistics/summarizer/second-phase/process.js +0 -118
- package/statistics/summarizer/summarizer.d.ts +0 -34
- package/statistics/summarizer/summarizer.js +0 -141
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Feature } from '../../feature';
|
|
2
|
-
import type { Writable } from 'ts-essentials';
|
|
3
|
-
declare const initialValueInfo: {
|
|
4
|
-
allNumerics: number;
|
|
5
|
-
imaginaryNumbers: number;
|
|
6
|
-
integers: number;
|
|
7
|
-
floatHex: number;
|
|
8
|
-
logical: number;
|
|
9
|
-
specialConstants: number;
|
|
10
|
-
strings: number;
|
|
11
|
-
};
|
|
12
|
-
export type ValueInfo = Writable<typeof initialValueInfo>;
|
|
13
|
-
export declare const values: Feature<ValueInfo>;
|
|
14
|
-
export {};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.values = void 0;
|
|
37
|
-
const xpath = __importStar(require("xpath-ts2"));
|
|
38
|
-
const post_process_1 = require("./post-process");
|
|
39
|
-
const assert_1 = require("../../../../util/assert");
|
|
40
|
-
const convert_values_1 = require("../../../../r-bridge/lang-4.x/convert-values");
|
|
41
|
-
const statistics_file_1 = require("../../../output/statistics-file");
|
|
42
|
-
const initialValueInfo = {
|
|
43
|
-
allNumerics: 0,
|
|
44
|
-
imaginaryNumbers: 0,
|
|
45
|
-
integers: 0,
|
|
46
|
-
floatHex: 0,
|
|
47
|
-
logical: 0,
|
|
48
|
-
specialConstants: 0,
|
|
49
|
-
strings: 0
|
|
50
|
-
};
|
|
51
|
-
const numericConstantQuery = xpath.parse('//NUM_CONST');
|
|
52
|
-
const stringConstantQuery = xpath.parse('//STR_CONST');
|
|
53
|
-
const specialConstantsQuery = xpath.parse('//NULL_CONST');
|
|
54
|
-
const shortLogicalSymbolQuery = xpath.parse('//SYMBOL[text() = \'T\' or text() = \'F\']');
|
|
55
|
-
function classifyNumericConstants(numeric, existing) {
|
|
56
|
-
if (numeric === convert_values_1.RTrue || numeric === convert_values_1.RFalse) {
|
|
57
|
-
return 'logical';
|
|
58
|
-
}
|
|
59
|
-
if (numeric === convert_values_1.RNa || numeric === 'NaN' || numeric === convert_values_1.RNull || numeric === 'Inf' || numeric === '-Inf') {
|
|
60
|
-
return 'special-constants';
|
|
61
|
-
}
|
|
62
|
-
if (numeric.includes('i')) {
|
|
63
|
-
existing.imaginaryNumbers++;
|
|
64
|
-
}
|
|
65
|
-
else if (numeric.endsWith('L')) {
|
|
66
|
-
existing.integers++;
|
|
67
|
-
}
|
|
68
|
-
else if (convert_values_1.RNumHexFloatRegex.test(numeric)) {
|
|
69
|
-
existing.floatHex++;
|
|
70
|
-
}
|
|
71
|
-
return 'allNumerics';
|
|
72
|
-
}
|
|
73
|
-
exports.values = {
|
|
74
|
-
name: 'Values',
|
|
75
|
-
description: 'All values used (as constants etc.)',
|
|
76
|
-
process(existing, input) {
|
|
77
|
-
const strings = stringConstantQuery.select({ node: input.parsedRAst });
|
|
78
|
-
const numerics = numericConstantQuery.select({ node: input.parsedRAst });
|
|
79
|
-
const specialConstants = specialConstantsQuery.select({ node: input.parsedRAst });
|
|
80
|
-
const specialLogicalSymbols = shortLogicalSymbolQuery.select({ node: input.parsedRAst });
|
|
81
|
-
const numbers = [];
|
|
82
|
-
numerics.map(n => [n, classifyNumericConstants(n.textContent ?? '<unknown>', existing)])
|
|
83
|
-
.forEach(([n, type]) => {
|
|
84
|
-
switch (type) {
|
|
85
|
-
case 'allNumerics':
|
|
86
|
-
numbers.push(n);
|
|
87
|
-
break;
|
|
88
|
-
case 'logical':
|
|
89
|
-
specialLogicalSymbols.push(n);
|
|
90
|
-
break;
|
|
91
|
-
case 'special-constants':
|
|
92
|
-
specialConstants.push(n);
|
|
93
|
-
break;
|
|
94
|
-
default:
|
|
95
|
-
(0, assert_1.assertUnreachable)(type);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
existing.strings += strings.length;
|
|
99
|
-
existing.allNumerics += numerics.length;
|
|
100
|
-
existing.specialConstants += specialConstants.length;
|
|
101
|
-
existing.logical += specialLogicalSymbols.length;
|
|
102
|
-
(0, statistics_file_1.appendStatisticsFile)(this.name, 'numeric', numbers, input.filepath);
|
|
103
|
-
(0, statistics_file_1.appendStatisticsFile)(this.name, 'string', strings, input.filepath);
|
|
104
|
-
(0, statistics_file_1.appendStatisticsFile)(this.name, 'specialConstant', specialConstants, input.filepath);
|
|
105
|
-
(0, statistics_file_1.appendStatisticsFile)(this.name, 'logical', specialLogicalSymbols, input.filepath);
|
|
106
|
-
return existing;
|
|
107
|
-
},
|
|
108
|
-
initialValue: initialValueInfo,
|
|
109
|
-
postProcess: post_process_1.postProcess
|
|
110
|
-
};
|
|
111
|
-
//# sourceMappingURL=values.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { FeatureStatisticsWithMeta } from '../../feature';
|
|
2
|
-
import { type SummarizedWithProject } from '../../post-processing';
|
|
3
|
-
import type { StatisticsSummarizerConfiguration } from '../../../summarizer/summarizer';
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
|
|
8
|
-
type VariableInfoMap = Map<string, SummarizedWithProject & {
|
|
9
|
-
linePercentageInFile: number[][];
|
|
10
|
-
}>;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export declare function writeVariableInfoToCsv(outputPath: string, filename: `${string}.csv`, data: VariableInfoMap): void;
|
|
15
|
-
export {};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.postProcess = postProcess;
|
|
7
|
-
exports.writeVariableInfoToCsv = writeVariableInfoToCsv;
|
|
8
|
-
const post_processing_1 = require("../../post-processing");
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const summarizer_1 = require("../../../../util/summarizer");
|
|
12
|
-
const files_1 = require("../../../../util/files");
|
|
13
|
-
function collectUsedVariables(featureRoot, info, config, outputPath) {
|
|
14
|
-
const used = collectVariableInfoFor(path_1.default.join(featureRoot, 'usedVariables.txt'), info, config);
|
|
15
|
-
writeVariableInfoToCsv(outputPath, 'used-variables.csv', used);
|
|
16
|
-
// we manually clear these maps to save memory
|
|
17
|
-
used.clear();
|
|
18
|
-
}
|
|
19
|
-
function collectDefinedVariables(featureRoot, info, config, outputPath) {
|
|
20
|
-
const defined = collectVariableInfoFor(path_1.default.join(featureRoot, 'definedVariables.txt'), info, config);
|
|
21
|
-
writeVariableInfoToCsv(outputPath, 'defined-variables.csv', defined);
|
|
22
|
-
defined.clear();
|
|
23
|
-
}
|
|
24
|
-
function collectRedefinedVariables(featureRoot, info, config, outputPath) {
|
|
25
|
-
const redefined = collectVariableInfoFor(path_1.default.join(featureRoot, 'redefinedVariables.txt'), info, config);
|
|
26
|
-
writeVariableInfoToCsv(outputPath, 'redefined-variables.csv', redefined);
|
|
27
|
-
redefined.clear();
|
|
28
|
-
}
|
|
29
|
-
function writeVariableCountsToCsv(outputPath, collected) {
|
|
30
|
-
const variablesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'variable-counts.csv'));
|
|
31
|
-
variablesOutStream.write(`kind,unique-projects,unique-files,${(0, summarizer_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
32
|
-
for (const [key, val] of Object.entries(collected)) {
|
|
33
|
-
if (key === 'unknownVariables') {
|
|
34
|
-
// they are for function calls etc and in hindsight not a good idea
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
const data = val;
|
|
38
|
-
const sum = (0, summarizer_1.summarizeMeasurement)(data.count);
|
|
39
|
-
variablesOutStream.write(`${JSON.stringify(key)},${data.uniqueProjects.size},${data.uniqueFiles.size},${(0, summarizer_1.summarizedMeasurement2Csv)(sum)}\n`);
|
|
40
|
-
}
|
|
41
|
-
variablesOutStream.close();
|
|
42
|
-
}
|
|
43
|
-
function collectInformation(info, config) {
|
|
44
|
-
const collected = {};
|
|
45
|
-
for (const [filepath, data] of info.entries()) {
|
|
46
|
-
const value = data.variables;
|
|
47
|
-
for (const [key, val] of Object.entries(value)) {
|
|
48
|
-
let get = collected[key];
|
|
49
|
-
if (!get) {
|
|
50
|
-
get = (0, post_processing_1.emptySummarizedWithProject)();
|
|
51
|
-
collected[key] = get;
|
|
52
|
-
}
|
|
53
|
-
get.count.push(val);
|
|
54
|
-
if (val > 0) {
|
|
55
|
-
(0, post_processing_1.recordFilePath)(get, filepath, config);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return collected;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
function postProcess(featureRoot, info, outputPath, config) {
|
|
65
|
-
const collected = collectInformation(info, config);
|
|
66
|
-
writeVariableCountsToCsv(outputPath, collected);
|
|
67
|
-
collectUsedVariables(featureRoot, info, config, outputPath);
|
|
68
|
-
collectDefinedVariables(featureRoot, info, config, outputPath);
|
|
69
|
-
collectRedefinedVariables(featureRoot, info, config, outputPath);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
*/
|
|
74
|
-
function writeVariableInfoToCsv(outputPath, filename, data) {
|
|
75
|
-
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, filename));
|
|
76
|
-
out.write(`variable,unique-projects,unique-files,${(0, summarizer_1.summarizedMeasurement2CsvHeader)('count')},${(0, summarizer_1.summarizedMeasurement2CsvHeader)('line-frac')}\n`);
|
|
77
|
-
for (const [key, val] of data.entries()) {
|
|
78
|
-
const { count, uniqueProjects, uniqueFiles, linePercentageInFile } = val;
|
|
79
|
-
const counts = (0, summarizer_1.summarizeMeasurement)(count);
|
|
80
|
-
const lineFrac = (0, summarizer_1.summarizeMeasurement)(linePercentageInFile.flat());
|
|
81
|
-
out.write(`${JSON.stringify(key)},${uniqueProjects.size},${uniqueFiles.size},${(0, summarizer_1.summarizedMeasurement2Csv)(counts)},${(0, summarizer_1.summarizedMeasurement2Csv)(lineFrac)}\n`);
|
|
82
|
-
}
|
|
83
|
-
out.close();
|
|
84
|
-
}
|
|
85
|
-
function collectVariableInfoFor(filepath, info, config) {
|
|
86
|
-
// variable name to summary
|
|
87
|
-
const collected = new Map();
|
|
88
|
-
(0, files_1.readLineByLineSync)(filepath, (line, lineNumber) => {
|
|
89
|
-
if (line.length === 0) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (lineNumber % 2_500 === 0) {
|
|
93
|
-
console.log(` Processed ${lineNumber} lines of ${filepath}`);
|
|
94
|
-
}
|
|
95
|
-
const [vars, context] = JSON.parse(line.toString());
|
|
96
|
-
const numberOfLines = info.get(context ?? '')?.stats.lines[0].length;
|
|
97
|
-
// first we have to collect what this file gives us
|
|
98
|
-
const perFile = new Map();
|
|
99
|
-
for (const [name, [line]] of vars) {
|
|
100
|
-
let get = perFile.get(name);
|
|
101
|
-
if (!get) {
|
|
102
|
-
get = { ...(0, post_processing_1.emptySummarizedWithProject)(), linePercentageInFile: [] };
|
|
103
|
-
perFile.set(name, get);
|
|
104
|
-
}
|
|
105
|
-
get.count.push(1);
|
|
106
|
-
if (numberOfLines) {
|
|
107
|
-
get.linePercentageInFile.push(line / numberOfLines);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// now we merge it into the global map (oh gosh this is so horrible
|
|
111
|
-
for (const [name, data] of perFile.entries()) {
|
|
112
|
-
let get = collected.get(name);
|
|
113
|
-
if (!get) {
|
|
114
|
-
get = { ...(0, post_processing_1.emptySummarizedWithProject)(), linePercentageInFile: [] };
|
|
115
|
-
collected.set(name, get);
|
|
116
|
-
}
|
|
117
|
-
get.count.push(data.count.length);
|
|
118
|
-
get.linePercentageInFile.push(data.linePercentageInFile);
|
|
119
|
-
if (data.count.length > 0) {
|
|
120
|
-
(0, post_processing_1.recordFilePath)(get, context, config);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
return collected;
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=post-process.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Feature } from '../../feature';
|
|
2
|
-
import type { Writable } from 'ts-essentials';
|
|
3
|
-
declare const initialVariableInfo: {
|
|
4
|
-
numberOfVariableUses: number;
|
|
5
|
-
numberOfDefinitions: number;
|
|
6
|
-
numberOfRedefinitions: number;
|
|
7
|
-
unknownVariables: number;
|
|
8
|
-
};
|
|
9
|
-
export type VariableInfo = Writable<typeof initialVariableInfo>;
|
|
10
|
-
export type DefinedVariableInformation = [
|
|
11
|
-
name: string,
|
|
12
|
-
location: [line: number, character: number]
|
|
13
|
-
];
|
|
14
|
-
export declare const variables: Feature<VariableInfo>;
|
|
15
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.variables = void 0;
|
|
4
|
-
const post_process_1 = require("./post-process");
|
|
5
|
-
const statistics_file_1 = require("../../../output/statistics-file");
|
|
6
|
-
const vertex_1 = require("../../../../dataflow/graph/vertex");
|
|
7
|
-
const range_1 = require("../../../../util/range");
|
|
8
|
-
const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
9
|
-
const r_symbol_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
10
|
-
const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
|
|
11
|
-
const initialVariableInfo = {
|
|
12
|
-
numberOfVariableUses: 0,
|
|
13
|
-
numberOfDefinitions: 0,
|
|
14
|
-
numberOfRedefinitions: 0,
|
|
15
|
-
// we failed to get the type/role, maybe for function call names etc.
|
|
16
|
-
unknownVariables: 0
|
|
17
|
-
};
|
|
18
|
-
function visitVariables(info, input) {
|
|
19
|
-
r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
|
|
20
|
-
if (!r_symbol_1.RSymbol.is(node) || r_symbol_1.RSymbol.isSpecial(node)) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
// search for the node in the DF graph
|
|
24
|
-
const mayNode = input.dataflow.graph.get(node.info.id);
|
|
25
|
-
if (mayNode === undefined) {
|
|
26
|
-
info.unknownVariables++;
|
|
27
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.variables.name, 'unknown', [[
|
|
28
|
-
model_1.RNode.lexeme(node),
|
|
29
|
-
range_1.SourceRange.getStart(node.location)
|
|
30
|
-
]], input.filepath);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const [dfNode] = mayNode;
|
|
34
|
-
if (dfNode.tag === vertex_1.VertexType.VariableDefinition) {
|
|
35
|
-
info.numberOfDefinitions++;
|
|
36
|
-
const lexeme = model_1.RNode.lexeme(node);
|
|
37
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.variables.name, 'definedVariables', [[
|
|
38
|
-
lexeme,
|
|
39
|
-
range_1.SourceRange.getStart(node.location)
|
|
40
|
-
]], input.filepath);
|
|
41
|
-
// checking for redefinitions is no longer possible in its current form!
|
|
42
|
-
}
|
|
43
|
-
else if (dfNode.tag === 'use') {
|
|
44
|
-
info.numberOfVariableUses++;
|
|
45
|
-
(0, statistics_file_1.appendStatisticsFile)(exports.variables.name, 'usedVariables', [[
|
|
46
|
-
model_1.RNode.lexeme(node),
|
|
47
|
-
range_1.SourceRange.getStart(node.location)
|
|
48
|
-
]], input.filepath);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
exports.variables = {
|
|
53
|
-
name: 'Variables',
|
|
54
|
-
description: 'Variable Usage, Assignments, and Redefinitions',
|
|
55
|
-
process(existing, input) {
|
|
56
|
-
visitVariables(existing, input);
|
|
57
|
-
return existing;
|
|
58
|
-
},
|
|
59
|
-
initialValue: initialVariableInfo,
|
|
60
|
-
postProcess: post_process_1.postProcess
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=variables.js.map
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { RParseRequestFromFile, RParseRequestFromText } from '../r-bridge/retriever';
|
|
2
|
-
/**
|
|
3
|
-
* Statistics on skipped files, the time required, and more.
|
|
4
|
-
* @see extractUsageStatistics
|
|
5
|
-
* @see initialMetaStatistics
|
|
6
|
-
*/
|
|
7
|
-
export interface MetaStatistics {
|
|
8
|
-
/**
|
|
9
|
-
* The number of requests that were parsed successfully
|
|
10
|
-
*/
|
|
11
|
-
successfulParsed: number;
|
|
12
|
-
/**
|
|
13
|
-
* The processing time for each request
|
|
14
|
-
*/
|
|
15
|
-
processingTimeMs: number[];
|
|
16
|
-
/**
|
|
17
|
-
* All failed requests (e.g., if they can not be converted to XML)
|
|
18
|
-
*/
|
|
19
|
-
failedRequests: (RParseRequestFromText | RParseRequestFromFile)[];
|
|
20
|
-
/**
|
|
21
|
-
* Number of lines with each individual line length consumed for each request
|
|
22
|
-
*/
|
|
23
|
-
lines: number[][];
|
|
24
|
-
/**
|
|
25
|
-
* The number of nodes in the normalized AST
|
|
26
|
-
*/
|
|
27
|
-
numberOfNormalizedNodes: number[];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Returns an initial {@link MetaStatistics} object, using neutral defaults (like the empty list).
|
|
31
|
-
*/
|
|
32
|
-
export declare function initialMetaStatistics(): MetaStatistics;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initialMetaStatistics = initialMetaStatistics;
|
|
4
|
-
/**
|
|
5
|
-
* Returns an initial {@link MetaStatistics} object, using neutral defaults (like the empty list).
|
|
6
|
-
*/
|
|
7
|
-
function initialMetaStatistics() {
|
|
8
|
-
return {
|
|
9
|
-
successfulParsed: 0,
|
|
10
|
-
numberOfNormalizedNodes: [],
|
|
11
|
-
processingTimeMs: [],
|
|
12
|
-
failedRequests: [],
|
|
13
|
-
lines: []
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=meta-statistics.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export type AppendFnType = string | number | symbol;
|
|
2
|
-
export interface StatisticAppendProvider {
|
|
3
|
-
append(name: string, fn: AppendFnType, content: string): void;
|
|
4
|
-
}
|
|
5
|
-
export type DummyAppendMemoryMap = Map<string, Map<AppendFnType, string[]>>;
|
|
6
|
-
export declare class DummyAppendProvider implements StatisticAppendProvider {
|
|
7
|
-
private readonly map;
|
|
8
|
-
/**
|
|
9
|
-
* If you pass a map the dummy will log all append calls to the map, using the feature name and the appendage type as keys
|
|
10
|
-
* @param map - The map to log to
|
|
11
|
-
*/
|
|
12
|
-
constructor(map?: DummyAppendMemoryMap | undefined);
|
|
13
|
-
append(name: string, fn: AppendFnType, content: string): void;
|
|
14
|
-
}
|
|
15
|
-
export declare const defaultStatisticsFileSuffix = ".txt";
|
|
16
|
-
/**
|
|
17
|
-
* Provides cached open connections for all files to connect.
|
|
18
|
-
* allowing to append to the same file often.
|
|
19
|
-
* <p>
|
|
20
|
-
* While we could simply reopen these files, it is safer/more performant to keep the connection open.
|
|
21
|
-
*/
|
|
22
|
-
export declare class StatisticFileProvider implements StatisticAppendProvider {
|
|
23
|
-
readonly statisticsDirectory: string;
|
|
24
|
-
private readonly connections;
|
|
25
|
-
constructor(statisticsDirectory: string | undefined);
|
|
26
|
-
/**
|
|
27
|
-
* @param name - the name of the feature {@link Feature#name}
|
|
28
|
-
* @param fn - the name of the feature-aspect to record
|
|
29
|
-
*/
|
|
30
|
-
private statisticsFile;
|
|
31
|
-
/**
|
|
32
|
-
* Append the given content to the information for a feature of the given name and function.
|
|
33
|
-
*/
|
|
34
|
-
append(name: string, fn: AppendFnType, content: string): void;
|
|
35
|
-
private getHandle;
|
|
36
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.StatisticFileProvider = exports.defaultStatisticsFileSuffix = exports.DummyAppendProvider = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const log_1 = require("../../util/log");
|
|
10
|
-
const assert_1 = require("../../util/assert");
|
|
11
|
-
class DummyAppendProvider {
|
|
12
|
-
map;
|
|
13
|
-
/**
|
|
14
|
-
* If you pass a map the dummy will log all append calls to the map, using the feature name and the appendage type as keys
|
|
15
|
-
* @param map - The map to log to
|
|
16
|
-
*/
|
|
17
|
-
constructor(map = undefined) {
|
|
18
|
-
this.map = map;
|
|
19
|
-
}
|
|
20
|
-
append(name, fn, content) {
|
|
21
|
-
if (log_1.log.settings.minLevel >= 1 /* LogLevel.Trace */) {
|
|
22
|
-
log_1.log.trace(`DummyAppendProvider: ${name} ${String(fn)} ${content}`);
|
|
23
|
-
}
|
|
24
|
-
if (this.map) {
|
|
25
|
-
const fnMap = this.map.get(name);
|
|
26
|
-
const contentArr = content.split('\n');
|
|
27
|
-
if (fnMap) {
|
|
28
|
-
const contentList = fnMap.get(fn);
|
|
29
|
-
if (contentList) {
|
|
30
|
-
contentList.push(...contentArr);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// just in case that the map already had some entries
|
|
34
|
-
fnMap.set(fn, contentArr);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.map.set(name, new Map([[fn, contentArr]]));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.DummyAppendProvider = DummyAppendProvider;
|
|
44
|
-
exports.defaultStatisticsFileSuffix = '.txt';
|
|
45
|
-
/**
|
|
46
|
-
* Provides cached open connections for all files to connect.
|
|
47
|
-
* allowing to append to the same file often.
|
|
48
|
-
* <p>
|
|
49
|
-
* While we could simply reopen these files, it is safer/more performant to keep the connection open.
|
|
50
|
-
*/
|
|
51
|
-
class StatisticFileProvider {
|
|
52
|
-
statisticsDirectory;
|
|
53
|
-
connections = new Map();
|
|
54
|
-
constructor(statisticsDirectory) {
|
|
55
|
-
(0, assert_1.guard)(statisticsDirectory !== undefined, 'Please supply an output directory!');
|
|
56
|
-
this.statisticsDirectory = statisticsDirectory;
|
|
57
|
-
// just to make sure that they are closed
|
|
58
|
-
process.on('beforeExit', () => {
|
|
59
|
-
this.connections.forEach(fd => {
|
|
60
|
-
fs_1.default.closeSync(fd);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* @param name - the name of the feature {@link Feature#name}
|
|
66
|
-
* @param fn - the name of the feature-aspect to record
|
|
67
|
-
*/
|
|
68
|
-
statisticsFile(name, fn) {
|
|
69
|
-
return path_1.default.join(this.statisticsDirectory, name, `${fn}${exports.defaultStatisticsFileSuffix}`);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Append the given content to the information for a feature of the given name and function.
|
|
73
|
-
*/
|
|
74
|
-
append(name, fn, content) {
|
|
75
|
-
const descriptor = this.getHandle(name, String(fn));
|
|
76
|
-
fs_1.default.appendFileSync(descriptor, content + '\n', 'utf8');
|
|
77
|
-
}
|
|
78
|
-
getHandle(name, fn) {
|
|
79
|
-
const key = `${name}-${fn}`;
|
|
80
|
-
const fileHandle = this.connections.get(key);
|
|
81
|
-
if (fileHandle) {
|
|
82
|
-
return fileHandle;
|
|
83
|
-
}
|
|
84
|
-
// open the connection and ensure the location
|
|
85
|
-
const filepath = this.statisticsFile(name, String(fn));
|
|
86
|
-
const dirpath = path_1.default.dirname(filepath);
|
|
87
|
-
if (!fs_1.default.existsSync(dirpath)) {
|
|
88
|
-
fs_1.default.mkdirSync(dirpath, { recursive: true });
|
|
89
|
-
}
|
|
90
|
-
const fileDescriptor = fs_1.default.openSync(filepath, 'a');
|
|
91
|
-
this.connections.set(key, fileDescriptor);
|
|
92
|
-
return fileDescriptor;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.StatisticFileProvider = StatisticFileProvider;
|
|
96
|
-
//# sourceMappingURL=file-provider.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { MetaStatistics } from '../meta-statistics';
|
|
2
|
-
import { type FeatureKey, type FeatureStatistics } from '../features/feature';
|
|
3
|
-
interface MinMaxAvgMedian {
|
|
4
|
-
sum: number;
|
|
5
|
-
min: number;
|
|
6
|
-
max: number;
|
|
7
|
-
avg: number;
|
|
8
|
-
median: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Calculates the min, max, average and median of the given data set.
|
|
12
|
-
*/
|
|
13
|
-
export declare function minMaxAvgAndMedian(data: number[]): MinMaxAvgMedian;
|
|
14
|
-
/**
|
|
15
|
-
* Formats the given statistics as a string.
|
|
16
|
-
*/
|
|
17
|
-
export declare function statsString(data: MinMaxAvgMedian, suffix?: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Prints the given feature statistics to the console.
|
|
20
|
-
*/
|
|
21
|
-
export declare function printFeatureStatistics(statistics: {
|
|
22
|
-
features: FeatureStatistics;
|
|
23
|
-
meta: MetaStatistics;
|
|
24
|
-
}, features?: 'all' | Set<FeatureKey>): void;
|
|
25
|
-
/**
|
|
26
|
-
* Prints a single feature statistics entry to the console.
|
|
27
|
-
*/
|
|
28
|
-
export declare function printFeatureStatisticsEntry(info: Record<string, unknown>): void;
|
|
29
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.minMaxAvgAndMedian = minMaxAvgAndMedian;
|
|
4
|
-
exports.statsString = statsString;
|
|
5
|
-
exports.printFeatureStatistics = printFeatureStatistics;
|
|
6
|
-
exports.printFeatureStatisticsEntry = printFeatureStatisticsEntry;
|
|
7
|
-
const ansi_1 = require("../../util/text/ansi");
|
|
8
|
-
const json_1 = require("../../util/json");
|
|
9
|
-
const feature_1 = require("../features/feature");
|
|
10
|
-
const arrays_1 = require("../../util/collections/arrays");
|
|
11
|
-
/**
|
|
12
|
-
* Calculates the min, max, average and median of the given data set.
|
|
13
|
-
*/
|
|
14
|
-
function minMaxAvgAndMedian(data) {
|
|
15
|
-
data = data.sort((a, b) => a - b);
|
|
16
|
-
const sum = (0, arrays_1.arraySum)(data);
|
|
17
|
-
return {
|
|
18
|
-
sum,
|
|
19
|
-
min: data[0],
|
|
20
|
-
max: data[data.length - 1],
|
|
21
|
-
avg: sum / data.length,
|
|
22
|
-
median: data[Math.floor(data.length / 2)]
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function formatStatNumber(num) {
|
|
26
|
-
return num === undefined ? '<?>' : Number(num.toFixed(3)).toLocaleString();
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Formats the given statistics as a string.
|
|
30
|
-
*/
|
|
31
|
-
function statsString(data, suffix = '') {
|
|
32
|
-
return `[${formatStatNumber(data.min)}${suffix} .. ${formatStatNumber(data.max)}${suffix}] (avg: ${formatStatNumber(data.avg)}${suffix}, median: ${formatStatNumber(data.median)}${suffix})`;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Prints the given feature statistics to the console.
|
|
36
|
-
*/
|
|
37
|
-
function printFeatureStatistics(statistics, features = 'all') {
|
|
38
|
-
for (const feature of Object.keys(statistics.features)) {
|
|
39
|
-
if (features !== 'all' && !features.has(feature)) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const meta = feature_1.ALL_FEATURES[feature];
|
|
43
|
-
console.log(`\n\n-----${meta.name}-------------`);
|
|
44
|
-
console.log(ansi_1.formatter.format(meta.description, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground }));
|
|
45
|
-
printFeatureStatisticsEntry(statistics.features[feature]);
|
|
46
|
-
console.log('\n\n');
|
|
47
|
-
}
|
|
48
|
-
const linesPerFile = minMaxAvgAndMedian(statistics.meta.lines.map(l => l.length));
|
|
49
|
-
const lineLengths = minMaxAvgAndMedian(statistics.meta.lines.flat());
|
|
50
|
-
const processingTimesPerFile = minMaxAvgAndMedian(statistics.meta.processingTimeMs);
|
|
51
|
-
console.log(`processed ${statistics.meta.successfulParsed} files (skipped ${statistics.meta.failedRequests.length} due to errors):
|
|
52
|
-
\ttotal processing time: ${processingTimesPerFile.sum} ms
|
|
53
|
-
\t\tprocessing time range: ${statsString(processingTimesPerFile, ' ms')}
|
|
54
|
-
\ttotal number of lines: ${lineLengths.sum}
|
|
55
|
-
\t\tline range: ${statsString(linesPerFile)}
|
|
56
|
-
\t\tline length range: ${statsString(lineLengths, ' chars')}
|
|
57
|
-
`);
|
|
58
|
-
}
|
|
59
|
-
const pad = 3;
|
|
60
|
-
/**
|
|
61
|
-
* Prints a single feature statistics entry to the console.
|
|
62
|
-
*/
|
|
63
|
-
function printFeatureStatisticsEntry(info) {
|
|
64
|
-
let longestKey = 0;
|
|
65
|
-
let longestValue = 0;
|
|
66
|
-
const out = new Map();
|
|
67
|
-
for (const [key, value] of Object.entries(info)) {
|
|
68
|
-
if (key.length > longestKey) {
|
|
69
|
-
longestKey = key.length;
|
|
70
|
-
}
|
|
71
|
-
const valueString = JSON.stringify(value, json_1.jsonReplacer);
|
|
72
|
-
out.set(key, valueString);
|
|
73
|
-
if (valueString.length > longestValue) {
|
|
74
|
-
longestValue = valueString.length;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
for (const [key, value] of out.entries()) {
|
|
78
|
-
console.log(`${key.padEnd(longestKey + pad)} ${value.padStart(longestValue)}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=print-stats.js.map
|