Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 29 May 2014 18:04:30 +0200
changeset 3563 1590b29dbdef
parent 3562 a16bc9e17d35
child 3564 81c4ba561754
Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
ProjectChecker.st
--- a/ProjectChecker.st	Thu May 29 18:04:24 2014 +0200
+++ b/ProjectChecker.st	Thu May 29 18:04:30 2014 +0200
@@ -480,33 +480,57 @@
 !
 
 checkMethodSTCCompilability2: method into: problemIssue
-    "Checks is the method can be compiled by STC based on selected lint rules"
+    | env rules violations |
+
+    "/ Check if SmallLint is available...
+    (Smalltalk at:#RBCompositeLintRule) isNil ifTrue:[ ^ self ].
+
+    env := SelectorEnvironment new.
+    env addClass: method mclass selector: method selector.
 
-    "Not yet implemented"
+    rules := RBCompositeLintRule allRules select:[:rule | (rule isTaggedAs: #stc) and:[ rule severity == #error ]].
+    rules runOnEnvironment: env.
+
+    violations := rules select:[:each | each result includesSelector: method selector in: method mclass ]. 
+    violations flatten do:[:each | 
+        problemIssue addViolation: each
+    ].
 
     "Created: / 11-04-2012 / 15:54:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 29-05-2014 / 16:59:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 checkMethodSTCCompilability: method
     "Checks is the method can be compiled by STC (since STC won't compile
      everything bytecode compiler/jit compiler does, sigh"
 
-    | issue |
+    | cls issue1 issue2 |
 
     "No need to check the method if the class is autoloaded"
-    (currentPackageDef autoloaded_classNames includes: method mclass theNonMetaclass name) ifTrue:[
+    cls := method mclass theNonMetaclass.
+    cls isPrivate ifTrue:[ 
+        cls := cls topOwningClass.
+    ].
+    (currentPackageDef autoloaded_classNames includes: cls name) ifTrue:[
         ^ self
     ].
-    
-    issue := ProjectProblem newMethodCompilabilityIssue.
-    issue method: method.
-    self checkMethodSTCCompilability1: method into: issue.
-    self checkMethodSTCCompilability2: method into: issue.
-    issue hasIssue ifTrue:[
-        self addProblem: issue
+
+    issue1 := ProjectProblem newMethodCompilabilityIssue1.
+    issue1 method: method.
+    self checkMethodSTCCompilability1: method into: issue1.
+    issue1 hasIssue ifTrue:[
+        self addProblem: issue1
+    ].
+
+    issue2 := ProjectProblem newMethodCompilabilityIssue2.
+    issue2 method: method.
+    self checkMethodSTCCompilability2: method into: issue2.
+    issue2 hasIssue ifTrue:[
+        self addProblem: issue2
     ]
 
     "Created: / 11-04-2012 / 12:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 29-05-2014 / 16:54:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 checkMethodSourceCode: method
@@ -568,7 +592,9 @@
 
 checkMethod: method
     (self checkMethodSourceCode: method) ifTrue:[
-        "/OK, method's source is OK, perform further checks
+        "/OK, method's source code is fine, perform more checks on
+        "/ it's source code.
+
         "/ ActivityNotification raiseRequestWith:self errorString:'Checking stc compilability...'.
         self checkMethodSTCCompilability: method.
         "/ ActivityNotification raiseRequestWith:self errorString:'Checking coding style...'.
@@ -576,6 +602,7 @@
     ]
 
     "Created: / 11-04-2012 / 12:27:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 29-05-2014 / 16:51:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 checkMethods
@@ -665,14 +692,14 @@
 !ProjectChecker class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/ProjectChecker.st,v 1.21 2014-04-22 21:49:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/ProjectChecker.st,v 1.22 2014-05-29 16:04:30 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic3/ProjectChecker.st,v 1.21 2014-04-22 21:49:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/ProjectChecker.st,v 1.22 2014-05-29 16:04:30 vrany Exp $'
 !
 
 version_SVN
-    ^ '$Id: ProjectChecker.st,v 1.21 2014-04-22 21:49:02 cg Exp $'
+    ^ '$Id: ProjectChecker.st,v 1.22 2014-05-29 16:04:30 vrany Exp $'
 ! !