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

New implementation for TEST.SUBPROGRAM autocompletion #195

Draft
wants to merge 27 commits into
base: update_ct_support_170
Choose a base branch
from

Conversation

Den1552
Copy link
Contributor

@Den1552 Den1552 commented Sep 6, 2024

Summary:

This implementation should provide an autocompletion list for TEST.SUBPROGRAM without using the fake TEST.VALUE line described in #170.

Explanation:

  • In order to get the autocompletion list for TEST.SUBPROGRAM, we need the <unit> from TEST.UNIT.
  • This is retrieved with getNearest() in tstCompletion.ts.
  • This <unit> is sent as an additional parameter to the Python logic.
  • In processSubprogramLines() (tstUtilities.py), we use this <unit> to retrieve, with getFunctions(), the autocompletion list of all the functions in this unit from the DataAPI.
  • At the end, we add SUBPROGRAM-specific autocompletions like <<INIT>>, <<COMPOUND>>, <<coded_tests_driver>>.

Basically, the implementation works. However, we need to answer some questions:

Questions:

  1. Passing this argument into getChoiceDataFromPython is straightforward, but how about the "server-side" autocompletion retrieval in getChoiceDataFromServer()?

    export async function getChoiceDataFromServer(

  2. What about the SUBPROGRAM-specific autocompletions (<<INIT>>, <<COMPOUND>>, coded_tests_driver)?
    Is it all right to add them like that in processSubprogramLines(), or should this also be retrieved from the DataAPI somehow?

Den1552 and others added 17 commits September 3, 2024 07:58
## Summary

Enhanced `launch.json.example` by adding a new debugger configuration
for VectorCAST unit tests.
## Summary

Added tests to get back to 100% coverage.

## Changed
- Added exports to functions in `vcast-server-test.ts `to enable testing
- Enhanced test for `transmitCommand()`
moved some of the common functions and global objects there.
when we ping.  Now that we have this version, we check that the
extension vcast version matches the server when we initialize.

Made the extension version computation a stand-alone function

Only compute the extension version once on startup and when the
extension option for vcast installation changes.

Only missing piece is to send the update the LSP with the server state
enviro data server and not.  This allows the auto-complete stuff
to work seemlessly
## Summary

`serverIsAlive()` now requires a `text` field in the response. Since we
mock the server fetch, I added a text field including `clicast-path` so
that the split operation does not fail.


https://github.com/vectorgrp/vector-vscode-vcast/blob/3d64e64ad7b1c88837de7b48c19666e102c60ac7/src-common/vcastServer.ts#L143
@Den1552 Den1552 requested a review from Zbigor September 6, 2024 11:46
@Den1552 Den1552 self-assigned this Sep 6, 2024
@Den1552 Den1552 changed the title Refactor subprogram autocompletion unit param Refactor subprogram autocompletion based on #193 Sep 6, 2024
@Den1552 Den1552 changed the title Refactor subprogram autocompletion based on #193 Refactor SUBPROGRAM autocompletion based on #193 Sep 6, 2024
@Den1552 Den1552 changed the title Refactor SUBPROGRAM autocompletion based on #193 Refactored SUBPROGRAM autocompletion based on #193 Sep 6, 2024
Copy link
Collaborator

@johnpaliotta johnpaliotta left a comment

Choose a reason for hiding this comment

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

Some very quick comments ...
Seems like some improvements could be made!

Thanks.

@@ -33,7 +33,7 @@ def main():
# We get here when the user types a "." or ":"

# argv has the name of the script as arg 1 and then user args
if len(sys.argv) == 4:
if ((len(sys.argv) == 4) or (len(sys.argv) == 5)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

@aytey
These are very quick comments, as it is the end of the day and I don't have time to look at this thoroughly

This is not good, the check for 4 was to validate that the number of args was correct for the call, just slapping 5 here makes no sense, and also invalidates the else below which says 3 args are expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored to argument parser in 78bf51f .

additionalParams = None

if(len(sys.argv) == 5):
# Additional autocompletion params
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not write comments like this, what is saved in arg5?

@@ -52,7 +58,7 @@ def main():
choiceData = choiceDataType()

elif mode == "choiceList-tst":
choiceData = processTstLine(enviroName, inputLine)
choiceData = processTstLine(enviroName, inputLine, additionalParams)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't even understand what is being done here yet but adding a new parameter cannot be the best way to do this

Copy link
Contributor Author

@Den1552 Den1552 Sep 11, 2024

Choose a reason for hiding this comment

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

I thought this would be the best way since

  • I need the unit to get all the functions for the TEST.SUBPROGRAM with getFunctions().
  • The changes are not really huge

I brainstormed some ideas in the notes here:
#193

I initially implemented Idea 1) because I believed it was the best option. However, if you'd like, I can review it again.

@@ -417,6 +417,29 @@ def processRequirementLines(api, pieces, triggerCharacter):

return returnData

def processSubprogramLines(api, pieces, triggerCharacter, additionalParams):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok so if you are only using this to pass the unit name, then change all of the parameter names etc to unitName, not additionalParams. Additionally additionalParams is a bad name because there is only one right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the moment, we would only need the <unit>, but I thought to make it as an object so that for future implementations I can simply add new params to this JSON.

I changed it now to be only unit. In case we will need more, I could enhance it.

@@ -43,6 +43,12 @@ def main():
# Contents of the line from the editor so far
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably did not want to tear this completely apart but I would probably convert this to use argparse now and have named parameters like --mode, --enviroName, --inputLine, --unit etc. and make unit optional, the others required.

(if it turns out we need unitName ... which it might)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored to argument parser in 78bf51f .

const { stdout } = await execAsync(getCodedTestsSupportCommand, {
cwd: enviroPath,
});
const { stdout, stderr } = await execAsync(getCodedTestsSupportCommand, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a (meaningful) comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in c73e858 .

);
console.log("++++++++++++++++++++++++++++++");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in 78bf51f.

returnData.extraText = choiceData.extraText;
returnData.messages = choiceData.messages;
choiceKind = choiceData.choiceKind;
// append actual choices to the default INIT and COMPOUND
choiceArray = choiceArray.concat(choiceData.choiceList);
// choiceArray = choiceArray.concat(choiceData.choiceList);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why iis this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am sorry it was only a Draft so I didn't delete pieces of the "old" code in case you do not like my idea how I solved it. Removed in 78bf51f .

// <<GLOBAL>> is valid on VALUE lines but not as a function name!
choiceArray = filterArray(choiceArray, "<<GLOBAL>>");
// choiceArray = filterArray(choiceArray, "<<GLOBAL>>");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in 78bf51f .

@johnpaliotta johnpaliotta changed the title Refactored SUBPROGRAM autocompletion based on #193 New implementation for TEST.SUBPROGRAM autocompletion Sep 10, 2024
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.

2 participants