java lint: validate language and source code when running Java lint.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 27 Mar 2015 16:10:51 +0000
changeset 3418 3df0a2df585e
parent 3417 1cde6fd1d7c7
child 3419 aa30aeb2ee07
child 3435 26cdaf601d11
java lint: validate language and source code when running Java lint. - the language may not be Java any longer as lint is run in background and could have been changed meanwhile. - do not run the compiler at all if code is empty
tools/JavaLintService.st
--- a/tools/JavaLintService.st	Fri Mar 27 16:37:34 2015 +0000
+++ b/tools/JavaLintService.st	Fri Mar 27 16:10:51 2015 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2006 by eXept Software AG
 	      All Rights Reserved
@@ -11,6 +13,8 @@
 "
 "{ Package: 'stx:libjava/tools' }"
 
+"{ NameSpace: Smalltalk }"
+
 Tools::BackgroundSourceProcessingService subclass:#JavaLintService
 	instanceVariableNames:'highlighter showingJava'
 	classVariableNames:'Debugging'
@@ -310,27 +314,33 @@
      #processSafely: which handle possible errors and protect against
      'debugger bomb'"
 
+    | lang |
+
     done := false.
     modified := false.
 
     Delay waitForMilliseconds: 1000."Give user some time to finish coding"
+    lang := codeView language.
+    lang isJava ifFalse:[ ^ self ].
 
-                       
     modified ifFalse:[
         | code |
         code := textView list asStringWithoutEmphasis.
-        modified ifFalse:[
-            | problems |
+        code notEmptyOrNil ifTrue:[ 
+            modified ifFalse:[
+                | problems |
 
-            problems := JavaCompiler new check: code.
-            modified ifFalse:[ 
-                highlighter problems: problems.
-                self rehighlight: delayed  
-            ].
-        ]
+                problems := JavaCompiler new check: code.
+                modified ifFalse:[ 
+                    highlighter problems: problems.
+                    self rehighlight: delayed  
+                ].
+            ]
+        ].
     ]
 
     "Created: / 07-08-2014 / 00:41:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-03-2015 / 16:00:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaLintService methodsFor:'redrawing'!