@eagleoutice/flowr 2.10.7 → 2.10.9
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 +21 -21
- package/abstract-interpretation/domains/multi-value-state-domain.d.ts +4 -10
- package/abstract-interpretation/domains/multi-value-state-domain.js +1 -6
- package/abstract-interpretation/domains/partial-product-domain.d.ts +6 -2
- package/abstract-interpretation/domains/partial-product-domain.js +7 -3
- package/config.d.ts +10 -0
- package/config.js +6 -2
- package/control-flow/extract-cfg.js +9 -3
- package/dataflow/extractor.js +10 -1
- package/dataflow/graph/graph.js +6 -2
- package/dataflow/info.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +20 -0
- package/documentation/wiki-linting-and-testing.js +1 -1
- package/documentation/wiki-mk/doc-context.d.ts +21 -1
- package/documentation/wiki-mk/doc-context.js +9 -0
- package/documentation/wiki-search.js +13 -2
- package/linter/linter-rules.d.ts +4 -2
- package/linter/rules/absolute-path.d.ts +3 -0
- package/linter/rules/absolute-path.js +37 -12
- package/linter/rules/file-path-validity.d.ts +9 -2
- package/linter/rules/file-path-validity.js +83 -36
- package/linter/rules/problematic-inputs.js +4 -1
- package/package.json +4 -3
- package/queries/catalog/dependencies-query/function-info/read-functions.js +21 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +18 -1
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +3 -1
- package/queries/catalog/input-sources-query/input-source-functions.js +322 -46
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +14 -9
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +4 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +8 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +13 -6
- package/queries/catalog/input-sources-query/simple-input-classifier.js +33 -8
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -2
- package/queries/catalog/linter-query/linter-query-format.js +9 -3
- package/queries/query.d.ts +3 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +10 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +10 -2
- package/search/flowr-search-builder.d.ts +50 -16
- package/search/flowr-search-builder.js +33 -17
- package/search/flowr-search-filters.d.ts +10 -1
- package/search/flowr-search-filters.js +10 -0
- package/search/flowr-search.d.ts +8 -3
- package/search/search-executor/search-generators.d.ts +2 -0
- package/search/search-executor/search-generators.js +2 -2
- package/util/objects.js +3 -1
- package/util/text/strings.d.ts +7 -0
- package/util/text/strings.js +23 -0
- package/util/version.js +1 -1
|
@@ -112,11 +112,17 @@ exports.LinterQueryDefinition = {
|
|
|
112
112
|
rules: joi_1.default.array().items(joi_1.default.string().valid(...Object.keys(linter_rules_1.LintingRules)), joi_1.default.object({
|
|
113
113
|
name: joi_1.default.string().valid(...Object.keys(linter_rules_1.LintingRules)).required(),
|
|
114
114
|
config: joi_1.default.object()
|
|
115
|
-
})).description('The rules to lint for. If unset, all rules will be included.')
|
|
115
|
+
})).description('The rules to lint for. If unset, all rules will be included.'),
|
|
116
116
|
}).description('The linter query lints for the given set of rules and returns the result.'),
|
|
117
|
-
flattenInvolvedNodes: (queryResults) => {
|
|
117
|
+
flattenInvolvedNodes: (queryResults, _queries, certainty) => {
|
|
118
118
|
const out = queryResults;
|
|
119
|
-
return Object.values(out.results).flatMap(v =>
|
|
119
|
+
return Object.values(out.results).flatMap(v => {
|
|
120
|
+
if (linter_format_1.LintingResults.isError(v)) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
const rows = certainty !== undefined ? v.results.filter(r => r.certainty === certainty) : v.results;
|
|
124
|
+
return rows.flatMap(r => r.involvedId);
|
|
125
|
+
}).filter(assert_1.isNotUndefined);
|
|
120
126
|
}
|
|
121
127
|
};
|
|
122
128
|
function addLintingRuleResult(ruleName, results, result) {
|
package/queries/query.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ import type { DoesCallQuery } from './catalog/does-call-query/does-call-query-fo
|
|
|
35
35
|
import type { InspectExceptionQuery } from './catalog/inspect-exceptions-query/inspect-exception-query-format';
|
|
36
36
|
import type { InputSourcesQuery } from './catalog/input-sources-query/input-sources-query-format';
|
|
37
37
|
import type { ProvenanceQuery } from './catalog/provenance-query/provenance-query-format';
|
|
38
|
+
import type { LintingResultCertainty } from '../linter/linter-format';
|
|
38
39
|
/**
|
|
39
40
|
* These are all queries that can be executed from within flowR
|
|
40
41
|
*/
|
|
@@ -69,7 +70,7 @@ export interface SupportedQuery<QueryType extends BaseQueryFormat['type'] = Base
|
|
|
69
70
|
* Flattens the involved query nodes to be added to a flowR search when the {@link fromQuery} function is used based on the given result after this query is executed.
|
|
70
71
|
* If this query does not involve any nodes, an empty array can be returned.
|
|
71
72
|
*/
|
|
72
|
-
flattenInvolvedNodes: (queryResults: BaseQueryResult, query: readonly Query[]) => NodeId[];
|
|
73
|
+
flattenInvolvedNodes: (queryResults: BaseQueryResult, query: readonly Query[], certainty?: LintingResultCertainty) => NodeId[];
|
|
73
74
|
}
|
|
74
75
|
export declare const SupportedQueries: {
|
|
75
76
|
readonly 'call-context': {
|
|
@@ -244,7 +245,7 @@ export declare const SupportedQueries: {
|
|
|
244
245
|
readonly completer: (line: readonly string[], startingNewArg: boolean, _config: FlowrConfig) => CommandCompletions;
|
|
245
246
|
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"linter">;
|
|
246
247
|
readonly schema: Joi.ObjectSchema<any>;
|
|
247
|
-
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => ((string & {
|
|
248
|
+
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult, _queries: readonly Query[], certainty: LintingResultCertainty | undefined) => ((string & {
|
|
248
249
|
__brand?: "node-id";
|
|
249
250
|
}) | (number & {
|
|
250
251
|
__brand?: "node-id";
|
|
@@ -127,7 +127,16 @@ function decorateAst(project, { getId = deterministicCountingIdGenerator(0) }) {
|
|
|
127
127
|
...project,
|
|
128
128
|
files: project.files.map(file => {
|
|
129
129
|
info.file = file.filePath;
|
|
130
|
-
|
|
130
|
+
let decoratedAst;
|
|
131
|
+
try {
|
|
132
|
+
decoratedAst = (0, stateful_fold_1.foldAstStateful)(file.root, 0, folds);
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
if (e instanceof RangeError) {
|
|
136
|
+
throw new Error(`AST decoration exceeded the call stack for '${file.filePath ?? '<inline>'}' (code is too deeply nested). Consider --stack-size=65536 when invoking Node.js.`, { cause: e });
|
|
137
|
+
}
|
|
138
|
+
throw e;
|
|
139
|
+
}
|
|
131
140
|
decoratedAst.info.role = "root" /* RoleInParent.Root */;
|
|
132
141
|
decoratedAst.info.index = 0;
|
|
133
142
|
return {
|
|
@@ -239,13 +239,21 @@ function convertTreeNode(node) {
|
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
case tree_sitter_types_1.TreeSitterType.NamespaceOperator: {
|
|
242
|
-
const [
|
|
242
|
+
const [comments, children] = splitComments(nonErrorChildren(node));
|
|
243
|
+
if (children.length < 3) {
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
const [lhs, int, rhs] = children;
|
|
243
247
|
return {
|
|
244
248
|
type: type_1.RType.Symbol,
|
|
245
249
|
location: makeSourceRange(rhs),
|
|
246
250
|
content: identifier_1.Identifier.make(rhs.text, lhs.text, int.text === ':::'),
|
|
247
251
|
lexeme: rhs.text,
|
|
248
|
-
...defaultInfo
|
|
252
|
+
...defaultInfo,
|
|
253
|
+
info: {
|
|
254
|
+
...defaultInfo.info,
|
|
255
|
+
adToks: comments.map(c => c[1]),
|
|
256
|
+
}
|
|
249
257
|
};
|
|
250
258
|
}
|
|
251
259
|
case '(':
|
|
@@ -8,15 +8,26 @@ import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processin
|
|
|
8
8
|
import type { Enrichment, EnrichmentElementArguments } from './search-executor/search-enrichers';
|
|
9
9
|
import { type MapperArguments, Mapper } from './search-executor/search-mappers';
|
|
10
10
|
import type { Query } from '../queries/query';
|
|
11
|
+
import type { LintingResultCertainty } from '../linter/linter-format';
|
|
11
12
|
import type TreeSitter from 'web-tree-sitter';
|
|
12
13
|
type FlowrCriteriaReturn<C extends SlicingCriteria> = FlowrSearchElements<ParentInformation, C extends [] ? never : C extends [infer _] ? [
|
|
13
14
|
FlowrSearchElement<ParentInformation>
|
|
14
15
|
] : FlowrSearchElement<ParentInformation>[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns all elements (nodes/dataflow vertices) from the given data without any filters.
|
|
18
|
+
*/
|
|
19
|
+
declare function all(): FlowrSearchBuilder<'all'>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns all elements (nodes/dataflow vertices) that match the given file path regex.
|
|
22
|
+
* This internally uses {@link get} to filter by file path.
|
|
23
|
+
*/
|
|
24
|
+
declare function all(filePathRegex: string): FlowrSearchBuilder<'get'>;
|
|
15
25
|
/**
|
|
16
26
|
* This object holds all the methods to generate search queries.
|
|
17
27
|
* For compatibility, please use the {@link Q} identifier object to access these methods.
|
|
18
28
|
*/
|
|
19
29
|
export declare const FlowrSearchGenerator: {
|
|
30
|
+
readonly name: "FlowrSearchGenerator";
|
|
20
31
|
/**
|
|
21
32
|
* Initialize a search query with the given elements.
|
|
22
33
|
* <b>This is not intended to serialize well</b> wrt. the nodes,
|
|
@@ -28,16 +39,16 @@ export declare const FlowrSearchGenerator: {
|
|
|
28
39
|
* Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
|
|
29
40
|
* Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
|
|
30
41
|
*/
|
|
31
|
-
readonly fromQuery: (
|
|
42
|
+
readonly fromQuery: (from: Query | readonly Query[], certainty?: LintingResultCertainty) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
|
|
32
43
|
/**
|
|
33
44
|
* Initializes a new search query based on the results of the given tree-sitter syntax query.
|
|
34
45
|
* Please note that this search generator is incompatible with the {@link RShell} parser and only works when using flowR with the {@link TreeSitterExecutor}.
|
|
35
46
|
*/
|
|
36
47
|
readonly syntax: (source: TreeSitter.Query | string, ...captures: readonly string[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
|
|
37
48
|
/**
|
|
38
|
-
* Returns all elements (nodes/dataflow vertices) from the given data.
|
|
49
|
+
* Returns all elements (nodes/dataflow vertices) from the given data without any (or with a filename filter).
|
|
39
50
|
*/
|
|
40
|
-
readonly all:
|
|
51
|
+
readonly all: typeof all;
|
|
41
52
|
/**
|
|
42
53
|
* Returns all elements that match the given {@link FlowrSearchGetFilters|filters}.
|
|
43
54
|
* You may pass a negative line number to count from the back.
|
|
@@ -55,30 +66,41 @@ export declare const FlowrSearchGenerator: {
|
|
|
55
66
|
* Short form of {@link get} with only the
|
|
56
67
|
* {@link FlowrSearchGetFilters#line|line} and {@link FlowrSearchGetFilters#column|column} filters:
|
|
57
68
|
* `get({line, column})`. Please use {@link FlowrSearchGenerator#locFuzzy|locFuzzy} for a fuzzy location search.
|
|
69
|
+
* @param line - the line number to search in
|
|
70
|
+
* @param column - the column number to search in
|
|
71
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
58
72
|
*/
|
|
59
|
-
readonly loc: (line?: number, column?: number) => FlowrSearchBuilder<"get">;
|
|
73
|
+
readonly loc: (line?: number, column?: number, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
60
74
|
/**
|
|
61
75
|
* Fuzzy variant of {@link loc} that matches any node whose source range contains the given position.
|
|
62
76
|
* @param line - the line number to search in (required for fuzzy matching)
|
|
63
77
|
* @param column - the column number to search in
|
|
64
78
|
* @param innermostOnly - if true, return only the deepest (innermost) matching nodes in the AST
|
|
79
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
65
80
|
*/
|
|
66
|
-
readonly locFuzzy: (line: number, column
|
|
81
|
+
readonly locFuzzy: (line: number, column?: number, innermostOnly?: boolean, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
67
82
|
/**
|
|
68
83
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} and {@link FlowrSearchGetFilters#line|line} filters:
|
|
69
84
|
* `get({name, line})`.
|
|
85
|
+
* @param name - the variable name to search for
|
|
86
|
+
* @param line - the line number to search in
|
|
87
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
70
88
|
*/
|
|
71
|
-
readonly varInLine: (name: string, line: number) => FlowrSearchBuilder<"get">;
|
|
89
|
+
readonly varInLine: (name: string, line: number, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
72
90
|
/**
|
|
73
91
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} filter:
|
|
74
92
|
* `get({name})`.
|
|
93
|
+
* @param name - the variable name to search for
|
|
94
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
75
95
|
*/
|
|
76
|
-
readonly var: (name: string) => FlowrSearchBuilder<"get">;
|
|
96
|
+
readonly var: (name: string, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
77
97
|
/**
|
|
78
98
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#id|id} filter:
|
|
79
99
|
* `get({id})`.
|
|
100
|
+
* @param id - the node id to search for
|
|
101
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
80
102
|
*/
|
|
81
|
-
readonly id: (id: NodeId) => FlowrSearchBuilder<"get">;
|
|
103
|
+
readonly id: (id: NodeId, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
82
104
|
};
|
|
83
105
|
/**
|
|
84
106
|
* This is the root object to use for creating searches.
|
|
@@ -87,6 +109,7 @@ export declare const FlowrSearchGenerator: {
|
|
|
87
109
|
* you can use what is provided by the {@link FlowrSearchBuilder} to further refine the search.
|
|
88
110
|
*/
|
|
89
111
|
export declare const Q: {
|
|
112
|
+
readonly name: "FlowrSearchGenerator";
|
|
90
113
|
/**
|
|
91
114
|
* Initialize a search query with the given elements.
|
|
92
115
|
* <b>This is not intended to serialize well</b> wrt. the nodes,
|
|
@@ -98,16 +121,16 @@ export declare const Q: {
|
|
|
98
121
|
* Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
|
|
99
122
|
* Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
|
|
100
123
|
*/
|
|
101
|
-
readonly fromQuery: (
|
|
124
|
+
readonly fromQuery: (from: Query | readonly Query[], certainty?: LintingResultCertainty) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
|
|
102
125
|
/**
|
|
103
126
|
* Initializes a new search query based on the results of the given tree-sitter syntax query.
|
|
104
127
|
* Please note that this search generator is incompatible with the {@link RShell} parser and only works when using flowR with the {@link TreeSitterExecutor}.
|
|
105
128
|
*/
|
|
106
129
|
readonly syntax: (source: TreeSitter.Query | string, ...captures: readonly string[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
|
|
107
130
|
/**
|
|
108
|
-
* Returns all elements (nodes/dataflow vertices) from the given data.
|
|
131
|
+
* Returns all elements (nodes/dataflow vertices) from the given data without any (or with a filename filter).
|
|
109
132
|
*/
|
|
110
|
-
readonly all:
|
|
133
|
+
readonly all: typeof all;
|
|
111
134
|
/**
|
|
112
135
|
* Returns all elements that match the given {@link FlowrSearchGetFilters|filters}.
|
|
113
136
|
* You may pass a negative line number to count from the back.
|
|
@@ -125,30 +148,41 @@ export declare const Q: {
|
|
|
125
148
|
* Short form of {@link get} with only the
|
|
126
149
|
* {@link FlowrSearchGetFilters#line|line} and {@link FlowrSearchGetFilters#column|column} filters:
|
|
127
150
|
* `get({line, column})`. Please use {@link FlowrSearchGenerator#locFuzzy|locFuzzy} for a fuzzy location search.
|
|
151
|
+
* @param line - the line number to search in
|
|
152
|
+
* @param column - the column number to search in
|
|
153
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
128
154
|
*/
|
|
129
|
-
readonly loc: (line?: number, column?: number) => FlowrSearchBuilder<"get">;
|
|
155
|
+
readonly loc: (line?: number, column?: number, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
130
156
|
/**
|
|
131
157
|
* Fuzzy variant of {@link loc} that matches any node whose source range contains the given position.
|
|
132
158
|
* @param line - the line number to search in (required for fuzzy matching)
|
|
133
159
|
* @param column - the column number to search in
|
|
134
160
|
* @param innermostOnly - if true, return only the deepest (innermost) matching nodes in the AST
|
|
161
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
135
162
|
*/
|
|
136
|
-
readonly locFuzzy: (line: number, column
|
|
163
|
+
readonly locFuzzy: (line: number, column?: number, innermostOnly?: boolean, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
137
164
|
/**
|
|
138
165
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} and {@link FlowrSearchGetFilters#line|line} filters:
|
|
139
166
|
* `get({name, line})`.
|
|
167
|
+
* @param name - the variable name to search for
|
|
168
|
+
* @param line - the line number to search in
|
|
169
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
140
170
|
*/
|
|
141
|
-
readonly varInLine: (name: string, line: number) => FlowrSearchBuilder<"get">;
|
|
171
|
+
readonly varInLine: (name: string, line: number, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
142
172
|
/**
|
|
143
173
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} filter:
|
|
144
174
|
* `get({name})`.
|
|
175
|
+
* @param name - the variable name to search for
|
|
176
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
145
177
|
*/
|
|
146
|
-
readonly var: (name: string) => FlowrSearchBuilder<"get">;
|
|
178
|
+
readonly var: (name: string, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
147
179
|
/**
|
|
148
180
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#id|id} filter:
|
|
149
181
|
* `get({id})`.
|
|
182
|
+
* @param id - the node id to search for
|
|
183
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
150
184
|
*/
|
|
151
|
-
readonly id: (id: NodeId) => FlowrSearchBuilder<"get">;
|
|
185
|
+
readonly id: (id: NodeId, filePathRegex?: string) => FlowrSearchBuilder<"get">;
|
|
152
186
|
};
|
|
153
187
|
export type FlowrSearchBuilderType<Generator extends GeneratorNames = GeneratorNames, Transformers extends TransformerNames[] = TransformerNames[], Info = ParentInformation, ElementType = FlowrSearchElements<Info, FlowrSearchElement<Info>[]>> = FlowrSearchBuilder<Generator, Transformers, Info, ElementType>;
|
|
154
188
|
/**
|
|
@@ -5,12 +5,18 @@ exports.getFlowrSearch = getFlowrSearch;
|
|
|
5
5
|
const search_optimizer_1 = require("./search-optimizer/search-optimizer");
|
|
6
6
|
const assert_1 = require("../util/assert");
|
|
7
7
|
const search_mappers_1 = require("./search-executor/search-mappers");
|
|
8
|
-
|
|
8
|
+
function all(filePathRegex) {
|
|
9
|
+
if (!filePathRegex) {
|
|
10
|
+
return new FlowrSearchBuilder({ type: 'generator', name: 'all', args: undefined });
|
|
11
|
+
}
|
|
12
|
+
return exports.FlowrSearchGenerator.get({ filePathRegex });
|
|
13
|
+
}
|
|
9
14
|
/**
|
|
10
15
|
* This object holds all the methods to generate search queries.
|
|
11
16
|
* For compatibility, please use the {@link Q} identifier object to access these methods.
|
|
12
17
|
*/
|
|
13
18
|
exports.FlowrSearchGenerator = {
|
|
19
|
+
name: 'FlowrSearchGenerator',
|
|
14
20
|
/**
|
|
15
21
|
* Initialize a search query with the given elements.
|
|
16
22
|
* <b>This is not intended to serialize well</b> wrt. the nodes,
|
|
@@ -24,8 +30,9 @@ exports.FlowrSearchGenerator = {
|
|
|
24
30
|
* Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
|
|
25
31
|
* Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
|
|
26
32
|
*/
|
|
27
|
-
fromQuery(
|
|
28
|
-
|
|
33
|
+
fromQuery(from, certainty) {
|
|
34
|
+
const queries = Array.isArray(from) ? from : [from];
|
|
35
|
+
return new FlowrSearchBuilder({ type: 'generator', name: 'from-query', args: { from: queries, certainty } });
|
|
29
36
|
},
|
|
30
37
|
/**
|
|
31
38
|
* Initializes a new search query based on the results of the given tree-sitter syntax query.
|
|
@@ -35,11 +42,9 @@ exports.FlowrSearchGenerator = {
|
|
|
35
42
|
return new FlowrSearchBuilder({ type: 'generator', name: 'syntax', args: { source, captures } });
|
|
36
43
|
},
|
|
37
44
|
/**
|
|
38
|
-
* Returns all elements (nodes/dataflow vertices) from the given data.
|
|
45
|
+
* Returns all elements (nodes/dataflow vertices) from the given data without any (or with a filename filter).
|
|
39
46
|
*/
|
|
40
|
-
all
|
|
41
|
-
return new FlowrSearchBuilder(AllGeneratorObj);
|
|
42
|
-
},
|
|
47
|
+
all: all,
|
|
43
48
|
/**
|
|
44
49
|
* Returns all elements that match the given {@link FlowrSearchGetFilters|filters}.
|
|
45
50
|
* You may pass a negative line number to count from the back.
|
|
@@ -65,39 +70,50 @@ exports.FlowrSearchGenerator = {
|
|
|
65
70
|
* Short form of {@link get} with only the
|
|
66
71
|
* {@link FlowrSearchGetFilters#line|line} and {@link FlowrSearchGetFilters#column|column} filters:
|
|
67
72
|
* `get({line, column})`. Please use {@link FlowrSearchGenerator#locFuzzy|locFuzzy} for a fuzzy location search.
|
|
73
|
+
* @param line - the line number to search in
|
|
74
|
+
* @param column - the column number to search in
|
|
75
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
68
76
|
*/
|
|
69
|
-
loc(line, column) {
|
|
70
|
-
return exports.FlowrSearchGenerator.get({ line, column });
|
|
77
|
+
loc(line, column, filePathRegex) {
|
|
78
|
+
return exports.FlowrSearchGenerator.get({ line, column, filePathRegex });
|
|
71
79
|
},
|
|
72
80
|
/**
|
|
73
81
|
* Fuzzy variant of {@link loc} that matches any node whose source range contains the given position.
|
|
74
82
|
* @param line - the line number to search in (required for fuzzy matching)
|
|
75
83
|
* @param column - the column number to search in
|
|
76
84
|
* @param innermostOnly - if true, return only the deepest (innermost) matching nodes in the AST
|
|
85
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
77
86
|
*/
|
|
78
|
-
locFuzzy(line, column, innermostOnly
|
|
79
|
-
return exports.FlowrSearchGenerator.get({ line, column, fuzzy: true, innermostOnly });
|
|
87
|
+
locFuzzy(line, column, innermostOnly, filePathRegex) {
|
|
88
|
+
return exports.FlowrSearchGenerator.get({ line, column, fuzzy: true, innermostOnly: innermostOnly ?? false, filePathRegex });
|
|
80
89
|
},
|
|
81
90
|
/**
|
|
82
91
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} and {@link FlowrSearchGetFilters#line|line} filters:
|
|
83
92
|
* `get({name, line})`.
|
|
93
|
+
* @param name - the variable name to search for
|
|
94
|
+
* @param line - the line number to search in
|
|
95
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
84
96
|
*/
|
|
85
|
-
varInLine(name, line) {
|
|
86
|
-
return exports.FlowrSearchGenerator.get({ name, line });
|
|
97
|
+
varInLine(name, line, filePathRegex) {
|
|
98
|
+
return exports.FlowrSearchGenerator.get({ name, line, filePathRegex });
|
|
87
99
|
},
|
|
88
100
|
/**
|
|
89
101
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} filter:
|
|
90
102
|
* `get({name})`.
|
|
103
|
+
* @param name - the variable name to search for
|
|
104
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
91
105
|
*/
|
|
92
|
-
var(name) {
|
|
93
|
-
return exports.FlowrSearchGenerator.get({ name });
|
|
106
|
+
var(name, filePathRegex) {
|
|
107
|
+
return exports.FlowrSearchGenerator.get({ name, filePathRegex });
|
|
94
108
|
},
|
|
95
109
|
/**
|
|
96
110
|
* Short form of {@link get} with only the {@link FlowrSearchGetFilters#id|id} filter:
|
|
97
111
|
* `get({id})`.
|
|
112
|
+
* @param id - the node id to search for
|
|
113
|
+
* @param filePathRegex - optional regex to filter by file path
|
|
98
114
|
*/
|
|
99
|
-
id(id) {
|
|
100
|
-
return exports.FlowrSearchGenerator.get({ id });
|
|
115
|
+
id(id, filePathRegex) {
|
|
116
|
+
return exports.FlowrSearchGenerator.get({ id, filePathRegex });
|
|
101
117
|
}
|
|
102
118
|
};
|
|
103
119
|
/**
|
|
@@ -26,7 +26,12 @@ export declare enum FlowrFilter {
|
|
|
26
26
|
* Only returns search elements whose {@link FunctionOriginInformation} match a given pattern or value.
|
|
27
27
|
* This filter accepts {@link OriginKindArgs}, which includes the {@link DataflowGraphVertexFunctionCall.origin} to match for, whether to match for every or some origins, and whether to include non-function-calls in the filtered query.
|
|
28
28
|
*/
|
|
29
|
-
OriginKind = "origin-kind"
|
|
29
|
+
OriginKind = "origin-kind",
|
|
30
|
+
/**
|
|
31
|
+
* Only returns search elements whose file path matches the given regular expression.
|
|
32
|
+
* This filter accepts {@link FilePathFilterArgs}, which includes the file path regex to test against.
|
|
33
|
+
*/
|
|
34
|
+
FilePathFilter = "file-path-filter"
|
|
30
35
|
}
|
|
31
36
|
export type FlowrFilterFunction<T> = (e: FlowrSearchElement<ParentInformation>, args: T, data: {
|
|
32
37
|
dataflow: DataflowInformation;
|
|
@@ -41,6 +46,7 @@ export declare const FlowrFilters: {
|
|
|
41
46
|
readonly "origin-kind": (e: FlowrSearchElement<ParentInformation>, args: OriginKindArgs, data: {
|
|
42
47
|
dataflow: DataflowInformation;
|
|
43
48
|
}) => boolean;
|
|
49
|
+
readonly "file-path-filter": (e: FlowrSearchElement<ParentInformation>, args: FilePathFilterArgs) => boolean;
|
|
44
50
|
};
|
|
45
51
|
export type FlowrFilterArgs<F extends FlowrFilter> = typeof FlowrFilters[F] extends FlowrFilterFunction<infer Args> ? Args : never;
|
|
46
52
|
export interface MatchesEnrichmentArgs<E extends Enrichment> {
|
|
@@ -52,6 +58,9 @@ export interface OriginKindArgs {
|
|
|
52
58
|
matchType?: 'some' | 'every';
|
|
53
59
|
keepNonFunctionCalls?: boolean;
|
|
54
60
|
}
|
|
61
|
+
export interface FilePathFilterArgs {
|
|
62
|
+
filePathRegex: string | RegExp;
|
|
63
|
+
}
|
|
55
64
|
/**
|
|
56
65
|
* Helper to create a regular expression that matches function names, ignoring their package.
|
|
57
66
|
*/
|
|
@@ -27,6 +27,11 @@ var FlowrFilter;
|
|
|
27
27
|
* This filter accepts {@link OriginKindArgs}, which includes the {@link DataflowGraphVertexFunctionCall.origin} to match for, whether to match for every or some origins, and whether to include non-function-calls in the filtered query.
|
|
28
28
|
*/
|
|
29
29
|
FlowrFilter["OriginKind"] = "origin-kind";
|
|
30
|
+
/**
|
|
31
|
+
* Only returns search elements whose file path matches the given regular expression.
|
|
32
|
+
* This filter accepts {@link FilePathFilterArgs}, which includes the file path regex to test against.
|
|
33
|
+
*/
|
|
34
|
+
FlowrFilter["FilePathFilter"] = "file-path-filter";
|
|
30
35
|
})(FlowrFilter || (exports.FlowrFilter = FlowrFilter = {}));
|
|
31
36
|
exports.ValidFlowrFilters = new Set(Object.values(FlowrFilter));
|
|
32
37
|
exports.ValidFlowrFiltersReverse = Object.fromEntries(Object.entries(FlowrFilter).map(([k, v]) => [v, k]));
|
|
@@ -65,6 +70,11 @@ exports.FlowrFilters = {
|
|
|
65
70
|
(origin) => args.origin.test(origin);
|
|
66
71
|
const origins = Array.isArray(dfgNode.origin) ? dfgNode.origin : [dfgNode.origin];
|
|
67
72
|
return args.matchType === 'every' ? origins.every(match) : origins.some(match);
|
|
73
|
+
}),
|
|
74
|
+
[FlowrFilter.FilePathFilter]: ((e, args) => {
|
|
75
|
+
const file = e.node.info.file;
|
|
76
|
+
const rx = args.filePathRegex instanceof RegExp ? args.filePathRegex : new RegExp(args.filePathRegex);
|
|
77
|
+
return rx.test(file ?? '');
|
|
68
78
|
})
|
|
69
79
|
};
|
|
70
80
|
/**
|
package/search/flowr-search.d.ts
CHANGED
|
@@ -42,14 +42,19 @@ export interface FlowrSearchGetFilter extends Record<string, unknown> {
|
|
|
42
42
|
*/
|
|
43
43
|
readonly id?: NodeId;
|
|
44
44
|
/**
|
|
45
|
-
* The node must stem
|
|
45
|
+
* The node must stem from a file with the given path matching the regex.
|
|
46
|
+
* Inline code (code without a file path) is treated as having an empty path `""`.
|
|
46
47
|
* Please note that you can address the full path!
|
|
47
48
|
* @example
|
|
48
49
|
* ```ts
|
|
49
50
|
* // matches all files in any 'tests' folder
|
|
50
|
-
*
|
|
51
|
+
* filePathRegex: '.*\\tests\\.*'
|
|
51
52
|
* // matches all files named 'myfile.R' in any folder
|
|
52
|
-
*
|
|
53
|
+
* filePathRegex: '.*\\/myfile\\.R$'
|
|
54
|
+
* // matches only inline code
|
|
55
|
+
* filePathRegex: '^$'
|
|
56
|
+
* // matches inline code or .R files
|
|
57
|
+
* filePathRegex: '^$|.*\\.R$'
|
|
53
58
|
* ```
|
|
54
59
|
*/
|
|
55
60
|
readonly filePathRegex?: string;
|
|
@@ -3,6 +3,7 @@ import type { TailTypesOrUndefined } from '../../util/collections/arrays';
|
|
|
3
3
|
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import { type SlicingCriteria } from '../../slicing/criterion/parse';
|
|
5
5
|
import { type Query } from '../../queries/query';
|
|
6
|
+
import type { LintingResultCertainty } from '../../linter/linter-format';
|
|
6
7
|
import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
7
8
|
import type TreeSitter from 'web-tree-sitter';
|
|
8
9
|
export declare const searchLogger: import("tslog").Logger<import("tslog").ILogObj>;
|
|
@@ -36,6 +37,7 @@ declare function generateFrom(_input: ReadonlyFlowrAnalysisProvider, args: {
|
|
|
36
37
|
}): FlowrSearchElements<ParentInformation>;
|
|
37
38
|
declare function generateFromQuery(input: ReadonlyFlowrAnalysisProvider, args: {
|
|
38
39
|
from: readonly Query[];
|
|
40
|
+
certainty?: LintingResultCertainty;
|
|
39
41
|
}): Promise<FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
|
|
40
42
|
declare function generateSyntax(input: ReadonlyFlowrAnalysisProvider, args: {
|
|
41
43
|
source: TreeSitter.Query | string;
|
|
@@ -38,7 +38,7 @@ async function generateGet(input, { filter: { line, column, id, name, nameIsRege
|
|
|
38
38
|
await getAllNodes(input));
|
|
39
39
|
if (filePathRegex) {
|
|
40
40
|
const filePathFilter = new RegExp(filePathRegex);
|
|
41
|
-
potentials = potentials.filter(({ info }) =>
|
|
41
|
+
potentials = potentials.filter(({ info }) => filePathFilter.test(info.file ?? ''));
|
|
42
42
|
}
|
|
43
43
|
if (line && line < 0) {
|
|
44
44
|
(0, assert_1.guard)(normalize.ast.files.length === 1, 'Currently, negative line numbers are only supported for single-file inputs');
|
|
@@ -102,7 +102,7 @@ async function generateFromQuery(input, args) {
|
|
|
102
102
|
}
|
|
103
103
|
const nodes = new Set();
|
|
104
104
|
const queryDef = query_1.SupportedQueries[query];
|
|
105
|
-
for (const node of queryDef.flattenInvolvedNodes(content, args.from)) {
|
|
105
|
+
for (const node of queryDef.flattenInvolvedNodes(content, args.from, args.certainty)) {
|
|
106
106
|
nodes.add({ node: (await input.normalize()).idMap.get(node) });
|
|
107
107
|
}
|
|
108
108
|
nodesByQuery.set(query, nodes);
|
package/util/objects.js
CHANGED
|
@@ -76,7 +76,9 @@ function deepMergeObjectInPlace(base, addon) {
|
|
|
76
76
|
deepMergeObjectWithResult(addon, base, base);
|
|
77
77
|
}
|
|
78
78
|
else if (baseIsArray && addonIsArray) {
|
|
79
|
-
(
|
|
79
|
+
for (const item of addon) {
|
|
80
|
+
base.push(item);
|
|
81
|
+
}
|
|
80
82
|
}
|
|
81
83
|
else {
|
|
82
84
|
throw new Error('cannot merge object with array!');
|
package/util/text/strings.d.ts
CHANGED
|
@@ -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
|
*/
|
package/util/text/strings.js
CHANGED
|
@@ -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.
|
|
9
|
+
const version = '2.10.9';
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves the current flowR version as a new {@link SemVer} object.
|
|
12
12
|
*/
|