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

[WIP] PR: Code analysis UX/UI improvements #20683

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c0e35ff
Code analysis issues #4
jsbautista Feb 9, 2023
538e666
Merge branch 'spyder-ide:master' into CodeAnalysisIssues
jsbautista Feb 9, 2023
64ba1bf
Apply suggestions
jsbautista Mar 6, 2023
ee5be1b
Apply suggestions
jsbautista Mar 13, 2023
975c624
Apply suggestions
jsbautista Mar 15, 2023
67b06e0
Apply suggestions
jsbautista Mar 20, 2023
893ec8d
Merge branch 'master' into CodeAnalysisIssues
jsbautista Mar 20, 2023
a556311
Apply suggestions
jsbautista Apr 2, 2023
6cc7933
Apply suggestions
jsbautista Apr 3, 2023
4513106
Apply suggestions
jsbautista Apr 10, 2023
448117b
Merge branch 'master' into CodeAnalysisIssues
jsbautista Apr 17, 2023
dd74b32
Apply suggestions
jsbautista Apr 17, 2023
ffa168e
Apply suggestions
jsbautista Apr 17, 2023
6a15d74
Apply suggestions
jsbautista Apr 24, 2023
fe74cbd
Apply suggestions
jsbautista May 1, 2023
d6ef847
Apply suggestions
jsbautista May 1, 2023
685664c
Apply suggestions
jsbautista May 1, 2023
9ebf845
Merge branch 'master' into CodeAnalysisIssues
jsbautista May 8, 2023
260d842
Apply suggestions
jsbautista May 8, 2023
7644f9f
Merge branch 'CodeAnalysisIssues' of https://github.com/jsbautista/sp…
jsbautista May 8, 2023
fda6a7c
Undo PanelEmptyWidget changes
dalthviz Jun 27, 2023
11dd72d
Merge remote-tracking branch 'upstream/master' into CodeAnalysisIssues
dalthviz Jun 27, 2023
7894d44
Fix open pylint preference page
dalthviz Jun 27, 2023
6cdab13
Fix tests and update real time code analysis handling
dalthviz Jun 27, 2023
2c68665
Run action from the run menu. Confpage changes. Text changes and comm…
dalthviz Jun 28, 2023
baba89c
Merge branch 'master' into CodeAnalysisIssues
dalthviz Jul 5, 2023
47ea86c
Testing
dalthviz Jul 7, 2023
2aacfb4
Merge branch 'master' into CodeAnalysisIssues
dalthviz Jul 7, 2023
8aabded
Testing
dalthviz Jul 7, 2023
f2867c4
More code clean up
dalthviz Jul 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
'history_filenames': [],
'max_entries': 30,
'project_dir': None,
'real_time_analysis': False,
}),
('workingdir',
{
Expand Down
12 changes: 10 additions & 2 deletions spyder/plugins/editor/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,18 @@ class Editor(SpyderPluginWidget, SpyderConfigurationObserver):
sig_codeeditor_created = Signal(object)
"""
This signal is emitted when a codeeditor is created.
"""

sig_diagnostics_update = Signal(str, list)
"""
This signal is emitted when new code analysis diagnostics are available.

Parameters
----------
codeeditor: spyder.plugins.editor.widgets.codeeditor.CodeEditor
The codeeditor.
filename: str
The file filename.
diagnostics: list
The file code analysis diagnostics.
"""

sig_codeeditor_deleted = Signal(object)
Expand Down Expand Up @@ -1795,6 +1802,7 @@ def register_editorstack(self, editorstack):
editorstack.sig_save_bookmarks.connect(self.save_bookmarks)
editorstack.sig_help_requested.connect(self.sig_help_requested)
editorstack.sig_codeeditor_created.connect(self.sig_codeeditor_created)
editorstack.sig_diagnostics_update.connect(self.sig_diagnostics_update)
editorstack.sig_codeeditor_changed.connect(self.sig_codeeditor_changed)
editorstack.sig_codeeditor_deleted.connect(self.sig_codeeditor_deleted)

Expand Down
4 changes: 4 additions & 0 deletions spyder/plugins/editor/widgets/codeeditor/lsp_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class LSPMixin:
#: Signal emitted when processing code analysis warnings is finished
sig_process_code_analysis = Signal()

#: Signal emitted when diagnostics is defined/set
sig_diagnostics_update = Signal(str, list)

# Used to start the status spinner in the editor
sig_start_operation_in_progress = Signal()

Expand Down Expand Up @@ -512,6 +515,7 @@ def sync_symbols_and_folding(self):
def process_code_analysis(self, diagnostics):
"""Process code analysis results in a thread."""
self.cleanup_code_analysis()
self.sig_diagnostics_update.emit(self.filename, diagnostics)
self._diagnostics = diagnostics

# Process diagnostics in a thread to improve performance.
Expand Down
3 changes: 3 additions & 0 deletions spyder/plugins/editor/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class EditorStack(QWidget, SpyderConfigurationAccessor):
active_languages_stats = Signal(set)
todo_results_changed = Signal()
sig_update_code_analysis_actions = Signal()
sig_diagnostics_update = Signal(str, list)
refresh_file_dependent_actions = Signal()
refresh_save_all_action = Signal()
text_changed_at = Signal(str, int)
Expand Down Expand Up @@ -2373,6 +2374,8 @@ def create_new_editor(self, fname, enc, txt, set_current, new=False,
editor.sig_new_file.connect(self.sig_new_file)
editor.sig_process_code_analysis.connect(
self.sig_update_code_analysis_actions)
editor.sig_diagnostics_update.connect(
self.sig_diagnostics_update)
editor.sig_refresh_formatting.connect(self.sig_refresh_formatting)
editor.sig_save_requested.connect(self.save)
language = get_file_language(fname, txt)
Expand Down
44 changes: 17 additions & 27 deletions spyder/plugins/pylint/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,27 @@
from spyder.api.preferences import PluginConfigPage
from spyder.api.translations import _
from spyder.plugins.pylint.main_widget import (MAX_HISTORY_ENTRIES,
MIN_HISTORY_ENTRIES,
PylintWidget)
MIN_HISTORY_ENTRIES)


class PylintConfigPage(PluginConfigPage):

def setup_page(self):
settings_group = QGroupBox(_("Settings"))
save_box = self.create_checkbox(_("Save file before analyzing it"),
'save_before', default=True)

settings_group = QGroupBox(_("Real time code analysis"))
linter_selection_label = QLabel(
_("Choose if real time code analysis results or "
"manually requested Pylint executions results "
"should be shown")
)
real_time_box = self.create_checkbox(
_("Enable real time code analysis"),
'real_time_analysis',
default=False
)
hist_group = QGroupBox(_("History"))
hist_label1 = QLabel(_("The following option will be applied at next "
"startup."))
hist_label1 = QLabel(_("Choose how many results you want to store in "
"the history results, pick a number between "
"1-100."))
hist_label1.setWordWrap(True)
hist_spin = self.create_spinbox(
_("History: "),
Expand All @@ -39,35 +46,18 @@ def setup_page(self):
step=1,
)

results_group = QGroupBox(_("Results"))
results_label1 = QLabel(_("Results are stored here:"))
results_label1.setWordWrap(True)

# Warning: do not try to regroup the following QLabel contents with
# widgets above -- this string was isolated here in a single QLabel
# on purpose: to fix spyder-ide/spyder#863.
results_label2 = QLabel(PylintWidget.DATAPATH)

results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse)
results_label2.setWordWrap(True)

settings_layout = QVBoxLayout()
settings_layout.addWidget(save_box)
settings_layout.addWidget(linter_selection_label)
settings_layout.addWidget(real_time_box)
settings_group.setLayout(settings_layout)

hist_layout = QVBoxLayout()
hist_layout.addWidget(hist_label1)
hist_layout.addWidget(hist_spin)
hist_group.setLayout(hist_layout)

results_layout = QVBoxLayout()
results_layout.addWidget(results_label1)
results_layout.addWidget(results_label2)
results_group.setLayout(results_layout)

vlayout = QVBoxLayout()
vlayout.addWidget(settings_group)
vlayout.addWidget(hist_group)
vlayout.addWidget(results_group)
vlayout.addStretch(1)
self.setLayout(vlayout)
Loading