Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.1.0 query api staging #1010

Merged
merged 49 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
4943b34
wip: query format definition
EagleoutIce Sep 18, 2024
4d8870a
Merge branch 'main' into 980-context-sensitive-call-pattern-queries
EagleoutIce Sep 20, 2024
617f338
wip: queries
EagleoutIce Sep 20, 2024
7feada0
Merge branch 'main' into 980-context-sensitive-call-pattern-queries
EagleoutIce Sep 20, 2024
afb550e
wip: query typing infrastructure
EagleoutIce Sep 20, 2024
267930b
Merge branch 'main' into 980-context-sensitive-call-pattern-queries
EagleoutIce Sep 20, 2024
61f1da5
wip: multi-stage query resolve
EagleoutIce Sep 20, 2024
25fe8ce
wip: basic queries :)
EagleoutIce Sep 20, 2024
73e5d10
wip: virtual query experimentation
EagleoutIce Sep 21, 2024
53ad324
feat: compound queries
EagleoutIce Sep 21, 2024
53c03e0
wip: working on built-in detection for queries
EagleoutIce Sep 21, 2024
7bab187
feat: only(Global|Local) call targets
EagleoutIce Sep 21, 2024
9a3d2c5
feat-fix: potential scope-change re-resolve
EagleoutIce Sep 21, 2024
5a305e0
feat(call-context): handle quoted values
EagleoutIce Sep 21, 2024
8a8e324
refactor: clean up call promotions
EagleoutIce Sep 21, 2024
989301a
wip: work on FDs
EagleoutIce Sep 21, 2024
7dd919a
Revert "wip: work on FDs" (Now tracked in #1005)
EagleoutIce Sep 22, 2024
2292b90
refactor: linkTo prerequisites
EagleoutIce Sep 22, 2024
dcfaf4a
feat: link-to basics
EagleoutIce Sep 22, 2024
9e0b41c
refactor: clean up current todo stack
EagleoutIce Sep 22, 2024
93a4efe
wip: query repl
EagleoutIce Sep 22, 2024
be95772
refactor: update repl commands file names
EagleoutIce Sep 22, 2024
dbdc874
feat(query): repl support
EagleoutIce Sep 22, 2024
69e4a3a
refactor: improve sophistication of query schemas
EagleoutIce Sep 22, 2024
c88c5ff
feat(query): server message
EagleoutIce Sep 22, 2024
6e8d0b6
wip(query): working on the doc
EagleoutIce Sep 22, 2024
ed95ab0
doc(query): extend query documentation
EagleoutIce Sep 22, 2024
7c9193a
refactor: auto generated wiki line
EagleoutIce Sep 23, 2024
f780732
doc(query): interface wiki entry
EagleoutIce Sep 23, 2024
7618f23
lint-fix: handle linter errors
EagleoutIce Sep 23, 2024
bbe25bd
refactor: remove outsourced todo markers
EagleoutIce Sep 23, 2024
ca535fc
Context Sensitive Call Pattern Queries (#1009)
EagleoutIce Sep 23, 2024
69b14a1
Apply code scanning fix for incomplete string escaping or encoding
EagleoutIce Sep 23, 2024
cf4bcad
doc(dfg): control dependencies
EagleoutIce Sep 23, 2024
59e7168
lint-fix: handle linter issues
EagleoutIce Sep 23, 2024
5f14a5e
Explain CDs in Graph Documentation (#1011)
EagleoutIce Sep 23, 2024
bb0df24
wip(dfg): document dataflow information
EagleoutIce Sep 23, 2024
13b7c1c
doc(dfg): unknown side effects
EagleoutIce Sep 23, 2024
326b95e
lint-fix: handle linter problems
EagleoutIce Sep 23, 2024
ffd8145
feat-fix(dfg): link with space
EagleoutIce Sep 23, 2024
7ed5f68
Document Unknown Side Effects (#1013)
EagleoutIce Sep 23, 2024
cb5b5dc
feat-fix: remove sources of double ref introduction
EagleoutIce Sep 23, 2024
e9de008
Perf: Remove Duplicated In- and Outoging References (#1014)
EagleoutIce Sep 23, 2024
91d5eab
wip: call space separation
EagleoutIce Sep 25, 2024
58afe5e
feat-fix: resolve by type
EagleoutIce Sep 26, 2024
1f21dbd
refactor(references): first step to bitmasks
EagleoutIce Sep 26, 2024
615098e
refactor: switch to bitmask for reference type
EagleoutIce Sep 27, 2024
a708bd6
refactor: fix sizeof of uncompacted objects
EagleoutIce Sep 27, 2024
2ca9a2c
Separate Resolution for Functions and Symbols (#1016)
EagleoutIce Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/broken-links-and-wiki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ jobs:
}

update_wiki_page "Capabilities" capabilities-markdown
update_wiki_page "Dataflow Graph" df-graph-wiki-markdown
update_wiki_page "Dataflow Graph" wiki:df-graph
update_wiki_page "Query API" wiki:query-api

if [ $CHANGED_ANY == "true" ]; then
git config --local user.email "action@github.com"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"summarizer": "ts-node src/cli/summarizer-app.ts",
"export-quads": "ts-node src/cli/export-quads-app.ts",
"capabilities-markdown": "ts-node src/documentation/print-capabilities-markdown.ts",
"df-graph-wiki-markdown": "ts-node src/documentation/print-dataflow-graph-wiki.ts",
"wiki:df-graph": "ts-node src/documentation/print-dataflow-graph-wiki.ts",
"wiki:query-api": "ts-node src/documentation/print-query-wiki.ts",
"build": "tsc --project .",
"build:bundle-flowr": "npm run build && esbuild --bundle dist/src/cli/flowr.js --platform=node --bundle --minify --target=node18 --outfile=dist/src/cli/flowr.min.js",
"lint-local": "npx eslint --version && npx eslint src/ test/ --rule \"no-warning-comments: off\"",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/common/scripts-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
summarizerOptions
} from './options';
import type { MergeableRecord } from '../../util/objects';
import { asOptionName } from '../repl/commands/commands';
import { asOptionName } from '../repl/commands/repl-commands';


interface BaseScriptInformation extends MergeableRecord {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/flowr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import { scripts } from './common/scripts-info';
import type { RShellOptions } from '../r-bridge/shell';
import { RShell, RShellReviveOptions } from '../r-bridge/shell';
import { waitOnScript } from './repl/execute';
import { standardReplOutput } from './repl/commands/main';
import { standardReplOutput } from './repl/commands/repl-main';
import { repl, replProcessAnswer } from './repl/core';
import { printVersionInformation } from './repl/commands/version';
import { printVersionInformation } from './repl/commands/repl-version';
import { printVersionRepl } from './repl/print-version';

let _scriptsText: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReplCommand } from './main';
import type { ReplCommand } from './repl-main';
import { PipelineExecutor } from '../../../core/pipeline-executor';
import { extractCFG } from '../../../util/cfg/cfg';
import type { RShell } from '../../../r-bridge/shell';
Expand Down Expand Up @@ -27,8 +27,8 @@ export const controlflowCommand: ReplCommand = {
};

export const controlflowStarCommand: ReplCommand = {
description: `Get a mermaid url of the control-flow graph of R code, start with '${fileProtocol}' to indicate a file`,
usageExample: ':controlflow',
description: 'Returns the URL to mermaid.live',
usageExample: ':controlflow*',
aliases: [ 'cfg*', 'cf*' ],
script: false,
fn: async(output, shell, remainingLine) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
import { quitCommand } from './quit';
import { quitCommand } from './repl-quit';
import { stdioCaptureProcessor, waitOnScript } from '../execute';
import type { ReplCommand } from './main';
import type { ReplCommand } from './repl-main';
import { rawPrompt } from '../prompt';
import { versionCommand } from './version';
import { parseCommand } from './parse';
import { executeCommand } from './execute';
import { normalizeCommand, normalizeStarCommand } from './normalize';
import { dataflowCommand, dataflowStarCommand } from './dataflow';
import { controlflowCommand, controlflowStarCommand } from './cfg';
import { versionCommand } from './repl-version';
import { parseCommand } from './repl-parse';
import { executeCommand } from './repl-execute';
import { normalizeCommand, normalizeStarCommand } from './repl-normalize';
import { dataflowCommand, dataflowStarCommand } from './repl-dataflow';
import { controlflowCommand, controlflowStarCommand } from './repl-cfg';
import type { OutputFormatter } from '../../../util/ansi';
import { italic , bold } from '../../../util/ansi';
import { splitAtEscapeSensitive } from '../../../util/args';
import { guard } from '../../../util/assert';
import { scripts } from '../../common/scripts-info';
import { getLineageCommand } from './lineage';
import { lineageCommand } from './repl-lineage';
import { queryCommand, queryStarCommand } from './repl-query';

function printHelpForScript(script: [string, ReplCommand], f: OutputFormatter): string {
const base = ` ${bold(padCmd(':' + script[0]), f)}${script[1].description}`;
function printHelpForScript(script: [string, ReplCommand], f: OutputFormatter, starredVersion?: ReplCommand): string {
let base = ` ${bold(padCmd(':' + script[0] + (starredVersion ? '[*]' : '')
), f)}${script[1].description}`;
if(starredVersion) {
base += ` (star: ${starredVersion.description})`;
}
if(script[1].aliases.length === 0) {
return base;
}
const aliases = script[1].aliases;
return `${base} (alias${aliases.length > 1 ? 'es' : ''}: ${aliases.map(a => bold(':' + a, f)).join(', ')})`;
}

function printCommandHelp(formatter: OutputFormatter) {
const scriptHelp = [];
const cmds = commands();
for(const c of Object.entries(cmds)) {
if(c[1].script || c[0].endsWith('*')) {
continue;
}
const starred = cmds[c[0] + '*'];
scriptHelp.push(printHelpForScript(c, formatter, starred));
}

return scriptHelp.sort().join('\n');
}

export const helpCommand: ReplCommand = {
description: 'Show help information',
script: false,
Expand All @@ -32,20 +51,20 @@ export const helpCommand: ReplCommand = {
fn: output => {
initCommandMapping();
output.stdout(`
If enabled, you can just enter R expressions which get evaluated right away:
If enabled ('--r-session-access'), you can just enter R expressions which get evaluated right away:
${rawPrompt} ${bold('1 + 1', output.formatter)}
${italic('[1] 2', output.formatter)}

Besides that, you can use the following commands. The scripts ${italic('can', output.formatter)} accept further arguments. There are the following basic commands:
Besides that, you can use the following commands. The scripts ${italic('can', output.formatter)} accept further arguments. In general, those ending with [*] may be called with and without the star.
There are the following basic commands:
${
Array.from(Object.entries(commands())).filter(([, { script }]) => !script).map(
c => printHelpForScript(c, output.formatter)).join('\n')
printCommandHelp(output.formatter)
}

Furthermore, you can directly call the following scripts which accept arguments. If you are unsure, try to add ${italic('--help', output.formatter)} after the command.
${
Array.from(Object.entries(commands())).filter(([, { script }]) => script).map(
([command, { description }]) => ` ${bold(padCmd(':' + command), output.formatter)}${description}`).join('\n')
([command, { description }]) => ` ${bold(padCmd(':' + command), output.formatter)}${description}`).sort().join('\n')
}

You can combine commands by separating them with a semicolon ${bold(';',output.formatter)}.
Expand All @@ -68,7 +87,9 @@ const _commands: Record<string, ReplCommand> = {
'dataflow*': dataflowStarCommand,
'controlflow': controlflowCommand,
'controlflow*': controlflowStarCommand,
'lineage': getLineageCommand
'lineage': lineageCommand,
'query': queryCommand,
'query*': queryStarCommand
};
let commandsInitialized = false;

Expand Down Expand Up @@ -167,7 +188,7 @@ export function asOptionName(argument: string): string{
let _longestCommandName: number | undefined = undefined;
export function longestCommandName(): number {
if(_longestCommandName === undefined) {
_longestCommandName = Array.from(Object.keys(commands()), k => k.length).reduce((p, n) => Math.max(p, n), 0);
_longestCommandName = Array.from(Object.keys(commands()), k => k.endsWith('*') ? k.length + 3 : k.length).reduce((p, n) => Math.max(p, n), 0);
}
return _longestCommandName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReplCommand } from './main';
import type { ReplCommand } from './repl-main';
import { PipelineExecutor } from '../../../core/pipeline-executor';
import { DEFAULT_DATAFLOW_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
import type { RShell } from '../../../r-bridge/shell';
Expand All @@ -25,7 +25,7 @@ export const dataflowCommand: ReplCommand = {
};

export const dataflowStarCommand: ReplCommand = {
description: `Get a mermaid url of the dataflow graph of R code, start with '${fileProtocol}' to indicate a file`,
description: 'Returns the URL to mermaid.live',
usageExample: ':dataflow*',
aliases: [ 'd*', 'df*' ],
script: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReplCommand, ReplOutput } from './main';
import type { ReplCommand, ReplOutput } from './repl-main';
import { italic } from '../../../util/ansi';
import type { RShell } from '../../../r-bridge/shell';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReplCommand } from './main';
import type { ReplCommand } from './repl-main';
import { PipelineExecutor } from '../../../core/pipeline-executor';
import { DEFAULT_DATAFLOW_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
import type { RShell } from '../../../r-bridge/shell';
Expand Down Expand Up @@ -65,7 +65,7 @@ export function getLineage(criterion: SingleSlicingCriterion, { idMap } : Normal
return result;
}

export const getLineageCommand: ReplCommand = {
export const lineageCommand: ReplCommand = {
description: 'Get the lineage of an R object',
usageExample: ':lineage',
aliases: ['lin'],
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReplCommand } from './main';
import type { ReplCommand } from './repl-main';
import { PipelineExecutor } from '../../../core/pipeline-executor';
import { DEFAULT_NORMALIZE_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
import type { RShell } from '../../../r-bridge/shell';
Expand All @@ -25,8 +25,8 @@ export const normalizeCommand: ReplCommand = {
};

export const normalizeStarCommand: ReplCommand = {
description: `Get a mermaid url of the normalized AST of R code, start with '${fileProtocol}' to indicate a file`,
usageExample: ':normalize',
description: 'Returns the URL to mermaid.live',
usageExample: ':normalize*',
aliases: [ 'n*' ],
script: false,
fn: async(output, shell, remainingLine) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReplCommand } from './main';
import type { ReplCommand } from './repl-main';
import type { OutputFormatter } from '../../../util/ansi';
import { FontStyles } from '../../../util/ansi';
import { PipelineExecutor } from '../../../core/pipeline-executor';
Expand All @@ -19,7 +19,7 @@ type DepthList = { depth: number, node: XmlBasedJson, leaf: boolean }[]

function toDepthMap(xml: XmlBasedJson): DepthList {
const root = getKeyGuarded<XmlBasedJson>(xml, RawRType.ExpressionList);

const visit: { depth: number, node: XmlBasedJson }[] = [ { depth: 0, node: root } ];
const result: DepthList = [];

Expand All @@ -30,7 +30,7 @@ function toDepthMap(xml: XmlBasedJson): DepthList {
}

const children = current.node[childrenKey] as unknown as XmlBasedJson[] | undefined ?? [];

result.push({ ...current, leaf: children.length === 0 });
children.reverse();

Expand Down
Loading
Loading