Permalink
Browse files

A few tweaks

  • Loading branch information...
aparajita committed Oct 7, 2011
1 parent 49235b3 commit 994b38b6bd67a66c8f691b8cbc617025f3cb52ba
View
@@ -400,26 +400,21 @@ def view_in_tab(view, title, text, file_type):
return tab, _id
-def reload_modules():
- lintersToReload = set()
+def lint_views(linter):
+ if not linter:
+ return
+
viewsToLint = []
for window in sublime.windows():
for view in window.views():
- for name, linter in LINTERS.items():
- module = sys.modules[linter.__module__]
-
- if module.__file__ == view.file_name():
- lintersToReload.add(linter)
- viewsToLint.append(view)
- break
+ viewLinter = select_linter(view)
- for linter in lintersToReload:
- print 'SublimeLinter: reloading language:', linter.language
- MOD_LOAD.reload_module(sys.modules[linter.__module__])
+ if viewLinter == linter:
+ viewsToLint.append(view)
for view in viewsToLint:
- queue_linter(select_linter(view), view, 0, 0, True)
+ queue_linter(linter, view, 0, 0, True)
def reload_view_module(view):
@@ -429,7 +424,7 @@ def reload_view_module(view):
if module.__file__ == view.file_name():
print 'SublimeLinter: reloading language:', linter.language
MOD_LOAD.reload_module(module)
- queue_linter(select_linter(view), view, 0, 0, True)
+ lint_views(linter)
break
@@ -721,8 +716,3 @@ def is_enabled(self):
return False
return enabled
-
-
-class SublimelinterReloadCommand(SublimelinterWindowCommand):
- def run_(self, args):
- reload_modules()
@@ -4,9 +4,8 @@
import os
import re
import tempfile
-import types
-
import subprocess
+
import sublime
# If the linter uses an executable that takes stdin, use this input method.
@@ -111,7 +110,7 @@ def _check_enabled(self, view):
return (True, 'built in')
elif isinstance(self.executable, basestring):
self.executable = self.get_mapped_executable(view, self.executable)
- elif isinstance(self.executable, types.BooleanType) and self.executable == False:
+ elif isinstance(self.executable, bool) and self.executable == False:
return (False, 'unknown error')
else:
return (False, 'bad type for CONFIG["executable"]')
@@ -1,5 +1,6 @@
# (c) 2005 Divmod, Inc. See LICENSE file for details
+
class Message(object):
message = ''
@@ -8,7 +9,7 @@ def __init__(self, filename, loc, use_column=True, level='W', message_args=()):
self.lineno = loc.lineno
self.col = getattr(loc, 'col_offset', None) if use_column else None
self.level = level
- self.message_args = message_args
+ self.message_args = message_args
def __str__(self):
if self.col is not None:
@@ -24,6 +25,7 @@ def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc, use_column=False, message_args=(name,))
self.name = name
+
class RedefinedWhileUnused(Message):
message = 'redefinition of unused %r from line %r'
@@ -32,6 +34,7 @@ def __init__(self, filename, loc, name, orig_loc):
self.name = name
self.orig_loc = orig_loc
+
class ImportShadowedByLoopVar(Message):
message = 'import %r from line %r shadowed by loop variable'
@@ -40,27 +43,31 @@ def __init__(self, filename, loc, name, orig_loc):
self.name = name
self.orig_loc = orig_loc
+
class ImportStarUsed(Message):
message = "'from %s import *' used; unable to detect undefined names"
def __init__(self, filename, loc, modname):
Message.__init__(self, filename, loc, message_args=(modname,))
self.name = modname
+
class UndefinedName(Message):
message = 'undefined name %r'
def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc, level='E', message_args=(name,))
self.name = name
+
class UndefinedExport(Message):
message = 'undefined name %r in __all__'
def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc, level='E', message_args=(name,))
self.name = name
+
class UndefinedLocal(Message):
message = "local variable %r (defined in enclosing scope on line %r) referenced before assignment"
@@ -69,13 +76,15 @@ def __init__(self, filename, loc, name, orig_loc):
self.name = name
self.orig_loc = orig_loc
+
class DuplicateArgument(Message):
message = 'duplicate argument %r in function definition'
def __init__(self, filename, loc, name):
Message.__init__(self, filename, loc, level='E', message_args=(name,))
self.name = name
+
class RedefinedFunction(Message):
message = 'redefinition of function %r from line %r'
@@ -84,6 +93,7 @@ def __init__(self, filename, loc, name, orig_loc):
self.name = name
self.orig_loc = orig_loc
+
class CouldNotCompile(Message):
def __init__(self, filename, loc, msg=None, line=None):
if msg and line:
@@ -96,13 +106,15 @@ def __init__(self, filename, loc, msg=None, line=None):
self.msg = msg
self.line = line
+
class LateFutureImport(Message):
message = 'future import(s) %r after other statements'
def __init__(self, filename, loc, names):
Message.__init__(self, filename, loc, message_args=(names,))
self.names = names
+
class UnusedVariable(Message):
"""
Indicates that a variable has been explicity assigned to but not actually
@@ -228,7 +228,7 @@ def underline_duplicate_argument(lineno, word, underlines):
if isinstance(error, (Pep8Error, Pep8Warning)):
self.underline_range(view, error.lineno, error.col, underlines)
- elif isinstance(error, (OffsetError, PythonError)):
+ elif isinstance(error, OffsetError):
self.underline_range(view, error.lineno, error.offset, underlines)
elif isinstance(error, (pyflakes.messages.RedefinedWhileUnused,

0 comments on commit 994b38b

Please sign in to comment.