Beispiel #1
0
 def outlineexplorer_data_list(self):
     oe_list = []
     for block_number, text, fold_level, def_type, def_name in self.oe_data:
         oe_list.append(
             OutlineExplorerData(testBlock(block_number), text, fold_level,
                                 def_type, def_name))
     return oe_list
Beispiel #2
0
from spyder.plugins.outlineexplorer.api import OutlineExplorerData

from spyder.utils.qthelpers import qapplication
from spyder.plugins.editor.widgets.codeeditor import CodeEditor

text = ('# test file\n'
        'class a():\n'
        '    self.b = 1\n'
        '    print(self.b)\n'
        '    \n'
        '    def some_method(self):\n'
        '        self.b = 3')

expected_oe_data = {
    1:
    OutlineExplorerData('class a():', 0, OutlineExplorerData.CLASS, 'a'),
    5:
    OutlineExplorerData('    def some_method(self):', 4,
                        OutlineExplorerData.FUNCTION, 'some_method')
}


@pytest.fixture()
def editor_outline_explorer_bot():
    """setup editor and outline_explorer."""
    app = qapplication()
    editor = CodeEditor(parent=None)
    editor.setup_editor(language='Python')
    outlineexplorer = OutlineExplorerWidget(editor)

    editor.set_text(text)
Beispiel #3
0
        self._line = line_number - 1

    def firstLineNumber(self):
        return self._line


text = ('# test file\n'
        'class a():\n'
        '    self.b = 1\n'
        '    print(self.b)\n'
        '    \n'
        '    def some_method(self):\n'
        '        self.b = 3')

expected_oe_list = [
    OutlineExplorerData(testBlock(2), 'class a():', 0,
                        OutlineExplorerData.CLASS, 'a'),
    OutlineExplorerData(testBlock(6), '    def some_method(self):', 4,
                        OutlineExplorerData.FUNCTION, 'some_method')
]


@pytest.fixture()
def editor_outline_explorer_bot():
    """setup editor and outline_explorer."""
    app = qapplication()
    editor = CodeEditor(parent=None)
    editor.setup_editor(language='Python')
    outlineexplorer = OutlineExplorerWidget(editor)

    editor.set_text(text)
import operator
import copy

from qtpy.QtWidgets import QComboBox, QHBoxLayout

from qtpy.QtCore import Slot
from qtpy.QtCore import QSize

from spyder.api.panel import Panel
from spyder.plugins.editor.utils.folding import FoldScope
from spyder.plugins.editor.utils.editor import TextBlockHelper
from spyder.plugins.outlineexplorer.api import OutlineExplorerData as OED
from spyder.utils import icon_manager as ima


DUMMY_OED = OED()
DUMMY_OED.fold_level = 0
DUMMY_OED.text = "<None>"


def populate(combobox, data):
    """
    Populate the given ``combobox`` with the class or function names.

    Parameters
    ----------
    combobox : :class:`qtpy.QtWidets.QComboBox`
        The combobox to populate
    data : list of :class:`FoldScopeHelper`
        The data to populate with. There should be one list element per
        class or function defintion in the file.
Beispiel #5
0
 def get_outlineexplorer_data(self):
     oe_dict = {}
     for block_number, text, fold_level, def_type, def_name in self.oe_data:
         oe_dict[block_number] = OutlineExplorerData(
             text, fold_level, def_type, def_name)
     return oe_dict
Beispiel #6
0
"""
import operator
import copy

from qtpy.QtWidgets import QComboBox, QHBoxLayout

from qtpy.QtCore import Slot
from qtpy.QtCore import QSize

from spyder.api.panel import Panel
from spyder.plugins.editor.utils.folding import FoldScope
from spyder.plugins.editor.utils.editor import TextBlockHelper
from spyder.plugins.outlineexplorer.api import OutlineExplorerData as OED
from spyder.utils import icon_manager as ima

DUMMY_OED = OED()
DUMMY_OED.fold_level = 0
DUMMY_OED.text = "<None>"


def populate(combobox, data):
    """
    Populate the given ``combobox`` with the class or function names.

    Parameters
    ----------
    combobox : :class:`qtpy.QtWidets.QComboBox`
        The combobox to populate
    data : list of :class:`FoldScopeHelper`
        The data to populate with. There should be one list element per
        class or function defintion in the file.