Skip to content

Commit

Permalink
pull isVariable check into reactive block
Browse files Browse the repository at this point in the history
  • Loading branch information
joswig committed Nov 2, 2024
1 parent 5f31b17 commit 521cacd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/components/sequencing/form/ArgEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
let argDef: FswCommandArgument | undefined = undefined;
let enableRepeatAdd: boolean = false;
let isVariable: boolean = false;
$: argDef = argInfo.argDef;
$: {
if (argDef && commandInfoMapper.isArgumentNodeOfVariableType(argInfo.node ?? null)) {
isVariable = commandInfoMapper.isArgumentNodeOfVariableType(argInfo.node ?? null);
if (!!argDef && isVariable) {
argDef = {
arg_type: 'enum',
bit_length: null,
Expand Down Expand Up @@ -79,7 +81,7 @@
{/if}
{:else}
<ArgTitle {argDef} />
{#if argInfo.node?.name === 'Enum' && isFswCommandArgumentEnum(argDef)}
{#if isVariable && isFswCommandArgumentEnum(argDef)}
<div class="st-typography-small-caps" title="Dictionary values must be quoted in editor">Global/Parameter</div>
<EnumEditor
{argDef}
Expand All @@ -91,7 +93,7 @@
}}
useQuotes={false}
/>
{:else if argDef.arg_type === 'enum' && argInfo.node}
{:else if isFswCommandArgumentEnum(argDef) && argInfo.node}
{#if commandInfoMapper.nodeTypeEnumCompatible(argInfo.node)}
<EnumEditor
{commandDictionary}
Expand Down
6 changes: 5 additions & 1 deletion src/utilities/codemirror/vml/vmlTreeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ export class VmlCommandInfoMapper implements CommandInfoMapper {
}

isArgumentNodeOfVariableType(argNode: SyntaxNode | null): boolean {
return argNode?.name === RULE_VARIABLE_NAME;
if (argNode?.name === RULE_CALL_PARAMETER) {
const variableNameNode = argNode.getChild(RULE_SIMPLE_EXPR)?.getChild(RULE_VARIABLE_NAME);
return !!variableNameNode && variableNameNode.from === argNode.from && variableNameNode.to === argNode.to;
}
return false;
}

nodeTypeEnumCompatible(node: SyntaxNode | null): boolean {
Expand Down

0 comments on commit 521cacd

Please sign in to comment.