DoWhatIMeanSupport.st
changeset 4426 76a0c105e8f4
parent 4423 c21baefab5d0
child 4427 fb066a08ef83
equal deleted inserted replaced
4425:c013e9757f1a 4426:76a0c105e8f4
    11 "
    11 "
    12 "{ Package: 'stx:libwidg2' }"
    12 "{ Package: 'stx:libwidg2' }"
    13 
    13 
    14 Object subclass:#DoWhatIMeanSupport
    14 Object subclass:#DoWhatIMeanSupport
    15 	instanceVariableNames:'tree tokens languageOrNil classOrNil methodOrNil contextOrNil
    15 	instanceVariableNames:'tree tokens languageOrNil classOrNil methodOrNil contextOrNil
    16 		instanceOrNil codeView rememberedScopeNodes'
    16 		instanceOrNil codeView rememberedScopeNodes codeAspect'
    17 	classVariableNames:'LastSource LastParseTree LastScanTokens LastChoices'
    17 	classVariableNames:'LastSource LastParseTree LastScanTokens LastChoices'
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'System-Support'
    19 	category:'System-Support'
    20 !
    20 !
    21 
    21 
    62 "
    62 "
    63 ! !
    63 ! !
    64 
    64 
    65 !DoWhatIMeanSupport class methodsFor:'code completion'!
    65 !DoWhatIMeanSupport class methodsFor:'code completion'!
    66 
    66 
       
    67 codeCompletionFor: aspect language: languageOrNil method:methodOrNil orClass:classOrNil context:contextOrNil codeView:codeView into:actionBlock
       
    68     "aspect is so-called code-aspect symbol saying what's edited - #method, #expression, #classDefinition...
       
    69      contextOrNil is the current context, if this is called from the debugger;
       
    70      nil, if called from the browser.
       
    71      If nonNil, we can make better guesses, because we actually know what a variable's type is.
       
    72      This is not yet done, sigh"
       
    73 
       
    74     ^ self new
       
    75         codeCompletionFor: aspect
       
    76         language: languageOrNil 
       
    77         method:methodOrNil orClass:classOrNil 
       
    78         context:contextOrNil 
       
    79         codeView:codeView into:actionBlock
       
    80 
       
    81     "Created: / 27-09-2013 / 10:19:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    82 !
       
    83 
    67 codeCompletionForLanguage: languageOrNil class: classOrNil context:contextOrNil codeView:codeView
    84 codeCompletionForLanguage: languageOrNil class: classOrNil context:contextOrNil codeView:codeView
    68     "contextOrNil is the current context, if this is called from the debugger;
    85     "contextOrNil is the current context, if this is called from the debugger;
    69      nil, if called from the browser.
    86      nil, if called from the browser.
    70      If nonNil, we can make better guesses, because we actually know what a variable's type is.
    87      If nonNil, we can make better guesses, because we actually know what a variable's type is.
    71      This is not yet done, sigh"
    88      This is not yet done, sigh"
    72 
    89 
    73     ^ self new 
    90     ^ self new 
    74         codeCompletionForLanguage: languageOrNil class:classOrNil context:contextOrNil codeView:codeView
    91         codeCompletionForLanguage: languageOrNil class:classOrNil context:contextOrNil codeView:codeView
    75 
    92 
    76     "Created: / 18-09-2013 / 13:34:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    93     "Created: / 18-09-2013 / 13:34:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    77 !
       
    78 
       
    79 codeCompletionForLanguage: languageOrNil method:methodOrNil orClass:classOrNil context:contextOrNil codeView:codeView into:actionBlock
       
    80     "contextOrNil is the current context, if this is called from the debugger;
       
    81      nil, if called from the browser.
       
    82      If nonNil, we can make better guesses, because we actually know what a variable's type is.
       
    83      This is not yet done, sigh"
       
    84 
       
    85     ^ self new
       
    86         codeCompletionForLanguage: languageOrNil 
       
    87         method:methodOrNil orClass:classOrNil 
       
    88         context:contextOrNil 
       
    89         codeView:codeView into:actionBlock
       
    90 
       
    91     "Created: / 18-09-2013 / 13:35:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    92 ! !
    94 ! !
    93 
    95 
    94 !DoWhatIMeanSupport class methodsFor:'code completion - obsolete'!
    96 !DoWhatIMeanSupport class methodsFor:'code completion - obsolete'!
    95 
    97 
    96 codeCompletionForClass:classOrNil context:contextOrNil codeView:codeView
    98 codeCompletionForClass:classOrNil context:contextOrNil codeView:codeView
  1126     "Created: / 16-01-2008 / 17:17:13 / cg"
  1128     "Created: / 16-01-2008 / 17:17:13 / cg"
  1127 ! !
  1129 ! !
  1128 
  1130 
  1129 !DoWhatIMeanSupport methodsFor:'code completion'!
  1131 !DoWhatIMeanSupport methodsFor:'code completion'!
  1130 
  1132 
  1131 codeCompletionForLanguage: languageOrNil class: classOrNilArg context:contextOrNilArg codeView:codeViewArg
  1133 codeCompletionFor: codeAspectArg language: languageOrNilArg method:methodOrNilArg orClass:classOrNilArg context:contextOrNilArg codeView:codeViewArg into:actionBlock
  1132     "OBSOLETE; migrating to use the the new 'xxx: into:' protocol.
       
  1133      contextOrNil is the current context, if this is called from the debugger;
       
  1134      nil, if called from the browser.
       
  1135      If nonNil, we can make better guesses, because we actually know what a variable's type is.
       
  1136      This is not yet done, sigh"
       
  1137 
       
  1138     | language |
       
  1139 
       
  1140     languageOrNil notNil ifTrue:[
       
  1141         language := languageOrNil
       
  1142     ] ifFalse:[
       
  1143         contextOrNilArg notNil ifTrue:[
       
  1144             language := contextOrNilArg method programmingLanguage.
       
  1145         ] ifFalse:[
       
  1146             classOrNilArg notNil ifTrue:[
       
  1147                 language := classOrNilArg programmingLanguage.
       
  1148             ]
       
  1149         ].
       
  1150     ].
       
  1151 
       
  1152     language notNil ifTrue:[
       
  1153         language isSmalltalk ifTrue:[
       
  1154             ^self codeCompletionForSmalltalkClass: classOrNil context: contextOrNil codeView: codeViewArg
       
  1155         ].
       
  1156     ].
       
  1157 
       
  1158     "/ No completion support for given language
       
  1159     self breakPoint: #cg.
       
  1160     self breakPoint: #jv.
       
  1161 
       
  1162     "Created: / 18-09-2013 / 13:49:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  1163 !
       
  1164 
       
  1165 codeCompletionForLanguage: languageOrNil method:methodOrNilArg orClass:classOrNilArg context:contextOrNilArg codeView:codeViewArg into:actionBlock
       
  1166     "provide code completion information by analyzing what the editing state is in codeViewArg
  1134     "provide code completion information by analyzing what the editing state is in codeViewArg
  1167      (cursor position, characters around cursor etc.) and calling back into actionBlock, passing
  1135      (cursor position, characters around cursor etc.) and calling back into actionBlock, passing
  1168      the info as argument. Te interface has been defined in that way (and tight coupling with internals
  1136      the info as argument. Te interface has been defined in that way (and tight coupling with internals
  1169      of the editor) because
  1137      of the editor) because
  1170         1) the completer needs to know about the text around the cursor position
  1138         1) the completer needs to know about the text around the cursor position
  1182      or nil, if called from the browser.
  1150      or nil, if called from the browser.
  1183      If nonNil, we can make better guesses, because we actually know what a variable's type is"
  1151      If nonNil, we can make better guesses, because we actually know what a variable's type is"
  1184 
  1152 
  1185     | language |
  1153     | language |
  1186 
  1154 
  1187     languageOrNil notNil ifTrue:[
  1155     codeAspect := codeAspectArg.
  1188         language := languageOrNil
  1156 
       
  1157     languageOrNilArg notNil ifTrue:[
       
  1158         language := languageOrNilArg
  1189     ] ifFalse:[
  1159     ] ifFalse:[
  1190         contextOrNilArg notNil ifTrue:[
  1160         contextOrNilArg notNil ifTrue:[
  1191             language := contextOrNilArg method programmingLanguage
  1161             language := contextOrNilArg method programmingLanguage
  1192         ] ifFalse:[
  1162         ] ifFalse:[
  1193             methodOrNilArg notNil ifTrue:[
  1163             methodOrNilArg notNil ifTrue:[
  1212 
  1182 
  1213     "/ No completion support for given language
  1183     "/ No completion support for given language
  1214     self breakPoint: #cg.
  1184     self breakPoint: #cg.
  1215     self breakPoint: #jv.
  1185     self breakPoint: #jv.
  1216 
  1186 
  1217     "Created: / 18-09-2013 / 13:54:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1187     "Created: / 27-09-2013 / 10:21:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  1188 !
       
  1189 
       
  1190 codeCompletionForLanguage: languageOrNil class: classOrNilArg context:contextOrNilArg codeView:codeViewArg
       
  1191     "OBSOLETE; migrating to use the the new 'xxx: into:' protocol.
       
  1192      contextOrNil is the current context, if this is called from the debugger;
       
  1193      nil, if called from the browser.
       
  1194      If nonNil, we can make better guesses, because we actually know what a variable's type is.
       
  1195      This is not yet done, sigh"
       
  1196 
       
  1197     | language |
       
  1198 
       
  1199     languageOrNil notNil ifTrue:[
       
  1200         language := languageOrNil
       
  1201     ] ifFalse:[
       
  1202         contextOrNilArg notNil ifTrue:[
       
  1203             language := contextOrNilArg method programmingLanguage.
       
  1204         ] ifFalse:[
       
  1205             classOrNilArg notNil ifTrue:[
       
  1206                 language := classOrNilArg programmingLanguage.
       
  1207             ]
       
  1208         ].
       
  1209     ].
       
  1210 
       
  1211     language notNil ifTrue:[
       
  1212         language isSmalltalk ifTrue:[
       
  1213             ^self codeCompletionForSmalltalkClass: classOrNil context: contextOrNil codeView: codeViewArg
       
  1214         ].
       
  1215     ].
       
  1216 
       
  1217     "/ No completion support for given language
       
  1218     self breakPoint: #cg.
       
  1219     self breakPoint: #jv.
       
  1220 
       
  1221     "Created: / 18-09-2013 / 13:49:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1218 ! !
  1222 ! !
  1219 
  1223 
  1220 !DoWhatIMeanSupport methodsFor:'code completion - JavaScript'!
  1224 !DoWhatIMeanSupport methodsFor:'code completion - JavaScript'!
  1221 
  1225 
  1222 codeCompletionForJavascriptMethod:methodOrNilArg orClass:classOrNilArg context:contextOrNilArg codeView:codeViewArg into:actionBlock
  1226 codeCompletionForJavascriptMethod:methodOrNilArg orClass:classOrNilArg context:contextOrNilArg codeView:codeViewArg into:actionBlock
  1604         suggestions2 notEmptyOrNil ifTrue:[
  1608         suggestions2 notEmptyOrNil ifTrue:[
  1605             actionBlock value:suggestions2 value:actions2 value:title2.
  1609             actionBlock value:suggestions2 value:actions2 value:title2.
  1606         ]
  1610         ]
  1607     ].
  1611     ].
  1608 ! !
  1612 ! !
  1609 
       
  1610 
  1613 
  1611 !DoWhatIMeanSupport methodsFor:'code completion-helpers'!
  1614 !DoWhatIMeanSupport methodsFor:'code completion-helpers'!
  1612 
  1615 
  1613 askUserForCompletion:what for:codeView at:position from:allTheBest 
  1616 askUserForCompletion:what for:codeView at:position from:allTheBest 
  1614     |list choice lastChoice|
  1617     |list choice lastChoice|
  4494 ! !
  4497 ! !
  4495 
  4498 
  4496 !DoWhatIMeanSupport class methodsFor:'documentation'!
  4499 !DoWhatIMeanSupport class methodsFor:'documentation'!
  4497 
  4500 
  4498 version
  4501 version
  4499     ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.175 2013-09-25 14:25:55 vrany Exp $'
  4502     ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.176 2013-09-27 09:28:05 vrany Exp $'
  4500 !
  4503 !
  4501 
  4504 
  4502 version_CVS
  4505 version_CVS
  4503     ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.175 2013-09-25 14:25:55 vrany Exp $'
  4506     ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.176 2013-09-27 09:28:05 vrany Exp $'
  4504 ! !
  4507 ! !
  4505 
  4508