SmallSense__MethodPO.st
branchcvs_MAIN
changeset 320 5242593726f0
parent 252 feba6ee5c814
child 381 57ef482699a6
child 1046 32bd2d8c19af
equal deleted inserted replaced
319:d0117a7b0c44 320:5242593726f0
       
     1 "
       
     2 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
       
     3 Copyright (C) 2013-2014 Jan Vrany
       
     4 
       
     5 This library is free software; you can redistribute it and/or
       
     6 modify it under the terms of the GNU Lesser General Public
       
     7 License as published by the Free Software Foundation; either
       
     8 version 2.1 of the License. 
       
     9 
       
    10 This library is distributed in the hope that it will be useful,
       
    11 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13 Lesser General Public License for more details.
       
    14 
       
    15 You should have received a copy of the GNU Lesser General Public
       
    16 License along with this library; if not, write to the Free Software
       
    17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
       
    18 "
       
    19 "{ Package: 'stx:goodies/smallsense' }"
       
    20 
       
    21 "{ NameSpace: SmallSense }"
       
    22 
       
    23 PO subclass:#MethodPO
       
    24 	instanceVariableNames:'selector classes'
       
    25 	classVariableNames:''
       
    26 	poolDictionaries:''
       
    27 	category:'SmallSense-Core-Interface-PO'
       
    28 !
       
    29 
       
    30 !MethodPO class methodsFor:'documentation'!
       
    31 
       
    32 copyright
       
    33 "
       
    34 stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
       
    35 Copyright (C) 2013-2014 Jan Vrany
       
    36 
       
    37 This library is free software; you can redistribute it and/or
       
    38 modify it under the terms of the GNU Lesser General Public
       
    39 License as published by the Free Software Foundation; either
       
    40 version 2.1 of the License. 
       
    41 
       
    42 This library is distributed in the hope that it will be useful,
       
    43 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    45 Lesser General Public License for more details.
       
    46 
       
    47 You should have received a copy of the GNU Lesser General Public
       
    48 License along with this library; if not, write to the Free Software
       
    49 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
       
    50 "
       
    51 ! !
       
    52 
       
    53 !MethodPO methodsFor:'accessing'!
       
    54 
       
    55 classes
       
    56     ^ classes
       
    57 !
       
    58 
       
    59 cursorColumnAfterComplete
       
    60 
       
    61     | idx |
       
    62     idx := self label indexOf: $:.
       
    63     ^idx == 0 ifTrue:[self label size + 1] ifFalse:[idx + 1].
       
    64 
       
    65     "Created: / 05-04-2011 / 17:08:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    66     "Modified: / 20-05-2014 / 11:43:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    67 !
       
    68 
       
    69 cursorColumnAfterCompleteForLanguage: language
       
    70     | stringToComplete idx |
       
    71 
       
    72     stringToComplete := self stringToCompleteForLanguage: language.
       
    73     language  isSmalltalk  ifTrue:[
       
    74         idx := stringToComplete indexOf: $:.
       
    75         ^idx == 0 ifTrue:[stringToComplete size] ifFalse:[idx].
       
    76     ].
       
    77     ((language askFor: #isJava) or:[language askFor: #isGroovy]) ifTrue:[
       
    78         ^ (stringToComplete at: stringToComplete size - 1) isSeparator
       
    79             ifTrue:[stringToComplete size- 2]
       
    80             ifFalse:[stringToComplete size]
       
    81     ].
       
    82 
       
    83     ^ stringToComplete size + 1.
       
    84 
       
    85     "Created: / 03-10-2013 / 16:50:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    86     "Modified: / 07-10-2013 / 12:30:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    87 !
       
    88 
       
    89 hint
       
    90     ^ (classes collect:[:each | each nameWithoutPrefix ]) asArray asStringWith:' , '.
       
    91 
       
    92     "Created: / 20-05-2014 / 12:27:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    93 !
       
    94 
       
    95 label
       
    96 
       
    97     label isNil ifTrue:[
       
    98         | someClass |
       
    99 
       
   100         someClass := classes anElement.
       
   101         label := selector.
       
   102         someClass programmingLanguage isSmalltalk ifFalse:[
       
   103             label := (someClass compiledMethodAt: selector) printStringForBrowserWithSelector: selector.
       
   104         ]
       
   105     ].
       
   106     ^ label
       
   107 
       
   108     "Created: / 07-04-2011 / 09:56:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   109     "Modified: / 20-05-2014 / 10:28:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   110 !
       
   111 
       
   112 selector
       
   113     ^ selector
       
   114 !
       
   115 
       
   116 stringToCompleteForLanguage: language
       
   117     | someClass |
       
   118 
       
   119     someClass := classes anElement.
       
   120     someClass isJavaClass ifTrue:[
       
   121         | method |
       
   122 
       
   123         method := someClass compiledMethodAt: selector.
       
   124         language isSmalltalk  ifTrue:[          
       
   125             ^ selector upTo: $(
       
   126         ].
       
   127         ((language askFor: #isJava) or:[language askFor: #isGroovy]) ifTrue:[
       
   128             | selector |
       
   129 
       
   130             selector := (method selector upTo: $().
       
   131             selector = '<init>' ifTrue:[ 
       
   132                 selector := someClass lastName.
       
   133             ].
       
   134             selector := selector , (method numArgs == 0 ifTrue:['()'] ifFalse:['(  )']).
       
   135             ^ selector
       
   136         ].
       
   137     ].
       
   138     ^ String 
       
   139         fromStringCollection: (selector tokensBasedOn: $:)
       
   140         separatedBy: ':  '.
       
   141 
       
   142     "Created: / 02-10-2013 / 02:33:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   143     "Modified: / 15-05-2014 / 13:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   144     "Modified: / 20-05-2014 / 10:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   145 ! !
       
   146 
       
   147 !MethodPO methodsFor:'initialization'!
       
   148 
       
   149 initializeWithClass: aClass selector: aSymbol
       
   150     ^ self initializeWithClasses: (Array with: aClass) selector: aSymbol
       
   151 
       
   152     "Created: / 20-05-2014 / 10:32:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   153 !
       
   154 
       
   155 initializeWithClasses: anArray"Of Classes" selector: aSymbol 
       
   156     selector := aSymbol.
       
   157     classes := anArray
       
   158 
       
   159     "Created: / 20-05-2014 / 10:32:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   160     "Modified: / 20-05-2014 / 11:34:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   161 ! !
       
   162 
       
   163 !MethodPO methodsFor:'testing'!
       
   164 
       
   165 isSmallSenseMethodPO
       
   166     ^ true
       
   167 ! !
       
   168 
       
   169 !MethodPO class methodsFor:'documentation'!
       
   170 
       
   171 version_HG
       
   172 
       
   173     ^ '$Changeset: <not expanded> $'
       
   174 !
       
   175 
       
   176 version_SVN
       
   177     ^ '$Id$'
       
   178 ! !
       
   179