extensions.st
changeset 361 09ed7e1f78a9
parent 359 c9f69a8e441c
parent 299 8fb1a71e54f2
child 362 b34840b66447
--- a/extensions.st	Wed Oct 15 11:50:23 2014 +0100
+++ b/extensions.st	Tue Nov 25 08:00:39 2014 +0000
@@ -216,12 +216,35 @@
 
 !Method methodsFor:'inspecting'!
 
-inspector2TabParseTreeInspector
+inspector2TabRBParseTreeInspector
+    <inspector2Tab>
+
     ^ (self newInspector2Tab)
-        label:'Parse Tree';
+        label:'Parse Tree (RB)';
         priority:35;
         application:
                 [
+                    | src node |
+
+                    src := self source.
+                    node := RBParser parseMethod: src.
+                    SmallSense::ParseTreeInspector new node:node source:src.
+                ];
+        yourself
+
+    "Created: / 15-10-2014 / 02:37:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Method methodsFor:'inspecting'!
+
+inspector2TabSTXParseTreeInspector
+    <inspector2Tab>
+
+    ^ (self newInspector2Tab)
+        label:'Parse Tree (ST/X)';
+        priority:36;
+        application:
+                [
                     | src parser |
 
                     src := self source.
@@ -230,17 +253,7 @@
                 ];
         yourself
 
-    "Created: / 09-04-2014 / 09:31:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 10-04-2014 / 08:58:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-!Method methodsFor:'inspecting'!
-
-inspector2Tabs
-    ^ super inspector2Tabs , #(inspector2TabParseTreeInspector)
-
-    "Created: / 09-04-2014 / 09:32:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 10-04-2014 / 08:47:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 15-10-2014 / 11:23:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ParseErrorNode methodsFor:'enumeration'!
@@ -304,6 +317,23 @@
     "Created: / 26-11-2011 / 12:37:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!ParseNode methodsFor:'inspecting'!
+
+inspector2TabSTXParseTreeInspector
+    <inspector2Tab>
+
+    ^ (self newInspector2Tab)
+        label:'Parse Tree (ST/X)';
+        priority:36;
+        application:
+                [
+                    SmallSense::ParseTreeInspector new node:self source:nil.
+                ];
+        yourself
+
+    "Created: / 15-10-2014 / 11:23:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !ParseNode methodsFor:'testing'!
 
 isSelector
@@ -322,6 +352,28 @@
     "Modified: / 24-09-2013 / 10:05:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!Parser methodsFor:'inspecting'!
+
+inspector2TabSTXParseTreeInspector
+    <inspector2Tab>
+
+    ^ (self newInspector2Tab)
+        label:'Parse Tree (ST/X)';
+        priority:36;
+        application:
+                [
+                    | src parser |
+
+                    source isExternalStream ifFalse:[ 
+                        src := source collection 
+                    ].
+                    SmallSense::ParseTreeInspector new node:tree source:src.
+                ];
+        yourself
+
+    "Created: / 15-10-2014 / 11:23:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !PrimaryNode methodsFor:'enumeration'!
 
 childNamesAndValuesDo:aBlock
@@ -340,6 +392,37 @@
     "Created: / 08-12-2013 / 22:25:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!RBBlockNode methodsFor:'enumeration'!
+
+childNamesAndValuesDo:aBlock
+    arguments withIndexDo:[:statement :index |
+        aBlock value: 'argument[', index printString ,']' value: statement
+    ].
+    body statements withIndexDo:[:statement :index |
+        aBlock value: 'statement[', index printString ,']' value: statement
+    ]
+
+    "Created: / 15-10-2014 / 10:42:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!RBContainsSmalltalkXEOLCommentRule methodsFor:'accessing'!
+
+fixes: fixer
+    | changes |
+
+    changes := self changes.
+    changes notEmptyOrNil ifTrue:[
+        fixer fix
+            label:'Change EOL comments to standard Smalltalk comments';
+            action: [ fixer apply:
+                ((ChangeSet withAll:changes) name: self name)
+            ].
+    ]
+
+    "Created: / 01-02-2012 / 12:11:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 17-10-2014 / 00:42:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !RBLintRule methodsFor:'accessing'!
 
 fixes: aSmallSenseQuickFixer
@@ -350,6 +433,65 @@
     "Created: / 01-02-2012 / 12:09:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!RBMethodNode methodsFor:'enumeration'!
+
+childNamesAndValuesDo:aBlock
+    arguments withIndexDo:[:statement :index |
+        aBlock value: 'argument[', index printString ,']' value: statement
+    ].
+    body statements withIndexDo:[:statement :index |
+        aBlock value: 'statement[', index printString ,']' value: statement
+    ]
+
+    "Created: / 15-10-2014 / 09:28:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-10-2014 / 10:41:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!RBProgramNode methodsFor:'enumeration'!
+
+childNamesAndValuesDo:aBlock
+
+    "Enumerates all direct children and evaluates a block
+     with its name (usually instVar name) and the node itself"
+
+    self class allInstVarNames withIndexDo:[:n :i|
+        | v |
+
+        n ~~ #parent ifTrue:[
+            v := self instVarAt: i.
+            (v isKindOf: RBProgramNode) ifTrue:[
+                aBlock value: n value: v
+            ] ifFalse:[
+                (v isSequenceable) ifTrue:[
+                    v withIndexDo:[ :v2 :i2|
+                        (v2 isKindOf: RBProgramNode) ifTrue:[
+                            aBlock value: (n, '[' , i2 printString , ']') value: v2.
+                        ]
+                    ]
+                ]
+            ]
+        ]
+    ]
+
+    "Created: / 15-10-2014 / 10:39:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!RBProgramNode methodsFor:'accessing'!
+
+endPosition
+    ^ self stop
+
+    "Created: / 15-10-2014 / 09:34:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!RBProgramNode methodsFor:'accessing'!
+
+startPosition
+    ^ self start
+
+    "Created: / 15-10-2014 / 09:34:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !RBTransformationRule methodsFor:'accessing'!
 
 fixes: fixer