Updated to take codeAspect as an argument for completion.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 27 Sep 2013 11:28:05 +0200
changeset 4426 76a0c105e8f4
parent 4425 c013e9757f1a
child 4427 fb066a08ef83
Updated to take codeAspect as an argument for completion. The codeAspect is then stored in an instvar for later use.
DoWhatIMeanSupport.st
--- a/DoWhatIMeanSupport.st	Fri Sep 27 10:10:46 2013 +0200
+++ b/DoWhatIMeanSupport.st	Fri Sep 27 11:28:05 2013 +0200
@@ -13,7 +13,7 @@
 
 Object subclass:#DoWhatIMeanSupport
 	instanceVariableNames:'tree tokens languageOrNil classOrNil methodOrNil contextOrNil
-		instanceOrNil codeView rememberedScopeNodes'
+		instanceOrNil codeView rememberedScopeNodes codeAspect'
 	classVariableNames:'LastSource LastParseTree LastScanTokens LastChoices'
 	poolDictionaries:''
 	category:'System-Support'
@@ -64,6 +64,23 @@
 
 !DoWhatIMeanSupport class methodsFor:'code completion'!
 
+codeCompletionFor: aspect language: languageOrNil method:methodOrNil orClass:classOrNil context:contextOrNil codeView:codeView into:actionBlock
+    "aspect is so-called code-aspect symbol saying what's edited - #method, #expression, #classDefinition...
+     contextOrNil is the current context, if this is called from the debugger;
+     nil, if called from the browser.
+     If nonNil, we can make better guesses, because we actually know what a variable's type is.
+     This is not yet done, sigh"
+
+    ^ self new
+        codeCompletionFor: aspect
+        language: languageOrNil 
+        method:methodOrNil orClass:classOrNil 
+        context:contextOrNil 
+        codeView:codeView into:actionBlock
+
+    "Created: / 27-09-2013 / 10:19:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 codeCompletionForLanguage: languageOrNil class: classOrNil context:contextOrNil codeView:codeView
     "contextOrNil is the current context, if this is called from the debugger;
      nil, if called from the browser.
@@ -74,21 +91,6 @@
         codeCompletionForLanguage: languageOrNil class:classOrNil context:contextOrNil codeView:codeView
 
     "Created: / 18-09-2013 / 13:34:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-codeCompletionForLanguage: languageOrNil method:methodOrNil orClass:classOrNil context:contextOrNil codeView:codeView into:actionBlock
-    "contextOrNil is the current context, if this is called from the debugger;
-     nil, if called from the browser.
-     If nonNil, we can make better guesses, because we actually know what a variable's type is.
-     This is not yet done, sigh"
-
-    ^ self new
-        codeCompletionForLanguage: languageOrNil 
-        method:methodOrNil orClass:classOrNil 
-        context:contextOrNil 
-        codeView:codeView into:actionBlock
-
-    "Created: / 18-09-2013 / 13:35:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !DoWhatIMeanSupport class methodsFor:'code completion - obsolete'!
@@ -1128,6 +1130,63 @@
 
 !DoWhatIMeanSupport methodsFor:'code completion'!
 
+codeCompletionFor: codeAspectArg language: languageOrNilArg method:methodOrNilArg orClass:classOrNilArg context:contextOrNilArg codeView:codeViewArg into:actionBlock
+    "provide code completion information by analyzing what the editing state is in codeViewArg
+     (cursor position, characters around cursor etc.) and calling back into actionBlock, passing
+     the info as argument. Te interface has been defined in that way (and tight coupling with internals
+     of the editor) because
+        1) the completer needs to know about the text around the cursor position
+        2) the edit operation for completion may be non-trivial
+           (although not yet fully implemented, non-local rewrite procedures may and will be added in the future
+     For example, in many situations, both a completion of a unary selector before the cursor,
+     or adding another keyword part after the cursor is posisble.
+     Thus, this provides a list of completions PLUS a list of edit operations (as per completion), to
+     perform the completion.
+     The caller has to open a dialog, providing the suggestions, and perform the corresponding edit operation.
+     An additional array containing a textual description for each suggestion is also provided, which could
+     be shown as info or appended to the suggestions (such as 'complete variable', 'complete keyword', etc.
+
+     ContextOrNil is the current context, if this is called from the debugger;
+     or nil, if called from the browser.
+     If nonNil, we can make better guesses, because we actually know what a variable's type is"
+
+    | language |
+
+    codeAspect := codeAspectArg.
+
+    languageOrNilArg notNil ifTrue:[
+        language := languageOrNilArg
+    ] ifFalse:[
+        contextOrNilArg notNil ifTrue:[
+            language := contextOrNilArg method programmingLanguage
+        ] ifFalse:[
+            methodOrNilArg notNil ifTrue:[
+                language := methodOrNilArg programmingLanguage          
+            ] ifFalse:[
+                classOrNilArg notNil ifTrue:[
+                    language := classOrNilArg programmingLanguage
+                ]
+            ]
+        ].
+    ].
+
+    language notNil ifTrue:[
+        language isSmalltalk ifTrue:[
+            ^self codeCompletionForSmalltalkMethod: methodOrNilArg orClass: classOrNilArg context: contextOrNilArg codeView: codeViewArg into: actionBlock
+        ].
+        language isSTXJavaScript ifTrue:[
+            ^self codeCompletionForJavascriptMethod: methodOrNilArg orClass: classOrNilArg context: contextOrNilArg codeView: codeViewArg into: actionBlock
+        ].
+
+    ].
+
+    "/ No completion support for given language
+    self breakPoint: #cg.
+    self breakPoint: #jv.
+
+    "Created: / 27-09-2013 / 10:21:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 codeCompletionForLanguage: languageOrNil class: classOrNilArg context:contextOrNilArg codeView:codeViewArg
     "OBSOLETE; migrating to use the the new 'xxx: into:' protocol.
      contextOrNil is the current context, if this is called from the debugger;
@@ -1160,61 +1219,6 @@
     self breakPoint: #jv.
 
     "Created: / 18-09-2013 / 13:49:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-codeCompletionForLanguage: languageOrNil method:methodOrNilArg orClass:classOrNilArg context:contextOrNilArg codeView:codeViewArg into:actionBlock
-    "provide code completion information by analyzing what the editing state is in codeViewArg
-     (cursor position, characters around cursor etc.) and calling back into actionBlock, passing
-     the info as argument. Te interface has been defined in that way (and tight coupling with internals
-     of the editor) because
-        1) the completer needs to know about the text around the cursor position
-        2) the edit operation for completion may be non-trivial
-           (although not yet fully implemented, non-local rewrite procedures may and will be added in the future
-     For example, in many situations, both a completion of a unary selector before the cursor,
-     or adding another keyword part after the cursor is posisble.
-     Thus, this provides a list of completions PLUS a list of edit operations (as per completion), to
-     perform the completion.
-     The caller has to open a dialog, providing the suggestions, and perform the corresponding edit operation.
-     An additional array containing a textual description for each suggestion is also provided, which could
-     be shown as info or appended to the suggestions (such as 'complete variable', 'complete keyword', etc.
-
-     ContextOrNil is the current context, if this is called from the debugger;
-     or nil, if called from the browser.
-     If nonNil, we can make better guesses, because we actually know what a variable's type is"
-
-    | language |
-
-    languageOrNil notNil ifTrue:[
-        language := languageOrNil
-    ] ifFalse:[
-        contextOrNilArg notNil ifTrue:[
-            language := contextOrNilArg method programmingLanguage
-        ] ifFalse:[
-            methodOrNilArg notNil ifTrue:[
-                language := methodOrNilArg programmingLanguage          
-            ] ifFalse:[
-                classOrNilArg notNil ifTrue:[
-                    language := classOrNilArg programmingLanguage
-                ]
-            ]
-        ].
-    ].
-
-    language notNil ifTrue:[
-        language isSmalltalk ifTrue:[
-            ^self codeCompletionForSmalltalkMethod: methodOrNilArg orClass: classOrNilArg context: contextOrNilArg codeView: codeViewArg into: actionBlock
-        ].
-        language isSTXJavaScript ifTrue:[
-            ^self codeCompletionForJavascriptMethod: methodOrNilArg orClass: classOrNilArg context: contextOrNilArg codeView: codeViewArg into: actionBlock
-        ].
-
-    ].
-
-    "/ No completion support for given language
-    self breakPoint: #cg.
-    self breakPoint: #jv.
-
-    "Created: / 18-09-2013 / 13:54:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !DoWhatIMeanSupport methodsFor:'code completion - JavaScript'!
@@ -1607,7 +1611,6 @@
     ].
 ! !
 
-
 !DoWhatIMeanSupport methodsFor:'code completion-helpers'!
 
 askUserForCompletion:what for:codeView at:position from:allTheBest 
@@ -4496,10 +4499,10 @@
 !DoWhatIMeanSupport class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.175 2013-09-25 14:25:55 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.176 2013-09-27 09:28:05 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.175 2013-09-25 14:25:55 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.176 2013-09-27 09:28:05 vrany Exp $'
 ! !