Fx in Smalltalk code completion - do not complete inside comments.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 29 Jan 2014 10:42:31 +0000
changeset 161 5ff416530ac4
parent 160 89a001a355b4
child 162 3fbeaaf9bdb5
Fx in Smalltalk code completion - do not complete inside comments.
SmallSense__GroovyCompletionEngineSimple.st
SmallSense__SmalltalkCompletionEngine.st
SmallSense__SmalltalkParseNodeFinder.st
SmallSense__SmalltalkParser.st
smallsense.rc
--- a/SmallSense__GroovyCompletionEngineSimple.st	Wed Jan 29 10:41:11 2014 +0000
+++ b/SmallSense__GroovyCompletionEngineSimple.st	Wed Jan 29 10:42:31 2014 +0000
@@ -9,6 +9,7 @@
 	category:'SmallSense-Groovy'
 !
 
+
 !GroovyCompletionEngineSimple methodsFor:'completion-private'!
 
 complete
@@ -20,3 +21,10 @@
     "Modified: / 21-01-2014 / 23:21:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!GroovyCompletionEngineSimple class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/SmallSense__SmalltalkCompletionEngine.st	Wed Jan 29 10:41:11 2014 +0000
+++ b/SmallSense__SmalltalkCompletionEngine.st	Wed Jan 29 10:42:31 2014 +0000
@@ -397,8 +397,8 @@
         ^ nil 
     ].
     nodeToPosition := SmalltalkParseNodeFinder new 
-                    findNodeIn: collector source tree: collector tree 
-                    line: line column: col.
+                        findNodeIn: collector source tree: collector tree comments: collector parser commentPositions
+                        line: line column: col.
     context node: nodeToPosition key position: nodeToPosition value.
 
     context isAfterNode ifTrue:[
@@ -419,7 +419,7 @@
     "Created: / 04-03-2011 / 13:01:14 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 08-04-2011 / 10:52:59 / Jakub <zelenja7@fel.cvut.cz>"
     "Created: / 26-11-2011 / 17:05:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 21-01-2014 / 23:21:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 29-01-2014 / 10:36:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 completeBefore:node
--- a/SmallSense__SmalltalkParseNodeFinder.st	Wed Jan 29 10:41:11 2014 +0000
+++ b/SmallSense__SmalltalkParseNodeFinder.st	Wed Jan 29 10:42:31 2014 +0000
@@ -12,7 +12,7 @@
 
 !SmalltalkParseNodeFinder methodsFor:'finding'!
 
-findNodeIn: source tree: tree line: line column: col
+findNodeIn: source tree: tree comments: comments line: line column: col
 
     | sourceS |
     sourceS := source readStream.
@@ -22,19 +22,27 @@
             ^nil
         ].        
     ].
-    ^self findNodeIn: source tree: tree position: sourceS position + col
+    ^self findNodeIn: source tree: tree comments: comments position: sourceS position + col
 
-    "Created: / 26-11-2011 / 15:33:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 29-01-2014 / 10:20:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-findNodeIn: source tree: tree position: pos
+findNodeIn: source tree: tree comments: comments position: pos
+    | i s |
 
     position := pos - 1.
+    i := 1.
+    [ i < comments size and:[ (s :=comments at:i) notNil ] ] whileTrue:[ 
+        (pos >= s and:[ pos <= (s + (comments at: i + 1) - 1)]) ifTrue:[ 
+            ^ nil -> pos.
+        ].
+        i := i + 2.
+    ].
+
     self visit: tree.
     ^(match ? previous) ->  pos.
 
-    "Created: / 26-11-2011 / 15:37:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 21-01-2014 / 23:18:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 29-01-2014 / 10:20:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkParseNodeFinder methodsFor:'visiting'!
--- a/SmallSense__SmalltalkParser.st	Wed Jan 29 10:41:11 2014 +0000
+++ b/SmallSense__SmalltalkParser.st	Wed Jan 29 10:42:31 2014 +0000
@@ -3,13 +3,19 @@
 "{ NameSpace: SmallSense }"
 
 SyntaxHighlighter subclass:#SmalltalkParser
-	instanceVariableNames:'errorRecovery error'
+	instanceVariableNames:'errorRecovery error commentPositions commentIndex'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'SmallSense-Smalltalk'
 !
 
 
+!SmalltalkParser methodsFor:'accessing'!
+
+commentPositions
+    ^ commentPositions
+! !
+
 !SmalltalkParser methodsFor:'error handling'!
 
 parseError:message position:startPos to:endPos
@@ -35,9 +41,13 @@
 
 initialize
     super initialize.
-    errorRecovery := true
+    errorRecovery := true.
+    commentPositions := Array new: 16.
+    commentIndex := -1.
+    saveComments := true.
 
     "Created: / 19-09-2013 / 11:25:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 29-01-2014 / 10:38:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkParser methodsFor:'parsing'!
@@ -498,10 +508,36 @@
 
 !SmalltalkParser methodsFor:'private'!
 
+beginComment
+    commentIndex := commentIndex + 2.
+    (commentPositions size) < (commentIndex + 1) ifTrue:[ 
+        | newPositions |
+
+        newPositions := Array new: commentPositions size + 16.
+        newPositions replaceFrom: 1 with: commentPositions.
+        commentPositions := newPositions.
+    ].
+    commentPositions at: commentIndex put: source position.
+
+    "Created: / 29-01-2014 / 10:13:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+endComment: comment
+    commentPositions at: commentIndex + 1 put: comment size.
+
+    "Created: / 29-01-2014 / 10:14:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+endComment: comment type: type
+    ^ self endComment: comment
+
+    "Created: / 29-01-2014 / 10:14:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 findNameSpaceWith:varName
     | ns |
 
-    "The super #findNameSpaceWith: checks whether the the gloval named 'varName' exists,
+    "The super #findNameSpaceWith: checks whether the the global named 'varName' exists,
      if not, returns the current namespace which is then prepended to 'varName'.
 
      Here we have to deal with uncomplete global names, so trick the caller by returning
@@ -517,6 +553,7 @@
     ^ super findNameSpaceWith:varName
 
     "Created: / 28-07-2013 / 13:49:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 29-01-2014 / 10:04:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkParser methodsFor:'syntax coloring'!
--- a/smallsense.rc	Wed Jan 29 10:41:11 2014 +0000
+++ b/smallsense.rc	Wed Jan 29 10:42:31 2014 +0000
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Wed, 22 Jan 2014 21:51:11 GMT\0"
+      VALUE "ProductDate", "Wed, 29 Jan 2014 10:41:45 GMT\0"
     END
 
   END