src/eric7/QScintilla/EditorAssembly.py

Sat, 26 Apr 2025 12:34:32 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 26 Apr 2025 12:34:32 +0200
branch
eric7
changeset 11240
c48c615c04a3
parent 11148
15e30f0c76a8
permissions
-rw-r--r--

MicroPython
- Added a configuration option to disable the support for the no longer produced Pimoroni Pico Wireless Pack.

1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
11090
f5f5f5803935 Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10907
diff changeset
3 # Copyright (c) 2011 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
7 Module implementing the editor assembly widget containing the navigation
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
8 combos and the editor widget.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
11 import contextlib
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
12
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
13 from PyQt6.QtCore import Qt, QTimer
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
14 from PyQt6.QtWidgets import QComboBox, QGridLayout, QSplitter, QWidget
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
16 from eric7 import Preferences
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
17 from eric7.EricGui import EricPixmapCache
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
18 from eric7.EricWidgets.EricApplication import ericApp
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
19 from eric7.Utilities.ModuleParser import Function
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
20
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
21 from .Editor import Editor
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
22 from .EditorButtonsWidget import EditorButtonsWidget
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
23 from .EditorOutline import EditorOutlineView
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
24
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class EditorAssembly(QWidget):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
28 Class implementing the editor assembly widget containing the navigation
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
29 combos and the editor widget.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
31
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
32 def __init__(self, dbs, fn="", vm=None, filetype="", editor=None, tv=None):
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
35
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @param dbs reference to the debug server object
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
37 @type DebugServer
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
38 @param fn name of the file to be opened. If it is None,
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
39 a new (empty) editor is opened.
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
40 @type str
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
41 @param vm reference to the view manager object
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
42 @type ViewManager.ViewManager
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
43 @param filetype type of the source file
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
44 @type str
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @param editor reference to an Editor object, if this is a cloned view
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
46 @type Editor
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @param tv reference to the task viewer object
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
48 @type TaskViewer
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8132
diff changeset
50 super().__init__()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.__layout = QGridLayout(self)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.__layout.setContentsMargins(0, 0, 0, 0)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__layout.setSpacing(1)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
55
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
56 self.__showNavigator = Preferences.getEditor("ShowSourceNavigator")
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
57 self.__showOutline = Preferences.getEditor("ShowSourceOutline")
10832
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
58 self.__outlineSortByOccurrence = Preferences.getEditor(
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
59 "SourceOutlineListContentsByOccurrence"
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
60 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
61
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
62 self.__editor = Editor(
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
63 dbs=dbs,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
64 fn=fn,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
65 vm=vm,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
66 filetype=filetype,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
67 editor=editor,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
68 tv=tv,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
69 assembly=self,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
70 )
5408
b67e07566aa1 Fix for the new editor button widget on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
71 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__globalsCombo = QComboBox()
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
73 self.__globalsCombo.setDuplicatesEnabled(True)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__membersCombo = QComboBox()
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
75 self.__membersCombo.setDuplicatesEnabled(True)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
76 self.__sourceOutline = EditorOutlineView(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
77 self.__editor, populate=self.__showOutline
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78 )
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
79 self.__editorSplitter = QSplitter(Qt.Orientation.Horizontal)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
80 self.__editorSplitter.setChildrenCollapsible(False)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
81 self.__editorSplitter.addWidget(self.__editor)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
82 self.__editorSplitter.addWidget(self.__sourceOutline)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
83
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
84 self.__layout.addWidget(self.__buttonsWidget, 1, 0, -1, 1)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
85 self.__layout.addWidget(self.__globalsCombo, 0, 1)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
86 self.__layout.addWidget(self.__membersCombo, 0, 2)
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
87 self.__layout.addWidget(self.__editorSplitter, 1, 1, 1, 2)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88
7343
e0808393413f EditorAssembly: fixed an issue causing the assembly widget handling focus instead of the embedded editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7267
diff changeset
89 self.setFocusProxy(self.__editor)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
90
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__module = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
92
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
93 self.__aboutToBeClosedCalled = False
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.__parseTimer = QTimer(self)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__parseTimer.setSingleShot(True)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__parseTimer.setInterval(5 * 1000)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.__editor.textChanged.connect(self.__resetParseTimer)
1807
9898a95461f1 Added a signal to the editor showing a refresh has happend and connected the editor assembly to it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1667
diff changeset
98 self.__editor.refreshed.connect(self.__resetParseTimer)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
99
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
100 self.__selectedGlobal = ""
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
101 self.__selectedMember = ""
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
102 self.__globalsBoundaries = {}
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
103 self.__membersBoundaries = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
104
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
105 self.__activateOutline(self.__showNavigator and self.__showOutline)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
106 self.__activateCombos(self.__showNavigator and not self.__showOutline)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
107
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
108 ericApp().getObject("UserInterface").preferencesChanged.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109 self.__preferencesChanged
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
112 def finishSetup(self):
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
113 """
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
114 Public method to finish the setup of the assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
115 """
10907
c424150d2ac8 Corrected some code formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10880
diff changeset
116 splitterWidth = self.parent().width() - self.__editorSplitter.handleWidth()
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
117 outlineWidth = Preferences.getEditor("SourceOutlineWidth")
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
118 self.__editorSplitter.setSizes([splitterWidth - outlineWidth, outlineWidth])
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
119
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
120 def aboutToBeClosed(self):
1421
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
121 """
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
122 Public method to stop and disconnect the timer and disconnect some signals.
1421
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
123 """
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
124 self.__parseTimer.stop()
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
125 if not self.__aboutToBeClosedCalled:
6317
e9ec47d52ff2 EditorAssembly: added a guard against shutdownTimer() being called multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6297
diff changeset
126 self.__editor.textChanged.disconnect(self.__resetParseTimer)
e9ec47d52ff2 EditorAssembly: added a guard against shutdownTimer() being called multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6297
diff changeset
127 self.__editor.refreshed.disconnect(self.__resetParseTimer)
9689
b18ad1f984b1 Corrected change 3a240d3f3b8c.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9688
diff changeset
128 ericApp().getObject("UserInterface").preferencesChanged.disconnect(
b18ad1f984b1 Corrected change 3a240d3f3b8c.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9688
diff changeset
129 self.__preferencesChanged
b18ad1f984b1 Corrected change 3a240d3f3b8c.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9688
diff changeset
130 )
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
131
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
132 self.__aboutToBeClosedCalled = True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
133
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 def getEditor(self):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 Public method to get the reference to the editor widget.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
137
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
138 @return reference to the editor widget
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
139 @rtype Editor
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 return self.__editor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
142
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
143 def __preferencesChanged(self):
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
144 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
145 Private slot handling a change of preferences.
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
146 """
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
147 showNavigator = Preferences.getEditor("ShowSourceNavigator")
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
148 showOutline = Preferences.getEditor("ShowSourceOutline")
10832
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
149 outlineSortByOccurrence = Preferences.getEditor(
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
150 "SourceOutlineListContentsByOccurrence"
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
151 )
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
152
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
153 if self.__outlineSortByOccurrence != outlineSortByOccurrence:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
154 self.__outlineSortByOccurrence = outlineSortByOccurrence
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
155 if self.__showOutline:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
156 self.__sourceOutline.repopulate()
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
157
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
158 if showOutline != self.__showOutline or showNavigator != self.__showNavigator:
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
159 self.__showOutline = showOutline
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
160 self.__showNavigator = showNavigator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
161 self.__activateOutline(self.__showNavigator and self.__showOutline)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
162 self.__activateCombos(self.__showNavigator and not self.__showOutline)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
163
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
164 self.finishSetup()
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
165
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
166 #######################################################################
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
167 ## Methods dealing with the navigation combos below
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
168 #######################################################################
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
169
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
170 def __activateCombos(self, activate):
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
171 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
172 Private slot to activate the navigation combo boxes.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
173
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
174 @param activate flag indicating to activate the combo boxes
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
175 @type bool
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
176 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
177 self.__globalsCombo.setVisible(activate)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
178 self.__membersCombo.setVisible(activate)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
179 if activate:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
180 self.__globalsCombo.activated[int].connect(self.__globalsActivated)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
181 self.__membersCombo.activated[int].connect(self.__membersActivated)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
182 self.__editor.cursorLineChanged.connect(self.__editorCursorLineChanged)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
183 self.__parseTimer.timeout.connect(self.__parseEditor)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
184
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
185 self.__parseEditor()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
187 line, _ = self.__editor.getCursorPosition()
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
188 self.__editorCursorLineChanged(line)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
189 else:
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
190 with contextlib.suppress(TypeError):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
191 self.__globalsCombo.activated[int].disconnect(self.__globalsActivated)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
192 self.__membersCombo.activated[int].disconnect(self.__membersActivated)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
193 self.__editor.cursorLineChanged.disconnect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
194 self.__editorCursorLineChanged
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
195 )
9688
f3817c476a62 Corrected another glitch in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9687
diff changeset
196 with contextlib.suppress(TypeError):
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
197 self.__parseTimer.timeout.disconnect(self.__parseEditor)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
198
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
199 self.__globalsCombo.clear()
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
200 self.__membersCombo.clear()
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
201 self.__globalsBoundaries = {}
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
202 self.__membersBoundaries = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
203
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
204 def __globalsActivated(self, index, moveCursor=True):
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
206 Private method to jump to the line of the selected global entry and to
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
207 populate the members combo box.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
208
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
209 @param index index of the selected entry
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
210 @type int
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
211 @param moveCursor flag indicating to move the editor cursor
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
212 @type bool
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 # step 1: go to the line of the selected entry
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 lineno = self.__globalsCombo.itemData(index)
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
216 if lineno is not None:
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
217 if moveCursor:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
218 txt = self.__editor.text(lineno - 1).rstrip()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
219 pos = len(txt.replace(txt.strip(), ""))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
220 self.__editor.gotoLine(lineno, pos if pos == 0 else pos + 1, True)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
221 self.__editor.setFocus()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
222
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
223 # step 2: populate the members combo, if the entry is a class
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
224 self.__membersCombo.clear()
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
225 self.__membersBoundaries = {}
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
226 self.__membersCombo.addItem("")
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
227 memberIndex = 0
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
228 entryName = self.__globalsCombo.itemText(index)
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
229 if self.__module:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
230 if entryName in self.__module.classes:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
231 entry = self.__module.classes[entryName]
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
232 elif entryName in self.__module.modules:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
233 entry = self.__module.modules[entryName]
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
234 # step 2.0: add module classes
8089
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
235 items = []
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
236 for cl in entry.classes.values():
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
237 if cl.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
238 icon = EricPixmapCache.getIcon("class_private")
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
239 elif cl.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
240 icon = EricPixmapCache.getIcon("class_protected")
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
241 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
242 icon = EricPixmapCache.getIcon("class")
8089
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
243 items.append((icon, cl.name, cl.lineno, cl.endlineno))
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
244 for itm in sorted(items, key=lambda x: (x[1], x[2])):
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
245 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
246 memberIndex += 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
247 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
248 else:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
249 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
250
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
251 # step 2.1: add class methods
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
252 items = []
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
253 for meth in entry.methods.values():
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
254 if meth.modifier == Function.Static:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
255 icon = EricPixmapCache.getIcon("method_static")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
256 elif meth.modifier == Function.Class:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
257 icon = EricPixmapCache.getIcon("method_class")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
258 elif meth.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
259 icon = EricPixmapCache.getIcon("method_private")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
260 elif meth.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
261 icon = EricPixmapCache.getIcon("method_protected")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
262 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
263 icon = EricPixmapCache.getIcon("method")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
264 items.append((icon, meth.name, meth.lineno, meth.endlineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
265 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
266 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
267 memberIndex += 1
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
268 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
269
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
270 # step 2.2: add class instance attributes
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
271 items = []
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
272 for attr in entry.attributes.values():
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
273 if attr.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
274 icon = EricPixmapCache.getIcon("attribute_private")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
275 elif attr.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
276 icon = EricPixmapCache.getIcon("attribute_protected")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
277 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
278 icon = EricPixmapCache.getIcon("attribute")
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
279 items.append((icon, attr.name, attr.lineno))
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
280 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
281 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
282
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
283 # step 2.3: add class attributes
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
284 items = []
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
285 icon = EricPixmapCache.getIcon("attribute_class")
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
286 for globalVar in entry.globals.values():
8089
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
287 items.append((icon, globalVar.name, globalVar.lineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
288 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
289 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
290
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
291 def __membersActivated(self, index, moveCursor=True):
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 Private method to jump to the line of the selected members entry.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
294
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
295 @param index index of the selected entry
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
296 @type int
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
297 @param moveCursor flag indicating to move the editor cursor
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
298 @type bool
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 lineno = self.__membersCombo.itemData(index)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
301 if lineno is not None and moveCursor:
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
302 txt = self.__editor.text(lineno - 1).rstrip()
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
303 pos = len(txt.replace(txt.strip(), ""))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
304 self.__editor.gotoLine(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
305 lineno, pos if pos == 0 else pos + 1, firstVisible=True, expand=True
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
306 )
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
307 self.__editor.setFocus()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
308
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 def __resetParseTimer(self):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 Private slot to reset the parse timer.
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 self.__parseTimer.stop()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 self.__parseTimer.start()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
315
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 def __parseEditor(self):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
318 Private method to parse the editor source and repopulate the globals
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
319 combo.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
321 from eric7.Utilities.ModuleParser import Module, getTypeFromTypeName
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
322
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 self.__module = None
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 sourceType = getTypeFromTypeName(self.__editor.determineFileType())
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 if sourceType != -1:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 src = self.__editor.text()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 if src:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 fn = self.__editor.getFileName()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 if fn is None:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 fn = ""
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 self.__module = Module("", fn, sourceType)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 self.__module.scan(src)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
333
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
334 # remember the current selections
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
335 self.__selectedGlobal = self.__globalsCombo.currentText()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
336 self.__selectedMember = self.__membersCombo.currentText()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
337
9691
12b8fe65c28c Fixed an issue causing the editor navigation selectors to malfunction, when the editor was parsed while a popup was open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9689
diff changeset
338 self.__globalsCombo.hidePopup()
12b8fe65c28c Fixed an issue causing the editor navigation selectors to malfunction, when the editor was parsed while a popup was open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9689
diff changeset
339 self.__membersCombo.hidePopup()
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 self.__globalsCombo.clear()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 self.__membersCombo.clear()
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
342 self.__globalsBoundaries = {}
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
343 self.__membersBoundaries = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
344
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 self.__globalsCombo.addItem("")
11148
15e30f0c76a8 Adjusted the code to the modified issue codes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11090
diff changeset
346 index = 0 # noqa: Y-113
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
347
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
348 # step 1: add modules
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
349 items = []
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
350 for module in self.__module.modules.values():
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
351 items.append(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
352 (
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
353 EricPixmapCache.getIcon("module"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
354 module.name,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
355 module.lineno,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
356 module.endlineno,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
357 )
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
358 )
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
359 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
360 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
361 index += 1
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
362 self.__globalsBoundaries[(itm[2], itm[3])] = index
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
363
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
364 # step 2: add classes
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
365 items = []
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 for cl in self.__module.classes.values():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 if cl.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
368 icon = EricPixmapCache.getIcon("class_private")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 elif cl.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
370 icon = EricPixmapCache.getIcon("class_protected")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
372 icon = EricPixmapCache.getIcon("class")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
373 items.append((icon, cl.name, cl.lineno, cl.endlineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
374 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
375 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
376 index += 1
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
377 self.__globalsBoundaries[(itm[2], itm[3])] = index
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
378
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
379 # step 3: add functions
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
380 items = []
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 for func in self.__module.functions.values():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 if func.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
383 icon = EricPixmapCache.getIcon("method_private")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 elif func.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
385 icon = EricPixmapCache.getIcon("method_protected")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
387 icon = EricPixmapCache.getIcon("method")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
388 items.append((icon, func.name, func.lineno, func.endlineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
389 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
390 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
391 index += 1
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
392 self.__globalsBoundaries[(itm[2], itm[3])] = index
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
393
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
394 # step 4: add attributes
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
395 items = []
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
396 for globalValue in self.__module.globals.values():
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
397 if globalValue.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
398 icon = EricPixmapCache.getIcon("attribute_private")
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
399 elif globalValue.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
400 icon = EricPixmapCache.getIcon("attribute_protected")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
402 icon = EricPixmapCache.getIcon("attribute")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
403 items.append((icon, globalValue.name, globalValue.lineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
404 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
405 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
406
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
407 # reset the currently selected entries without moving the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
408 # text cursor
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
409 index = self.__globalsCombo.findText(self.__selectedGlobal)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
410 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
411 self.__globalsCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
412 self.__globalsActivated(index, moveCursor=False)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
413 index = self.__membersCombo.findText(self.__selectedMember)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
414 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
415 self.__membersCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
416 self.__membersActivated(index, moveCursor=False)
7175
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
417 else:
9691
12b8fe65c28c Fixed an issue causing the editor navigation selectors to malfunction, when the editor was parsed while a popup was open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9689
diff changeset
418 self.__globalsCombo.hidePopup()
12b8fe65c28c Fixed an issue causing the editor navigation selectors to malfunction, when the editor was parsed while a popup was open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9689
diff changeset
419 self.__membersCombo.hidePopup()
7175
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
420 self.__globalsCombo.clear()
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
421 self.__membersCombo.clear()
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
422 self.__globalsBoundaries = {}
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
423 self.__membersBoundaries = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
424
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
425 def __editorCursorLineChanged(self, lineno):
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
426 """
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
427 Private slot handling a line change of the cursor of the editor.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
428
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
429 @param lineno line number of the cursor
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
430 @type int
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
431 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
432 lineno += 1 # cursor position is zero based, code info one based
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
433
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
434 # step 1: search in the globals
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
435 indexFound = 0
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
436 for (lower, upper), index in self.__globalsBoundaries.items():
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
437 if upper == -1:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
438 upper = 1000000 # it is the last line
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
439 if lower <= lineno <= upper:
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
440 indexFound = index
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
441 break
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
442 self.__globalsCombo.setCurrentIndex(indexFound)
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
443 self.__globalsActivated(indexFound, moveCursor=False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
444
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
445 # step 2: search in members
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
446 indexFound = 0
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
447 for (lower, upper), index in self.__membersBoundaries.items():
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
448 if upper == -1:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
449 upper = 1000000 # it is the last line
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
450 if lower <= lineno <= upper:
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
451 indexFound = index
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
452 break
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
453 self.__membersCombo.setCurrentIndex(indexFound)
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
454 self.__membersActivated(indexFound, moveCursor=False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
455
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
456 #######################################################################
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
457 ## Methods dealing with the source outline below
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
458 #######################################################################
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
459
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
460 def __activateOutline(self, activate):
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
461 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
462 Private slot to activate the source outline view.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
463
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
464 @param activate flag indicating to activate the source outline view
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
465 @type bool
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
466 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
467 self.__sourceOutline.setActive(activate)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
468
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
469 if activate:
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
470 self.__sourceOutline.setVisible(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
471 self.__sourceOutline.isSupportedLanguage(self.__editor.getLanguage())
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
472 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
473
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
474 self.__parseTimer.timeout.connect(self.__sourceOutline.repopulate)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
475 self.__editor.languageChanged.connect(self.__editorChanged)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
476 self.__editor.editorRenamed.connect(self.__editorChanged)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
477 else:
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
478 self.__sourceOutline.hide()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
479
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
480 with contextlib.suppress(TypeError):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
481 self.__parseTimer.timeout.disconnect(self.__sourceOutline.repopulate)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
482 self.__editor.languageChanged.disconnect(self.__editorChanged)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
483 self.__editor.editorRenamed.disconnect(self.__editorChanged)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
484
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
485 def __editorChanged(self):
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
486 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
487 Private slot handling changes of the editor language or file name.
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
488 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
489 supported = self.__sourceOutline.isSupportedLanguage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
490 self.__editor.getLanguage()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
491 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
492
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
493 self.__sourceOutline.setVisible(supported)

eric ide

mercurial