Skip to content

Update to NB-25 #382

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

Merged
merged 11 commits into from
Mar 7, 2025
Merged

Update to NB-25 #382

merged 11 commits into from
Mar 7, 2025

Conversation

Achal1607
Copy link
Member

@Achal1607 Achal1607 commented Mar 4, 2025

This PR aims to update LS to NB-25.

@Achal1607 Achal1607 requested review from lahodaj and sid-srini March 4, 2025 09:32
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Mar 4, 2025
Copy link
Member

@sid-srini sid-srini left a comment

Choose a reason for hiding this comment

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

Thanks a lot @Achal1607 for upgrading the LS to NB25.

@@ -237,7 +237,11 @@ class RunConfigurationProvider implements vscode.DebugConfigurationProvider {
if (vmArgs) {
if (!config.vmArgs) {
config.vmArgs = vmArgs;
} else if (Array.isArray(config.vmArgs)) {
let cfg: string[] = config.vmArgs;
cfg.push(vmArgs);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the vmArgs be treated conditionally, just like config.vmArgs?
i.e. check whether it is an array or a string. If there is a mismatch between the types of both, then the vmArgs needs to be converted to the type of the config.vmArgs. Right?
In case vmArgs is a string and is to be pushed into an array, then we should perhaps split using quote-aware whitespace-delimiters into an array before pushing. That would ensure that downstream usage of config.vmArgs does not cause the double-quoting of multiple args into a single arg, which would not be understood by the JVM.

Copy link
Member Author

@Achal1607 Achal1607 Mar 6, 2025

Choose a reason for hiding this comment

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

vmArgs is always a string since it comes from the settings.json. In package.json you can find:

"jdk.runConfig.vmOptions": {
	"type": "string",
	"default": "",
	"description": "%jdk.configuration.vmOptions.description%"
}

So, we don't need to do any string manipulation there IMO.
launch.json can have array of vmArgs. For example:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "jdk",
            "request": "launch",
            "name": "Launch Java App",
            "vmArgs": ["-Xms256m"]
        }
    ]
}

But the side panel can only have string type of vmOptions as it comes from the settings.json.
image

In future can also convert settings.json configuration to take input as array as well.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Then we would need to do just the following:

In case vmArgs is a string and is to be pushed into an array, then we should perhaps split using quote-aware whitespace-delimiters into an array before pushing. That would ensure that downstream usage of config.vmArgs does not cause the double-quoting of multiple args into a single arg, which would not be understood by the JVM.

@sid-srini sid-srini added this to the JVSC 24.0.0 milestone Mar 5, 2025
@Achal1607
Copy link
Member Author

@sid-srini I have addressed all the review comments. Please review it again. Thanks

@Achal1607 Achal1607 requested a review from sid-srini March 6, 2025 06:50
while (i < input.length && f) {
current += input[i];
if (input[i] === quoteType && input[i - 1] != "\\")
Copy link
Member

Choose a reason for hiding this comment

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

Typically, this will be functionally correct, although the performance maybe improved by storing a regex reference and performing a search followed by concat of substr. However, in certain corner cases this may not give the correct result. For e.g. when there are a balanced number of escape backslashes which indicate a literal backslash instead:

  • "abc \\" def should become 2 strings; whereas the current code would retain it as a single string.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing out this edge case, will update the method.

@Achal1607 Achal1607 force-pushed the only-update-nb-25 branch from b8bd745 to ce36fc5 Compare March 7, 2025 04:38
@Achal1607
Copy link
Member Author

@sid-srini Addressed review comments. Thanks

@Achal1607 Achal1607 requested a review from sid-srini March 7, 2025 04:38
Copy link
Member

@sid-srini sid-srini left a comment

Choose a reason for hiding this comment

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

Thanks @Achal1607 for completing the upgrade to NB25 and also improving the implementation of some of the new functionality. LGTM 👍

while (i < input.length && f) {
current += input[i];
const isEscapingSomethingElse = (i > 1 && input[i - 1] == "\\" && input[i - 2] == "\\");
Copy link
Member

Choose a reason for hiding this comment

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

Nit: an index out-of-bounds error may occur with the unchecked i-1 or i-2 index access. Safety or performance-wise, it may be better to add a separate else-if block for keeping track of number of continuous occurrences of char == '\\' i.e. isEscapingActive and just check that during quote handling.

Copy link
Member Author

Choose a reason for hiding this comment

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

i > 1 will check if index is greater than 1 if it is true then only javascript will check other conditions.

image

Please correct me if I perceived your comment incorrectly?

@Achal1607 Achal1607 merged commit 419f2fd into oracle:main Mar 7, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants