-
Notifications
You must be signed in to change notification settings - Fork 5
[Feature] Implement diagnostic and quick fix for missing configuration #451
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
Draft
Wagner-Laranjeiras
wants to merge
9
commits into
development
Choose a base branch
from
feature/wagner/diagnostic-and-quick-fix-for-missing-config
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f71af15
Implement new diagnostic and Quick fix for missing configuration. Fix…
Wagner-Laranjeiras 8daadc8
work in progrss
Wagner-Laranjeiras 7ba3dc0
work on review
Wagner-Laranjeiras 0b492bf
Merge branch 'development' into feature/wagner/diagnostic-and-quick-f…
Wagner-Laranjeiras 12e28a6
solve conflicts
Wagner-Laranjeiras 29efbe9
minor tweaks
Wagner-Laranjeiras 246e452
remove fullCode
Wagner-Laranjeiras f26fdf0
fix code placement
Wagner-Laranjeiras f9c9073
work in progress
Wagner-Laranjeiras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /** | ||
| * 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 { URI } from "vscode-uri"; | ||
| import { FileSystemProviderInstance } from "../workspace/file-system-provider"; | ||
| import { Mutex } from "../workspace/mutex"; | ||
| import { PluginConfigurationProviderInstance } from "../workspace/plugin-configuration-provider"; | ||
| import { ExecuteCommandParams } from "vscode-languageserver"; | ||
| import { UriUtils } from "../utils/uri"; | ||
| import { PluginConfiguration } from "./constants"; | ||
|
|
||
| export async function commandResolveInclude(params: ExecuteCommandParams) { | ||
| return Mutex.run(async () => { | ||
| const [uri, content] = params.arguments as string[]; | ||
| try { | ||
| await FileSystemProviderInstance.writeFile(URI.parse(uri), content); | ||
| } catch (err) { | ||
| console.error("Failed to write proc_grps.json:", err); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| export async function commandCreateConfig(params: ExecuteCommandParams) { | ||
| return Mutex.run(async () => { | ||
| const workspaceFolderUri = URI.parse( | ||
| PluginConfigurationProviderInstance.getWorkspacePath(), | ||
| ); | ||
| if (!workspaceFolderUri) { | ||
| return; | ||
| } | ||
| try { | ||
| if (!params.arguments) { | ||
| return; | ||
| } | ||
| const entryUri = params.arguments[0]; | ||
| await FileSystemProviderInstance.writeFile( | ||
| UriUtils.joinPath( | ||
| workspaceFolderUri, | ||
| PluginConfiguration.PROGRAM_FILE_PATH, | ||
| ), | ||
| JSON.stringify( | ||
| { | ||
| ...PluginConfiguration.DEFAULT_PROGRAM_FILE_CONTENT, | ||
| pgms: [ | ||
| { | ||
| ...PluginConfiguration.DEFAULT_PROGRAM_FILE_CONTENT.pgms[0], | ||
| program: entryUri, | ||
| }, | ||
| ], | ||
| }, | ||
| null, | ||
| 2, | ||
| ), | ||
| ); | ||
| await FileSystemProviderInstance.writeFile( | ||
| UriUtils.joinPath( | ||
| workspaceFolderUri, | ||
| PluginConfiguration.PROCESS_GROUP_FILE_PATH, | ||
| ), | ||
| JSON.stringify( | ||
| PluginConfiguration.DEFAULT_PROCESS_GROUP_FILE_CONTENT, | ||
| null, | ||
| 2, | ||
| ), | ||
| ); | ||
| } catch (err) { | ||
| console.error("Failed to create configuration: ", err); | ||
| } | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * 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. | ||
| * | ||
| */ | ||
|
|
||
| export namespace PluginConfiguration { | ||
| export const PROGRAM_FILE_PATH = ".pliplugin/pgm_conf.json"; | ||
| export const PROCESS_GROUP_FILE_PATH = ".pliplugin/proc_grps.json"; | ||
| export const DEFAULT_PROGRAM_FILE_CONTENT = { | ||
| pgms: [ | ||
| { | ||
| program: "", | ||
| pgroup: "default", | ||
| }, | ||
| ], | ||
| }; | ||
| export const DEFAULT_PROCESS_GROUP_FILE_CONTENT = { | ||
| pgroups: [ | ||
| { | ||
| name: "default", | ||
| "compiler-options": [], | ||
| libs: ["cpy", "inc"], | ||
| "include-extensions": [".pli", ".pl1", ".inc"], | ||
| "implicit-builtins": ["SUBSTR"], | ||
| "lsp-options": { | ||
| "check-margins": true, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
| } | ||
|
|
||
| export namespace Commands { | ||
| export const RESOLVE_INCLUDE = "pli.applyQuickFixResolveInclude"; | ||
| export const CREATE_CONFIG = "pli.applyQuickFixCreateConfig"; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||
| /** | ||||||
| * 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"; | ||||||
|
|
||||||
| export const lspCodes = { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Exported constants are usually either CamelCase or SNAKE_CASE.
Suggested change
|
||||||
| IncludeResolution: { | ||||||
| MissingConfiguration: { | ||||||
| code: "LSPIR001", | ||||||
| severity: Severity.E, | ||||||
| message: | ||||||
| "Could not resolve include directive. Plugin configuration is missing", | ||||||
| } as SimplePLICode, | ||||||
| }, | ||||||
| }; | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
validationpart of the package.