@eagleoutice/flowr 1.4.1 → 1.4.2
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 +3 -3
- package/abstract-interpretation/processor.js +9 -3
- package/benchmark/slicer.d.ts +0 -3
- package/benchmark/slicer.js +4 -16
- package/benchmark/stats/print.js +0 -2
- package/benchmark/stats/stats.d.ts +2 -3
- package/benchmark/stats/stats.js +1 -1
- package/cli/benchmark-app.d.ts +1 -0
- package/cli/benchmark-app.js +21 -6
- package/cli/benchmark-helper-app.d.ts +2 -0
- package/cli/benchmark-helper-app.js +15 -6
- package/cli/common/options.js +4 -1
- package/cli/common/scripts-info.d.ts +1 -0
- package/cli/common/scripts-info.js +15 -1
- package/cli/export-quads-app.js +1 -5
- package/cli/repl/commands/cfg.js +2 -2
- package/cli/repl/commands/commands.d.ts +3 -1
- package/cli/repl/commands/commands.js +67 -28
- package/cli/repl/commands/dataflow.js +2 -2
- package/cli/repl/commands/normalize.js +2 -2
- package/cli/repl/commands/parse.js +12 -12
- package/cli/repl/commands/quit.js +4 -1
- package/cli/repl/core.d.ts +4 -2
- package/cli/repl/core.js +63 -7
- package/cli/repl/execute.d.ts +1 -1
- package/cli/repl/execute.js +3 -3
- package/cli/repl/server/connection.js +3 -8
- package/cli/repl/server/net.js +2 -2
- package/cli/statistics-helper-app.js +0 -1
- package/cli/summarizer-app.js +1 -2
- package/config.d.ts +16 -0
- package/config.js +75 -0
- package/core/input.d.ts +1 -1
- package/core/output.d.ts +1 -2
- package/core/print/parse-printer.d.ts +1 -2
- package/core/print/parse-printer.js +6 -4
- package/core/slicer.js +4 -8
- package/core/steps.d.ts +7 -24
- package/core/steps.js +5 -12
- package/dataflow/environments/environment.js +8 -0
- package/dataflow/environments/register.js +1 -0
- package/dataflow/extractor.d.ts +2 -2
- package/dataflow/extractor.js +10 -2
- package/dataflow/internal/process/functions/function-call.js +7 -1
- package/dataflow/internal/process/functions/source.d.ts +8 -0
- package/dataflow/internal/process/functions/source.js +81 -0
- package/dataflow/processor.d.ts +10 -1
- package/flowr.d.ts +2 -0
- package/flowr.js +14 -9
- package/package.json +41 -18
- package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/index.js +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
- package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
- package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +6 -11
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
- package/r-bridge/lang-4.x/values.d.ts +0 -1
- package/r-bridge/lang-4.x/values.js +14 -6
- package/r-bridge/retriever.d.ts +25 -21
- package/r-bridge/retriever.js +73 -23
- package/r-bridge/shell-executor.d.ts +3 -17
- package/r-bridge/shell-executor.js +9 -78
- package/r-bridge/shell.d.ts +5 -27
- package/r-bridge/shell.js +31 -92
- package/statistics/features/supported/assignments/post-process.js +6 -6
- package/statistics/features/supported/comments/post-process.js +2 -2
- package/statistics/features/supported/data-access/post-process.js +4 -4
- package/statistics/features/supported/defined-functions/post-process.js +4 -4
- package/statistics/features/supported/expression-list/post-process.js +3 -3
- package/statistics/features/supported/loops/post-process.js +3 -3
- package/statistics/features/supported/used-functions/post-process.js +5 -5
- package/statistics/features/supported/used-packages/post-process.js +5 -5
- package/statistics/features/supported/values/post-process.js +3 -3
- package/statistics/features/supported/variables/post-process.js +3 -3
- package/statistics/output/ansi.js +1 -1
- package/statistics/statistics.js +7 -8
- package/util/args.d.ts +8 -4
- package/util/args.js +11 -4
- package/util/cfg/visitor.js +1 -1
- package/util/files.d.ts +6 -0
- package/util/files.js +11 -1
- package/util/log.js +3 -0
- package/util/summarizer/benchmark/first-phase/input.d.ts +2 -1
- package/util/summarizer/benchmark/first-phase/input.js +20 -4
- package/util/summarizer/benchmark/first-phase/process.d.ts +2 -1
- package/util/summarizer/benchmark/first-phase/process.js +14 -5
- package/util/summarizer/benchmark/second-phase/graph.js +1 -1
- package/util/summarizer/benchmark/second-phase/process.d.ts +2 -0
- package/util/summarizer/benchmark/second-phase/process.js +48 -11
- package/util/summarizer/benchmark/summarizer.d.ts +0 -4
- package/util/summarizer/benchmark/summarizer.js +16 -7
- package/util/summarizer/statistics/first-phase/process.js +8 -8
- package/util/summarizer/statistics/post-process/post-process-output.js +4 -5
- package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
- package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
- package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
- package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
package/r-bridge/shell.js
CHANGED
|
@@ -26,16 +26,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.RShell = exports.DEFAULT_R_SHELL_OPTIONS = exports.DEFAULT_R_SHELL_EXEC_OPTIONS = exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = void 0;
|
|
29
|
+
exports.RShell = exports.DEFAULT_R_SHELL_OPTIONS = exports.DEFAULT_R_SHELL_EXEC_OPTIONS = exports.DEFAULT_R_PATH = exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = void 0;
|
|
30
30
|
const child_process_1 = require("child_process");
|
|
31
31
|
const objects_1 = require("../util/objects");
|
|
32
|
-
const readline = __importStar(require("
|
|
32
|
+
const readline = __importStar(require("readline"));
|
|
33
33
|
const lang_4_x_1 = require("./lang-4.x");
|
|
34
34
|
const log_1 = require("../util/log");
|
|
35
35
|
const preload_1 = __importDefault(require("semver/preload"));
|
|
36
36
|
const os_1 = require("../util/os");
|
|
37
37
|
const fs_1 = __importDefault(require("fs"));
|
|
38
|
-
const
|
|
38
|
+
const config_1 = require("../config");
|
|
39
39
|
exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
|
|
40
40
|
from: 'stdout',
|
|
41
41
|
postamble: `🐧${'-'.repeat(5)}🐧`,
|
|
@@ -47,13 +47,14 @@ exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
|
|
|
47
47
|
automaticallyTrimOutput: true,
|
|
48
48
|
errorStopsWaiting: true
|
|
49
49
|
};
|
|
50
|
+
exports.DEFAULT_R_PATH = (0, os_1.getPlatform)() === 'windows' ? 'R.exe' : 'R';
|
|
50
51
|
exports.DEFAULT_R_SHELL_EXEC_OPTIONS = {
|
|
51
|
-
pathToRExecutable: (0,
|
|
52
|
+
pathToRExecutable: (0, config_1.getConfig)().rPath ?? exports.DEFAULT_R_PATH,
|
|
52
53
|
commandLineOptions: ['--vanilla', '--quiet', '--no-echo', '--no-save'],
|
|
53
54
|
cwd: process.cwd(),
|
|
54
55
|
env: process.env,
|
|
55
56
|
eol: '\n',
|
|
56
|
-
homeLibPath: (0, os_1.getPlatform)() === 'windows' ? undefined : '~/.r-libs'
|
|
57
|
+
homeLibPath: (0, os_1.getPlatform)() === 'windows' ? undefined : '~/.r-libs'
|
|
57
58
|
};
|
|
58
59
|
exports.DEFAULT_R_SHELL_OPTIONS = {
|
|
59
60
|
...exports.DEFAULT_R_SHELL_EXEC_OPTIONS,
|
|
@@ -74,7 +75,6 @@ class RShell {
|
|
|
74
75
|
session;
|
|
75
76
|
log;
|
|
76
77
|
versionCache = null;
|
|
77
|
-
tokenMapCache = null;
|
|
78
78
|
// should never be more than one, but let's be sure
|
|
79
79
|
tempDirs = new Set();
|
|
80
80
|
constructor(options) {
|
|
@@ -116,30 +116,28 @@ class RShell {
|
|
|
116
116
|
this.versionCache = preload_1.default.coerce(result[0]);
|
|
117
117
|
return result.length === 1 ? this.versionCache : null;
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* @note For multiple calls, this makes use of caching
|
|
123
|
-
*/
|
|
124
|
-
async tokenMap() {
|
|
125
|
-
if (this.tokenMapCache === null) {
|
|
126
|
-
this.tokenMapCache = await this.retrieveTokenMap();
|
|
127
|
-
}
|
|
128
|
-
return this.tokenMapCache;
|
|
119
|
+
injectLibPaths(...paths) {
|
|
120
|
+
this.log.debug(`injecting lib paths ${JSON.stringify(paths)}`);
|
|
121
|
+
this._sendCommand(`.libPaths(c(.libPaths(), ${paths.map(lang_4_x_1.ts2r).join(',')}))`);
|
|
129
122
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
123
|
+
tryToInjectHomeLibPath() {
|
|
124
|
+
// ensure the path exists first
|
|
125
|
+
if (this.options.homeLibPath === undefined) {
|
|
126
|
+
this.log.debug('ensuring home lib path exists (automatic inject)');
|
|
127
|
+
this.sendCommand('if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { dir.create(path=Sys.getenv("R_LIBS_USER"),showWarnings=FALSE,recursive=TRUE) }');
|
|
128
|
+
this.sendCommand('.libPaths(c(.libPaths(), Sys.getenv("R_LIBS_USER")))');
|
|
136
129
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
for (const [key, value] of parsed) {
|
|
140
|
-
cache[value] = (0, retriever_1.removeTokenMapQuotationMarks)(key);
|
|
130
|
+
else {
|
|
131
|
+
this.injectLibPaths(this.options.homeLibPath);
|
|
141
132
|
}
|
|
142
|
-
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* checks if a given package is already installed on the system!
|
|
136
|
+
*/
|
|
137
|
+
async isPackageInstalled(packageName) {
|
|
138
|
+
this.log.debug(`checking if package "${packageName}" is installed`);
|
|
139
|
+
const result = await this.sendCommandWithOutput(`cat(system.file(package="${packageName}")!="","${this.options.eol}")`);
|
|
140
|
+
return result.length === 1 && result[0] === 'TRUE';
|
|
143
141
|
}
|
|
144
142
|
/**
|
|
145
143
|
* Send a command and collect the output
|
|
@@ -197,69 +195,6 @@ class RShell {
|
|
|
197
195
|
this.log.info('continue in case of Errors');
|
|
198
196
|
this._sendCommand('options(error=function() {})');
|
|
199
197
|
}
|
|
200
|
-
injectLibPaths(...paths) {
|
|
201
|
-
this.log.debug(`injecting lib paths ${JSON.stringify(paths)}`);
|
|
202
|
-
this._sendCommand(`.libPaths(c(.libPaths(), ${paths.map(lang_4_x_1.ts2r).join(',')}))`);
|
|
203
|
-
}
|
|
204
|
-
tryToInjectHomeLibPath() {
|
|
205
|
-
// ensure the path exists first
|
|
206
|
-
if (this.options.homeLibPath === undefined) {
|
|
207
|
-
this.log.debug('ensuring home lib path exists (automatic inject)');
|
|
208
|
-
this.sendCommand('if(!dir.exists(Sys.getenv("R_LIBS_USER"))) { dir.create(path=Sys.getenv("R_LIBS_USER"),showWarnings=FALSE,recursive=TRUE) }');
|
|
209
|
-
this.sendCommand('.libPaths(c(.libPaths(), Sys.getenv("R_LIBS_USER")))');
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
this.injectLibPaths(this.options.homeLibPath);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* checks if a given package is already installed on the system!
|
|
217
|
-
*/
|
|
218
|
-
async isPackageInstalled(packageName) {
|
|
219
|
-
this.log.debug(`checking if package "${packageName}" is installed`);
|
|
220
|
-
const result = await this.sendCommandWithOutput(`cat(system.file(package="${packageName}")!="","${this.options.eol}")`);
|
|
221
|
-
return result.length === 1 && result[0] === 'TRUE';
|
|
222
|
-
}
|
|
223
|
-
async allInstalledPackages() {
|
|
224
|
-
this.log.debug('getting all installed packages');
|
|
225
|
-
const [packages] = await this.sendCommandWithOutput(`cat(paste0(installed.packages()[,1], collapse=","),"${this.options.eol}")`);
|
|
226
|
-
return packages.split(',');
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Installs the package using a temporary location
|
|
230
|
-
*
|
|
231
|
-
* @param packageName - The package to install
|
|
232
|
-
* @param autoload - If true, the package will be loaded after installation
|
|
233
|
-
* @param force - If true, the package will be installed no if it is already on the system and ready to be loaded
|
|
234
|
-
*/
|
|
235
|
-
async ensurePackageInstalled(packageName, autoload = false, force = false) {
|
|
236
|
-
const packageExistedAlready = await this.isPackageInstalled(packageName);
|
|
237
|
-
if (!force && packageExistedAlready) {
|
|
238
|
-
this.log.info(`package "${packageName}" is already installed`);
|
|
239
|
-
if (autoload) {
|
|
240
|
-
this.sendCommand(`library(${(0, lang_4_x_1.ts2r)(packageName)})`);
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
packageName,
|
|
244
|
-
packageExistedAlready: true
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
// obtain a temporary directory
|
|
248
|
-
const tempdir = await this.obtainTmpDir();
|
|
249
|
-
this.log.debug(`using temporary directory: "${tempdir}" to install package "${packageName}"`);
|
|
250
|
-
await this.sendCommandWithOutput(`install.packages(${(0, lang_4_x_1.ts2r)(packageName)},repos="https://cloud.r-project.org/",quiet=FALSE,lib=temp)`, {
|
|
251
|
-
ms: 750_000,
|
|
252
|
-
resetOnNewData: true
|
|
253
|
-
});
|
|
254
|
-
if (autoload) {
|
|
255
|
-
this.sendCommand(`library(${(0, lang_4_x_1.ts2r)(packageName)},lib.loc=temp)`);
|
|
256
|
-
}
|
|
257
|
-
return {
|
|
258
|
-
packageName,
|
|
259
|
-
libraryLocation: tempdir,
|
|
260
|
-
packageExistedAlready
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
198
|
/**
|
|
264
199
|
* Obtain the temporary directory used by R.
|
|
265
200
|
* Additionally, this marks the directory for removal when the shell exits.
|
|
@@ -307,7 +242,9 @@ class RShellSession {
|
|
|
307
242
|
input: this.bareSession.stderr,
|
|
308
243
|
terminal: false
|
|
309
244
|
});
|
|
310
|
-
this.onExit(() => {
|
|
245
|
+
this.onExit(() => {
|
|
246
|
+
this.end();
|
|
247
|
+
});
|
|
311
248
|
this.options = options;
|
|
312
249
|
this.log = log;
|
|
313
250
|
this.setupRSessionLoggers();
|
|
@@ -351,7 +288,9 @@ class RShellSession {
|
|
|
351
288
|
this.collectionTimeout = makeTimer();
|
|
352
289
|
}
|
|
353
290
|
};
|
|
354
|
-
error = () => {
|
|
291
|
+
error = () => {
|
|
292
|
+
resolve(result);
|
|
293
|
+
};
|
|
355
294
|
this.onExit(error);
|
|
356
295
|
this.on(from, 'line', handler);
|
|
357
296
|
action?.();
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.postProcess = void 0;
|
|
7
7
|
const common_syntax_probability_1 = require("../../common-syntax-probability");
|
|
8
8
|
const numbers_1 = require("../../../../util/numbers");
|
|
9
|
-
const
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
12
12
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
@@ -35,7 +35,7 @@ function retrieveUsageCombinationCounts(collected) {
|
|
|
35
35
|
return new Map();
|
|
36
36
|
}
|
|
37
37
|
const allCombinations = [...(0, arrays_1.getUniqueCombinationsOfSize)(ops, 1)];
|
|
38
|
-
const store = new Map;
|
|
38
|
+
const store = new Map();
|
|
39
39
|
for (const combs of allCombinations) {
|
|
40
40
|
if (combs.length === 1) {
|
|
41
41
|
// we can just copy the information
|
|
@@ -61,7 +61,7 @@ function retrieveUsageCombinationCounts(collected) {
|
|
|
61
61
|
function writeOperatorCombinationsUsageToCsv(collected, outputPath) {
|
|
62
62
|
// now to get all projects exhausted with _only_ a given subset (e.g., all projects only using '=')
|
|
63
63
|
const operators = retrieveUsageCombinationCounts(collected);
|
|
64
|
-
const out =
|
|
64
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'assignments-assigned-combinations.csv'));
|
|
65
65
|
out.write('assignment,unique-projects,unique-files\n');
|
|
66
66
|
for (const [key, val] of operators.entries()) {
|
|
67
67
|
out.write(`${JSON.stringify(key)},${val.uniqueProjects},${val.uniqueFiles}\n`);
|
|
@@ -69,7 +69,7 @@ function writeOperatorCombinationsUsageToCsv(collected, outputPath) {
|
|
|
69
69
|
out.close();
|
|
70
70
|
}
|
|
71
71
|
function writeAssignmentMetadataToCsv(outputPath, collected) {
|
|
72
|
-
const out =
|
|
72
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'assignments-meta.csv'));
|
|
73
73
|
out.write(`kind,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
74
74
|
const summarizedDeepestNesting = (0, process_1.summarizeMeasurement)(collected.deepestNesting.flat());
|
|
75
75
|
out.write(`deepest-nesting,${(0, data_1.summarizedMeasurement2Csv)(summarizedDeepestNesting)}\n`);
|
|
@@ -78,7 +78,7 @@ function writeAssignmentMetadataToCsv(outputPath, collected) {
|
|
|
78
78
|
out.close();
|
|
79
79
|
}
|
|
80
80
|
function writeAssignedTypesToCsv(outputPath, collected) {
|
|
81
|
-
const out =
|
|
81
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'assignments-assigned.csv'));
|
|
82
82
|
out.write(`kind,name,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
83
83
|
for (const [entryName, values] of Object.entries(collected.assigned)) {
|
|
84
84
|
if (Array.isArray(values)) {
|
|
@@ -93,7 +93,7 @@ function writeAssignedTypesToCsv(outputPath, collected) {
|
|
|
93
93
|
out.close();
|
|
94
94
|
}
|
|
95
95
|
function writeAssignmentOperatorsToCsv(outputPath, collected) {
|
|
96
|
-
const fnOutStream =
|
|
96
|
+
const fnOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'assignments-assignment-operators.csv'));
|
|
97
97
|
fnOutStream.write(`assignment,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
98
98
|
for (const [key, val] of Object.entries(collected.assignmentOperator)) {
|
|
99
99
|
const { uniqueProjects, uniqueFiles, counts } = val;
|
|
@@ -7,7 +7,7 @@ exports.postProcess = void 0;
|
|
|
7
7
|
const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
8
8
|
const comments_1 = require("./comments");
|
|
9
9
|
const assert_1 = require("../../../../util/assert");
|
|
10
|
-
const
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
12
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
13
13
|
// monoids would be helpful :c
|
|
@@ -37,7 +37,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
37
37
|
for (const [filepath, feature] of info.entries()) {
|
|
38
38
|
appendCommentsPostProcessing(collected, feature.comments, feature.stats.lines[0].length, filepath, config.projectSkip);
|
|
39
39
|
}
|
|
40
|
-
const fnOutStream =
|
|
40
|
+
const fnOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'comments.csv'));
|
|
41
41
|
fnOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)('count')},${(0, data_1.summarizedMeasurement2CsvHeader)('frac-of-lines')}\n`);
|
|
42
42
|
for (const [key, val] of Object.entries(collected)) {
|
|
43
43
|
const { count, uniqueProjects, uniqueFiles, fracOfLines } = val;
|
|
@@ -8,7 +8,7 @@ const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
|
8
8
|
const common_syntax_probability_1 = require("../../common-syntax-probability");
|
|
9
9
|
const post_processing_1 = require("../../post-processing");
|
|
10
10
|
const numbers_1 = require("../../../../util/numbers");
|
|
11
|
-
const
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
14
14
|
function addToList(data, dataAccess, filepath, config) {
|
|
@@ -37,7 +37,7 @@ function summarizeForBracket(dataAccess, data, filepath, config) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
function writeSingleOrDoubleEmpty(outputPath, key, name, vals) {
|
|
40
|
-
const out =
|
|
40
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, `data-access-type-${key}-${name}.csv`));
|
|
41
41
|
// name is for fields like number etc. to allow to group multiple entries
|
|
42
42
|
out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
43
43
|
out.write(`"0",${vals.uniqueProjects.size},${vals.uniqueFiles.size},${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(vals.count))}\n`);
|
|
@@ -51,7 +51,7 @@ function writeSingleOrDoubleBrackets(data, outputPath, key) {
|
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
// non-0-column
|
|
54
|
-
const out =
|
|
54
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, `data-access-type-${key}-${name}.csv`));
|
|
55
55
|
// name is for fields like number etc. to allow to group multiple entries
|
|
56
56
|
out.write(`kind,name,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
57
57
|
for (const [entryName, values] of Object.entries(vals)) {
|
|
@@ -91,7 +91,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
91
91
|
summarizeForBracket(dataAccess.singleBracket, summarize.singleBracket, filepath, config);
|
|
92
92
|
summarizeForBracket(dataAccess.doubleBracket, summarize.doubleBracket, filepath, config);
|
|
93
93
|
}
|
|
94
|
-
const metaOut =
|
|
94
|
+
const metaOut = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'data-access-meta.csv'));
|
|
95
95
|
metaOut.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
96
96
|
for (const [key, value] of Object.entries(summarize)) {
|
|
97
97
|
const data = value;
|
|
@@ -8,7 +8,7 @@ const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
|
8
8
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
9
9
|
const files_1 = require("../../../../util/files");
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
12
|
const time_1 = require("../../../../util/time");
|
|
13
13
|
const defined_functions_1 = require("./defined-functions");
|
|
14
14
|
const post_processing_1 = require("../../post-processing");
|
|
@@ -42,7 +42,7 @@ function retrievePerFileDefinitionInformation(featureRoot, info, config, outputP
|
|
|
42
42
|
// we collect only `all-calls`
|
|
43
43
|
(0, files_1.readLineByLineSync)(path_1.default.join(featureRoot, `${defined_functions_1.AllDefinitionsFileBase}.txt`), (line, lineNumber) => processNextLine(definitionsPerFile, lineNumber, info, JSON.parse(String(line))));
|
|
44
44
|
console.log(` [${(0, time_1.date2string)(new Date())}] Defined functions process completed, start to write out function info`);
|
|
45
|
-
const fnOutStream =
|
|
45
|
+
const fnOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-definitions.csv'));
|
|
46
46
|
const prefixes = ['total', 'params', 'length-lines', 'length-chars', 'length-non-ws-chars', 'return-explicit', 'return-implicit', 'return-only-explicit', 'return-only-implicit', 'exit-points-line-crac', 'def-line-frac'];
|
|
47
47
|
const others = prefixes.flatMap(data_1.summarizedMeasurement2CsvHeader).join(',');
|
|
48
48
|
fnOutStream.write(`counter,${others}\n`);
|
|
@@ -84,7 +84,7 @@ function retrieveMetaInformation(info, config, outputPath) {
|
|
|
84
84
|
addToList(data.deepestNesting, us.deepestNesting, filepath, config);
|
|
85
85
|
}
|
|
86
86
|
console.log(` [${(0, time_1.date2string)(new Date())}] Defined functions metadata reading completed, summarizing and writing to file`);
|
|
87
|
-
const out =
|
|
87
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-definitions-meta.csv'));
|
|
88
88
|
out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
89
89
|
for (const [key, val] of Object.entries(data)) {
|
|
90
90
|
const data = val;
|
|
@@ -107,7 +107,7 @@ function retrieveAssignedFunctionNames(featureRoot, config, outputPath) {
|
|
|
107
107
|
addToList(get, count, context ?? '', config);
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
const varNamesOut =
|
|
110
|
+
const varNamesOut = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-definitions-var-names.csv'));
|
|
111
111
|
varNamesOut.write(`name,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
112
112
|
for (const [key, val] of varNames.entries()) {
|
|
113
113
|
varNamesOut.write(`${JSON.stringify(key)},${val.uniqueProjects.size},${val.uniqueFiles.size},${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(val.count))}\n`);
|
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.postProcess = void 0;
|
|
7
7
|
const post_processing_1 = require("../../post-processing");
|
|
8
|
-
const
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
11
11
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
12
12
|
function postProcess(featureRoot, info, outputPath, config) {
|
|
13
13
|
const collected = {};
|
|
14
|
-
const deepestNestingOut =
|
|
14
|
+
const deepestNestingOut = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'deepest-nesting-per-file.csv'));
|
|
15
15
|
deepestNestingOut.write('file,deepest-nesting\n');
|
|
16
16
|
for (const [filepath, data] of info.entries()) {
|
|
17
17
|
const value = data.expressionList;
|
|
@@ -31,7 +31,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
deepestNestingOut.close();
|
|
34
|
-
const variablesOutStream =
|
|
34
|
+
const variablesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'used-expression-lists.csv'));
|
|
35
35
|
variablesOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
36
36
|
for (const [key, val] of Object.entries(collected)) {
|
|
37
37
|
const data = val;
|
|
@@ -8,7 +8,7 @@ const post_processing_1 = require("../../post-processing");
|
|
|
8
8
|
const common_syntax_probability_1 = require("../../common-syntax-probability");
|
|
9
9
|
const numbers_1 = require("../../../../util/numbers");
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
12
|
const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
13
13
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
14
14
|
function postProcess(featureRoot, info, outputPath, config) {
|
|
@@ -41,7 +41,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const metaOut =
|
|
44
|
+
const metaOut = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'loops-meta.csv'));
|
|
45
45
|
metaOut.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
46
46
|
for (const [key, val] of Object.entries(collected)) {
|
|
47
47
|
const data = val;
|
|
@@ -50,7 +50,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
// new file for each :D
|
|
53
|
-
const out =
|
|
53
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, `loops-type-${key}.csv`));
|
|
54
54
|
// name is for fields like number etc to allow to group multiple entries
|
|
55
55
|
out.write(`kind,name,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
56
56
|
for (const [name, vals] of Object.entries(data)) {
|
|
@@ -9,7 +9,7 @@ const common_syntax_probability_1 = require("../../common-syntax-probability");
|
|
|
9
9
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
10
10
|
const files_1 = require("../../../../util/files");
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
13
|
const time_1 = require("../../../../util/time");
|
|
14
14
|
const used_functions_1 = require("./used-functions");
|
|
15
15
|
const numbers_1 = require("../../../../util/numbers");
|
|
@@ -33,7 +33,7 @@ function retrieveFunctionCallInformation(featureRoot, info, config, outputPath)
|
|
|
33
33
|
'assign',
|
|
34
34
|
'get',
|
|
35
35
|
'setGeneric',
|
|
36
|
-
'R6Class'].map(name => [name,
|
|
36
|
+
'R6Class'].map(name => [name, fs_1.default.createWriteStream(path_1.default.join(outputPath, `${name}.csv`))]));
|
|
37
37
|
for (const [, value] of importantFunctions) {
|
|
38
38
|
value.write('filepath,location,namespace,inspected by,classification,notes\n');
|
|
39
39
|
}
|
|
@@ -44,7 +44,7 @@ function retrieveFunctionCallInformation(featureRoot, info, config, outputPath)
|
|
|
44
44
|
}
|
|
45
45
|
importantFunctions.clear();
|
|
46
46
|
console.log(` [${(0, time_1.date2string)(new Date())}] Used functions process completed, start to write out function info`);
|
|
47
|
-
const fnOutStream =
|
|
47
|
+
const fnOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-calls.csv'));
|
|
48
48
|
const prefixes = ['total', 'args', 'line-frac'];
|
|
49
49
|
const others = prefixes.flatMap(data_1.summarizedMeasurement2CsvHeader).join(',');
|
|
50
50
|
fnOutStream.write(`function,unique-projects,unique-files,${others}\n`);
|
|
@@ -58,7 +58,7 @@ function retrieveFunctionCallInformation(featureRoot, info, config, outputPath)
|
|
|
58
58
|
fnOutStream.close();
|
|
59
59
|
}
|
|
60
60
|
function writeFunctionCallsMetaInformationToCsv(outputPath, data) {
|
|
61
|
-
const out =
|
|
61
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-calls-meta.csv'));
|
|
62
62
|
out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
63
63
|
out.write(`average-call,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.averageCall.flat()))}\n`);
|
|
64
64
|
out.write(`nested-calls,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.nestedCalls.flat()))}\n`);
|
|
@@ -102,7 +102,7 @@ function retrieveFunctionCallMetaInformation(info, outputPath) {
|
|
|
102
102
|
// we treat the first/0-argument entry separate for legacy reasons
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
|
-
const out =
|
|
105
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, `function-calls-arg-${index}.csv`));
|
|
106
106
|
out.write(`kind,name,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
107
107
|
for (const [name, vals] of Object.entries(arg)) {
|
|
108
108
|
if (Array.isArray(vals)) {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.postProcess = void 0;
|
|
7
7
|
const post_processing_1 = require("../../post-processing");
|
|
8
8
|
const used_packages_1 = require("./used-packages");
|
|
9
|
-
const
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
12
12
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
@@ -29,7 +29,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
const variablesOutStream =
|
|
32
|
+
const variablesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'loading-functions.csv'));
|
|
33
33
|
variablesOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
34
34
|
for (const [key, val] of Object.entries(collected)) {
|
|
35
35
|
const data = val;
|
|
@@ -58,7 +58,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
const output = path_1.default.join(outputPath, 'all-operators.csv');
|
|
61
|
-
const out =
|
|
61
|
+
const out = fs_1.default.createWriteStream(output);
|
|
62
62
|
out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
63
63
|
for (const [key, val] of loadedLibraries.entries()) {
|
|
64
64
|
const { count, uniqueProjects, uniqueFiles } = val;
|
|
@@ -71,7 +71,7 @@ exports.postProcess = postProcess;
|
|
|
71
71
|
// directly writes the results to the output path
|
|
72
72
|
function retrieveDataForLoad(operator, readFromPath, outputPath, config) {
|
|
73
73
|
const input = path_1.default.join(readFromPath, `${operator}.txt`);
|
|
74
|
-
if (!
|
|
74
|
+
if (!fs_1.default.existsSync(input)) {
|
|
75
75
|
// if there is nothing with this, just return :)
|
|
76
76
|
return new Map();
|
|
77
77
|
}
|
|
@@ -108,7 +108,7 @@ function retrieveDataForLoad(operator, readFromPath, outputPath, config) {
|
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
const output = path_1.default.join(outputPath, `${operator}.csv`);
|
|
111
|
-
const out =
|
|
111
|
+
const out = fs_1.default.createWriteStream(output);
|
|
112
112
|
out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
113
113
|
for (const [key, val] of collected.entries()) {
|
|
114
114
|
const { count, uniqueProjects, uniqueFiles } = val;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.postProcess = void 0;
|
|
7
7
|
const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
8
|
-
const
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
11
11
|
const files_1 = require("../../../../util/files");
|
|
@@ -28,7 +28,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
const valuesOutStream =
|
|
31
|
+
const valuesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'values.csv'));
|
|
32
32
|
valuesOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
33
33
|
for (const [key, val] of Object.entries(collected)) {
|
|
34
34
|
const data = val;
|
|
@@ -60,7 +60,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
const magicNumbersOutStream =
|
|
63
|
+
const magicNumbersOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'magic-numbers.csv'));
|
|
64
64
|
magicNumbersOutStream.write(`num,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
65
65
|
for (const [key, val] of valueMap.entries()) {
|
|
66
66
|
const sum = (0, process_1.summarizeMeasurement)(val.count);
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.writeVariableInfoToCsv = exports.postProcess = void 0;
|
|
7
7
|
const post_processing_1 = require("../../post-processing");
|
|
8
|
-
const
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const data_1 = require("../../../../util/summarizer/benchmark/data");
|
|
11
11
|
const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
|
|
@@ -27,7 +27,7 @@ function collectRedefinedVariables(featureRoot, info, config, outputPath) {
|
|
|
27
27
|
redefined.clear();
|
|
28
28
|
}
|
|
29
29
|
function writeVariableCountsToCsv(outputPath, collected) {
|
|
30
|
-
const variablesOutStream =
|
|
30
|
+
const variablesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'variable-counts.csv'));
|
|
31
31
|
variablesOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
|
|
32
32
|
for (const [key, val] of Object.entries(collected)) {
|
|
33
33
|
if (key === 'unknownVariables') {
|
|
@@ -67,7 +67,7 @@ function postProcess(featureRoot, info, outputPath, config) {
|
|
|
67
67
|
}
|
|
68
68
|
exports.postProcess = postProcess;
|
|
69
69
|
function writeVariableInfoToCsv(outputPath, filename, data) {
|
|
70
|
-
const out =
|
|
70
|
+
const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, filename));
|
|
71
71
|
out.write(`variable,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)('count')},${(0, data_1.summarizedMeasurement2CsvHeader)('line-frac')}\n`);
|
|
72
72
|
for (const [key, val] of data.entries()) {
|
|
73
73
|
const { count, uniqueProjects, uniqueFiles, linePercentageInFile } = val;
|
package/statistics/statistics.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.extractUsageStatistics = exports.staticRequests = void 0;
|
|
7
|
+
const r_bridge_1 = require("../r-bridge");
|
|
7
8
|
const features_1 = require("./features");
|
|
8
9
|
const xmldom_1 = require("@xmldom/xmldom");
|
|
9
10
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -37,7 +38,6 @@ exports.staticRequests = staticRequests;
|
|
|
37
38
|
async function extractUsageStatistics(shell, onRequest, features, requests, rootPath) {
|
|
38
39
|
let result = initializeFeatureStatistics();
|
|
39
40
|
const meta = (0, meta_statistics_1.initialMetaStatistics)();
|
|
40
|
-
let first = true;
|
|
41
41
|
const outputs = new Map();
|
|
42
42
|
for await (const request of requests) {
|
|
43
43
|
onRequest(request);
|
|
@@ -45,14 +45,10 @@ async function extractUsageStatistics(shell, onRequest, features, requests, root
|
|
|
45
45
|
const suffix = request.request === 'file' ? request.content.replace(new RegExp('^' + (rootPath ?? '')), '') : undefined;
|
|
46
46
|
try {
|
|
47
47
|
let output;
|
|
48
|
-
({ stats: result, output } = await extractSingle(result, shell,
|
|
49
|
-
...request,
|
|
50
|
-
ensurePackageInstalled: first
|
|
51
|
-
}, features, suffix));
|
|
48
|
+
({ stats: result, output } = await extractSingle(result, shell, request, features, suffix));
|
|
52
49
|
outputs.set(request, output);
|
|
53
50
|
processMetaOnSuccessful(meta, request);
|
|
54
51
|
meta.numberOfNormalizedNodes.push(output.normalize.idMap.size);
|
|
55
|
-
first = false;
|
|
56
52
|
}
|
|
57
53
|
catch (e) {
|
|
58
54
|
log_1.log.error('for request: ', request, e);
|
|
@@ -89,8 +85,11 @@ async function extractSingle(result, shell, request, features, suffixFilePath) {
|
|
|
89
85
|
stepOfInterest: 'dataflow',
|
|
90
86
|
request, shell
|
|
91
87
|
}).allRemainingSteps();
|
|
92
|
-
//
|
|
93
|
-
const
|
|
88
|
+
// retrieve parsed xml through (legacy) xmlparsedata
|
|
89
|
+
const suffix = request.request === 'file' ? ', encoding="utf-8"' : '';
|
|
90
|
+
shell.sendCommands(`try(flowr_parsed<-parse(${request.request}=${JSON.stringify(request.content)},keep.source=TRUE${suffix}),silent=FALSE)`, 'try(flowr_output<-xmlparsedata::xml_parse_data(flowr_parsed,includeText=TRUE,pretty=FALSE),silent=FALSE)');
|
|
91
|
+
const parsed = (await shell.sendCommandWithOutput(`cat(flowr_output,${(0, r_bridge_1.ts2r)(shell.options.eol)})`)).join(shell.options.eol);
|
|
92
|
+
const doc = parser.parseFromString(parsed, 'text/xml');
|
|
94
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
94
|
for (const [key, feature] of Object.entries(features_1.ALL_FEATURES)) {
|
|
96
95
|
if (features !== 'all' && !features.has(key)) {
|
package/util/args.d.ts
CHANGED
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* This splits an input string on the given split string (e.g., ` `) but checks if the string is quoted or escaped.
|
|
7
|
+
* This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
|
|
8
8
|
*
|
|
9
|
-
* Given an input string like `a "b c" d
|
|
9
|
+
* Given an input string like `a "b c" d`, with a space character as split, and escapeQuote set to true,
|
|
10
|
+
* this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
|
|
11
|
+
*
|
|
12
|
+
* When escapeQuote is set to false instead, we keep quotation marks in the result (i.e., `a`, `"b c"`, and `d`.).
|
|
10
13
|
*
|
|
11
14
|
* @param inputString - The string to split
|
|
12
|
-
* @param
|
|
15
|
+
* @param escapeQuote - Keep quotes in args
|
|
16
|
+
* @param split - The **single** character to split on (can not be backslash or quote)
|
|
13
17
|
*/
|
|
14
|
-
export declare function splitAtEscapeSensitive(inputString: string, split?: string): string[];
|
|
18
|
+
export declare function splitAtEscapeSensitive(inputString: string, escapeQuote?: boolean, split?: string): string[];
|