Skip to content

Commit

Permalink
lint-fix: handle linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
EagleoutIce committed Aug 30, 2024
1 parent e7031f0 commit 6ad0857
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/dataflow/environments/built-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-i
import { EdgeType } from '../graph/edge'
import { processLibrary } from '../internal/process/functions/call/built-in/built-in-library'
import { processSourceCall } from '../internal/process/functions/call/built-in/built-in-source'
import {ForceArguments} from "../internal/process/functions/call/common";
import type { ForceArguments } from '../internal/process/functions/call/common'

export const BuiltIn = 'built-in'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { dataflowLogger } from '../../../../../logger'
import { RType } from '../../../../../../r-bridge/lang-4.x/ast/model/type'
import { EdgeType } from '../../../../../graph/edge'
import { makeAllMaybe, makeReferenceMaybe } from '../../../../../environments/environment'
import {ForceArguments} from "../common";
import type { ForceArguments } from '../common'

export function processAccess<OtherInfo>(
name: RSymbol<OtherInfo & ParentInformation>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { RUnnamedArgument } from '../../../../../../r-bridge/lang-4.x/ast/m
import { VertexType } from '../../../../../graph/vertex'
import { define } from '../../../../../environments/define'
import { EdgeType } from '../../../../../graph/edge'
import {ForceArguments} from "../common";
import type { ForceArguments } from '../common'

function toReplacementSymbol<OtherInfo>(target: RNodeWithParent<OtherInfo & ParentInformation> & Base<OtherInfo> & Location, prefix: string, superAssignment: boolean): RSymbol<OtherInfo & ParentInformation> {
return {
Expand Down Expand Up @@ -149,7 +149,7 @@ function processAssignmentToString<OtherInfo>(
rootId,
data,
reverseOrder: !config.swapSourceAndTarget,
forceArgs: config.forceArgs
forceArgs: config.forceArgs
})

return processAssignmentToSymbol<OtherInfo & ParentInformation>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/node
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id'
import type { IdentifierReference } from '../../../../../environments/identifier'
import { EdgeType } from '../../../../../graph/edge'
import {ForceArguments} from "../common";
import type { ForceArguments } from '../common'


export function processQuote<OtherInfo>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { initializeCleanDataflowInformation } from '../../../../../info'
import { processKnownFunctionCall } from '../known-call-handling'
import { expensiveTrace } from '../../../../../../util/log'
import { processAssignment } from './built-in-assignment'
import {ForceArguments, processAllArguments} from '../common'
import type { ForceArguments } from '../common'
import { processAllArguments } from '../common'
import { guard } from '../../../../../../util/assert'
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate'
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { RType } from '../../../../../../r-bridge/lang-4.x/ast/model/type'
import { overwriteEnvironment } from '../../../../../environments/overwrite'
import type { NoInfo } from '../../../../../../r-bridge/lang-4.x/ast/model/model'
import { expensiveTrace } from '../../../../../../util/log'
import {ForceArguments} from "../common";

let sourceProvider = requestProviderFromFile()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/node
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id'
import { dataflowLogger } from '../../../../../logger'
import { EdgeType } from '../../../../../graph/edge'
import {ForceArguments} from "../common";
import type { ForceArguments } from '../common'


export function processSpecialBinOp<OtherInfo>(
Expand Down
47 changes: 24 additions & 23 deletions src/dataflow/internal/process/functions/call/common.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import type {DataflowInformation} from '../../../../info'
import type {DataflowProcessorInformation} from '../../../../processor'
import {processDataflowFor} from '../../../../processor'
import type {RNode} from '../../../../../r-bridge/lang-4.x/ast/model/model'
import type {ParentInformation} from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate'
import type {RFunctionArgument} from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call'
import {EmptyArgument} from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call'
import type {DataflowGraph, FunctionArgument} from '../../../../graph/graph'
import type {NodeId} from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id'
import type {REnvironmentInformation} from '../../../../environments/environment'
import type {IdentifierReference} from '../../../../environments/identifier'
import {overwriteEnvironment} from '../../../../environments/overwrite'
import {resolveByName} from '../../../../environments/resolve-by-name'
import {RType} from '../../../../../r-bridge/lang-4.x/ast/model/type'
import {DataflowGraphVertexFunctionDefinition, isFunctionDefinitionVertex, VertexType} from '../../../../graph/vertex'
import type {RSymbol} from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol'
import {EdgeType} from '../../../../graph/edge'
import type { DataflowInformation } from '../../../../info'
import type { DataflowProcessorInformation } from '../../../../processor'
import { processDataflowFor } from '../../../../processor'
import type { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model'
import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate'
import type { RFunctionArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call'
import { EmptyArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call'
import type { DataflowGraph, FunctionArgument } from '../../../../graph/graph'
import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id'
import type { REnvironmentInformation } from '../../../../environments/environment'
import type { IdentifierReference } from '../../../../environments/identifier'
import { overwriteEnvironment } from '../../../../environments/overwrite'
import { resolveByName } from '../../../../environments/resolve-by-name'
import { RType } from '../../../../../r-bridge/lang-4.x/ast/model/type'
import type { DataflowGraphVertexFunctionDefinition } from '../../../../graph/vertex'
import { isFunctionDefinitionVertex, VertexType } from '../../../../graph/vertex'
import type { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol'
import { EdgeType } from '../../../../graph/edge'

export interface ForceArguments {
/** which of the arguments should be forced? this may be all, e.g., if the function itself is unknown on encounter */
Expand Down Expand Up @@ -43,17 +44,17 @@ export interface ProcessAllArgumentResult {
function forceVertexArgumentValueReferences(rootId: NodeId, value: DataflowInformation, graph: DataflowGraph, env: REnvironmentInformation): void {
const valueVertex = graph.getVertex(value.entryPoint)
if(!valueVertex) {
return;
return
}
// link read if it is function definition directly and reference the exit point
if(valueVertex.tag !== VertexType.Value) {
if(valueVertex.tag === VertexType.FunctionDefinition) {
for(const exit of valueVertex.exitPoints) {
graph.addEdge(rootId, exit, {type: EdgeType.Reads})
graph.addEdge(rootId, exit, { type: EdgeType.Reads })
}
} else {
for (const exit of value.exitPoints) {
graph.addEdge(rootId, exit.nodeId, {type: EdgeType.Reads})
for(const exit of value.exitPoints) {
graph.addEdge(rootId, exit.nodeId, { type: EdgeType.Reads })
}
}
}
Expand All @@ -64,8 +65,8 @@ function forceVertexArgumentValueReferences(rootId: NodeId, value: DataflowInfor
for(const ref of [...value.in, ...containedSubflowIn.flatMap(n => n.subflow.in)]) {
if(ref.name) {
const resolved = resolveByName(ref.name, env) ?? []
for (const resolve of resolved) {
graph.addEdge(ref.nodeId, resolve.nodeId, {type: EdgeType.Reads})
for(const resolve of resolved) {
graph.addEdge(ref.nodeId, resolve.nodeId, { type: EdgeType.Reads })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { DataflowProcessorInformation } from '../../../../processor'
import { processDataflowFor } from '../../../../processor'
import type { DataflowInformation } from '../../../../info'
import { ExitPointType } from '../../../../info'
import {ForceArguments, processAllArguments} from './common'
import type { ForceArguments } from './common'
import { processAllArguments } from './common'
import type { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol'
import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate'
import type { RFunctionArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call'
Expand Down
27 changes: 14 additions & 13 deletions test/functionality/_helper/dataflow/dataflow-builder-printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
* The goal is to create syntactically correct TypeScript code in a best-effort approach.
*/

import {assertUnreachable, isNotUndefined} from '../../../../src/util/assert'
import {DefaultMap} from '../../../../src/util/defaultmap'
import {EnvironmentBuilderPrinter} from './environment-builder-printer'
import {wrap, wrapControlDependencies, wrapReference} from './printer'
import {EdgeType, splitEdgeTypes} from '../../../../src/dataflow/graph/edge'
import type {DataflowGraph, FunctionArgument} from '../../../../src/dataflow/graph/graph'
import {isPositionalArgument} from '../../../../src/dataflow/graph/graph'
import type {NodeId} from '../../../../src/r-bridge/lang-4.x/ast/model/processing/node-id'
import {
import { assertUnreachable, isNotUndefined } from '../../../../src/util/assert'
import { DefaultMap } from '../../../../src/util/defaultmap'
import { EnvironmentBuilderPrinter } from './environment-builder-printer'
import { wrap, wrapControlDependencies, wrapReference } from './printer'
import { EdgeType, splitEdgeTypes } from '../../../../src/dataflow/graph/edge'
import type { DataflowGraph, FunctionArgument } from '../../../../src/dataflow/graph/graph'
import { isPositionalArgument } from '../../../../src/dataflow/graph/graph'
import type { NodeId } from '../../../../src/r-bridge/lang-4.x/ast/model/processing/node-id'
import type {
DataflowGraphVertexFunctionCall,
DataflowGraphVertexFunctionDefinition,
DataflowGraphVertexInfo,
DataflowGraphVertexUse,
DataflowGraphVertexUse } from '../../../../src/dataflow/graph/vertex'
import {
VertexType
} from '../../../../src/dataflow/graph/vertex'
import {EmptyArgument} from '../../../../src/r-bridge/lang-4.x/ast/model/nodes/r-function-call'
import type {REnvironmentInformation} from '../../../../src/dataflow/environments/environment'
import type {ControlDependency} from '../../../../src/dataflow/info'
import { EmptyArgument } from '../../../../src/r-bridge/lang-4.x/ast/model/nodes/r-function-call'
import type { REnvironmentInformation } from '../../../../src/dataflow/environments/environment'
import type { ControlDependency } from '../../../../src/dataflow/info'


/** we add the node id to allow convenience sorting if we want that in the future (or grouping or, ...) */
Expand Down
10 changes: 5 additions & 5 deletions test/functionality/slicing/static-program-slices/calls-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,14 @@ x`)
})
describe('Lapply Forcing the Map Function Body', () => {
assertSliced(label('Forcing Second Argument', []), shell,
`res <- lapply(1:3, function(x) x + 1)`, ['1@res'],
`res <- lapply(1:3, function(x) x + 1)`
'res <- lapply(1:3, function(x) x + 1)', ['1@res'],
'res <- lapply(1:3, function(x) x + 1)'
)
assertSliced(label('Forcing Including Reference', []), shell,
`foo <- bar()\nres <- lapply(1:3, function(x) foo * 2)`, ['2@res'],
`foo <- bar()\nres <- lapply(1:3, function(x) foo * 2)`
'foo <- bar()\nres <- lapply(1:3, function(x) foo * 2)', ['2@res'],
'foo <- bar()\nres <- lapply(1:3, function(x) foo * 2)'
)
});
})
})
describe('Closures', () => {
assertSliced(label('closure w/ default arguments',['name-normal', ...OperatorDatabase['<-'].capabilities, 'formals-default', 'numbers', 'newlines', 'implicit-return', 'normal-definition', 'closures', 'unnamed-arguments']),
Expand Down

0 comments on commit 6ad0857

Please sign in to comment.