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

Vml Library Support #1602

Open
wants to merge 36 commits into
base: develop
Choose a base branch
from
Open

Vml Library Support #1602

wants to merge 36 commits into from

Conversation

joswig
Copy link
Collaborator

@joswig joswig commented Jan 23, 2025

@joswig joswig force-pushed the feat/vml_libraries branch from 04fbbe2 to 1acdc23 Compare February 2, 2025 04:05
@joswig joswig force-pushed the feat/vml_libraries branch from 6bded13 to 553ee27 Compare February 3, 2025 17:31
@joswig joswig force-pushed the feat/vml_libraries branch from 0f3fcfe to 2be0db9 Compare February 3, 2025 23:52
Copy link
Contributor

@goetzrrGit goetzrrGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will approve this as I’ll be out tomorrow. If you’d like to merge, please feel free to do so.

We’ve already discussed some issues:

Autocomplete doesn’t pop up with Control+Space; please verify with Bryan (non-blocking).
SeqN’s Selected command panel needs full hookups for library sequences like VML (see [GitHub issue #1550]). (non-blocking)

No big issues that I ran into.

src/utilities/codemirror/vml/vmlTooltip.ts Outdated Show resolved Hide resolved
Comment on lines +62 to +74
if (statementNode) {
const vmManagementNode = statementNode.getChild(RULE_VM_MANAGEMENT);
if (vmManagementNode) {
const spawnNode = vmManagementNode.getChild(RULE_SPAWN);
if (spawnNode) {
return spawnNode.getChild(RULE_CALL_PARAMETERS);
}
}

// ISSUE and ISSUE_DYNAMIC
return statementNode.firstChild?.getChild(RULE_CALL_PARAMETERS) ?? null;
}
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: Always found that make conditionals top level and removing nesting more readability.

    if (!statementNode) {
      return null;
    }
    const vmManagementNode = statementNode.getChild(RULE_VM_MANAGEMENT);
    if (!vmManagementNode) {
      return statementNode.firstChild?.getChild(RULE_CALL_PARAMETERS) ?? null;
    }

    const spawnNode = vmManagementNode.getChild(RULE_SPAWN);
    if (!spawnNode) {
      return null;
    }

    return spawnNode.getChild(RULE_CALL_PARAMETERS);

src/utilities/codemirror/vml/vmlTreeUtils.ts Outdated Show resolved Hide resolved
src/utilities/codemirror/vml/vmlTreeUtils.ts Outdated Show resolved Hide resolved
src/utilities/codemirror/vml/vmlTreeUtils.ts Outdated Show resolved Hide resolved
workspace_id: sequence.workspace_id,
};
});
if (isInVmlMode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pull this logic out into a util function so we can add some unit tests to it?

name: sequence.name,
parameters: parseVariables(tree.topNode, sequence.definition, 'ParameterDeclaration') ?? [],
tree,
type: 'librarySequence',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make librarySequence an enum?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, or remove it depending on your take on #1602 (comment)

}
}
</script>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be wrapped in a <div></div> so that it doesn't affect the parent component's hierarchy in an unexpected way?

@@ -155,9 +155,16 @@ export type LibrarySequence = {
name: string;
parameters: VariableDeclaration[];
tree: Tree;
type: 'librarySequence';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other type strings that this can be?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I added it to keep the associated type guard trivial and match the pattern we're using with FswCommand.

Do you have a preference on avoiding explicit typing?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh I see it now. I don't necessarily have an issue with the explicit typing, but it's not intuitive as to what the purpose was. There's nothing relating the LibrarySequence type to a FswCommand type unless you have enough context of how it's being used and that might cause some issues in the future if we have to change the Command types. I think ideally, these types can extend from a common interface. If that's too out of this scope, then I think making the type an enum that's shared with all the command types would suffice for now.

src/utilities/codemirror/vml/vmlAdaptation.ts Show resolved Hide resolved
const cursorLine = context.state.doc.lineAt(selection.ranges[0].to);
const cursorLineTrimmed = cursorLine.text.trim();

if (!cursorLineTrimmed) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to compare cursorLineTrimmed explicitly with an "" to make it more apparent what the comment on the following line means?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in b848d63

case 'UINT':
case 'FLOAT':
return {
arg_type: { FLOAT: 'float', INT: 'integer', UINT: 'unsigned' }[variable.type] as
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little forced. I think I'd be okay with this being a little repetitive for the sake of being more clear if each number case returned almost the same object.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 284aa51

function validateArguments(
commandDictionary: CommandDictionary,
commandDef: FswCommand,
functionNode: SyntaxNode,
functionNameNode: SyntaxNode,
docText: string,
// issue_dynamic puts the stem into the first argument
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind fleshing this comment out a little bit more to be clearer to someone who's not too familiar with VML?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in fa3ed42

above: true,
create() {
const dom = document.createElement('div');
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is something generating an error here for a try/catch to be necessary? It's not immediately clear as to what that would be. StringTooltip.svelte isn't throwing anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to satisfy SonarQube, I'll look for another way

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh weird. It's not flagging the other tooltips though, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe they haven't been scanned yet since they are unchanged in the PR

Copy link

sonarqubecloud bot commented Feb 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check VML block library parameters
3 participants