@eagleoutice/flowr 2.4.7 → 2.5.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 +48 -38
- package/abstract-interpretation/data-frame/absint-visitor.js +3 -2
- package/benchmark/slicer.js +2 -2
- package/benchmark/summarizer/first-phase/process.js +1 -1
- package/benchmark/summarizer/second-phase/graph.js +2 -2
- package/cli/repl/commands/repl-query.js +11 -2
- package/cli/repl/core.d.ts +2 -2
- package/cli/repl/core.js +26 -7
- package/cli/repl/server/connection.js +3 -1
- package/cli/repl/server/messages/message-slice.d.ts +3 -0
- package/cli/repl/server/messages/message-slice.js +2 -0
- package/cli/slicer-app.js +7 -2
- package/control-flow/extract-cfg.d.ts +3 -3
- package/control-flow/extract-cfg.js +4 -4
- package/control-flow/useless-loop.js +30 -21
- package/dataflow/environments/built-in.d.ts +1 -1
- package/dataflow/environments/default-builtin-config.d.ts +9 -0
- package/dataflow/environments/default-builtin-config.js +21 -21
- package/dataflow/environments/environment.js +18 -9
- package/dataflow/environments/overwrite.js +2 -2
- package/dataflow/extractor.js +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +4 -4
- package/dataflow/graph/graph.d.ts +3 -3
- package/dataflow/graph/graph.js +4 -1
- package/dataflow/graph/quads.js +4 -4
- package/dataflow/info.js +1 -1
- package/dataflow/internal/linker.d.ts +2 -0
- package/dataflow/internal/linker.js +18 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +68 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/common.js +4 -3
- package/documentation/doc-util/doc-query.js +6 -2
- package/documentation/doc-util/doc-types.d.ts +7 -2
- package/documentation/doc-util/doc-types.js +20 -4
- package/documentation/print-core-wiki.js +5 -1
- package/documentation/print-dataflow-graph-wiki.js +21 -12
- package/documentation/print-faq-wiki.js +5 -0
- package/documentation/print-interface-wiki.js +2 -0
- package/documentation/print-linter-wiki.js +2 -3
- package/documentation/print-linting-and-testing-wiki.js +4 -0
- package/documentation/print-query-wiki.js +22 -7
- package/documentation/print-readme.js +6 -0
- package/linter/linter-executor.js +25 -17
- package/linter/linter-format.d.ts +10 -1
- package/linter/linter-format.js +8 -0
- package/linter/linter-rules.d.ts +1 -0
- package/linter/rules/absolute-path.js +8 -8
- package/linter/rules/dataframe-access-validation.js +1 -1
- package/linter/rules/file-path-validity.js +8 -11
- package/linter/rules/naming-convention.d.ts +5 -1
- package/linter/rules/naming-convention.js +24 -8
- package/linter/rules/seeded-randomness.js +2 -2
- package/linter/rules/unused-definition.js +1 -1
- package/package.json +20 -15
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +5 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +14 -12
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +6 -5
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +2 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/config-query/config-query-executor.js +7 -1
- package/queries/catalog/config-query/config-query-format.d.ts +7 -0
- package/queries/catalog/config-query/config-query-format.js +72 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -75
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +50 -26
- package/queries/catalog/dependencies-query/dependencies-query-format.js +75 -20
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -2
- package/queries/catalog/dependencies-query/function-info/visualize-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +13 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -1
- package/queries/catalog/linter-query/linter-query-format.js +4 -0
- package/queries/query-print.d.ts +2 -2
- package/queries/query-print.js +3 -2
- package/queries/query.d.ts +28 -21
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
- package/r-bridge/retriever.d.ts +14 -2
- package/r-bridge/retriever.js +10 -4
- package/search/flowr-search-builder.d.ts +1 -1
- package/search/flowr-search-builder.js +1 -1
- package/search/flowr-search-filters.d.ts +20 -10
- package/search/flowr-search-filters.js +19 -3
- package/search/search-executor/search-enrichers.d.ts +1 -1
- package/search/search-executor/search-enrichers.js +3 -2
- package/search/search-executor/search-generators.js +1 -1
- package/search/search-executor/search-transformer.js +1 -1
- package/util/formats/adapter-format.d.ts +6 -0
- package/util/formats/adapter-format.js +3 -0
- package/util/formats/adapter.d.ts +16 -0
- package/util/formats/adapter.js +42 -0
- package/util/formats/adapters/r-adapter.d.ts +4 -0
- package/util/formats/adapters/r-adapter.js +7 -0
- package/util/formats/adapters/rmd-adapter.d.ts +26 -0
- package/util/formats/adapters/rmd-adapter.js +91 -0
- package/util/objects.d.ts +11 -0
- package/util/objects.js +26 -0
- package/util/version.js +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Node } from 'commonmark';
|
|
2
|
+
import type { RParseRequest, RParseRequestFromText } from '../../../r-bridge/retriever';
|
|
3
|
+
export interface CodeBlock {
|
|
4
|
+
options: string;
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
export type CodeBlockEx = CodeBlock & {
|
|
8
|
+
startpos: {
|
|
9
|
+
line: number;
|
|
10
|
+
col: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export interface RmdInfo {
|
|
14
|
+
type: 'Rmd';
|
|
15
|
+
blocks: CodeBlock[];
|
|
16
|
+
options: object;
|
|
17
|
+
}
|
|
18
|
+
export declare const RmdAdapter: {
|
|
19
|
+
convertRequest: (request: RParseRequest) => RParseRequestFromText<RmdInfo>;
|
|
20
|
+
};
|
|
21
|
+
export declare function isRCodeBlock(node: Node): node is Node & {
|
|
22
|
+
literal: string;
|
|
23
|
+
info: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function restoreBlocksWithoutMd(blocks: CodeBlockEx[], totalLines: number): string;
|
|
26
|
+
export declare function parseCodeBlockOptions(header: string, content: string): string;
|
|
@@ -0,0 +1,91 @@
|
|
|
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.RmdAdapter = void 0;
|
|
7
|
+
exports.isRCodeBlock = isRCodeBlock;
|
|
8
|
+
exports.restoreBlocksWithoutMd = restoreBlocksWithoutMd;
|
|
9
|
+
exports.parseCodeBlockOptions = parseCodeBlockOptions;
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const commonmark_1 = require("commonmark");
|
|
12
|
+
const gray_matter_1 = __importDefault(require("gray-matter"));
|
|
13
|
+
const assert_1 = require("../../assert");
|
|
14
|
+
exports.RmdAdapter = {
|
|
15
|
+
convertRequest: (request) => {
|
|
16
|
+
// Read and Parse Markdown
|
|
17
|
+
const raw = request.request === 'text'
|
|
18
|
+
? request.content
|
|
19
|
+
: fs_1.default.readFileSync(request.content, 'utf-8').toString();
|
|
20
|
+
const parser = new commonmark_1.Parser();
|
|
21
|
+
const ast = parser.parse(raw);
|
|
22
|
+
// Parse Frontmatter
|
|
23
|
+
const frontmatter = (0, gray_matter_1.default)(raw);
|
|
24
|
+
// Parse Codeblocks
|
|
25
|
+
const walker = ast.walker();
|
|
26
|
+
const blocks = [];
|
|
27
|
+
let e;
|
|
28
|
+
while ((e = walker.next())) {
|
|
29
|
+
const node = e.node;
|
|
30
|
+
if (!isRCodeBlock(node)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
blocks.push({
|
|
34
|
+
code: node.literal,
|
|
35
|
+
options: parseCodeBlockOptions(node.info, node.literal),
|
|
36
|
+
startpos: { line: node.sourcepos[0][0] + 1, col: 0 }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
request: 'text',
|
|
41
|
+
content: restoreBlocksWithoutMd(blocks, countNewlines(raw)),
|
|
42
|
+
info: {
|
|
43
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
44
|
+
blocks: blocks.map(({ startpos, ...block }) => block),
|
|
45
|
+
options: frontmatter.data,
|
|
46
|
+
type: 'Rmd'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const RTagRegex = /{[rR](?:[\s,][^}]*)?}/;
|
|
52
|
+
function isRCodeBlock(node) {
|
|
53
|
+
return node.type === 'code_block' && node.literal !== null && node.info !== null && RTagRegex.test(node.info);
|
|
54
|
+
}
|
|
55
|
+
const LineRegex = /\r\n|\r|\n/;
|
|
56
|
+
function countNewlines(str) {
|
|
57
|
+
return str.split(LineRegex).length - 1;
|
|
58
|
+
}
|
|
59
|
+
function restoreBlocksWithoutMd(blocks, totalLines) {
|
|
60
|
+
let line = 1;
|
|
61
|
+
let output = '';
|
|
62
|
+
const goToLine = (n) => {
|
|
63
|
+
const diff = n - line;
|
|
64
|
+
(0, assert_1.guard)(diff >= 0);
|
|
65
|
+
line += diff;
|
|
66
|
+
output += '\n'.repeat(diff);
|
|
67
|
+
};
|
|
68
|
+
for (const block of blocks) {
|
|
69
|
+
goToLine(block.startpos.line);
|
|
70
|
+
output += block.code;
|
|
71
|
+
line += countNewlines(block.code);
|
|
72
|
+
}
|
|
73
|
+
// Add remainder of file
|
|
74
|
+
goToLine(totalLines + 1);
|
|
75
|
+
return output;
|
|
76
|
+
}
|
|
77
|
+
function parseCodeBlockOptions(header, content) {
|
|
78
|
+
let opts = header.length === 3 // '{r}' => header.length=3 (no options in header)
|
|
79
|
+
? ''
|
|
80
|
+
: header.substring(3, header.length - 1).trim();
|
|
81
|
+
const lines = content.split('\n');
|
|
82
|
+
for (const line of lines) {
|
|
83
|
+
if (!line.trim().startsWith('#|')) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
const opt = line.substring(3);
|
|
87
|
+
opts += opts.length === 0 ? opt : `, ${opt}`;
|
|
88
|
+
}
|
|
89
|
+
return opts;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=rmd-adapter.js.map
|
package/util/objects.d.ts
CHANGED
|
@@ -10,12 +10,23 @@ type OrReadonly<T> = T | Readonly<T> | DeepReadonly<T>;
|
|
|
10
10
|
/**
|
|
11
11
|
* Given two objects deeply merges them, if an object is an array it will merge the array values!
|
|
12
12
|
* Guarantees some type safety by requiring objects to merge to be from the same type (allows undefined)
|
|
13
|
+
*
|
|
14
|
+
* @see {@link deepMergeObjectInPlace} to merge into an existing object
|
|
13
15
|
*/
|
|
14
16
|
export declare function deepMergeObject<T extends Mergeable>(base: Required<OrReadonly<T>>, addon?: T | DeepPartial<T> | Partial<T>): Required<T>;
|
|
15
17
|
export declare function deepMergeObject<T extends Mergeable>(base: DeepRequired<OrReadonly<T>>, addon?: T | DeepPartial<T> | Partial<T>): DeepRequired<T>;
|
|
16
18
|
export declare function deepMergeObject<T extends Mergeable>(base: OrReadonly<T>, addon?: DeepPartial<T> | Partial<T>): T;
|
|
17
19
|
export declare function deepMergeObject(base: Mergeable, addon: Mergeable): Mergeable;
|
|
18
20
|
export declare function deepMergeObject(base?: Mergeable, addon?: Mergeable): Mergeable | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Given two objects deeply merges them, if an object is an array it will merge the array values!
|
|
23
|
+
* Modifies the `base` object in place and also returns it.
|
|
24
|
+
* Guarantees some type safety by requiring objects to merge to be from the same type (allows undefined)
|
|
25
|
+
*
|
|
26
|
+
* @see {@link deepMergeObject} to create a new merged object
|
|
27
|
+
*/
|
|
28
|
+
export declare function deepMergeObjectInPlace<T extends Mergeable>(base: T, addon?: DeepPartial<T> | Partial<T>): T;
|
|
29
|
+
export declare function deepMergeObjectInPlace<T extends Mergeable>(base: T | undefined, addon?: DeepPartial<T> | Partial<T>): T | undefined;
|
|
19
30
|
type Defined<T> = Exclude<T, undefined>;
|
|
20
31
|
type DefinedRecord<T> = {
|
|
21
32
|
[K in keyof T as T[K] extends undefined ? never : K]: Defined<T[K]>;
|
package/util/objects.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isObjectOrArray = isObjectOrArray;
|
|
4
4
|
exports.deepMergeObject = deepMergeObject;
|
|
5
|
+
exports.deepMergeObjectInPlace = deepMergeObjectInPlace;
|
|
5
6
|
exports.compactRecord = compactRecord;
|
|
6
7
|
const json_1 = require("./json");
|
|
7
8
|
/**
|
|
@@ -56,6 +57,31 @@ function deepMergeObjectWithResult(addon, base, result) {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
}
|
|
60
|
+
function deepMergeObjectInPlace(base, addon) {
|
|
61
|
+
if (!base) {
|
|
62
|
+
return addon;
|
|
63
|
+
}
|
|
64
|
+
else if (!addon) {
|
|
65
|
+
return base;
|
|
66
|
+
}
|
|
67
|
+
else if (typeof base !== 'object' || typeof addon !== 'object') {
|
|
68
|
+
// this case should be guarded by type guards, but in case we do not know
|
|
69
|
+
throw new Error('illegal types for deepMergeObjectInPlace!');
|
|
70
|
+
}
|
|
71
|
+
assertSameType(base, addon);
|
|
72
|
+
const baseIsArray = Array.isArray(base);
|
|
73
|
+
const addonIsArray = Array.isArray(addon);
|
|
74
|
+
if (!baseIsArray && !addonIsArray) {
|
|
75
|
+
deepMergeObjectWithResult(addon, base, base);
|
|
76
|
+
}
|
|
77
|
+
else if (baseIsArray && addonIsArray) {
|
|
78
|
+
(base).push(...addon);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw new Error('cannot merge object with array!');
|
|
82
|
+
}
|
|
83
|
+
return base;
|
|
84
|
+
}
|
|
59
85
|
function assertSameType(base, addon) {
|
|
60
86
|
if (base !== undefined && addon !== undefined && typeof base !== typeof addon) {
|
|
61
87
|
throw new Error(`cannot merge different types! ${typeof base} (${JSON.stringify(base, json_1.jsonReplacer)}) !== ${typeof addon} (${JSON.stringify(addon, json_1.jsonReplacer)})`);
|
package/util/version.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.flowrVersion = flowrVersion;
|
|
4
4
|
const semver_1 = require("semver");
|
|
5
5
|
// this is automatically replaced with the current version by release-it
|
|
6
|
-
const version = '2.
|
|
6
|
+
const version = '2.5.0';
|
|
7
7
|
function flowrVersion() {
|
|
8
8
|
return new semver_1.SemVer(version);
|
|
9
9
|
}
|