cleanup more
This commit is contained in:
parent
1d54ac1433
commit
802373ba16
1 changed files with 11 additions and 17 deletions
|
|
@ -51,22 +51,16 @@ function nestedInputProperties({state, setState, suggestionPriority}: CallBlockP
|
|||
return {state: state.input, setState: setInput, onCancel: onInputCancel, suggestionPriority: inputSuggestionPriorirty};
|
||||
}
|
||||
|
||||
export function CallBlock({ state, setState, suggestionPriority }: CallBlockProps) {
|
||||
export function CallBlock(props: CallBlockProps) {
|
||||
const env = useContext(EnvContext);
|
||||
const resolved = evalEditorBlock(state, env);
|
||||
const resolved = evalEditorBlock(props.state, env);
|
||||
return <span className={"functionBlock" + ((resolved.kind === "error") ? " unifyError" : "")}>
|
||||
<FunctionHeader
|
||||
state={state}
|
||||
setState={setState}
|
||||
suggestionPriority={suggestionPriority}
|
||||
/>
|
||||
<FunctionHeader {...props} />
|
||||
<div className="functionParams">
|
||||
<div className="outputParam">
|
||||
{/* Sequence of input parameters */}
|
||||
<InputParams
|
||||
state={state}
|
||||
setState={setState}
|
||||
suggestionPriority={suggestionPriority}
|
||||
{...props}
|
||||
depth={0}
|
||||
errorDepth={(resolved.kind === "error") ? (resolved.depth) : -1}
|
||||
/>
|
||||
|
|
@ -84,11 +78,11 @@ function computePriority(fn: ResolvedType, input: ResolvedType, outPriority: (s:
|
|||
return score;
|
||||
}
|
||||
|
||||
function FunctionHeader({ state, setState, suggestionPriority }) {
|
||||
function FunctionHeader(props) {
|
||||
const env = useContext(EnvContext);
|
||||
const globalContext = useContext(GlobalContext);
|
||||
const nestedProperties = nestedFnProperties({state, setState, suggestionPriority}, env);
|
||||
if (state.fn.kind === "call" && globalContext?.syntacticSugar) {
|
||||
const nestedProperties = nestedFnProperties(props, env);
|
||||
if (props.state.fn.kind === "call" && globalContext?.syntacticSugar) {
|
||||
// if the function we're calling is itself the result of a function call,
|
||||
// then we are anonymous, and so we don't draw a function name
|
||||
return <FunctionHeader {...nestedProperties} />;
|
||||
|
|
@ -102,21 +96,21 @@ function FunctionHeader({ state, setState, suggestionPriority }) {
|
|||
}
|
||||
}
|
||||
|
||||
function InputParams({ state, setState, suggestionPriority, depth, errorDepth }) {
|
||||
function InputParams({ depth, errorDepth, ...rest }) {
|
||||
const env = useContext(EnvContext);
|
||||
const globalContext = useContext(GlobalContext);
|
||||
const isOffending = depth === errorDepth;
|
||||
return <div className={"inputParam" + (isOffending ? " offending" : "")}>
|
||||
{state.fn.kind === "call"
|
||||
{rest.state.fn.kind === "call"
|
||||
&& globalContext?.syntacticSugar
|
||||
&& <InputParams
|
||||
{...nestedFnProperties({state, setState, suggestionPriority}, env)}
|
||||
{...nestedFnProperties(rest as CallBlockProps, env)}
|
||||
depth={depth+1}
|
||||
errorDepth={errorDepth}
|
||||
/>}
|
||||
{/* Our own input param */}
|
||||
<Editor
|
||||
{...nestedInputProperties({state, setState, suggestionPriority}, env)}
|
||||
{...nestedInputProperties(rest as CallBlockProps, env)}
|
||||
/>
|
||||
</div>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue