@eagleoutice/flowr 2.10.6 → 2.10.8

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 (78) hide show
  1. package/README.md +9 -9
  2. package/abstract-interpretation/domains/multi-value-state-domain.d.ts +4 -10
  3. package/abstract-interpretation/domains/multi-value-state-domain.js +1 -6
  4. package/abstract-interpretation/domains/partial-product-domain.d.ts +6 -2
  5. package/abstract-interpretation/domains/partial-product-domain.js +7 -3
  6. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  7. package/dataflow/environments/built-in-proc-name.d.ts +22 -20
  8. package/dataflow/environments/built-in-proc-name.js +22 -20
  9. package/dataflow/environments/built-in.d.ts +19 -19
  10. package/dataflow/environments/identifier.d.ts +5 -0
  11. package/dataflow/environments/reference-to-maybe.js +32 -6
  12. package/dataflow/eval/resolve/alias-tracking.js +5 -0
  13. package/dataflow/graph/graph.js +51 -30
  14. package/dataflow/graph/vertex.d.ts +12 -11
  15. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +49 -12
  16. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -2
  17. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +12 -6
  18. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +22 -8
  19. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +57 -1
  20. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  21. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +7 -7
  22. package/documentation/wiki-linting-and-testing.js +1 -1
  23. package/documentation/wiki-mk/doc-context.d.ts +21 -1
  24. package/documentation/wiki-mk/doc-context.js +9 -0
  25. package/documentation/wiki-search.js +13 -2
  26. package/linter/linter-format.d.ts +4 -0
  27. package/linter/linter-rules.d.ts +9 -7
  28. package/linter/rules/absolute-path.d.ts +3 -2
  29. package/linter/rules/absolute-path.js +37 -12
  30. package/linter/rules/dataframe-access-validation.d.ts +4 -7
  31. package/linter/rules/dataframe-access-validation.js +3 -3
  32. package/linter/rules/dead-code.d.ts +4 -7
  33. package/linter/rules/file-path-validity.d.ts +9 -4
  34. package/linter/rules/file-path-validity.js +83 -36
  35. package/linter/rules/function-finder-util.d.ts +1 -3
  36. package/linter/rules/function-finder-util.js +2 -2
  37. package/linter/rules/naming-convention.d.ts +0 -2
  38. package/linter/rules/network-functions.js +4 -1
  39. package/linter/rules/problematic-inputs.d.ts +0 -2
  40. package/linter/rules/problematic-inputs.js +4 -1
  41. package/linter/rules/roxygen-arguments.d.ts +0 -2
  42. package/linter/rules/seeded-randomness.d.ts +0 -2
  43. package/linter/rules/stop-with-call-arg.d.ts +3 -6
  44. package/linter/rules/unused-definition.d.ts +0 -2
  45. package/linter/rules/useless-loop.d.ts +0 -2
  46. package/package.json +7 -6
  47. package/queries/catalog/dependencies-query/dependencies-query-executor.js +6 -2
  48. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
  49. package/queries/catalog/dependencies-query/function-info/read-functions.js +21 -1
  50. package/queries/catalog/dependencies-query/function-info/source-functions.js +1 -1
  51. package/queries/catalog/dependencies-query/function-info/write-functions.js +18 -1
  52. package/queries/catalog/input-sources-query/input-source-functions.d.ts +3 -1
  53. package/queries/catalog/input-sources-query/input-source-functions.js +322 -46
  54. package/queries/catalog/input-sources-query/input-sources-query-executor.js +14 -9
  55. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +4 -2
  56. package/queries/catalog/input-sources-query/input-sources-query-format.js +8 -4
  57. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +13 -6
  58. package/queries/catalog/input-sources-query/simple-input-classifier.js +33 -8
  59. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -2
  60. package/queries/catalog/linter-query/linter-query-format.js +9 -3
  61. package/queries/query.d.ts +3 -2
  62. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
  63. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +16 -16
  64. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  65. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +8 -0
  66. package/search/flowr-search-builder.d.ts +64 -16
  67. package/search/flowr-search-builder.js +41 -16
  68. package/search/flowr-search-filters.d.ts +10 -1
  69. package/search/flowr-search-filters.js +10 -0
  70. package/search/flowr-search.d.ts +17 -3
  71. package/search/search-executor/search-generators.d.ts +3 -1
  72. package/search/search-executor/search-generators.js +30 -4
  73. package/slicing/static/static-slicer.js +2 -2
  74. package/util/range.d.ts +13 -1
  75. package/util/range.js +32 -2
  76. package/util/text/strings.d.ts +7 -0
  77. package/util/text/strings.js +23 -0
  78. package/util/version.js +1 -1
@@ -5,6 +5,7 @@ exports.getGenerator = getGenerator;
5
5
  const flowr_search_1 = require("../flowr-search");
6
6
  const parse_1 = require("../../slicing/criterion/parse");
7
7
  const assert_1 = require("../../util/assert");
8
+ const range_1 = require("../../util/range");
8
9
  const query_1 = require("../../queries/query");
9
10
  const search_enrichers_1 = require("./search-enrichers");
10
11
  const log_1 = require("../../util/log");
@@ -30,14 +31,14 @@ async function getAllNodes(data) {
30
31
  return [...new Map([...normalize.idMap.values()].map(n => [n.info.id, n]))
31
32
  .values()];
32
33
  }
33
- async function generateGet(input, { filter: { line, column, id, name, nameIsRegex, filePathRegex } }) {
34
+ async function generateGet(input, { filter: { line, column, id, name, nameIsRegex, filePathRegex, fuzzy, innermostOnly } }) {
34
35
  const normalize = await input.normalize();
35
36
  let potentials = (id ?
36
37
  [normalize.idMap.get(id)].filter(assert_1.isNotUndefined) :
37
38
  await getAllNodes(input));
38
39
  if (filePathRegex) {
39
40
  const filePathFilter = new RegExp(filePathRegex);
40
- potentials = potentials.filter(({ info }) => info.file && filePathFilter.test(info.file));
41
+ potentials = potentials.filter(({ info }) => filePathFilter.test(info.file ?? ''));
41
42
  }
42
43
  if (line && line < 0) {
43
44
  (0, assert_1.guard)(normalize.ast.files.length === 1, 'Currently, negative line numbers are only supported for single-file inputs');
@@ -45,7 +46,32 @@ async function generateGet(input, { filter: { line, column, id, name, nameIsRege
45
46
  (id ? (await getAllNodes(input)) : potentials).reduce((maxLine, { location }) => location && location[2] > maxLine ? location[2] : maxLine, 0);
46
47
  line = maxLines + line + 1;
47
48
  }
48
- if (line && column) {
49
+ if (fuzzy) {
50
+ (0, assert_1.guard)(line, 'Fuzzy location matching requires line to be provided');
51
+ potentials = potentials.filter(node => {
52
+ const range = range_1.SourceRange.fromNode(node);
53
+ if (!range) {
54
+ return false;
55
+ }
56
+ return column === undefined ? (range[0] <= line && line <= range[2]) : range_1.SourceRange.containsPosition(range, line, column);
57
+ });
58
+ if (innermostOnly && potentials.length > 1) {
59
+ potentials = potentials.filter(node => {
60
+ const range = range_1.SourceRange.fromNode(node);
61
+ return range && !potentials.some(other => {
62
+ if (other === node) {
63
+ return false;
64
+ }
65
+ else if (other.info.parent === node.info.id) {
66
+ return true;
67
+ }
68
+ const otherRange = range_1.SourceRange.fromNode(other);
69
+ return otherRange && range_1.SourceRange.isStrictSubsetOf(otherRange, range);
70
+ });
71
+ });
72
+ }
73
+ }
74
+ else if (line && column) {
49
75
  potentials = potentials.filter(({ location }) => location?.[0] === line && location?.[1] === column);
50
76
  }
51
77
  else if (line) {
@@ -76,7 +102,7 @@ async function generateFromQuery(input, args) {
76
102
  }
77
103
  const nodes = new Set();
78
104
  const queryDef = query_1.SupportedQueries[query];
79
- for (const node of queryDef.flattenInvolvedNodes(content, args.from)) {
105
+ for (const node of queryDef.flattenInvolvedNodes(content, args.from, args.certainty)) {
80
106
  nodes.add({ node: (await input.normalize()).idMap.get(node) });
81
107
  }
82
108
  nodesByQuery.set(query, nodes);
@@ -41,7 +41,7 @@ function staticSlice(ctx, info, { idMap }, ids, direction, threshold = 75, cache
41
41
  for (const startId of ids) {
42
42
  queue.add(startId, emptyEnv, basePrint, false);
43
43
  // retrieve the minimum nesting of all nodes to only add control dependencies if they are "part" of the current execution
44
- minNesting = Math.min(minNesting, idMap.get(startId)?.info.nesting ?? minNesting);
44
+ minNesting = Math.min(minNesting, idMap.get(startId)?.info.nest ?? minNesting);
45
45
  sliceSeedIds.add(startId);
46
46
  }
47
47
  /* additionally,
@@ -67,7 +67,7 @@ function staticSlice(ctx, info, { idMap }, ids, direction, threshold = 75, cache
67
67
  if (currentVertex.cds && currentVertex.cds.length > 0) {
68
68
  const topLevel = graph.isRoot(id) || sliceSeedIds.has(id);
69
69
  for (const cd of currentVertex.cds.filter(({ id }) => !queue.hasId(id))) {
70
- if (!topLevel || (idMap.get(cd.id)?.info.nesting ?? 0) >= minNesting) {
70
+ if (!topLevel || (idMap.get(cd.id)?.info.nest ?? 0) >= minNesting) {
71
71
  queue.add(cd.id, baseEnvironment, baseEnvFingerprint, false);
72
72
  }
73
73
  }
package/util/range.d.ts CHANGED
@@ -113,10 +113,22 @@ export declare const SourceRange: {
113
113
  * @returns a positive number if `r1` comes after `r2`, a negative number if `r1` comes before `r2`, and `0` if they are equal
114
114
  */
115
115
  readonly compare: (this: void, [r1sl, r1sc, ,]: SourceRange, [r2sl, r2sc, ,]: SourceRange) => number;
116
+ /**
117
+ * Checks if two ranges are equal (i.e., they start and end at the same position).
118
+ */
119
+ readonly equals: (this: void, [r1sl, r1sc, r1el, r1ec]: SourceRange, [r2sl, r2sc, r2el, r2ec]: SourceRange) => boolean;
120
+ /**
121
+ * Checks if a given position (line, column) is contained within the range.
122
+ */
123
+ readonly containsPosition: (this: void, [sl, sc, el, ec]: SourceRange, line: number, column: number) => boolean;
116
124
  /**
117
125
  * Checks if the first range is a subset of the second range.
118
126
  */
119
127
  readonly isSubsetOf: (this: void, [r1sl, r1sc, r1el, r1ec]: SourceRange, [r2sl, r2sc, r2el, r2ec]: SourceRange) => boolean;
128
+ /**
129
+ * Checks if the first range is a strict subset of the second range (i.e., it is a subset but not equal).
130
+ */
131
+ readonly isStrictSubsetOf: (this: void, r1: SourceRange, r2: SourceRange) => boolean;
120
132
  /**
121
133
  * Combines overlapping or subset ranges into a minimal set of ranges.
122
134
  * @see {@link SourceRange.merge} for merging multiple ranges into a single range.
@@ -152,7 +164,7 @@ export declare const SourceLocation: {
152
164
  * @returns undefined if the given range is undefined
153
165
  * @see {@link SourceRange.fromNode} for getting the range from an AST node
154
166
  */
155
- readonly fromNode: <OtherInfo>(this: void, node: RNode<OtherInfo>) => SourceLocation | undefined;
167
+ readonly fromNode: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => SourceLocation | undefined;
156
168
  /**
157
169
  * Maps the file part of a {@link SourceLocation|source location} using the given mapper function.
158
170
  */
package/util/range.js CHANGED
@@ -150,11 +150,41 @@ exports.SourceRange = {
150
150
  return r1sl - r2sl;
151
151
  }
152
152
  },
153
+ /**
154
+ * Checks if two ranges are equal (i.e., they start and end at the same position).
155
+ */
156
+ equals([r1sl, r1sc, r1el, r1ec], [r2sl, r2sc, r2el, r2ec]) {
157
+ return r1sl === r2sl && r1sc === r2sc && r1el === r2el && r1ec === r2ec;
158
+ },
159
+ /**
160
+ * Checks if a given position (line, column) is contained within the range.
161
+ */
162
+ containsPosition([sl, sc, el, ec], line, column) {
163
+ if (line < sl || line > el) {
164
+ return false;
165
+ }
166
+ else if (sl === el) {
167
+ return sc <= column && column <= ec;
168
+ }
169
+ else if (line === sl) {
170
+ return column >= sc;
171
+ }
172
+ else if (line === el) {
173
+ return column <= ec;
174
+ }
175
+ return true;
176
+ },
153
177
  /**
154
178
  * Checks if the first range is a subset of the second range.
155
179
  */
156
180
  isSubsetOf([r1sl, r1sc, r1el, r1ec], [r2sl, r2sc, r2el, r2ec]) {
157
- return (r1sl > r2sl || r1sl === r2sl && r1sc >= r2sc) && (r1el < r2el || r1sl === r2sl && r1ec <= r2ec);
181
+ return (r1sl > r2sl || r1sl === r2sl && r1sc >= r2sc) && (r1el < r2el || r1el === r2el && r1ec <= r2ec);
182
+ },
183
+ /**
184
+ * Checks if the first range is a strict subset of the second range (i.e., it is a subset but not equal).
185
+ */
186
+ isStrictSubsetOf(r1, r2) {
187
+ return exports.SourceRange.isSubsetOf(r1, r2) && !exports.SourceRange.equals(r1, r2);
158
188
  },
159
189
  /**
160
190
  * Combines overlapping or subset ranges into a minimal set of ranges.
@@ -208,7 +238,7 @@ exports.SourceLocation = {
208
238
  */
209
239
  fromNode(node) {
210
240
  const range = exports.SourceRange.fromNode(node);
211
- return range !== undefined ? exports.SourceLocation.from(range, node.info.file) : undefined;
241
+ return node !== undefined && range !== undefined ? exports.SourceLocation.from(range, node.info.file) : undefined;
212
242
  },
213
243
  /**
214
244
  * Maps the file part of a {@link SourceLocation|source location} using the given mapper function.
@@ -19,6 +19,13 @@ export declare function joinWithLast(strs: readonly string[], { join, last, join
19
19
  last?: string;
20
20
  joinTwo?: string;
21
21
  }): string;
22
+ /** Check if the given string looks like a remote URL (http/https/ftp/ftps/s3/gs). */
23
+ export declare function isUrl(p: string): boolean;
24
+ /**
25
+ * If `s` is a `file://` URI, return the local filesystem path it refers to.
26
+ * Returns `undefined` for any other string.
27
+ */
28
+ export declare function fileUrlToPath(s: string): string | undefined;
22
29
  /**
23
30
  * Check if the given path is an absolute path.
24
31
  */
@@ -7,9 +7,12 @@ exports.startAndEndsWith = startAndEndsWith;
7
7
  exports.withoutWhitespace = withoutWhitespace;
8
8
  exports.longestCommonPrefix = longestCommonPrefix;
9
9
  exports.joinWithLast = joinWithLast;
10
+ exports.isUrl = isUrl;
11
+ exports.fileUrlToPath = fileUrlToPath;
10
12
  exports.isAbsolutePath = isAbsolutePath;
11
13
  exports.dropRawStringSurround = dropRawStringSurround;
12
14
  const path_1 = __importDefault(require("path"));
15
+ const url_1 = require("url");
13
16
  /**
14
17
  * Check if the given string starts and ends with the given letter
15
18
  */
@@ -57,6 +60,26 @@ function joinWithLast(strs, { join = ', ', last = ', and ', joinTwo = ' and ' }
57
60
  }
58
61
  return strs.slice(0, -1).join(join) + last + strs[strs.length - 1];
59
62
  }
63
+ const UrlPattern = /^(https?|ftps?|s3|gs):\/\//i;
64
+ /** Check if the given string looks like a remote URL (http/https/ftp/ftps/s3/gs). */
65
+ function isUrl(p) {
66
+ return UrlPattern.test(p);
67
+ }
68
+ /**
69
+ * If `s` is a `file://` URI, return the local filesystem path it refers to.
70
+ * Returns `undefined` for any other string.
71
+ */
72
+ function fileUrlToPath(s) {
73
+ if (!s.startsWith('file://')) {
74
+ return undefined;
75
+ }
76
+ try {
77
+ return (0, url_1.fileURLToPath)(s);
78
+ }
79
+ catch {
80
+ return undefined;
81
+ }
82
+ }
60
83
  /**
61
84
  * Check if the given path is an absolute path.
62
85
  */
package/util/version.js CHANGED
@@ -6,7 +6,7 @@ exports.printVersionInformation = printVersionInformation;
6
6
  const semver_1 = require("semver");
7
7
  const assert_1 = require("./assert");
8
8
  // this is automatically replaced with the current version by release-it
9
- const version = '2.10.6';
9
+ const version = '2.10.8';
10
10
  /**
11
11
  * Retrieves the current flowR version as a new {@link SemVer} object.
12
12
  */