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

feat: Diagnostics suppression for files with no pgm_conf configuration #89

Merged
merged 33 commits into from
Dec 17, 2020

Conversation

michalbali256
Copy link
Contributor

@michalbali256 michalbali256 commented Oct 7, 2020

Added the diagnosticsSuppressLimit option, that a number and limits the number of diagnostics that are shown when there is no configuration for currently opened file in the pgm_conf. The reason why to introduce such limit is that the majority of HLASM source files use macros and copy files. When there is no configuration, symbols defined in those external files are not accessible thus the plugin shows many diagnostics that are not useful. To increase usability of the plugin in such cases, we do not show diagnostics at all.

The limit allows to edit small files with small amount of diagnostics even without configuration. It can be configured either in VS Code settings for user-specific configuration or in pgm_conf for project-specific configuration. When both are configured, the pgm_conf is prioritized.

  • Added handler for workspace/didChangeConfiguration notification
  • Added implementation of LSP requests from server to client, needed for workspace/configuration request
  • Added a class to parser_library that holds client/workspace configuration

language_server/src/lsp/feature_workspace_folders.cpp Outdated Show resolved Hide resolved
language_server/src/lsp/lsp_server.cpp Outdated Show resolved Hide resolved
{
if (suppress_diags_limit_)
return suppress_diags_limit_.value();
return lib_config::get_instance()->diag_supress_limit;
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't the lib_config instance be just another member of the workspace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The configuration can be changed by the user during lifetime of workspace, so we need to get the instance every time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking that perhaps each workspace might have different limits?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, right now the static lib_config instance represents the configuration of VS Code client. At the same time, you can override the limit of each workspace by writing the configuration into pgm_conf.json.

Copy link
Contributor Author

@michalbali256 michalbali256 Oct 12, 2020

Choose a reason for hiding this comment

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

I can get rid of the static instance and create a member instance of workspace_manager, would that be preferable?
But we still need some code to merge the global and workspace configurations.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that you should not have a static instance at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for late editing of the previous comment.

I meant adding the instance as a non-static member of workspace manager.

language_server/src/lsp/feature_workspace_folders.cpp Outdated Show resolved Hide resolved
language_server/src/lsp/feature_workspace_folders.h Outdated Show resolved Hide resolved
@@ -114,7 +115,7 @@ class PARSER_LIBRARY_EXPORT workspace_manager
virtual void register_highlighting_consumer(highlighting_consumer* consumer);
virtual void register_diagnostics_consumer(diagnostics_consumer* consumer);
virtual void register_performance_metrics_consumer(performance_metrics_consumer* consumer);

virtual void set_message_consumer(message_consumer* consumer);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we unify the naming of consumer setting/registering?

Copy link
Contributor

Choose a reason for hiding this comment

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

or, does it make sense to register more message consumers?

#include "json.hpp"

#include "parser_library_export.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

seems like this is important part of added logic. please add a comment describing this structure


#include "lib_config.h"

static std::shared_ptr<lib_config> config_instance = std::make_shared<lib_config>();
Copy link
Contributor

Choose a reason for hiding this comment

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

is static needed here?

Copy link
Contributor

Choose a reason for hiding this comment

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

could be anonymous namespace instead...

But I am still wondering if this should be part of the server's state.



// if there is no processor group assigned to the program, delete diagnostics that may have been created
if (cancel_ && cancel_->load()) // skip, if parsing was cancelled using the cancellation token
Copy link
Contributor

Choose a reason for hiding this comment

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

can you simplify?

Suggested change
if (cancel_ && cancel_->load()) // skip, if parsing was cancelled using the cancellation token
if (cancel_ && *cancel_) // skip, if parsing was cancelled using the cancellation token

@sonarcloud
Copy link

sonarcloud bot commented Oct 21, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 10 Code Smells

95.2% 95.2% Coverage
0.0% 0.0% Duplication

@@ -58,6 +58,7 @@ class server : public response_provider
std::vector<std::unique_ptr<feature>> features_;

std::map<std::string, method> methods_;
std::unordered_map<json, method> request_handlers_;
Copy link
Contributor

Choose a reason for hiding this comment

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

could you elaborate on why use json as the key?

# Conflicts:
#	language_server/src/lsp/feature_workspace_folders.cpp
#	language_server/test/lsp/lsp_server_test.cpp
#	language_server/test/response_provider_mock.h
#	parser_library/src/workspace_manager.cpp
#	parser_library/src/workspace_manager_impl.h
@sonarcloud
Copy link

sonarcloud bot commented Dec 17, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 15 Code Smells

95.2% 95.2% Coverage
0.0% 0.0% Duplication

@michalbali256 michalbali256 merged commit c287ff1 into development Dec 17, 2020
@michalbali256 michalbali256 deleted the suppress-diags branch December 17, 2020 20:55
@github-actions
Copy link

🎉 This PR is included in version 0.12.0-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 0.12.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

SWETAS04 pushed a commit to SWETAS04/che-che4z-lsp-for-hlasm that referenced this pull request Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants