

def Linter(self, view, lineNumber):
    self.linterQueue -= 1
    if (self.linterQueue > 0):
        return
    elif self.completionRunning:
        return
    self.linterRunning = True
    if view:
        SublimePapyrus.ClearLinterHighlights(view)

    def Exit():
        self.linterRunning = False
        return False
    global cacheLock
    global lex
    global syn
    global sem
    global SUBLIME_VERSION
    with cacheLock:
        if (not self.linterErrors.get(self.bufferID, None)):
            self.linterErrors[self.bufferID] = {
                
            }
        settings = None
        if view:
            settings = SublimePapyrus.GetSettings()
        if ((SUBLIME_VERSION >= 3103) and view.is_auto_complete_visible()):
            return Exit()
        if view:
            SublimePapyrus.SetStatus(view, 'sublimepapyrus-linter', 'The linter is running...')
        scriptContents = None
        if view:
            scriptContents = view.substr(sublime.Region(0, view.size()))
        else:
            scriptContents = self.scriptContents
        lineCount = (scriptContents.count('\n') + 1)
        statements = []
        lines = []
        tokens = []
        currentLine = None
        try:
            for token in lex.Process(scriptContents):
                if (token.type == lex.NEWLINE):
                    if tokens:
                        if currentLine:
                            stat = syn.Process(tokens)
                            if stat:
                                statements.append(stat)
                        elif (token.line >= lineNumber):
                            currentLine = syn.Process(tokens)
                            if currentLine:
                                while lines:
                                    stat = syn.Process(lines.pop(0))
                                    if stat:
                                        statements.append(stat)
                                statements.append(currentLine)
                            currentLine = True
                        else:
                            lines.append(tokens)
                        tokens = []
                    elif (token.line >= lineNumber):
                        while lines:
                            stat = syn.Process(lines.pop(0))
                            if stat:
                                statements.append(stat)
                        currentLine = True
                elif ((token.type != lex.COMMENT_LINE) and (token.type != lex.COMMENT_BLOCK)):
                    tokens.append(token)
        except Linter.LexicalError as e:
            if view:
                error = self.linterErrors[self.bufferID].get(e.message, None)
                if (error and (error.message == e.message) and (abs((error.line - e.line)) < (settings.get('linter_error_line_threshold', 2) + 1))):
                    SublimePapyrus.HighlightLinter(view, e.line, e.column, False)
                else:
                    SublimePapyrus.HighlightLinter(view, e.line, e.column)
                self.linterErrors[self.bufferID][e.message] = e
                SublimePapyrus.SetStatus(view, 'sublimepapyrus-linter', ('Error on line %d, column %d: %s' % (e.line, e.column, e.message)))
                if settings.get('linter_panel_error_messages', False):
                    view.window().show_quick_panel([[e.message, ('Line %d, column %d' % (e.line, e.column))]], None)
            return Exit()
        except Linter.SyntacticError as e:
            if view:
                error = self.linterErrors[self.bufferID].get(e.message, None)
                if (error and (error.message == e.message) and (abs((error.line - e.line)) < (settings.get('linter_error_line_threshold', 2) + 1))):
                    SublimePapyrus.HighlightLinter(view, e.line, center=False)
                else:
                    SublimePapyrus.HighlightLinter(view, e.line)
                self.linterErrors[self.bufferID][e.message] = e
                SublimePapyrus.SetStatus(view, 'sublimepapyrus-linter', ('Error on line %d: %s' % (e.line, e.message)))
                if settings.get('linter_panel_error_messages', False):
                    view.window().show_quick_panel([[e.message, ('Line %d' % e.line)]], None)
            return Exit()
        if statements:
            try:
                script = None
                if view:
                    script = sem.Process(statements, SublimePapyrus.GetSourcePaths(view))
                else:
                    script = sem.Process(statements, self.sourcePaths)
                if script:
                    self.SetScript(self.bufferID, script)
            except Linter.SemanticError as e:
                if view:
                    error = self.linterErrors[self.bufferID].get(scriptContents.message, None)
                    if (error and (error.message == e.message) and (abs((error.line - e.line)) < (settings.get('linter_error_line_threshold', 2) + 1))):
                        SublimePapyrus.HighlightLinter(view, e.line, center=False)
                    else:
                        SublimePapyrus.HighlightLinter(view, e.line)
                    self.linterErrors[self.bufferID][e.message] = e
                    SublimePapyrus.SetStatus(view, 'sublimepapyrus-linter', ('Error on line %d: %s' % (e.line, e.message)))
                    if settings.get('linter_panel_error_messages', False):
                        view.window().show_quick_panel([[e.message, ('Line %d' % e.line)]], None)
                return Exit()
            if view:
                SublimePapyrus.ClearStatus(view, 'sublimepapyrus-linter')
            if self.linterErrors.get(self.bufferID, None):
                del self.linterErrors[self.bufferID]
    return Exit()

dataset/ETHPy150Open Kapiainen/SublimePapyrus/Source/Modules/Skyrim/Plugin.py EventListener.Linter/VarMisuse@1010/1361 `e`->`scriptContents`