11 |
11 |
12 import ast |
12 import ast |
13 |
13 |
14 from PyQt5.QtCore import pyqtSlot, Qt, QTimer |
14 from PyQt5.QtCore import pyqtSlot, Qt, QTimer |
15 from PyQt5.QtGui import QCursor, QBrush |
15 from PyQt5.QtGui import QCursor, QBrush |
16 from PyQt5.QtWidgets import QTreeWidget, QApplication, QTreeWidgetItem, \ |
16 from PyQt5.QtWidgets import ( |
17 QAbstractItemView, QWidget, QVBoxLayout |
17 QTreeWidget, QApplication, QTreeWidgetItem, QAbstractItemView, QWidget, |
|
18 QVBoxLayout |
|
19 ) |
18 |
20 |
19 from ThirdParty.asttokens.asttokens import ASTTokens |
21 from ThirdParty.asttokens.asttokens import ASTTokens |
20 |
22 |
21 |
23 |
22 class PythonAstViewer(QWidget): |
24 class PythonAstViewer(QWidget): |
253 |
255 |
254 text = self.tr("{0}: {1}").format(name, value) |
256 text = self.tr("{0}: {1}").format(name, value) |
255 itm = QTreeWidgetItem(parent, [text]) |
257 itm = QTreeWidgetItem(parent, [text]) |
256 itm.setExpanded(True) |
258 itm.setExpanded(True) |
257 |
259 |
258 if hasattr(nodeOrFields, "lineno") and \ |
260 if ( |
259 hasattr(nodeOrFields, "col_offset"): |
261 hasattr(nodeOrFields, "lineno") and |
|
262 hasattr(nodeOrFields, "col_offset") |
|
263 ): |
260 itm.setData(0, self.StartLineRole, nodeOrFields.lineno) |
264 itm.setData(0, self.StartLineRole, nodeOrFields.lineno) |
261 itm.setData(0, self.StartIndexRole, nodeOrFields.col_offset) |
265 itm.setData(0, self.StartIndexRole, nodeOrFields.col_offset) |
262 startStr = self.tr("{0},{1}").format( |
266 startStr = self.tr("{0},{1}").format( |
263 nodeOrFields.lineno, nodeOrFields.col_offset) |
267 nodeOrFields.lineno, nodeOrFields.col_offset) |
264 endStr = "" |
268 endStr = "" |
265 |
269 |
266 if hasattr(nodeOrFields, "end_lineno") and \ |
270 if ( |
267 hasattr(nodeOrFields, "end_col_offset"): |
271 hasattr(nodeOrFields, "end_lineno") and |
|
272 hasattr(nodeOrFields, "end_col_offset") |
|
273 ): |
268 itm.setData(0, self.EndLineRole, nodeOrFields.end_lineno) |
274 itm.setData(0, self.EndLineRole, nodeOrFields.end_lineno) |
269 itm.setData(0, self.EndIndexRole, |
275 itm.setData(0, self.EndIndexRole, |
270 nodeOrFields.end_col_offset) |
276 nodeOrFields.end_col_offset) |
271 endStr = self.tr("{0},{1}").format( |
277 endStr = self.tr("{0},{1}").format( |
272 nodeOrFields.end_lineno, nodeOrFields.end_col_offset) |
278 nodeOrFields.end_lineno, nodeOrFields.end_col_offset) |