Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added support for java verification using java -Xlint #15

Merged
merged 1 commit into from

3 participants

Scott Dunlop Matt Hauck Ryan Hileman
Scott Dunlop

Added support for Java lint, using javac -Xlint and a temporary file.

Ryan Hileman lunixbochs merged commit a569b18 into from
Matt Hauck

Hmm, this doesn't appear to be working. Is this feature still in?

Ryan Hileman
Owner

Java linting is disabled - I built eclim-based linting but it had a couple of problems.

You should be able to reenable Java linting in your SublimeLint user settings file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 69 additions and 0 deletions.
  1. +69 −0 sublimelint/modules/java.py
69 sublimelint/modules/java.py
View
@@ -0,0 +1,69 @@
+# coffee.py - sublimelint package for checking coffee-script files
+
+import subprocess, os, tempfile, shutil
+
+def check(codeString, filename):
+ if filename is None: return '' # can't check an unsaved file.
+
+ info = None
+ if os.name == 'nt':
+ info = subprocess.STARTUPINFO()
+ info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+ info.wShowWindow = subprocess.SW_HIDE
+
+ tempdir = tempfile.mkdtemp()
+ temp = os.path.join(tempdir, os.path.basename(filename))
+
+ tempout = open(temp, 'w')
+ tempout.write(codeString)
+ tempout.flush()
+ tempout.close()
+
+ try:
+ process = subprocess.Popen(
+ ('javac', '-Xlint', temp),
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ startupinfo=info
+ )
+ result = process.communicate('')[1]
+ finally:
+ shutil.rmtree(tempdir)
+
+ return result
+
+import re
+__all__ = ['run', 'language']
+language = 'Java'
+
+compile_err = re.compile('^[^:]+:([0-9]+): +(.*)$')
+
+def run(code, view, filename='untitled'):
+ errors = check(code, filename)
+
+ lines = set()
+ underline = [] # leave this here for compatibility with original plugin
+
+ errorMessages = {}
+ def addMessage(lineno, message):
+ message = str(message)
+ if lineno in errorMessages:
+ errorMessages[lineno].append(message)
+ else:
+ errorMessages[lineno] = [message]
+
+ for line in errors.splitlines():
+ match = compile_err.match(line)
+ if match:
+ line, error = match.groups()
+ else:
+ continue
+
+ lineno = int(line) - 1
+ lines.add(lineno)
+ addMessage(lineno, error)
+
+ return underline, lines, errorMessages, True
+
+if __name__ == '__main__':
+ import sys
+ print run(open(sys.argv[1]).read(), 'bah', sys.argv[1])
Something went wrong with that request. Please try again.