@eagleoutice/flowr 2.13.15 → 2.14.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 +31 -37
- package/abstract-interpretation/absint-visitor.js +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
- package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
- package/abstract-interpretation/data-frame/resolve-args.js +10 -5
- package/abstract-interpretation/unsupported-functions.d.ts +1 -0
- package/abstract-interpretation/unsupported-functions.js +1 -0
- package/benchmark/calibration.d.ts +12 -5
- package/benchmark/calibration.js +42 -14
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +5 -4
- package/benchmark/stats/size-of.js +1 -1
- package/benchmark/summarizer/first-phase/process.d.ts +2 -0
- package/benchmark/summarizer/first-phase/process.js +2 -0
- package/cli/common/options.d.ts +0 -31
- package/cli/common/options.js +1 -8
- package/cli/common/scripts-info.d.ts +0 -38
- package/cli/common/scripts-info.js +0 -8
- package/cli/repl/commands/repl-query.js +37 -2
- package/cli/repl/core.js +6 -3
- package/cli/repl/parser/slice-query-parser.js +1 -1
- package/cli/repl/print-version.js +2 -2
- package/config.d.ts +16 -0
- package/config.js +79 -0
- package/control-flow/control-flow-graph.d.ts +2 -0
- package/control-flow/control-flow-graph.js +2 -0
- package/control-flow/extract-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -1
- package/control-flow/useless-loop.js +1 -1
- package/core/print/slice-diff-ansi.js +1 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/built-in-props.d.ts +8 -1
- package/dataflow/environments/built-in-props.js +18 -0
- package/dataflow/environments/built-in.d.ts +7 -1
- package/dataflow/environments/built-in.js +42 -3
- package/dataflow/environments/default-builtin-config.d.ts +442 -10
- package/dataflow/environments/default-builtin-config.js +188 -18
- package/dataflow/environments/environment.d.ts +1 -1
- package/dataflow/environments/identifier.d.ts +7 -2
- package/dataflow/environments/identifier.js +6 -1
- package/dataflow/environments/query-fn-props.js +2 -2
- package/dataflow/environments/reference-to-maybe.js +5 -5
- package/dataflow/environments/resolve-by-name.d.ts +3 -0
- package/dataflow/environments/resolve-by-name.js +30 -5
- package/dataflow/environments/resolve-helper.d.ts +6 -0
- package/dataflow/environments/resolve-helper.js +6 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
- package/dataflow/eval/resolve/alias-tracking.js +21 -14
- package/dataflow/eval/resolve/node-value.d.ts +6 -0
- package/dataflow/eval/resolve/node-value.js +15 -9
- package/dataflow/eval/resolve/resolve-argument.js +2 -2
- package/dataflow/eval/resolve/resolve-numbers.js +2 -2
- package/dataflow/eval/resolve/resolve-operators.js +4 -3
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -1
- package/dataflow/eval/resolve/resolve.d.ts +5 -5
- package/dataflow/eval/resolve/resolve.js +10 -11
- package/dataflow/eval/values/general.d.ts +4 -1
- package/dataflow/eval/values/general.js +4 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/fn/exceptions-of-function.js +5 -4
- package/dataflow/fn/higher-order-function.d.ts +1 -1
- package/dataflow/fn/higher-order-function.js +22 -2
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +15 -15
- package/dataflow/graph/df-helper.d.ts +17 -2
- package/dataflow/graph/df-helper.js +11 -5
- package/dataflow/graph/diff-dataflow-graph.js +6 -6
- package/dataflow/graph/edge.d.ts +27 -0
- package/dataflow/graph/edge.js +33 -0
- package/dataflow/graph/graph-helper.d.ts +4 -4
- package/dataflow/graph/graph-helper.js +5 -5
- package/dataflow/graph/graph.d.ts +11 -1
- package/dataflow/graph/graph.js +16 -5
- package/dataflow/graph/vertex.d.ts +47 -6
- package/dataflow/graph/vertex.js +47 -6
- package/dataflow/internal/linker.d.ts +1 -0
- package/dataflow/internal/linker.js +11 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +8 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +15 -12
- package/dataflow/internal/process/functions/call/common.d.ts +9 -1
- package/dataflow/internal/process/functions/call/common.js +17 -6
- package/dataflow/internal/process/functions/call/deferred.d.ts +7 -0
- package/dataflow/internal/process/functions/call/deferred.js +24 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
- package/dataflow/internal/process/functions/call/nse.d.ts +34 -5
- package/dataflow/internal/process/functions/call/nse.js +114 -6
- package/dataflow/internal/process/functions/call/quoted.d.ts +6 -0
- package/dataflow/internal/process/functions/call/quoted.js +26 -11
- package/dataflow/origin/dfg-get-origin.d.ts +1 -0
- package/dataflow/origin/dfg-get-origin.js +9 -6
- package/documentation/data/faq/faqs.js +88 -88
- package/documentation/data/faq/recommended-configs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +1 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-auto-gen.js +6 -2
- package/documentation/doc-util/doc-functions.js +1 -1
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-create-linting-rules.js +45 -45
- package/documentation/wiki-dataflow-graph.js +25 -18
- package/documentation/wiki-linting-and-testing.js +93 -5
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-overview.js +12 -1
- package/documentation/wiki-signature-database.js +3 -0
- package/linter/linter-format.d.ts +1 -0
- package/linter/linter-format.js +1 -0
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/no-leaked-credentials.js +2 -1
- package/linter/rules/stop-with-call-arg.js +4 -4
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +5 -4
- package/linter/rules/undefined-symbol.js +3 -3
- package/linter/rules/unused-definition.js +2 -1
- package/package.json +35 -45
- package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
- package/project/context/flowr-analyzer-environment-context.js +25 -0
- package/project/dependency-version-space.js +1 -2
- package/project/flowr-analyzer.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +3 -3
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
- package/project/sigdb/build.js +16 -16
- package/project/sigdb/codec.d.ts +1 -1
- package/project/sigdb/codec.js +13 -13
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +33 -33
- package/project/sigdb/index-format.js +2 -2
- package/project/sigdb/manifest.js +21 -21
- package/project/sigdb/memory-source.d.ts +64 -0
- package/project/sigdb/memory-source.js +133 -0
- package/project/sigdb/reader.js +13 -13
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
- package/queries/catalog/dependencies-query/link-devices.js +2 -2
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/does-call-query/does-call-query-format.js +2 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +2 -2
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
- package/queries/catalog/signature-query/signature-query-executor.js +3 -2
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
- package/r-bridge/retriever.d.ts +2 -1
- package/r-bridge/retriever.js +3 -2
- package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
- package/r-bridge/roxygen2/documentation-provider.js +1 -0
- package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +2 -2
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.d.ts +1 -0
- package/slicing/criterion/parse.js +4 -3
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/static-slicer.js +4 -3
- package/util/assert.js +1 -1
- package/util/log.d.ts +4 -1
- package/util/log.js +15 -2
- package/util/logic.js +2 -2
- package/util/mermaid/cfg.js +1 -1
- package/util/mermaid/dfg.js +6 -6
- package/util/mermaid/mermaid.js +3 -1
- package/util/quads.js +19 -6
- package/util/r-version.d.ts +2 -0
- package/util/r-version.js +2 -0
- package/util/record.d.ts +1 -0
- package/util/record.js +1 -0
- package/util/schema.js +2 -2
- package/util/text/ansi.d.ts +2 -0
- package/util/text/ansi.js +8 -0
- package/util/text/name-rank.d.ts +29 -0
- package/util/text/name-rank.js +39 -0
- package/util/text/url-encoding.d.ts +15 -0
- package/util/text/url-encoding.js +59 -0
- package/util/version.js +1 -1
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -44
|
@@ -35,7 +35,7 @@ function tryNormalizeFunctionCall(data, mappedWithName) {
|
|
|
35
35
|
// special handling when someone calls a function by string
|
|
36
36
|
return parseNamedFunctionCall(data, namedSymbolContent, mappedWithName, location, content);
|
|
37
37
|
}
|
|
38
|
-
else if (namedSymbolContent.
|
|
38
|
+
else if (!namedSymbolContent.some(x => x.name === type_1.RawRType.SymbolFunctionCall)) {
|
|
39
39
|
parser_1.parseLog.trace(`is not named function call, as the name is not of type ${type_1.RType.FunctionCall}, but: ${namedSymbolContent.map(n => n.name).join(',')}`);
|
|
40
40
|
return tryParseUnnamedFunctionCall(data, mappedWithName, location, content);
|
|
41
41
|
}
|
|
@@ -27,7 +27,7 @@ function tryNormalizeFunctionDefinition(data, mappedWithName) {
|
|
|
27
27
|
(0, assert_1.guard)(closingParenIndex !== -1, () => `expected closing parenthesis, yet received ${JSON.stringify(mappedWithName)}`);
|
|
28
28
|
const splitParameters = (0, arrays_1.splitArrayOn)(mappedWithName.slice(2, closingParenIndex), x => x.name === type_1.RawRType.Comma);
|
|
29
29
|
const parameters = splitParameters.map(x => (0, normalize_parameter_1.tryNormalizeParameter)(data, x));
|
|
30
|
-
if (parameters.
|
|
30
|
+
if (parameters.includes(undefined)) {
|
|
31
31
|
parser_1.parseLog.error(`function had unexpected unknown parameters: ${JSON.stringify(parameters.filter(assert_1.isNotUndefined))}, aborting.`);
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
package/r-bridge/retriever.d.ts
CHANGED
|
@@ -70,7 +70,8 @@ export declare function retrieveParseDataFromRCode(request: RParseRequest, shell
|
|
|
70
70
|
/**
|
|
71
71
|
* Uses {@link retrieveParseDataFromRCode} and returns the nicely formatted object-AST.
|
|
72
72
|
* If successful, allows further querying the last result with {@link retrieveNumberOfRTokensOfLastParse}.
|
|
73
|
-
* This function is outdated and should only be used for legacy reasons.
|
|
73
|
+
* This function is outdated and should only be used for legacy reasons.
|
|
74
|
+
* @useInstead {@link FlowrAnalyzer}
|
|
74
75
|
*/
|
|
75
76
|
export declare function retrieveNormalizedAstFromRCode(request: RParseRequest, shell: RShell): Promise<NormalizedAst>;
|
|
76
77
|
/**
|
package/r-bridge/retriever.js
CHANGED
|
@@ -50,7 +50,7 @@ function requestFromInput(input) {
|
|
|
50
50
|
if (file) {
|
|
51
51
|
return {
|
|
52
52
|
request: 'file',
|
|
53
|
-
content: content.
|
|
53
|
+
content: content.slice(exports.fileProtocol.length),
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
@@ -148,7 +148,8 @@ function retrieveParseDataFromRCode(request, shell) {
|
|
|
148
148
|
/**
|
|
149
149
|
* Uses {@link retrieveParseDataFromRCode} and returns the nicely formatted object-AST.
|
|
150
150
|
* If successful, allows further querying the last result with {@link retrieveNumberOfRTokensOfLastParse}.
|
|
151
|
-
* This function is outdated and should only be used for legacy reasons.
|
|
151
|
+
* This function is outdated and should only be used for legacy reasons.
|
|
152
|
+
* @useInstead {@link FlowrAnalyzer}
|
|
152
153
|
*/
|
|
153
154
|
async function retrieveNormalizedAstFromRCode(request, shell) {
|
|
154
155
|
const data = await retrieveParseDataFromRCode(request, shell);
|
|
@@ -11,5 +11,6 @@ export type Documentation = RoxygenTag | readonly RoxygenTag[];
|
|
|
11
11
|
* Additionally, this function instruments the normalized AST to cache the parsed documentation for future queries.
|
|
12
12
|
* @param idMap - The AST ID map to use for looking up nodes and traversing the AST.
|
|
13
13
|
* @param nodeId - The ID of the node to get documentation for.
|
|
14
|
+
* @useInstead {@link RNode.documentation}
|
|
14
15
|
*/
|
|
15
16
|
export declare function getDocumentationOf(nodeId: NodeId, idMap: AstIdMap<ParentInformation & DocumentationInfo>): Documentation | undefined;
|
|
@@ -36,6 +36,7 @@ const defaultRetriever = (c, a) => (0, roxygen_parse_1.parseRoxygenCommentsOfNod
|
|
|
36
36
|
* Additionally, this function instruments the normalized AST to cache the parsed documentation for future queries.
|
|
37
37
|
* @param idMap - The AST ID map to use for looking up nodes and traversing the AST.
|
|
38
38
|
* @param nodeId - The ID of the node to get documentation for.
|
|
39
|
+
* @useInstead {@link RNode.documentation}
|
|
39
40
|
*/
|
|
40
41
|
function getDocumentationOf(nodeId, idMap) {
|
|
41
42
|
const node = idMap.get(nodeId);
|
|
@@ -5,7 +5,7 @@ import type { AstIdMap, ParentInformation } from '../lang-4.x/ast/model/processi
|
|
|
5
5
|
* Parses the roxygen comments attached to a node into a RoxygenBlock AST node.
|
|
6
6
|
* Will return `undefined` if there are no valid roxygen comments attached to the node.
|
|
7
7
|
* Please note that this does *not* do any clever mapping of parameters or requests.
|
|
8
|
-
* For a higher-level function that also traverses up the AST to find comments attached to parent nodes, see {@link
|
|
8
|
+
* For a higher-level function that also traverses up the AST to find comments attached to parent nodes, see {@link RNode.documentation}.
|
|
9
9
|
* @param node - The node to parse the roxygen comments for
|
|
10
10
|
* @param idMap - An optional id map to traverse up the AST to find comments attached to parent nodes
|
|
11
11
|
*/
|
|
@@ -27,7 +27,7 @@ function prepareCommentContext(commentText) {
|
|
|
27
27
|
* Parses the roxygen comments attached to a node into a RoxygenBlock AST node.
|
|
28
28
|
* Will return `undefined` if there are no valid roxygen comments attached to the node.
|
|
29
29
|
* Please note that this does *not* do any clever mapping of parameters or requests.
|
|
30
|
-
* For a higher-level function that also traverses up the AST to find comments attached to parent nodes, see {@link
|
|
30
|
+
* For a higher-level function that also traverses up the AST to find comments attached to parent nodes, see {@link RNode.documentation}.
|
|
31
31
|
* @param node - The node to parse the roxygen comments for
|
|
32
32
|
* @param idMap - An optional id map to traverse up the AST to find comments attached to parent nodes
|
|
33
33
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RType } from '../r-bridge/lang-4.x/ast/model/type';
|
|
2
|
-
import { VertexType } from '../dataflow/graph/vertex';
|
|
2
|
+
import type { VertexType } from '../dataflow/graph/vertex';
|
|
3
3
|
import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { FlowrSearchElement } from './flowr-search';
|
|
5
5
|
import type { Enrichment } from './search-executor/search-enrichers';
|
|
@@ -60,7 +60,7 @@ exports.FlowrFilters = {
|
|
|
60
60
|
}),
|
|
61
61
|
[FlowrFilter.OriginKind]: ((e, args, data) => {
|
|
62
62
|
const dfgNode = data.dataflow.graph.getVertex(e.node.info.id);
|
|
63
|
-
if (!dfgNode ||
|
|
63
|
+
if (!dfgNode || !vertex_1.FunctionCallVertex.is(dfgNode)) {
|
|
64
64
|
return args.keepNonFunctionCalls ?? false;
|
|
65
65
|
}
|
|
66
66
|
const match = typeof args.origin === 'string' ?
|
|
@@ -80,7 +80,7 @@ exports.FlowrFilters = {
|
|
|
80
80
|
[FlowrFilter.CallProps]: ((e, args, data) => {
|
|
81
81
|
const graph = data.dataflow.graph;
|
|
82
82
|
const vertex = graph.getVertex(e.node.info.id);
|
|
83
|
-
if (
|
|
83
|
+
if (!vertex_1.FunctionCallVertex.is(vertex)) {
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
/* what the call resolved to decides, as a definition in the analyzed code shadows the built-in; a call
|
|
@@ -13,7 +13,7 @@ const cfg_kind_1 = require("../../project/cfg-kind");
|
|
|
13
13
|
const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
14
14
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
15
15
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
16
|
-
const
|
|
16
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
17
17
|
/**
|
|
18
18
|
* An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
|
|
19
19
|
* See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
|
|
@@ -43,7 +43,7 @@ exports.Enrichments = {
|
|
|
43
43
|
const df = shared?.dfg ?? await analyzer.dataflow();
|
|
44
44
|
const n = shared?.ast ?? await analyzer.normalize();
|
|
45
45
|
const callVertex = df.graph.getVertex(e.node.info.id);
|
|
46
|
-
if (
|
|
46
|
+
if (vertex_1.FunctionCallVertex.is(callVertex)) {
|
|
47
47
|
const origins = df_helper_1.Dataflow.origin(df.graph, callVertex.id);
|
|
48
48
|
if (!origins || origins.length === 0) {
|
|
49
49
|
const name = (0, node_id_1.recoverName)(callVertex.id, n.idMap);
|
|
@@ -111,7 +111,7 @@ exports.Enrichments = {
|
|
|
111
111
|
const shared = s.enrichmentContent(Enrichment.LastCall);
|
|
112
112
|
const df = (shared?.dfg ?? await analyzer.dataflow()).graph;
|
|
113
113
|
const vertex = df.getVertex(e.node.info.id);
|
|
114
|
-
if (
|
|
114
|
+
if (vertex_1.FunctionCallVertex.is(vertex)) {
|
|
115
115
|
const n = shared?.ast ?? await analyzer.normalize();
|
|
116
116
|
const cfg = (shared?.cfg ?? await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.Quick)).graph;
|
|
117
117
|
for (const arg of args) {
|
|
@@ -168,7 +168,7 @@ exports.Enrichments = {
|
|
|
168
168
|
});
|
|
169
169
|
const shared = search.enrichmentContent(Enrichment.Roxygen);
|
|
170
170
|
const normalize = shared?.ast ?? await analyzer.normalize();
|
|
171
|
-
const roxygen =
|
|
171
|
+
const roxygen = model_1.RNode.documentation(e.node.info.id, normalize.idMap);
|
|
172
172
|
if (roxygen !== undefined) {
|
|
173
173
|
const comments = (Array.isArray(roxygen) ? roxygen : [roxygen]);
|
|
174
174
|
content.documentation.push(...comments);
|
|
@@ -114,7 +114,7 @@ async function generateSyntax(input, args) {
|
|
|
114
114
|
args.captures = [defaultCaptureName];
|
|
115
115
|
}
|
|
116
116
|
// allow specifying capture names with or without the @ in front :)
|
|
117
|
-
const captures = new Set(args.captures.map(c => c.startsWith('@') ? c.
|
|
117
|
+
const captures = new Set(args.captures.map(c => c.startsWith('@') ? c.slice(1) : c));
|
|
118
118
|
const info = input.parserInformation();
|
|
119
119
|
(0, assert_1.guard)(info.name === 'tree-sitter', 'treeSitterQuery can only be used with TreeSitterExecutor parsers!');
|
|
120
120
|
const result = await info.treeSitterQuery(args.source);
|
|
@@ -44,6 +44,7 @@ export type DecodedCriteria = ReadonlyArray<DecodedCriterion>;
|
|
|
44
44
|
* The helper object associated with {@link SlicingCriteria} which makes it easy to parse, validate and resolve slicing criteria.
|
|
45
45
|
*/
|
|
46
46
|
export declare const SlicingCriteria: {
|
|
47
|
+
readonly name: "SlicingCriteria";
|
|
47
48
|
/**
|
|
48
49
|
* Decodes all slicing criteria to their corresponding node ids
|
|
49
50
|
* @throws CriteriaParseError if any of the criteria can not be resolved
|
|
@@ -48,7 +48,7 @@ exports.SlicingCriterion = {
|
|
|
48
48
|
tryParse(criterion, idMap) {
|
|
49
49
|
criterion = criterion.toString(); // in case it's a number
|
|
50
50
|
if (criterion.startsWith('$')) {
|
|
51
|
-
return node_id_1.NodeId.normalize(criterion.
|
|
51
|
+
return node_id_1.NodeId.normalize(criterion.slice(1));
|
|
52
52
|
}
|
|
53
53
|
const split = splitFileFilter(criterion);
|
|
54
54
|
if (split === undefined) {
|
|
@@ -57,8 +57,8 @@ exports.SlicingCriterion = {
|
|
|
57
57
|
const { rest: base, file } = split;
|
|
58
58
|
if (base.includes('@')) {
|
|
59
59
|
const at = base.indexOf('@');
|
|
60
|
-
const line = parseLineNumber(base.
|
|
61
|
-
const name = base.
|
|
60
|
+
const line = parseLineNumber(base.slice(0, Math.max(0, at)), idMap, file);
|
|
61
|
+
const name = base.slice(Math.max(0, at + 1));
|
|
62
62
|
if (line === undefined || name.length === 0) {
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
@@ -92,6 +92,7 @@ exports.SlicingCriterion = {
|
|
|
92
92
|
* The helper object associated with {@link SlicingCriteria} which makes it easy to parse, validate and resolve slicing criteria.
|
|
93
93
|
*/
|
|
94
94
|
exports.SlicingCriteria = {
|
|
95
|
+
name: 'SlicingCriteria',
|
|
95
96
|
/**
|
|
96
97
|
* Decodes all slicing criteria to their corresponding node ids
|
|
97
98
|
* @throws CriteriaParseError if any of the criteria can not be resolved
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NodeToSlice } from './slicer-types';
|
|
2
2
|
import type { VisitingQueue } from './visiting-queue';
|
|
3
3
|
import { type Fingerprint } from './fingerprint';
|
|
4
|
-
import {
|
|
4
|
+
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
|
|
5
5
|
import type { REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
6
6
|
import { type DataflowGraph, type OutgoingEdges } from '../../dataflow/graph/graph';
|
|
7
7
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
@@ -9,7 +9,6 @@ exports.handleReturns = handleReturns;
|
|
|
9
9
|
const assert_1 = require("../../util/assert");
|
|
10
10
|
const fingerprint_1 = require("./fingerprint");
|
|
11
11
|
const linker_1 = require("../../dataflow/internal/linker");
|
|
12
|
-
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
13
12
|
const graph_1 = require("../../dataflow/graph/graph");
|
|
14
13
|
const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
|
|
15
14
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
@@ -19,6 +18,7 @@ const built_in_function_definition_1 = require("../../dataflow/internal/process/
|
|
|
19
18
|
const static_slicer_1 = require("./static-slicer");
|
|
20
19
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
21
20
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
21
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
22
22
|
/**
|
|
23
23
|
* Returns the function call targets (definitions) by the given caller
|
|
24
24
|
*/
|
|
@@ -105,7 +105,7 @@ function findEnclosingFunctionDefinition(id, idMap) {
|
|
|
105
105
|
*/
|
|
106
106
|
function sliceReachesFunctionInterface(fnDefId, graph, queue, idMap, ctx) {
|
|
107
107
|
const vertex = graph.getVertex(fnDefId);
|
|
108
|
-
if (vertex === undefined ||
|
|
108
|
+
if (vertex === undefined || !vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
111
|
// (a) the slice reaches a parameter of this definition
|
|
@@ -14,6 +14,7 @@ const edge_1 = require("../../dataflow/graph/edge");
|
|
|
14
14
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
15
15
|
const slice_direction_1 = require("../../util/slice-direction");
|
|
16
16
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
17
|
+
const graph_1 = require("../../dataflow/graph/graph");
|
|
17
18
|
exports.slicerLogger = log_1.log.getSubLogger({ name: 'slicer' });
|
|
18
19
|
/**
|
|
19
20
|
* Computes the node ids to include in a static slice, starting from the given seed ids.
|
|
@@ -98,7 +99,7 @@ function staticSlice(options) {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
if (!onlyForSideEffects) {
|
|
101
|
-
if (
|
|
102
|
+
if (vertex_1.FunctionCallVertex.is(currentVertex) && !currentVertex.onlyBuiltin) {
|
|
102
103
|
(0, slice_call_1.sliceForCall)(current, currentVertex, info, queue, ctx);
|
|
103
104
|
}
|
|
104
105
|
const ret = (0, slice_call_1.handleReturns)(id, queue, currentEdges, baseEnvFingerprint, baseEnvironment);
|
|
@@ -151,11 +152,11 @@ function staticSlice(options) {
|
|
|
151
152
|
function freeNamesOf(slice, graph) {
|
|
152
153
|
const free = new Set();
|
|
153
154
|
for (const id of slice) {
|
|
154
|
-
if (graph.getVertex(id)
|
|
155
|
+
if (!vertex_1.UseVertex.is(graph.getVertex(id))) {
|
|
155
156
|
continue;
|
|
156
157
|
}
|
|
157
158
|
let defined = false;
|
|
158
|
-
for (const [target, edge] of graph.outgoingEdges(id) ??
|
|
159
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
159
160
|
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && (slice.has(target) || node_id_1.NodeId.isBuiltIn(target))) {
|
|
160
161
|
defined = true;
|
|
161
162
|
break;
|
package/util/assert.js
CHANGED
|
@@ -102,7 +102,7 @@ node version: ${process.version}
|
|
|
102
102
|
node arch: ${process.arch}
|
|
103
103
|
node platform: ${process.platform}
|
|
104
104
|
message: \`${message}\`
|
|
105
|
-
stack trace:\n\`\`\`\n${prepareStack(new Error().stack)}\n\`\`\`
|
|
105
|
+
stack trace:\n\`\`\`\n${prepareStack(new Error('stack capture for the issue report').stack)}\n\`\`\`
|
|
106
106
|
|
|
107
107
|
---
|
|
108
108
|
`).replaceAll('(', '%28').replaceAll(')', '%29').replaceAll('-', '%2D');
|
package/util/log.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ILogObj, type ISettingsParam, Logger } from 'tslog';
|
|
2
|
-
import {
|
|
2
|
+
import type { Options } from 'rotating-file-stream';
|
|
3
3
|
export declare const expensiveTrace: (log: Logger<ILogObj> | undefined, supplier: () => string) => void;
|
|
4
4
|
export declare class FlowrLogger extends Logger<ILogObj> {
|
|
5
5
|
/** by keeping track of all children we can propagate updates of the settings (e.g., in tests) */
|
|
@@ -8,6 +8,9 @@ export declare class FlowrLogger extends Logger<ILogObj> {
|
|
|
8
8
|
updateSettings(updater: (logger: Logger<ILogObj>) => void): void;
|
|
9
9
|
/**
|
|
10
10
|
* make the logger log to a file as well
|
|
11
|
+
*
|
|
12
|
+
* Rotation needs the optional `rotating-file-stream` dependency. Without it (the slim runtime images install with
|
|
13
|
+
* `--omit=optional`) the log is appended to a single file instead.
|
|
11
14
|
*/
|
|
12
15
|
logToFile(filename?: string, options?: Options): void;
|
|
13
16
|
}
|
package/util/log.js
CHANGED
|
@@ -3,13 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.log = exports.LogLevelNames = exports.FlowrLogger = exports.expensiveTrace = void 0;
|
|
4
4
|
exports.setLogLevel = setLogLevel;
|
|
5
5
|
const tslog_1 = require("tslog");
|
|
6
|
-
const
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
7
|
const expensiveTrace = (log, supplier) => {
|
|
8
8
|
if (log !== undefined && log.settings.minLevel <= 1 /* LogLevel.Trace */) {
|
|
9
9
|
log.trace(supplier());
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
exports.expensiveTrace = expensiveTrace;
|
|
13
|
+
/** The rotating stream, or `undefined` if the optional dependency is not installed. */
|
|
14
|
+
function rotatingStream(filename, options) {
|
|
15
|
+
try {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- optional dependency, absent by design in slim installs
|
|
17
|
+
return require('rotating-file-stream').createStream(filename, options);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
13
23
|
class FlowrLogger extends tslog_1.Logger {
|
|
14
24
|
/** by keeping track of all children we can propagate updates of the settings (e.g., in tests) */
|
|
15
25
|
childLoggers = [];
|
|
@@ -26,13 +36,16 @@ class FlowrLogger extends tslog_1.Logger {
|
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
38
|
* make the logger log to a file as well
|
|
39
|
+
*
|
|
40
|
+
* Rotation needs the optional `rotating-file-stream` dependency. Without it (the slim runtime images install with
|
|
41
|
+
* `--omit=optional`) the log is appended to a single file instead.
|
|
29
42
|
*/
|
|
30
43
|
logToFile(filename = 'flowr.log', options = {
|
|
31
44
|
size: '10M',
|
|
32
45
|
interval: '1d',
|
|
33
46
|
compress: 'gzip',
|
|
34
47
|
}) {
|
|
35
|
-
const stream = (0,
|
|
48
|
+
const stream = rotatingStream(filename, options) ?? (0, fs_1.createWriteStream)(filename, { flags: 'a' });
|
|
36
49
|
exports.log.attachTransport((logObj) => {
|
|
37
50
|
stream.write(`${JSON.stringify(logObj)}\n`);
|
|
38
51
|
});
|
package/util/logic.js
CHANGED
|
@@ -20,10 +20,10 @@ exports.TernaryLogic = {
|
|
|
20
20
|
return Ternary.Maybe;
|
|
21
21
|
},
|
|
22
22
|
or(...values) {
|
|
23
|
-
if (values.
|
|
23
|
+
if (values.includes(Ternary.Always)) {
|
|
24
24
|
return Ternary.Always;
|
|
25
25
|
}
|
|
26
|
-
else if (values.
|
|
26
|
+
else if (values.includes(Ternary.Maybe)) {
|
|
27
27
|
return Ternary.Maybe;
|
|
28
28
|
}
|
|
29
29
|
return Ternary.Never;
|
package/util/mermaid/cfg.js
CHANGED
package/util/mermaid/dfg.js
CHANGED
|
@@ -12,12 +12,12 @@ const identifier_1 = require("../../dataflow/environments/identifier");
|
|
|
12
12
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
13
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
14
14
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
15
|
-
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
16
15
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
17
16
|
const info_1 = require("./info");
|
|
18
17
|
const range_1 = require("../range");
|
|
19
18
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
20
19
|
const info_2 = require("../../dataflow/info");
|
|
20
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
21
21
|
function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
|
|
22
22
|
if (subflow === undefined) {
|
|
23
23
|
return;
|
|
@@ -160,7 +160,7 @@ function builtInDisplayName(builtInId) {
|
|
|
160
160
|
return pkgFn ? `${pkgFn[0]}::${pkgFn[1]}` : String(builtInId).replace('built-in:', '');
|
|
161
161
|
}
|
|
162
162
|
function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
163
|
-
const fCall =
|
|
163
|
+
const fCall = vertex_1.FunctionCallVertex.is(info);
|
|
164
164
|
const { open, close } = mermaidNodeBrackets(info.tag);
|
|
165
165
|
const origId = id;
|
|
166
166
|
id = mermaid_1.Mermaid.escapeId(id);
|
|
@@ -184,7 +184,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
184
184
|
const lexeme = node?.lexeme ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0]?.lexeme : '') ?? '??';
|
|
185
185
|
let display = lexeme;
|
|
186
186
|
if (fCall && vertex_1.FunctionCallVertex.is(info)) {
|
|
187
|
-
const q = identifier_1.Identifier.toQualified(
|
|
187
|
+
const q = identifier_1.Identifier.toQualified(df_helper_1.Dataflow.origin(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
|
|
188
188
|
const qs = q !== undefined ? identifier_1.Identifier.toString(q) : undefined;
|
|
189
189
|
if (qs !== undefined && qs !== lexeme) {
|
|
190
190
|
display = qs;
|
|
@@ -199,10 +199,10 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
199
199
|
const escapedName = node ? `*${mermaid_1.Mermaid.escape(`[${node.type}]`)}* ${boldLexeme(lexeme, display)}` : '??';
|
|
200
200
|
const deps = info.cds ? ', ' + info.cds.map(c => mermaid_1.Mermaid.escapeId(c.id) + (c.when ? '+' : '-')).join(', ') : '';
|
|
201
201
|
const lnks = info.link?.origin ? ', links: ' + info.link.origin.map(o => mermaid_1.Mermaid.escapeId(o)).join(', ') : '';
|
|
202
|
-
const source =
|
|
202
|
+
const source = vertex_1.VariableDefinitionVertex.is(info) ? info.source : undefined;
|
|
203
203
|
const sources = source ? ', v: ' + source.map(s => mermaid_1.Mermaid.escapeId(s)).join(', ') : '';
|
|
204
204
|
const n = node?.info.fullRange ?? node?.location ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0].location : undefined);
|
|
205
|
-
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (
|
|
205
|
+
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (vertex_1.FunctionDefinitionVertex.is(info) && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
|
|
206
206
|
}
|
|
207
207
|
if (mark?.has(id)) {
|
|
208
208
|
mermaid.nodeLines.push(` style ${idPrefix}${id} ${mermaid.markStyle.vertex} `);
|
|
@@ -210,7 +210,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
210
210
|
if (mermaid.rootGraph.unknownSideEffects.values().some(l => node_id_1.NodeId.normalize(l) === node_id_1.NodeId.normalize(origId))) {
|
|
211
211
|
mermaid.nodeLines.push(` style ${idPrefix}${id} stroke:red,stroke-width:5px; `);
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
213
|
+
if (vertex_1.FunctionDefinitionVertex.is(info)) {
|
|
214
214
|
subflowToMermaid(origId, info.subflow, mermaid, idPrefix);
|
|
215
215
|
}
|
|
216
216
|
const edges = mermaid.rootGraph.outgoingEdges(node_id_1.NodeId.normalize(origId));
|
package/util/mermaid/mermaid.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Mermaid = void 0;
|
|
4
|
+
const url_encoding_1 = require("../text/url-encoding");
|
|
4
5
|
/**
|
|
5
6
|
* Global mermaid helper object with useful functions.
|
|
6
7
|
*/
|
|
@@ -81,7 +82,8 @@ exports.Mermaid = {
|
|
|
81
82
|
autoSync: true
|
|
82
83
|
}
|
|
83
84
|
};
|
|
84
|
-
|
|
85
|
+
/* `btoa` rather than a `Buffer`, so the pages flowR ships can build this url as well */
|
|
86
|
+
return `https://mermaid.live/${edit ? 'edit' : 'view'}#base64:${(0, url_encoding_1.toBase64)(new TextEncoder().encode(JSON.stringify(obj)))}`;
|
|
85
87
|
}
|
|
86
88
|
};
|
|
87
89
|
//# sourceMappingURL=mermaid.js.map
|
package/util/quads.js
CHANGED
|
@@ -13,13 +13,25 @@ exports.defaultQuadIdGenerator = defaultQuadIdGenerator;
|
|
|
13
13
|
exports.defaultQuadIgnoreIf = defaultQuadIgnoreIf;
|
|
14
14
|
exports.serialize2quads = serialize2quads;
|
|
15
15
|
exports.graph2quads = graph2quads;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The `n3` module, or a clear error if the optional dependency is missing.
|
|
18
|
+
* Install it to serialize quads (`npm i n3`), everything else works without it.
|
|
19
|
+
*/
|
|
20
|
+
function n3() {
|
|
21
|
+
try {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- optional dependency, resolved only when quads are requested
|
|
23
|
+
return require('n3');
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Error('quad serialization needs the optional `n3` dependency, install it with `npm i n3`');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const namedNode = (v) => n3().DataFactory.namedNode(v);
|
|
30
|
+
const quad = (s, p, o, g) => n3().DataFactory.quad(s, p, o, g);
|
|
19
31
|
const objects_1 = require("./objects");
|
|
20
32
|
const assert_1 = require("./assert");
|
|
21
33
|
const defaultmap_1 = require("./collections/defaultmap");
|
|
22
|
-
const literal = (v, n) =>
|
|
34
|
+
const literal = (v, n) => n3().DataFactory.literal(v, n);
|
|
23
35
|
const log_1 = require("./log");
|
|
24
36
|
const domain = 'https://uni-ulm.de/r-ast/';
|
|
25
37
|
/**
|
|
@@ -46,7 +58,8 @@ exports.DefaultQuadSerializationConfiguration = {
|
|
|
46
58
|
function retrieveContext(context, obj) {
|
|
47
59
|
return typeof context === 'string' ? context : context(obj);
|
|
48
60
|
}
|
|
49
|
-
|
|
61
|
+
let cachedWriter;
|
|
62
|
+
const writer = () => cachedWriter ??= new (n3().Writer)({ format: 'N-Quads' });
|
|
50
63
|
/**
|
|
51
64
|
* Serializes the given object or array to rdf quads.
|
|
52
65
|
* @param obj - The object to serialize (must be a Record and no array etc.)
|
|
@@ -61,7 +74,7 @@ function serialize2quads(obj, config) {
|
|
|
61
74
|
store = new Set();
|
|
62
75
|
const quads = [];
|
|
63
76
|
serializeObject(obj, quads, useConfig);
|
|
64
|
-
return writer.quadsToString(quads);
|
|
77
|
+
return writer().quadsToString(quads);
|
|
65
78
|
}
|
|
66
79
|
/**
|
|
67
80
|
* Serializes the given directed graph to rdf quads.
|
package/util/r-version.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type RVersion = SemVer & {
|
|
|
11
11
|
};
|
|
12
12
|
/** Helpers for R package versions (`1.2-3` style), which are freer than SemVer. */
|
|
13
13
|
export declare const RVersion: {
|
|
14
|
+
readonly name: "RVersion";
|
|
14
15
|
/**
|
|
15
16
|
* Parse an R version string into a {@link SemVer}, normalizing R's freer scheme (e.g. `0.4-9`). Unlike
|
|
16
17
|
* `new SemVer(version)` this coerces where needed; the original string is available via `.str`. Returns
|
|
@@ -37,6 +38,7 @@ export declare const RVersion: {
|
|
|
37
38
|
export declare function rReleaseDate(version: string): Date | undefined;
|
|
38
39
|
/** Helpers for R package version ranges (DESCRIPTION constraints like `>= 0.4-9`). */
|
|
39
40
|
export declare const RRange: {
|
|
41
|
+
readonly name: "RRange";
|
|
40
42
|
/**
|
|
41
43
|
* Parse an R version range string into a {@link Range}, normalizing R's freer scheme. The original range
|
|
42
44
|
* string is available via `.str`.
|
package/util/r-version.js
CHANGED
|
@@ -80,6 +80,7 @@ function makeRange(range, original) {
|
|
|
80
80
|
}
|
|
81
81
|
/** Helpers for R package versions (`1.2-3` style), which are freer than SemVer. */
|
|
82
82
|
exports.RVersion = {
|
|
83
|
+
name: 'RVersion',
|
|
83
84
|
/**
|
|
84
85
|
* Parse an R version string into a {@link SemVer}, normalizing R's freer scheme (e.g. `0.4-9`). Unlike
|
|
85
86
|
* `new SemVer(version)` this coerces where needed; the original string is available via `.str`. Returns
|
|
@@ -159,6 +160,7 @@ function rReleaseDate(version) {
|
|
|
159
160
|
}
|
|
160
161
|
/** Helpers for R package version ranges (DESCRIPTION constraints like `>= 0.4-9`). */
|
|
161
162
|
exports.RRange = {
|
|
163
|
+
name: 'RRange',
|
|
162
164
|
/**
|
|
163
165
|
* Parse an R version range string into a {@link Range}, normalizing R's freer scheme. The original range
|
|
164
166
|
* string is available via `.str`.
|
package/util/record.d.ts
CHANGED
package/util/record.js
CHANGED
package/util/schema.js
CHANGED
|
@@ -75,7 +75,7 @@ function firstUnknownSchemaSegment(description, path) {
|
|
|
75
75
|
const pattern = patternObject(node);
|
|
76
76
|
if (pattern !== undefined) {
|
|
77
77
|
if (pattern.keyValids !== undefined && !pattern.keyValids.includes(path[i])) {
|
|
78
|
-
return { segment: path[i], available: pattern.keyValids.map(
|
|
78
|
+
return { segment: path[i], available: pattern.keyValids.map(String), at: path.slice(0, i) };
|
|
79
79
|
}
|
|
80
80
|
node = pattern.value;
|
|
81
81
|
continue;
|
|
@@ -110,7 +110,7 @@ function descriptionPathKeys(description, path) {
|
|
|
110
110
|
}
|
|
111
111
|
const keys = Object.keys((node.keys ?? {}));
|
|
112
112
|
// a `.pattern()` object declares no keys, but a `.valid(...)` key schema restricts them to a known set
|
|
113
|
-
const valids = patternObject(node)?.keyValids?.map(
|
|
113
|
+
const valids = patternObject(node)?.keyValids?.map(String) ?? [];
|
|
114
114
|
return [...keys, ...valids.filter(v => !keys.includes(v))];
|
|
115
115
|
}
|
|
116
116
|
/** every settable path in a schema description, intermediate objects included */
|
package/util/text/ansi.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ export declare function faint(s: string, f?: OutputFormatter, options?: FormatOp
|
|
|
63
63
|
*/
|
|
64
64
|
export declare function ansiInfo(s: string, f?: OutputFormatter): string;
|
|
65
65
|
export declare const escape = "\u001B[";
|
|
66
|
+
/** The text without any colouring, for wherever an escape sequence would only show up as `[0m`. */
|
|
67
|
+
export declare function stripAnsi(text: string): string;
|
|
66
68
|
/** best-effort, env-based OSC 8 hyperlink support (`FORCE_HYPERLINK`/`NO_HYPERLINK` override; unknown terminals are treated as unsupported) */
|
|
67
69
|
export declare function supportsHyperlinks(): boolean;
|
|
68
70
|
export declare const ansiFormatter: {
|
package/util/text/ansi.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.bold = bold;
|
|
|
6
6
|
exports.color = color;
|
|
7
7
|
exports.faint = faint;
|
|
8
8
|
exports.ansiInfo = ansiInfo;
|
|
9
|
+
exports.stripAnsi = stripAnsi;
|
|
9
10
|
exports.supportsHyperlinks = supportsHyperlinks;
|
|
10
11
|
exports.setFormatter = setFormatter;
|
|
11
12
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -90,6 +91,13 @@ function ansiInfo(s, f = exports.formatter) {
|
|
|
90
91
|
return f.format(s, { color: 7 /* Colors.White */, effect: ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
|
|
91
92
|
}
|
|
92
93
|
exports.escape = '\x1b[';
|
|
94
|
+
/** every {@link escape} sequence, so a place that cannot colour (a browser, a log file) can drop them */
|
|
95
|
+
// eslint-disable-next-line no-control-regex -- the escape character is what an escape sequence starts with
|
|
96
|
+
const AnsiSequence = /\x1b\[[\d;]*m/g;
|
|
97
|
+
/** The text without any colouring, for wherever an escape sequence would only show up as `[0m`. */
|
|
98
|
+
function stripAnsi(text) {
|
|
99
|
+
return text.replaceAll(AnsiSequence, '');
|
|
100
|
+
}
|
|
93
101
|
const colorSuffix = 'm';
|
|
94
102
|
let hyperlinkSupport;
|
|
95
103
|
/** best-effort, env-based OSC 8 hyperlink support (`FORCE_HYPERLINK`/`NO_HYPERLINK` override; unknown terminals are treated as unsupported) */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a reader most likely meant when typing a name: a well-used package first, base R ahead of CRAN, and
|
|
3
|
+
* the things one rarely reaches for last, which are S3 methods, `%operators%` and names starting with a dot.
|
|
4
|
+
*
|
|
5
|
+
* The signature browser and the playground's completion both offer names out of the same database, so they
|
|
6
|
+
* order them with the same {@link rankName}, and what one of them learns the other one knows.
|
|
7
|
+
*/
|
|
8
|
+
export interface NameRankInput {
|
|
9
|
+
/** the name being offered */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/** what was typed, empty when nothing was */
|
|
12
|
+
readonly needle: string;
|
|
13
|
+
/** how far down the fuzzy match sits, `0` being the closest; `0` when nothing was typed */
|
|
14
|
+
readonly rank?: number;
|
|
15
|
+
/** how often the owning package was downloaded, `0` when unknown */
|
|
16
|
+
readonly downloads?: number;
|
|
17
|
+
/** the owning package ships with R */
|
|
18
|
+
readonly baseR?: boolean;
|
|
19
|
+
/** the owning package is `base` itself */
|
|
20
|
+
readonly base?: boolean;
|
|
21
|
+
/** flowR carries a definition of its own for the name, so it is one people actually call */
|
|
22
|
+
readonly known?: boolean;
|
|
23
|
+
/** the name is an S3 method, like `print.foo` */
|
|
24
|
+
readonly s3?: boolean;
|
|
25
|
+
/** the name holds a value rather than a function */
|
|
26
|
+
readonly variable?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** The points {@link NameRankInput} earns, higher being offered first. */
|
|
29
|
+
export declare function rankName(of: NameRankInput): number;
|