@eagleoutice/flowr 2.7.0 → 2.7.3

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.
Files changed (168) hide show
  1. package/README.md +14 -14
  2. package/abstract-interpretation/absint-visitor.d.ts +160 -0
  3. package/abstract-interpretation/absint-visitor.js +279 -0
  4. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +2 -2
  5. package/abstract-interpretation/data-frame/dataframe-domain.js +23 -7
  6. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +6 -6
  7. package/abstract-interpretation/data-frame/mappers/access-mapper.js +10 -14
  8. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +15 -9
  9. package/abstract-interpretation/data-frame/mappers/arguments.js +27 -4
  10. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +17 -17
  11. package/abstract-interpretation/data-frame/mappers/function-mapper.js +55 -67
  12. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +7 -7
  13. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +25 -29
  14. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -1
  15. package/abstract-interpretation/data-frame/resolve-args.js +1 -1
  16. package/abstract-interpretation/data-frame/semantics.js +5 -6
  17. package/abstract-interpretation/data-frame/shape-inference.d.ts +52 -28
  18. package/abstract-interpretation/data-frame/shape-inference.js +67 -90
  19. package/abstract-interpretation/domains/bounded-set-domain.d.ts +2 -2
  20. package/abstract-interpretation/domains/interval-domain.d.ts +2 -2
  21. package/abstract-interpretation/domains/set-range-domain.d.ts +10 -4
  22. package/abstract-interpretation/domains/set-range-domain.js +7 -1
  23. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +2 -2
  24. package/abstract-interpretation/domains/singleton-domain.d.ts +2 -2
  25. package/benchmark/slicer.js +13 -14
  26. package/cli/common/options.d.ts +431 -8
  27. package/cli/common/options.js +1 -1
  28. package/cli/common/scripts-info.d.ts +431 -7
  29. package/cli/flowr-main-options.d.ts +102 -2
  30. package/cli/flowr.d.ts +102 -2
  31. package/cli/repl/commands/repl-commands.d.ts +25 -0
  32. package/cli/repl/commands/repl-query.js +17 -5
  33. package/cli/wiki.d.ts +13 -0
  34. package/cli/wiki.js +7 -2
  35. package/config.d.ts +4 -4
  36. package/config.js +1 -1
  37. package/control-flow/basic-cfg-guided-visitor.js +7 -8
  38. package/control-flow/control-flow-graph.d.ts +1 -1
  39. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  40. package/control-flow/semantic-cfg-guided-visitor.js +1 -1
  41. package/dataflow/eval/resolve/alias-tracking.js +1 -1
  42. package/dataflow/internal/linker.d.ts +2 -0
  43. package/dataflow/internal/linker.js +10 -12
  44. package/documentation/doc-capabilities.d.ts +1 -1
  45. package/documentation/doc-readme.d.ts +1 -1
  46. package/documentation/doc-util/doc-cfg.js +1 -1
  47. package/documentation/doc-util/doc-cli-option.d.ts +6 -6
  48. package/documentation/doc-util/doc-cli-option.js +3 -3
  49. package/documentation/doc-util/doc-dfg.d.ts +1 -1
  50. package/documentation/doc-util/doc-files.d.ts +3 -0
  51. package/documentation/doc-util/doc-files.js +4 -1
  52. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  53. package/documentation/issue-linting-rule.d.ts +1 -1
  54. package/documentation/wiki-analyzer.d.ts +1 -1
  55. package/documentation/wiki-cfg.d.ts +1 -1
  56. package/documentation/wiki-core.d.ts +1 -1
  57. package/documentation/wiki-dataflow-graph.d.ts +1 -1
  58. package/documentation/wiki-dataflow-graph.js +6 -6
  59. package/documentation/wiki-engine.d.ts +1 -1
  60. package/documentation/wiki-engine.js +9 -10
  61. package/documentation/wiki-faq.d.ts +1 -1
  62. package/documentation/wiki-interface.d.ts +1 -1
  63. package/documentation/wiki-interface.js +12 -13
  64. package/documentation/wiki-linter.d.ts +1 -1
  65. package/documentation/wiki-linting-and-testing.d.ts +1 -1
  66. package/documentation/wiki-mk/doc-context.d.ts +54 -1
  67. package/documentation/wiki-mk/doc-context.js +17 -0
  68. package/documentation/wiki-mk/doc-maker.d.ts +5 -5
  69. package/documentation/wiki-mk/doc-maker.js +3 -1
  70. package/documentation/wiki-normalized-ast.d.ts +1 -1
  71. package/documentation/wiki-onboarding.d.ts +1 -1
  72. package/documentation/wiki-overview.d.ts +9 -0
  73. package/documentation/wiki-overview.js +248 -0
  74. package/documentation/wiki-query.d.ts +1 -1
  75. package/documentation/wiki-query.js +17 -1
  76. package/documentation/wiki-search.d.ts +1 -1
  77. package/documentation/wiki-setup.d.ts +9 -0
  78. package/documentation/wiki-setup.js +122 -0
  79. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  80. package/linter/rules/dataframe-access-validation.js +8 -10
  81. package/linter/rules/unused-definition.js +1 -1
  82. package/package.json +1 -1
  83. package/project/context/flowr-analyzer-context.d.ts +4 -0
  84. package/project/context/flowr-analyzer-context.js +3 -1
  85. package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -2
  86. package/project/context/flowr-analyzer-dependencies-context.js +4 -2
  87. package/project/context/flowr-analyzer-files-context.d.ts +9 -1
  88. package/project/context/flowr-analyzer-files-context.js +4 -0
  89. package/project/context/flowr-analyzer-functions-context.d.ts +29 -0
  90. package/project/context/flowr-analyzer-functions-context.js +68 -0
  91. package/project/context/flowr-file.d.ts +2 -0
  92. package/project/context/flowr-file.js +2 -0
  93. package/project/plugins/file-plugins/{flowr-description-file.d.ts → files/flowr-description-file.d.ts} +1 -1
  94. package/project/plugins/file-plugins/files/flowr-description-file.js +75 -0
  95. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +32 -0
  96. package/project/plugins/file-plugins/files/flowr-namespace-file.js +102 -0
  97. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +27 -0
  98. package/project/plugins/file-plugins/files/flowr-news-file.js +152 -0
  99. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
  100. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
  101. package/project/plugins/file-plugins/flowr-analyzer-namespace-file-plugin.d.ts +22 -0
  102. package/project/plugins/file-plugins/flowr-analyzer-namespace-file-plugin.js +34 -0
  103. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +23 -0
  104. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +35 -0
  105. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +1 -1
  106. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +1 -1
  107. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  108. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +1 -1
  109. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  110. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +1 -1
  111. package/project/plugins/flowr-analyzer-plugin-defaults.js +4 -0
  112. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +5 -1
  113. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +10 -0
  114. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +56 -0
  115. package/project/plugins/package-version-plugins/package.d.ts +15 -2
  116. package/project/plugins/package-version-plugins/package.js +33 -5
  117. package/project/plugins/plugin-registry.d.ts +3 -1
  118. package/project/plugins/plugin-registry.js +4 -0
  119. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +7 -1
  120. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -1
  121. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -0
  122. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -1
  123. package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -2
  124. package/queries/catalog/files-query/files-query-executor.d.ts +6 -0
  125. package/queries/catalog/files-query/files-query-executor.js +49 -0
  126. package/queries/catalog/files-query/files-query-format.d.ts +36 -0
  127. package/queries/catalog/files-query/files-query-format.js +114 -0
  128. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  129. package/queries/query.d.ts +10 -1
  130. package/queries/query.js +3 -1
  131. package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -1
  132. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +8 -8
  133. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +8 -8
  134. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +0 -1
  135. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +0 -1
  136. package/statistics/features/supported/data-access/data-access.js +1 -1
  137. package/util/containers.js +1 -1
  138. package/util/files.d.ts +0 -7
  139. package/util/files.js +0 -41
  140. package/util/mermaid/ast.d.ts +3 -2
  141. package/util/mermaid/ast.js +13 -7
  142. package/util/mermaid/cfg.d.ts +3 -2
  143. package/util/mermaid/cfg.js +26 -6
  144. package/util/mermaid/dfg.d.ts +1 -7
  145. package/util/mermaid/dfg.js +7 -3
  146. package/util/mermaid/info.d.ts +17 -0
  147. package/util/mermaid/info.js +5 -0
  148. package/util/prefix.d.ts +9 -5
  149. package/util/prefix.js +14 -6
  150. package/util/r-regex.d.ts +21 -0
  151. package/util/r-regex.js +25 -0
  152. package/util/text/args.js +12 -3
  153. package/util/version.js +1 -1
  154. package/abstract-interpretation/data-frame/absint-info.d.ts +0 -109
  155. package/abstract-interpretation/data-frame/absint-info.js +0 -31
  156. package/abstract-interpretation/data-frame/absint-visitor.d.ts +0 -57
  157. package/abstract-interpretation/data-frame/absint-visitor.js +0 -176
  158. package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +0 -21
  159. package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +0 -34
  160. package/documentation/doc-util/doc-print.d.ts +0 -5
  161. package/documentation/doc-util/doc-print.js +0 -36
  162. package/project/plugins/file-plugins/flowr-description-file.js +0 -37
  163. package/project/plugins/file-plugins/notebooks/notebook.d.ts +0 -0
  164. package/project/plugins/file-plugins/notebooks/notebook.js +0 -2
  165. /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.d.ts +0 -0
  166. /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.js +0 -0
  167. /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.d.ts +0 -0
  168. /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.js +0 -0
@@ -0,0 +1,29 @@
1
+ import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
2
+ import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
3
+ import { FlowrAnalyzerPackageVersionsPlugin } from '../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin';
4
+ export declare enum FunctionTypes {
5
+ Function = "function",
6
+ ExportTypes = "exportTypes",
7
+ S3 = "S3"
8
+ }
9
+ export interface FunctionInfo {
10
+ name: string;
11
+ packageOrigin: string;
12
+ isExported: boolean;
13
+ isS3Generic: boolean;
14
+ s3TypeDispatch?: string;
15
+ inferredType?: string;
16
+ }
17
+ export interface ReadOnlyFlowrAnalyzerFunctionsContext {
18
+ readonly name: string;
19
+ getFunctionInfo(name: string, className?: string): FunctionInfo | FunctionInfo[] | undefined;
20
+ }
21
+ export declare class FlowrAnalyzerFunctionsContext extends AbstractFlowrAnalyzerContext<undefined, void, FlowrAnalyzerPackageVersionsPlugin> implements ReadOnlyFlowrAnalyzerFunctionsContext {
22
+ readonly name = "flowr-analyzer-functions-context";
23
+ private functionInfo;
24
+ constructor(ctx: FlowrAnalyzerContext, plugins?: readonly FlowrAnalyzerPackageVersionsPlugin[]);
25
+ addFunctionInfo(info: FunctionInfo): void;
26
+ private mergeFunctionInfo;
27
+ getFunctionInfo(pkg: string, name: string, s3TypeDispatch?: string): FunctionInfo | FunctionInfo[] | undefined;
28
+ reset(): void;
29
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerFunctionsContext = exports.FunctionTypes = void 0;
4
+ const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-context");
5
+ const flowr_analyzer_package_versions_plugin_1 = require("../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin");
6
+ const flowr_analyzer_package_versions_namespace_file_plugin_1 = require("../plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin");
7
+ var FunctionTypes;
8
+ (function (FunctionTypes) {
9
+ FunctionTypes["Function"] = "function";
10
+ FunctionTypes["ExportTypes"] = "exportTypes";
11
+ FunctionTypes["S3"] = "S3";
12
+ })(FunctionTypes || (exports.FunctionTypes = FunctionTypes = {}));
13
+ class FlowrAnalyzerFunctionsContext extends abstract_flowr_analyzer_context_1.AbstractFlowrAnalyzerContext {
14
+ name = 'flowr-analyzer-functions-context';
15
+ functionInfo = new Map();
16
+ constructor(ctx, plugins) {
17
+ super(ctx, flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin.defaultPlugin(), plugins);
18
+ }
19
+ addFunctionInfo(info) {
20
+ const list = this.functionInfo.get(info.name);
21
+ if (!list) {
22
+ this.functionInfo.set(info.name, [info]);
23
+ return;
24
+ }
25
+ const other = list.find(e => e.name === info.name &&
26
+ e.packageOrigin === info.packageOrigin &&
27
+ e.s3TypeDispatch === info.s3TypeDispatch);
28
+ if (other) {
29
+ flowr_analyzer_package_versions_namespace_file_plugin_1.namespaceFileLog.warn('Namespace information is being merged!');
30
+ this.mergeFunctionInfo(other, info);
31
+ }
32
+ else {
33
+ list.push(info);
34
+ }
35
+ }
36
+ mergeFunctionInfo(functionInfo, other) {
37
+ if (functionInfo.name !== other.name || functionInfo.packageOrigin !== other.packageOrigin) {
38
+ throw new Error(`Cannot merge FunctionInfo for ${functionInfo.name} and ${other.name}`);
39
+ }
40
+ if (functionInfo.s3TypeDispatch !== other.s3TypeDispatch) {
41
+ throw new Error(`Cannot merge FunctionInfo with different S3 dispatch for ${functionInfo.name}`);
42
+ }
43
+ if (!functionInfo.inferredType && other.inferredType) {
44
+ functionInfo.inferredType = other.inferredType;
45
+ }
46
+ functionInfo.isExported ||= other.isExported;
47
+ functionInfo.isS3Generic ||= other.isS3Generic;
48
+ }
49
+ getFunctionInfo(pkg, name, s3TypeDispatch) {
50
+ if (s3TypeDispatch) {
51
+ return this.functionInfo.get(`${name}`)?.find(e => e.packageOrigin === pkg && e.s3TypeDispatch === s3TypeDispatch);
52
+ }
53
+ else if (name.includes('.')) {
54
+ const parts = name.split('.');
55
+ s3TypeDispatch = parts.pop();
56
+ const splitName = parts.join('.');
57
+ if (this.functionInfo.has(splitName)) {
58
+ return this.functionInfo.get(splitName)?.find(e => e.packageOrigin === pkg && e.s3TypeDispatch === s3TypeDispatch);
59
+ }
60
+ }
61
+ return this.functionInfo.get(name)?.filter(e => e.packageOrigin === pkg);
62
+ }
63
+ reset() {
64
+ this.functionInfo = new Map();
65
+ }
66
+ }
67
+ exports.FlowrAnalyzerFunctionsContext = FlowrAnalyzerFunctionsContext;
68
+ //# sourceMappingURL=flowr-analyzer-functions-context.js.map
@@ -15,6 +15,8 @@ export declare enum FileRole {
15
15
  Description = "description",
16
16
  /** The `NAMESPACE` file in R packages, currently not specially supported. */
17
17
  Namespace = "namespace",
18
+ /** The `NEWS` file in R packages */
19
+ News = "news",
18
20
  /** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
19
21
  Data = "data",
20
22
  /**
@@ -17,6 +17,8 @@ var FileRole;
17
17
  FileRole["Description"] = "description";
18
18
  /** The `NAMESPACE` file in R packages, currently not specially supported. */
19
19
  FileRole["Namespace"] = "namespace";
20
+ /** The `NEWS` file in R packages */
21
+ FileRole["News"] = "news";
20
22
  /** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
21
23
  FileRole["Data"] = "data";
22
24
  /**
@@ -1,4 +1,4 @@
1
- import { type FlowrFileProvider, type FileRole, FlowrFile } from '../../context/flowr-file';
1
+ import { type FlowrFileProvider, type FileRole, FlowrFile } from '../../../context/flowr-file';
2
2
  export type DCF = Map<string, string[]>;
3
3
  /**
4
4
  * This decorates a text file and provides access to its content as a DCF (Debian Control File)-like structure.
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrDescriptionFile = void 0;
4
+ const flowr_file_1 = require("../../../context/flowr-file");
5
+ /**
6
+ * This decorates a text file and provides access to its content as a DCF (Debian Control File)-like structure.
7
+ */
8
+ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
9
+ wrapped;
10
+ /**
11
+ * Prefer the static {@link FlowrDescriptionFile.from} method to create instances of this class as it will not re-create if already a description file
12
+ * and handle role assignments.
13
+ */
14
+ constructor(file) {
15
+ super(file.path(), file.role);
16
+ this.wrapped = file;
17
+ }
18
+ /**
19
+ * Loads and parses the content of the wrapped file as a DCF structure.
20
+ * @see {@link parseDCF} for details on the parsing logic.
21
+ */
22
+ loadContent() {
23
+ return parseDCF(this.wrapped);
24
+ }
25
+ /**
26
+ * Description file lifter, this does not re-create if already a description file
27
+ */
28
+ static from(file, role) {
29
+ if (role) {
30
+ file.assignRole(role);
31
+ }
32
+ return file instanceof FlowrDescriptionFile ? file : new FlowrDescriptionFile(file);
33
+ }
34
+ }
35
+ exports.FlowrDescriptionFile = FlowrDescriptionFile;
36
+ /**
37
+ * Parses the given file in the 'Debian Control Format'.
38
+ * @param file - The file to parse
39
+ */
40
+ function parseDCF(file) {
41
+ const result = new Map();
42
+ let currentKey = '';
43
+ let currentValue = '';
44
+ const indentRegex = new RegExp(/^\s/);
45
+ const firstColonRegex = new RegExp(/:(.*)/s);
46
+ const fileContent = file.content().toString().split(/\r?\n/);
47
+ for (const line of fileContent) {
48
+ if (indentRegex.test(line)) {
49
+ currentValue += '\n' + line.trim();
50
+ }
51
+ else {
52
+ if (currentKey) {
53
+ const values = currentValue ? cleanValues(currentValue) : [];
54
+ result.set(currentKey, values);
55
+ }
56
+ const [key, rest] = line.split(firstColonRegex).map(s => s.trim());
57
+ currentKey = key?.trim() ?? '';
58
+ currentValue = rest?.trim() ?? '';
59
+ }
60
+ }
61
+ if (currentKey) {
62
+ const values = currentValue ? cleanValues(currentValue) : [];
63
+ result.set(currentKey, values);
64
+ }
65
+ return result;
66
+ }
67
+ const cleanSplitRegex = /[\n,]+/;
68
+ const cleanQuotesRegex = /'/g;
69
+ function cleanValues(values) {
70
+ return values
71
+ .split(cleanSplitRegex)
72
+ .map(s => s.trim().replace(cleanQuotesRegex, ''))
73
+ .filter(s => s.length > 0);
74
+ }
75
+ //# sourceMappingURL=flowr-description-file.js.map
@@ -0,0 +1,32 @@
1
+ import type { FileRole, FlowrFileProvider } from '../../../context/flowr-file';
2
+ import { FlowrFile } from '../../../context/flowr-file';
3
+ export interface NamespaceInfo {
4
+ exportedSymbols: string[];
5
+ exportedFunctions: string[];
6
+ exportS3Generics: Map<string, string[]>;
7
+ loadsWithSideEffects: boolean;
8
+ }
9
+ export interface NamespaceFormat {
10
+ current: NamespaceInfo;
11
+ [packageName: string]: NamespaceInfo;
12
+ }
13
+ /**
14
+ * This decorates a text file and provides access to its content in the {@link NamespaceFormat}.
15
+ */
16
+ export declare class FlowrNamespaceFile extends FlowrFile<NamespaceFormat> {
17
+ private readonly wrapped;
18
+ /**
19
+ * Prefer the static {@link FlowrNamespaceFile.from} method to create instances of this class as it will not re-create if already a namespace file
20
+ * and handle role assignments.
21
+ */
22
+ constructor(file: FlowrFileProvider);
23
+ /**
24
+ * Loads and parses the content of the wrapped file in the {@link NamespaceFormat}.
25
+ * @see {@link parseNamespace} for details on the parsing logic.
26
+ */
27
+ protected loadContent(): NamespaceFormat;
28
+ /**
29
+ * Namespace file lifter, this does not re-create if already a namespace file
30
+ */
31
+ static from(file: FlowrFileProvider | FlowrNamespaceFile, role?: FileRole): FlowrNamespaceFile;
32
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrNamespaceFile = void 0;
4
+ const flowr_file_1 = require("../../../context/flowr-file");
5
+ /**
6
+ * This decorates a text file and provides access to its content in the {@link NamespaceFormat}.
7
+ */
8
+ class FlowrNamespaceFile extends flowr_file_1.FlowrFile {
9
+ wrapped;
10
+ /**
11
+ * Prefer the static {@link FlowrNamespaceFile.from} method to create instances of this class as it will not re-create if already a namespace file
12
+ * and handle role assignments.
13
+ */
14
+ constructor(file) {
15
+ super(file.path(), file.role);
16
+ this.wrapped = file;
17
+ }
18
+ /**
19
+ * Loads and parses the content of the wrapped file in the {@link NamespaceFormat}.
20
+ * @see {@link parseNamespace} for details on the parsing logic.
21
+ */
22
+ loadContent() {
23
+ return parseNamespace(this.wrapped);
24
+ }
25
+ /**
26
+ * Namespace file lifter, this does not re-create if already a namespace file
27
+ */
28
+ static from(file, role) {
29
+ if (role) {
30
+ file.assignRole(role);
31
+ }
32
+ return file instanceof FlowrNamespaceFile ? file : new FlowrNamespaceFile(file);
33
+ }
34
+ }
35
+ exports.FlowrNamespaceFile = FlowrNamespaceFile;
36
+ const cleanLineCommentRegex = /^#.*$/gm;
37
+ /**
38
+ * Parses the given NAMESPACE file
39
+ */
40
+ function parseNamespace(file) {
41
+ const result = {
42
+ current: {
43
+ exportedSymbols: [],
44
+ exportedFunctions: [],
45
+ exportS3Generics: new Map(),
46
+ loadsWithSideEffects: false,
47
+ },
48
+ };
49
+ const fileContent = file.content().toString().replaceAll(cleanLineCommentRegex, '').trim()
50
+ .split(/\r?\n/).filter(Boolean);
51
+ for (const line of fileContent) {
52
+ const match = line.trim().match(/^(\w+)\(([^)]*)\)$/);
53
+ if (!match) {
54
+ continue;
55
+ }
56
+ const [, type, args] = match;
57
+ switch (type) {
58
+ case 'exportClasses':
59
+ case 'exportMethods':
60
+ result.current.exportedFunctions.push(args);
61
+ break;
62
+ case 'S3method':
63
+ {
64
+ const parts = args.split(',').map(s => s.trim());
65
+ if (parts.length !== 2) {
66
+ continue;
67
+ }
68
+ const [pkg, func] = parts;
69
+ let arr = result.current.exportS3Generics.get(pkg);
70
+ if (!arr) {
71
+ arr = [];
72
+ result.current.exportS3Generics.set(pkg, arr);
73
+ }
74
+ arr.push(func);
75
+ break;
76
+ }
77
+ case 'export':
78
+ result.current.exportedSymbols.push(args);
79
+ break;
80
+ case 'useDynLib':
81
+ {
82
+ const parts = args.split(',').map(s => s.trim());
83
+ if (parts.length !== 2) {
84
+ continue;
85
+ }
86
+ const [pkg] = parts;
87
+ if (!result[pkg]) {
88
+ result[pkg] = {
89
+ exportedSymbols: [],
90
+ exportedFunctions: [],
91
+ exportS3Generics: new Map(),
92
+ loadsWithSideEffects: false,
93
+ };
94
+ }
95
+ result[pkg].loadsWithSideEffects = true;
96
+ break;
97
+ }
98
+ }
99
+ }
100
+ return result;
101
+ }
102
+ //# sourceMappingURL=flowr-namespace-file.js.map
@@ -0,0 +1,27 @@
1
+ import { type FlowrFileProvider, type FileRole, FlowrFile } from '../../../context/flowr-file';
2
+ export interface NewsChunk {
3
+ header?: string;
4
+ version?: string;
5
+ date?: string;
6
+ entries: string[] | NewsChunk[];
7
+ }
8
+ /**
9
+ * This decorates a text file and provides access to its content following R's NEWS file structure.
10
+ */
11
+ export declare class FlowrNewsFile extends FlowrFile<NewsChunk[]> {
12
+ private readonly wrapped;
13
+ /**
14
+ * Prefer the static {@link FlowrNewsFile.from} method to create instances of this class as it will not re-create if already a news file
15
+ * and handle role assignments.
16
+ */
17
+ constructor(file: FlowrFileProvider);
18
+ /**
19
+ * Loads and parses the content of the wrapped file as news chunks.
20
+ * @see {@link parseNews} for details on the parsing logic.
21
+ */
22
+ protected loadContent(): NewsChunk[];
23
+ /**
24
+ * News file lifter, this does not re-create if already a news file
25
+ */
26
+ static from(file: FlowrFileProvider | FlowrNewsFile, role?: FileRole): FlowrNewsFile;
27
+ }
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrNewsFile = void 0;
4
+ const flowr_file_1 = require("../../../context/flowr-file");
5
+ const r_regex_1 = require("../../../../util/r-regex");
6
+ const objects_1 = require("../../../../util/objects");
7
+ /**
8
+ * This decorates a text file and provides access to its content following R's NEWS file structure.
9
+ */
10
+ class FlowrNewsFile extends flowr_file_1.FlowrFile {
11
+ wrapped;
12
+ /**
13
+ * Prefer the static {@link FlowrNewsFile.from} method to create instances of this class as it will not re-create if already a news file
14
+ * and handle role assignments.
15
+ */
16
+ constructor(file) {
17
+ super(file.path(), file.role);
18
+ this.wrapped = file;
19
+ }
20
+ /**
21
+ * Loads and parses the content of the wrapped file as news chunks.
22
+ * @see {@link parseNews} for details on the parsing logic.
23
+ */
24
+ loadContent() {
25
+ return parseNews(this.wrapped);
26
+ }
27
+ /**
28
+ * News file lifter, this does not re-create if already a news file
29
+ */
30
+ static from(file, role) {
31
+ if (role) {
32
+ file.assignRole(role);
33
+ }
34
+ return file instanceof FlowrNewsFile ? file : new FlowrNewsFile(file);
35
+ }
36
+ }
37
+ exports.FlowrNewsFile = FlowrNewsFile;
38
+ function makeRversionRegex() {
39
+ // ^([[:space:]]*(%s)|(%s))(%s).*$
40
+ const fst = 'CHANGES? *(IN|FOR).*VERSION *|CHANGES? *(IN|FOR|TO) *';
41
+ const pVersion = r_regex_1.RStandardRegexp.ValidPackageVersion.source;
42
+ const pName = r_regex_1.RStandardRegexp.ValidPackageName.source;
43
+ const teachingDemos = [
44
+ // TeachingDemos pomp ouch
45
+ 'NEW IN .*',
46
+ // HyperbolicDist nls2 proto
47
+ 'VERSION:? *',
48
+ `${pName} +`,
49
+ // E.g., lattice:
50
+ // Changes in lattice 0.17
51
+ `CHANGES IN ${pName} +`,
52
+ // sv*
53
+ `== Changes in ${pName} +`,
54
+ // tcltk2
55
+ '== Version +',
56
+ // R2WinBUGS
57
+ 'update *',
58
+ 'v *',
59
+ '',
60
+ ].join('|');
61
+ const weAreNicerFlags = 'i';
62
+ const pkgVersionLine = `\\s*(${pName})\\s+version\\s+(${pVersion})\\s*|\\s*#+\\s*${pName} (\\([^)]*\\)|${pVersion}).*`;
63
+ return new RegExp(`^(\\s*(${fst})|(${teachingDemos}))((${pVersion}).*)|${pkgVersionLine}$`, weAreNicerFlags);
64
+ }
65
+ //"^.*([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2})[[:punct:][:space:]]*$",
66
+ const RDateRegex = new RegExp(`^.*(\\d{4}-\\d{2}-\\d{2})[${r_regex_1.RPunctuationChars}\\s]*$`);
67
+ // ^[[:space:]]*([o*+-])
68
+ const RBulletPointRegex = /^\s*(?<bullet>[o*+-])/;
69
+ // ^([[:alpha:]].*)[[:space:]]*$"
70
+ const RCategoryRegex = /^((#+\s*)?([A-Za-z].*))\s*$/;
71
+ const AnyVersionRegex = new RegExp(r_regex_1.RStandardRegexp.ValidPackageVersion.source + '|dev(e(l(opment)?)?)? (ver(sion)?)?|(?<=\\()[^)]*(?=\\))', 'i');
72
+ function splitLinesRegex(relevantLines, regex) {
73
+ const lineChunks = [];
74
+ let currentChunk = [];
75
+ for (const line of relevantLines) {
76
+ if (regex.test(line)) {
77
+ if (currentChunk.length > 0) {
78
+ lineChunks.push(currentChunk);
79
+ }
80
+ currentChunk = [line];
81
+ }
82
+ else {
83
+ currentChunk.push(line);
84
+ }
85
+ }
86
+ if (currentChunk.length > 0) {
87
+ lineChunks.push(currentChunk);
88
+ }
89
+ return lineChunks;
90
+ }
91
+ /**
92
+ * Parses the given file into news chunks.
93
+ * @param file - The file to parse
94
+ * @see https://github.com/r-devel/r-svn/blob/44474af03ae77fd3b9a340279fa10cb698d106c3/src/library/tools/R/news.R#L91-L92
95
+ */
96
+ function parseNews(file) {
97
+ // ^[[:space:]]*[[:punct:]]*[[:space:]]*
98
+ const noiseRegex = new RegExp(`^\\s*[${r_regex_1.RPunctuationChars}]*\\s*$`);
99
+ const lines = file.content().toString().split(/\r?\n/)
100
+ // first we clean underlines and friends (according to the R impl)
101
+ .filter(l => !noiseRegex.test(l));
102
+ // this is a port of the incredible complex R NEWS regex, but luckily it is not too liberal :D
103
+ const regexVersion = makeRversionRegex();
104
+ // filter lines that match the version regex
105
+ const versionLines = lines.map(line => regexVersion.test(line));
106
+ // drop the header by removing everything before the first match
107
+ const firstVersionIndex = versionLines.findIndex(v => v);
108
+ const relevantLines = lines.slice(firstVersionIndex);
109
+ // split at every version line
110
+ const lineChunks = splitLinesRegex(relevantLines, regexVersion);
111
+ /**
112
+ * @see https://github.com/r-devel/r-svn/blob/44474af03ae77fd3b9a340279fa10cb698d106c3/src/library/tools/R/news.R#L183
113
+ */
114
+ function processChunk(lines, header) {
115
+ let date;
116
+ let head;
117
+ if (header) {
118
+ head = AnyVersionRegex.exec(header)?.[0];
119
+ date = RDateRegex.exec(header)?.[1];
120
+ }
121
+ const content = lines.join('\n').trim();
122
+ const hasBullets = RBulletPointRegex.exec(content);
123
+ if (hasBullets) {
124
+ const separator = hasBullets.groups?.bullet ?? '-';
125
+ const lineChunks = splitLinesRegex(lines, new RegExp(`^\\s*[${separator}]\\s+`)).map(
126
+ // apparently we have to trim leading '\tab' indentations
127
+ chunkLines => chunkLines.map(l => {
128
+ return l.replace(new RegExp(`^\\s*[${separator}]\\s+`), '').replace(/^\t?/gm, '').trim();
129
+ }).join('\n'));
130
+ return (0, objects_1.compactRecord)({
131
+ header,
132
+ version: head,
133
+ date,
134
+ entries: lineChunks
135
+ });
136
+ }
137
+ else {
138
+ // from the spec: "Categories should be non-empty starting in column 1."
139
+ const categoryChunks = splitLinesRegex(lines, RCategoryRegex);
140
+ // different to R we may accept no category blobs here
141
+ return (0, objects_1.compactRecord)({
142
+ header,
143
+ version: head,
144
+ date,
145
+ entries: categoryChunks.length > 1 ?
146
+ categoryChunks.map(chunkLines => processChunk(chunkLines, header = RCategoryRegex.exec(chunkLines[0])?.[1])) : [content]
147
+ });
148
+ }
149
+ }
150
+ return lineChunks.map(l => processChunk(l.slice(1), l[0]));
151
+ }
152
+ //# sourceMappingURL=flowr-news-file.js.map
@@ -2,7 +2,7 @@ import { FlowrAnalyzerFilePlugin } from './flowr-analyzer-file-plugin';
2
2
  import { SemVer } from 'semver';
3
3
  import type { PathLike } from 'fs';
4
4
  import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
5
- import { FlowrDescriptionFile } from './flowr-description-file';
5
+ import { FlowrDescriptionFile } from './files/flowr-description-file';
6
6
  import { type FlowrFileProvider } from '../../context/flowr-file';
7
7
  export declare const descriptionFileLog: import("tslog").Logger<import("tslog").ILogObj>;
8
8
  /**
@@ -4,7 +4,7 @@ exports.FlowrAnalyzerDescriptionFilePlugin = exports.descriptionFileLog = void 0
4
4
  const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
5
5
  const semver_1 = require("semver");
6
6
  const log_1 = require("../../../util/log");
7
- const flowr_description_file_1 = require("./flowr-description-file");
7
+ const flowr_description_file_1 = require("./files/flowr-description-file");
8
8
  const flowr_file_1 = require("../../context/flowr-file");
9
9
  const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
10
10
  exports.descriptionFileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-loading-order-description-file-plugin' });
@@ -0,0 +1,22 @@
1
+ import { FlowrAnalyzerFilePlugin } from './flowr-analyzer-file-plugin';
2
+ import { SemVer } from 'semver';
3
+ import type { PathLike } from 'fs';
4
+ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
5
+ import type { FlowrFileProvider } from '../../context/flowr-file';
6
+ import { FlowrNamespaceFile } from './files/flowr-namespace-file';
7
+ /**
8
+ * This plugin provides support for R `NAMESPACE` files.
9
+ */
10
+ export declare class FlowrAnalyzerNamespaceFilePlugin extends FlowrAnalyzerFilePlugin {
11
+ readonly name = "flowr-analyzer-namespace-file-plugin";
12
+ readonly description = "This plugin provides support for NAMESPACE files and extracts their content into the NAMESPACEFormat.";
13
+ readonly version: SemVer;
14
+ private readonly pattern;
15
+ /**
16
+ * Creates a new instance of the NAMESPACE file plugin.
17
+ * @param filePattern - The pattern to identify NAMESPACE files, see {@link NamespaceFilePattern} for the default pattern.
18
+ */
19
+ constructor(filePattern?: RegExp);
20
+ applies(file: PathLike): boolean;
21
+ process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): FlowrNamespaceFile;
22
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerNamespaceFilePlugin = void 0;
4
+ const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
5
+ const semver_1 = require("semver");
6
+ const flowr_file_1 = require("../../context/flowr-file");
7
+ const flowr_namespace_file_1 = require("./files/flowr-namespace-file");
8
+ const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
9
+ const NamespaceFilePattern = /^NAMESPACE(\.txt)?$/i;
10
+ /**
11
+ * This plugin provides support for R `NAMESPACE` files.
12
+ */
13
+ class FlowrAnalyzerNamespaceFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin {
14
+ name = 'flowr-analyzer-namespace-file-plugin';
15
+ description = 'This plugin provides support for NAMESPACE files and extracts their content into the NAMESPACEFormat.';
16
+ version = new semver_1.SemVer('0.1.0');
17
+ pattern;
18
+ /**
19
+ * Creates a new instance of the NAMESPACE file plugin.
20
+ * @param filePattern - The pattern to identify NAMESPACE files, see {@link NamespaceFilePattern} for the default pattern.
21
+ */
22
+ constructor(filePattern = NamespaceFilePattern) {
23
+ super();
24
+ this.pattern = filePattern;
25
+ }
26
+ applies(file) {
27
+ return this.pattern.test((0, built_in_source_1.platformBasename)(file.toString()));
28
+ }
29
+ process(_ctx, file) {
30
+ return flowr_namespace_file_1.FlowrNamespaceFile.from(file, flowr_file_1.FileRole.Namespace);
31
+ }
32
+ }
33
+ exports.FlowrAnalyzerNamespaceFilePlugin = FlowrAnalyzerNamespaceFilePlugin;
34
+ //# sourceMappingURL=flowr-analyzer-namespace-file-plugin.js.map
@@ -0,0 +1,23 @@
1
+ import { FlowrAnalyzerFilePlugin } from './flowr-analyzer-file-plugin';
2
+ import { SemVer } from 'semver';
3
+ import type { PathLike } from 'fs';
4
+ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
5
+ import { type FlowrFileProvider } from '../../context/flowr-file';
6
+ import { FlowrNewsFile } from './files/flowr-news-file';
7
+ /**
8
+ * This plugin provides support for R `NEWS` files.
9
+ * @see https://rdrr.io/r/utils/news.html
10
+ */
11
+ export declare class FlowrAnalyzerNewsFilePlugin extends FlowrAnalyzerFilePlugin {
12
+ readonly name = "flowr-analyzer-news-file-plugin";
13
+ readonly description = "This plugin provides support for NEWS files and extracts their content into version chunks.";
14
+ readonly version: SemVer;
15
+ private readonly pattern;
16
+ /**
17
+ * Creates a new instance of the NEWS file plugin.
18
+ * @param filePattern - The pattern to identify NEWS files, see {@link NewsFilePattern} for the default pattern.
19
+ */
20
+ constructor(filePattern?: RegExp);
21
+ applies(file: PathLike): boolean;
22
+ process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): FlowrNewsFile;
23
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerNewsFilePlugin = void 0;
4
+ const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
5
+ const semver_1 = require("semver");
6
+ const flowr_file_1 = require("../../context/flowr-file");
7
+ const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
8
+ const flowr_news_file_1 = require("./files/flowr-news-file");
9
+ const NewsFilePattern = /^NEWS(\.(rd|md))?$/i;
10
+ /**
11
+ * This plugin provides support for R `NEWS` files.
12
+ * @see https://rdrr.io/r/utils/news.html
13
+ */
14
+ class FlowrAnalyzerNewsFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin {
15
+ name = 'flowr-analyzer-news-file-plugin';
16
+ description = 'This plugin provides support for NEWS files and extracts their content into version chunks.';
17
+ version = new semver_1.SemVer('0.1.0');
18
+ pattern;
19
+ /**
20
+ * Creates a new instance of the NEWS file plugin.
21
+ * @param filePattern - The pattern to identify NEWS files, see {@link NewsFilePattern} for the default pattern.
22
+ */
23
+ constructor(filePattern = NewsFilePattern) {
24
+ super();
25
+ this.pattern = filePattern;
26
+ }
27
+ applies(file) {
28
+ return this.pattern.test((0, built_in_source_1.platformBasename)(file.toString()));
29
+ }
30
+ process(_ctx, file) {
31
+ return flowr_news_file_1.FlowrNewsFile.from(file, flowr_file_1.FileRole.News);
32
+ }
33
+ }
34
+ exports.FlowrAnalyzerNewsFilePlugin = FlowrAnalyzerNewsFilePlugin;
35
+ //# sourceMappingURL=flowr-analyzer-news-file-plugin.js.map
@@ -3,7 +3,7 @@ import { SemVer } from 'semver';
3
3
  import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
4
4
  import type { FlowrFileProvider } from '../../../context/flowr-file';
5
5
  import { FlowrAnalyzerFilePlugin } from '../flowr-analyzer-file-plugin';
6
- import { FlowrJupyterFile } from './flowr-jupyter-file';
6
+ import { FlowrJupyterFile } from '../files/flowr-jupyter-file';
7
7
  /**
8
8
  * The plugin provides support for Jupyter (`.ipynb`) files
9
9
  */