src/eric7/QScintilla/EditorAssembly.py

branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9412:45e7bb09c120 9413:80c06d472826
11 import contextlib 11 import contextlib
12 12
13 from PyQt6.QtCore import QTimer 13 from PyQt6.QtCore import QTimer
14 from PyQt6.QtWidgets import QWidget, QGridLayout, QComboBox 14 from PyQt6.QtWidgets import QWidget, QGridLayout, QComboBox
15 15
16 from EricWidgets.EricApplication import ericApp 16 from eric7.EricWidgets.EricApplication import ericApp
17 17
18 import UI.PixmapCache 18 from eric7.EricGui import EricPixmapCache
19 import Preferences 19 from eric7 import Preferences
20 20
21 21
22 class EditorAssembly(QWidget): 22 class EditorAssembly(QWidget):
23 """ 23 """
24 Class implementing the editor assembly widget containing the navigation 24 Class implementing the editor assembly widget containing the navigation
195 entry = self.__module.modules[entryName] 195 entry = self.__module.modules[entryName]
196 # step 2.0: add module classes 196 # step 2.0: add module classes
197 items = [] 197 items = []
198 for cl in entry.classes.values(): 198 for cl in entry.classes.values():
199 if cl.isPrivate(): 199 if cl.isPrivate():
200 icon = UI.PixmapCache.getIcon("class_private") 200 icon = EricPixmapCache.getIcon("class_private")
201 elif cl.isProtected(): 201 elif cl.isProtected():
202 icon = UI.PixmapCache.getIcon("class_protected") 202 icon = EricPixmapCache.getIcon("class_protected")
203 else: 203 else:
204 icon = UI.PixmapCache.getIcon("class") 204 icon = EricPixmapCache.getIcon("class")
205 items.append((icon, cl.name, cl.lineno, cl.endlineno)) 205 items.append((icon, cl.name, cl.lineno, cl.endlineno))
206 for itm in sorted(items, key=lambda x: (x[1], x[2])): 206 for itm in sorted(items, key=lambda x: (x[1], x[2])):
207 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) 207 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
208 memberIndex += 1 208 memberIndex += 1
209 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex 209 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex
210 else: 210 else:
211 return 211 return
212 212
213 # step 2.1: add class methods 213 # step 2.1: add class methods
214 from Utilities.ModuleParser import Function 214 from eric7.Utilities.ModuleParser import Function
215 215
216 items = [] 216 items = []
217 for meth in entry.methods.values(): 217 for meth in entry.methods.values():
218 if meth.modifier == Function.Static: 218 if meth.modifier == Function.Static:
219 icon = UI.PixmapCache.getIcon("method_static") 219 icon = EricPixmapCache.getIcon("method_static")
220 elif meth.modifier == Function.Class: 220 elif meth.modifier == Function.Class:
221 icon = UI.PixmapCache.getIcon("method_class") 221 icon = EricPixmapCache.getIcon("method_class")
222 elif meth.isPrivate(): 222 elif meth.isPrivate():
223 icon = UI.PixmapCache.getIcon("method_private") 223 icon = EricPixmapCache.getIcon("method_private")
224 elif meth.isProtected(): 224 elif meth.isProtected():
225 icon = UI.PixmapCache.getIcon("method_protected") 225 icon = EricPixmapCache.getIcon("method_protected")
226 else: 226 else:
227 icon = UI.PixmapCache.getIcon("method") 227 icon = EricPixmapCache.getIcon("method")
228 items.append((icon, meth.name, meth.lineno, meth.endlineno)) 228 items.append((icon, meth.name, meth.lineno, meth.endlineno))
229 for itm in sorted(items, key=lambda x: (x[1], x[2])): 229 for itm in sorted(items, key=lambda x: (x[1], x[2])):
230 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) 230 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
231 memberIndex += 1 231 memberIndex += 1
232 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex 232 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex
233 233
234 # step 2.2: add class instance attributes 234 # step 2.2: add class instance attributes
235 items = [] 235 items = []
236 for attr in entry.attributes.values(): 236 for attr in entry.attributes.values():
237 if attr.isPrivate(): 237 if attr.isPrivate():
238 icon = UI.PixmapCache.getIcon("attribute_private") 238 icon = EricPixmapCache.getIcon("attribute_private")
239 elif attr.isProtected(): 239 elif attr.isProtected():
240 icon = UI.PixmapCache.getIcon("attribute_protected") 240 icon = EricPixmapCache.getIcon("attribute_protected")
241 else: 241 else:
242 icon = UI.PixmapCache.getIcon("attribute") 242 icon = EricPixmapCache.getIcon("attribute")
243 items.append((icon, attr.name, attr.lineno)) 243 items.append((icon, attr.name, attr.lineno))
244 for itm in sorted(items, key=lambda x: (x[1], x[2])): 244 for itm in sorted(items, key=lambda x: (x[1], x[2])):
245 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) 245 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
246 246
247 # step 2.3: add class attributes 247 # step 2.3: add class attributes
248 items = [] 248 items = []
249 icon = UI.PixmapCache.getIcon("attribute_class") 249 icon = EricPixmapCache.getIcon("attribute_class")
250 for globalVar in entry.globals.values(): 250 for globalVar in entry.globals.values():
251 items.append((icon, globalVar.name, globalVar.lineno)) 251 items.append((icon, globalVar.name, globalVar.lineno))
252 for itm in sorted(items, key=lambda x: (x[1], x[2])): 252 for itm in sorted(items, key=lambda x: (x[1], x[2])):
253 self.__membersCombo.addItem(itm[0], itm[1], itm[2]) 253 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
254 254
280 def __parseEditor(self): 280 def __parseEditor(self):
281 """ 281 """
282 Private method to parse the editor source and repopulate the globals 282 Private method to parse the editor source and repopulate the globals
283 combo. 283 combo.
284 """ 284 """
285 from Utilities.ModuleParser import Module, getTypeFromTypeName 285 from eric7.Utilities.ModuleParser import Module, getTypeFromTypeName
286 286
287 self.__module = None 287 self.__module = None
288 sourceType = getTypeFromTypeName(self.__editor.determineFileType()) 288 sourceType = getTypeFromTypeName(self.__editor.determineFileType())
289 if sourceType != -1: 289 if sourceType != -1:
290 src = self.__editor.text() 290 src = self.__editor.text()
310 # step 1: add modules 310 # step 1: add modules
311 items = [] 311 items = []
312 for module in self.__module.modules.values(): 312 for module in self.__module.modules.values():
313 items.append( 313 items.append(
314 ( 314 (
315 UI.PixmapCache.getIcon("module"), 315 EricPixmapCache.getIcon("module"),
316 module.name, 316 module.name,
317 module.lineno, 317 module.lineno,
318 module.endlineno, 318 module.endlineno,
319 ) 319 )
320 ) 320 )
325 325
326 # step 2: add classes 326 # step 2: add classes
327 items = [] 327 items = []
328 for cl in self.__module.classes.values(): 328 for cl in self.__module.classes.values():
329 if cl.isPrivate(): 329 if cl.isPrivate():
330 icon = UI.PixmapCache.getIcon("class_private") 330 icon = EricPixmapCache.getIcon("class_private")
331 elif cl.isProtected(): 331 elif cl.isProtected():
332 icon = UI.PixmapCache.getIcon("class_protected") 332 icon = EricPixmapCache.getIcon("class_protected")
333 else: 333 else:
334 icon = UI.PixmapCache.getIcon("class") 334 icon = EricPixmapCache.getIcon("class")
335 items.append((icon, cl.name, cl.lineno, cl.endlineno)) 335 items.append((icon, cl.name, cl.lineno, cl.endlineno))
336 for itm in sorted(items, key=lambda x: (x[1], x[2])): 336 for itm in sorted(items, key=lambda x: (x[1], x[2])):
337 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) 337 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
338 index += 1 338 index += 1
339 self.__globalsBoundaries[(itm[2], itm[3])] = index 339 self.__globalsBoundaries[(itm[2], itm[3])] = index
340 340
341 # step 3: add functions 341 # step 3: add functions
342 items = [] 342 items = []
343 for func in self.__module.functions.values(): 343 for func in self.__module.functions.values():
344 if func.isPrivate(): 344 if func.isPrivate():
345 icon = UI.PixmapCache.getIcon("method_private") 345 icon = EricPixmapCache.getIcon("method_private")
346 elif func.isProtected(): 346 elif func.isProtected():
347 icon = UI.PixmapCache.getIcon("method_protected") 347 icon = EricPixmapCache.getIcon("method_protected")
348 else: 348 else:
349 icon = UI.PixmapCache.getIcon("method") 349 icon = EricPixmapCache.getIcon("method")
350 items.append((icon, func.name, func.lineno, func.endlineno)) 350 items.append((icon, func.name, func.lineno, func.endlineno))
351 for itm in sorted(items, key=lambda x: (x[1], x[2])): 351 for itm in sorted(items, key=lambda x: (x[1], x[2])):
352 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) 352 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
353 index += 1 353 index += 1
354 self.__globalsBoundaries[(itm[2], itm[3])] = index 354 self.__globalsBoundaries[(itm[2], itm[3])] = index
355 355
356 # step 4: add attributes 356 # step 4: add attributes
357 items = [] 357 items = []
358 for globalValue in self.__module.globals.values(): 358 for globalValue in self.__module.globals.values():
359 if globalValue.isPrivate(): 359 if globalValue.isPrivate():
360 icon = UI.PixmapCache.getIcon("attribute_private") 360 icon = EricPixmapCache.getIcon("attribute_private")
361 elif globalValue.isProtected(): 361 elif globalValue.isProtected():
362 icon = UI.PixmapCache.getIcon("attribute_protected") 362 icon = EricPixmapCache.getIcon("attribute_protected")
363 else: 363 else:
364 icon = UI.PixmapCache.getIcon("attribute") 364 icon = EricPixmapCache.getIcon("attribute")
365 items.append((icon, globalValue.name, globalValue.lineno)) 365 items.append((icon, globalValue.name, globalValue.lineno))
366 for itm in sorted(items, key=lambda x: (x[1], x[2])): 366 for itm in sorted(items, key=lambda x: (x[1], x[2])):
367 self.__globalsCombo.addItem(itm[0], itm[1], itm[2]) 367 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
368 368
369 # reset the currently selected entries without moving the 369 # reset the currently selected entries without moving the

eric ide

mercurial