Skip to content

Conversation

@Wagner-Laranjeiras
Copy link

@Wagner-Laranjeiras Wagner-Laranjeiras commented Oct 17, 2025

[Feature] Implement diagnostic and quick fix for missing configuration and [Bugfix] Fix non existent lib breaking all INCLUDES.

Issue: XXX

Summary:
[Feature] This PR introduces a new Diagnostic (_TB002) and Quick Fix action (pli.applyQuickFixCreateConfig) for missing files. When the config files are not present, the diagnostic will be thrown at the file in the %INCLUDE. The Quick Fix will then offer creating the configuration, having the current file as the program entry point.
[Bugfix] Fix INCLUDES resolution breaking because of non existent directory added to libs.

Changes

  • apply-quick-fixes.ts file now has a generic function which calls more specific functions based on the current diagnostic.
  • New commands.ts file, which contains functions called at the connection-handler.
  • New constants.ts file, which contains namespaces for the Commands codes and PluginConfiguration.
  • New check for throwing diagnostic at the instruction-interpreter.ts file. Now, before trying to resolve an INCLUDE, we check if the full configuration is present (via the new helper "hasFullConfig()") and throw the new Diagnostic if it's not.
  • Modify readDir function to catch error when trying to read directory and return an empty array if it's the case.

Notes

  • Tests are still a work in progress.
  • Specific issue for this PR is not yet created.
  • I'll look into the commented code that needs to be cleaned up.

@github-actions
Copy link

github-actions bot commented Oct 17, 2025

PR Preview Action v1.6.0

🚀 View preview at
https://zowe.github.io/zowe-pli-language-support/pr/pr-451/

Built to branch previews at 2025-10-30 12:53 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Contributor

@msujew msujew left a comment

Choose a reason for hiding this comment

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

I've noticed that our .pluplugin directory handling is a bit inaccurate in case the user opens multiple workspace folders. See #454 as a potential follow up on this.

@Wagner-Laranjeiras Wagner-Laranjeiras force-pushed the feature/wagner/diagnostic-and-quick-fix-for-missing-config branch from 0b0ee24 to 6cd2b92 Compare October 27, 2025 12:37
… Libs bug for inexistent lib.

Signed-off-by: Wagner Laranjeiras <[email protected]>
@Wagner-Laranjeiras Wagner-Laranjeiras force-pushed the feature/wagner/diagnostic-and-quick-fix-for-missing-config branch from ceffbcf to f71af15 Compare October 28, 2025 13:58
Signed-off-by: Wagner Laranjeiras <[email protected]>
};
let diagnostic: Diagnostic;

if (!(await hasFullConfig())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: I don't think we necessarily need to wait here for the file system. Assuming the current unit has a config available to it, it will be accessible via the processGroup/programConfig field. Accessing the file system might considerably slow down the interpreter in the error case.

Comment on lines 2029 to 2033
diagnostic = diagnosticFromCode(
InternalCodes.DiagnosticMissingConfiguration,
item.token,
);
diagnostic.data = { entryUri: context.entryUri.toString() };
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: This shouldn't be implemented as an internal code. Internal codes are internal, because they shouldn't be displayed to the user. Generating this diagnostic however will show the internal code to the user. Reuse the IBM3841I code instead and add additional data into the .data field to differentiate between the quick fixes that are applied to these diagnostics.

Copy link
Author

Choose a reason for hiding this comment

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

Ah ok. I understood that Internal codes were custom ones we had generate outside of the PLI-Codes.

Comment on lines 23 to 28
DiagnosticMissingConfiguration: {
code: "_TB002",
severity: Severity.E,
message: "Configuration is missing.",
fullCode: "_TB002E",
} as SimplePLICode,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove, see reason above.

// add any contained directories to the libs list, as well as the toProcess list
const libUri = UriUtils.joinPath(URI.parse(this.workspacePath), lib);
const entries = await FileSystemProviderInstance.readDir(libUri);
console.log(entries);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove before undrafting this PR.

Comment on lines 370 to 377
try {
// directory to add for handling
libsToProcess.push(`${lib}/${fileName}`);
// also add to the full libs list
computedLibs.add(`${lib}/${fileName}`);
} catch (err) {
console.error(`Failed to add ${lib}/${fileName}: `, err);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: How can an array push/a set add operation fail?

Copy link
Author

Choose a reason for hiding this comment

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

I was testing if somehow that could be the problem and ended up letting this there because I wasn't sure it couldn't fail. Gonna remove it though.

Comment on lines 50 to 53
} catch (err) {
console.error(`Error reading directory: ${uri.fsPath}`, err);
return [];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: IMO the call site should handle any file system failure. Only the caller knows what to do with a failure:

  1. Do nothing (which would be essentially the same as returning []).
  2. Log the error and continue (perhaps displaying it to the user)
  3. Bubble up the error

Signed-off-by: Wagner Laranjeiras <[email protected]>
…ix-for-missing-config

Signed-off-by: Wagner-Laranjeiras <[email protected]>
Signed-off-by: Wagner Laranjeiras <[email protected]>
Signed-off-by: Wagner Laranjeiras <[email protected]>
Signed-off-by: Wagner Laranjeiras <[email protected]>
Signed-off-by: Wagner Laranjeiras <[email protected]>
Signed-off-by: Wagner Laranjeiras <[email protected]>
import { Severity } from "../language-server/types";
import { SimplePLICode } from "../validation/pli-codes";

export const lspCodes = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Exported constants are usually either CamelCase or SNAKE_CASE.

Suggested change
export const lspCodes = {
export const LspCodes = {

Comment on lines +1 to +13
/**
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

import { Severity } from "../language-server/types";
import { SimplePLICode } from "../validation/pli-codes";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Please put this file in the validation part of the package.

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.

3 participants