Example #1
0
    def __onTabChanged( self, index ):
        " Triggered when another tab becomes active "

        # If the timer is still active that means the tab was switched before
        # the handler had a chance to work. Therefore update the previous tab
        # first if so.
        if self.__updateTimer.isActive():
            self.__updateTimer.stop()
            self.__updateView()

        # Now, switch the pyflakes browser to the new tab
        if index == -1:
            widget = self.__editorsManager.currentWidget()
        else:
            widget = self.__editorsManager.getWidgetByIndex( index )
        if widget is None:
            self.__currentUUID = None
            self.setFlakesNotAvailable( self.__uiLabel )
            return

        if widget.getType() not in [ MainWindowTabWidgetBase.PlainTextEditor,
                                     MainWindowTabWidgetBase.VCSAnnotateViewer ]:
            self.__currentUUID = None
            self.setFlakesNotAvailable( self.__uiLabel )
            return

        # This is text editor, detect the file type
        if widget.getFileType() not in [ PythonFileType, Python3FileType ]:
            self.__currentUUID = None
            self.setFlakesNotAvailable( self.__uiLabel )
            return


        # This is a python file, check if we already have the parsed info in
        # the cache
        uuid = widget.getUUID()
        self.__currentUUID = uuid
        if uuid in self.__flakesResults:
            # We have it, change the icon and the tooltip correspondingly
            results = self.__flakesResults[ uuid ].messages
            self.setFlakesResults( self.__uiLabel, results, None )
            return

        # It is first time we are here, create a new
        editor = widget.getEditor()
        self.connect( editor, SIGNAL( 'SCEN_CHANGE()' ),
                              self.__onBufferChanged )
        self.connect( editor, SIGNAL( 'cursorPositionChanged(int,int)' ),
                              self.__cursorPositionChanged )

        results = getFileErrors( editor.text() )
        attributes = PyflakesAttributes()
        attributes.messages = results
        attributes.changed = False
        self.__flakesResults[ uuid ] = attributes
        self.__currentUUID = uuid

        self.setFlakesResults( self.__uiLabel, results, editor )
        return
Example #2
0
    def __onTabChanged(self, index):
        " Triggered when another tab becomes active "

        # If the timer is still active that means the tab was switched before
        # the handler had a chance to work. Therefore update the previous tab
        # first if so.
        if self.__updateTimer.isActive():
            self.__updateTimer.stop()
            self.__updateView()

        # Now, switch the pyflakes browser to the new tab
        if index == -1:
            widget = self.__editorsManager.currentWidget()
        else:
            widget = self.__editorsManager.getWidgetByIndex(index)
        if widget is None:
            self.__currentUUID = None
            self.setFlakesNotAvailable(self.__uiLabel)
            return

        if widget.getType() not in [
                MainWindowTabWidgetBase.PlainTextEditor,
                MainWindowTabWidgetBase.VCSAnnotateViewer
        ]:
            self.__currentUUID = None
            self.setFlakesNotAvailable(self.__uiLabel)
            return

        # This is text editor, detect the file type
        if widget.getFileType() not in [PythonFileType, Python3FileType]:
            self.__currentUUID = None
            self.setFlakesNotAvailable(self.__uiLabel)
            return

        # This is a python file, check if we already have the parsed info in
        # the cache
        uuid = widget.getUUID()
        self.__currentUUID = uuid
        if uuid in self.__flakesResults:
            # We have it, change the icon and the tooltip correspondingly
            results = self.__flakesResults[uuid].messages
            self.setFlakesResults(self.__uiLabel, results, None)
            return

        # It is first time we are here, create a new
        editor = widget.getEditor()
        self.connect(editor, SIGNAL('SCEN_CHANGE()'), self.__onBufferChanged)
        self.connect(editor, SIGNAL('cursorPositionChanged(int,int)'),
                     self.__cursorPositionChanged)

        results = getFileErrors(editor.text())
        attributes = PyflakesAttributes()
        attributes.messages = results
        attributes.changed = False
        self.__flakesResults[uuid] = attributes
        self.__currentUUID = uuid

        self.setFlakesResults(self.__uiLabel, results, editor)
        return
Example #3
0
    def __updateView( self ):
        " Updates the view when a file is changed "
        self.__updateTimer.stop()
        if self.__currentUUID is None:
            return
        widget = self.__editorsManager.getWidgetByUUID( self.__currentUUID )
        if widget is None:
            return

        if self.__flakesResults[ self.__currentUUID ].changed == False:
            return

        editor = widget.getEditor()
        results = getFileErrors( editor.text() )

        self.__flakesResults[ self.__currentUUID ].messages = results
        self.__flakesResults[ self.__currentUUID ].changed = False

        self.setFlakesResults( self.__uiLabel, results, editor )
        return
Example #4
0
    def __updateView(self):
        " Updates the view when a file is changed "
        self.__updateTimer.stop()
        if self.__currentUUID is None:
            return
        widget = self.__editorsManager.getWidgetByUUID(self.__currentUUID)
        if widget is None:
            return

        if self.__flakesResults[self.__currentUUID].changed == False:
            return

        editor = widget.getEditor()
        results = getFileErrors(editor.text())

        self.__flakesResults[self.__currentUUID].messages = results
        self.__flakesResults[self.__currentUUID].changed = False

        self.setFlakesResults(self.__uiLabel, results, editor)
        return