Home ⌂Doc Index ◂Up ▴

eric6.UI.PythonAstViewer

Module implementing a widget to visualize the Python AST for some Python sources.

Global Attributes

None

Classes

PythonAstViewer Class implementing a widget to visualize the Python AST for some Python sources.

Functions

None


PythonAstViewer

Class implementing a widget to visualize the Python AST for some Python sources.

Derived from

QWidget

Class Attributes

EndIndexRole
EndLineRole
StartIndexRole
StartLineRole

Class Methods

None

Methods

PythonAstViewer Constructor
__astItemClicked Private slot handling a user click on an AST node item.
__astViewerStateChanged Private slot to toggle the display of the AST viewer.
__clearSelection Private method to clear all selected items.
__createErrorItem Private method to create a top level error item.
__editorChanged Private slot to handle a change of the current editor.
__editorDoubleClicked Private slot to handle a mouse button double click in the editor.
__editorSaved Private slot to reload the AST after the connected editor was saved.
__findClosestContainingItem Private method to search for the tree item that contains a range closest.
__findClosestContainingNode Private method to search for the AST node that contains a range closest.
__grabFocus Private method to grab the input focus.
__lastEditorClosed Private slot to handle the last editor closed signal of the view manager.
__loadAST Private method to generate the AST from the source of the current editor and visualize it.
__markTextRanges Private method to modify the AST nodes with end_lineno and end_col_offset information.
__populateNode Private method to populate the tree view with a node.
__rangeContainsSmaller Private method to check, if second is contained in first.
__rangeContainsSmallerOrEqual Private method to check, if second is contained in or equal to first.
__resizeColumns Private method to resize the columns to suitable values.
__selectItemForEditorSelection Private slot to select the item corresponding to an editor selection.
hide Public slot to hide the AST viewer.
resizeEvent Protected method to handle resize events.
show Public slot to show the AST viewer.
shutdown Public method to perform shutdown actions.

Static Methods

None

PythonAstViewer (Constructor)

PythonAstViewer(viewmanager, parent=None)

Constructor

viewmanager (ViewManager)
reference to the viewmanager object
parent (QWidget)
reference to the parent widget

PythonAstViewer.__astItemClicked

__astItemClicked(itm, column)

Private slot handling a user click on an AST node item.

itm (QTreeWidgetItem)
reference to the clicked item
column (int)
column number of the click

PythonAstViewer.__astViewerStateChanged

__astViewerStateChanged(on)

Private slot to toggle the display of the AST viewer.

on (bool)
flag indicating to show the AST

PythonAstViewer.__clearSelection

__clearSelection()

Private method to clear all selected items.

PythonAstViewer.__createErrorItem

__createErrorItem(error)

Private method to create a top level error item.

error (str)
error message
Returns:
generated item
Return Type:
QTreeWidgetItem

PythonAstViewer.__editorChanged

__editorChanged(editor)

Private slot to handle a change of the current editor.

editor (Editor)
reference to the current editor

PythonAstViewer.__editorDoubleClicked

__editorDoubleClicked(editor, pos, buttons)

Private slot to handle a mouse button double click in the editor.

editor (Editor)
reference to the editor, that emitted the signal
pos (QPoint)
position of the double click
buttons (Qt.MouseButtons)
mouse buttons that were double clicked

PythonAstViewer.__editorSaved

__editorSaved(editor)

Private slot to reload the AST after the connected editor was saved.

editor (Editor)
reference to the editor that performed a save action

PythonAstViewer.__findClosestContainingItem

__findClosestContainingItem(itm, textRange)

Private method to search for the tree item that contains a range closest.

itm (QTreeWidgetItem)
tree item to start searching at
textRange (tuple of (int, int, int, int))
tuple giving the start and end positions
Returns:
best matching tree item
Return Type:
QTreeWidgetItem

PythonAstViewer.__findClosestContainingNode

__findClosestContainingNode(node, textRange)

Private method to search for the AST node that contains a range closest.

node (ast.AST)
AST node to start searching at
textRange (tuple of (int, int, int, int))
tuple giving the start and end positions
Returns:
best matching node
Return Type:
ast.AST

PythonAstViewer.__grabFocus

__grabFocus()

Private method to grab the input focus.

PythonAstViewer.__lastEditorClosed

__lastEditorClosed()

Private slot to handle the last editor closed signal of the view manager.

PythonAstViewer.__loadAST

__loadAST()

Private method to generate the AST from the source of the current editor and visualize it.

PythonAstViewer.__markTextRanges

__markTextRanges(tree, source)

Private method to modify the AST nodes with end_lineno and end_col_offset information.

Note: The modifications are only done for nodes containing lineno and col_offset attributes.

tree (ast.AST)
reference to the AST to be modified
source (str)
source code the AST was created from

PythonAstViewer.__populateNode

__populateNode(name, nodeOrFields, parent)

Private method to populate the tree view with a node.

name (str)
name of the node
nodeOrFields (ast.AST or list)
reference to the node or a list node fields
parent (QTreeWidget or QTreeWidgetItem)
reference to the parent item

PythonAstViewer.__rangeContainsSmaller

__rangeContainsSmaller(first, second)

Private method to check, if second is contained in first.

first (tuple of (int, int, int, int))
text range to check against
second (tuple of (int, int, int, int))
text range to check for
Returns:
flag indicating second is contained in first
Return Type:
bool

PythonAstViewer.__rangeContainsSmallerOrEqual

__rangeContainsSmallerOrEqual(first, second)

Private method to check, if second is contained in or equal to first.

first (tuple of (int, int, int, int))
text range to check against
second (tuple of (int, int, int, int))
text range to check for
Returns:
flag indicating second is contained in or equal to first
Return Type:
bool

PythonAstViewer.__resizeColumns

__resizeColumns()

Private method to resize the columns to suitable values.

PythonAstViewer.__selectItemForEditorSelection

__selectItemForEditorSelection()

Private slot to select the item corresponding to an editor selection.

PythonAstViewer.hide

hide()

Public slot to hide the AST viewer.

PythonAstViewer.resizeEvent

resizeEvent(evt)

Protected method to handle resize events.

evt (QResizeEvent)
resize event

PythonAstViewer.show

show()

Public slot to show the AST viewer.

PythonAstViewer.shutdown

shutdown()

Public method to perform shutdown actions.

Up



Home ⌂Doc Index ◂Up ▴