|
1 " |
|
2 Copyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls) |
|
3 Copyright (C) 2001 eXept Software AG |
|
4 |
|
5 Permission is hereby granted, free of charge, to any |
|
6 person obtaining a copy of this software and associated |
|
7 documentation files (the 'Software'), to deal in the |
|
8 Software without restriction, including without limitation |
|
9 the rights to use, copy, modify, merge, publish, distribute, |
|
10 sublicense, and/or sell copies of the Software, and to |
|
11 permit persons to whom the Software is furnished to do so, |
|
12 subject to the following conditions: |
|
13 |
|
14 The above copyright notice and this permission notice shall |
|
15 be included in all copies or substantial portions of the Software. |
|
16 |
|
17 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
20 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
22 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
23 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
24 " |
1 "{ Package: 'stx:libtool2' }" |
25 "{ Package: 'stx:libtool2' }" |
2 |
26 |
3 "{ NameSpace: Smalltalk }" |
27 "{ NameSpace: Smalltalk }" |
4 |
28 |
5 ApplicationModel subclass:#MethodFinderWindow |
29 ApplicationModel subclass:#MethodFinderWindow |
6 instanceVariableNames:'argumentsEditor messageAnswerEditor receiverEditor receiver |
30 instanceVariableNames:'resultHolder selectorPatternHolder classOfResultHolder |
|
31 selectedClassOfResultHolder selectedImplementorsHolder |
|
32 argumentsEditor messageAnswerEditor receiverEditor receiver |
7 resultSelectors arg2BoxVisible arg1BoxVisible arg4BoxVisible |
33 resultSelectors arg2BoxVisible arg1BoxVisible arg4BoxVisible |
8 arg3BoxVisible argCountHolder argCountList argument1Editor |
34 arg3BoxVisible argCountHolder argCountList argument1Editor |
9 argument2Editor argument3Editor argument4Editor resultSelected |
35 argument2Editor argument3Editor argument4Editor resultSelected |
10 lookAtResultEditor codeHolder searchProcess' |
36 lookAtResultEditor codeHolder searchProcess' |
11 classVariableNames:'' |
37 classVariableNames:'' |
13 category:'Interface-Tools' |
39 category:'Interface-Tools' |
14 ! |
40 ! |
15 |
41 |
16 !MethodFinderWindow class methodsFor:'documentation'! |
42 !MethodFinderWindow class methodsFor:'documentation'! |
17 |
43 |
|
44 copyright |
|
45 " |
|
46 Copyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls) |
|
47 Copyright (C) 2001 eXept Software AG |
|
48 |
|
49 Permission is hereby granted, free of charge, to any |
|
50 person obtaining a copy of this software and associated |
|
51 documentation files (the 'Software'), to deal in the |
|
52 Software without restriction, including without limitation |
|
53 the rights to use, copy, modify, merge, publish, distribute, |
|
54 sublicense, and/or sell copies of the Software, and to |
|
55 permit persons to whom the Software is furnished to do so, |
|
56 subject to the following conditions: |
|
57 |
|
58 The above copyright notice and this permission notice shall |
|
59 be included in all copies or substantial portions of the Software. |
|
60 |
|
61 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
62 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
63 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
64 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
65 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
66 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
67 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
68 " |
|
69 ! |
|
70 |
18 documentation |
71 documentation |
19 " |
72 " |
|
73 a tool to find implementing methods by example. |
|
74 Give it values for a receiver, optional arguments and a desired result, |
|
75 and it will find methods which do that for you. |
|
76 Please read the online documentation for details (open via the tool's help menu). |
|
77 |
20 [author:] |
78 [author:] |
21 ported from Squeak and GUI enhanced by James Hayes james@exept.de |
79 original squeak version by Ted Kaehler, Scott Wallace and Dan Ingalls. |
|
80 ported from Squeak and GUI enhanced 2001 by James Hayes james@exept.de. |
|
81 improved by Claus Gittinger. |
22 " |
82 " |
23 ! ! |
83 ! ! |
24 |
84 |
25 !MethodFinderWindow class methodsFor:'constants'! |
85 !MethodFinderWindow class methodsFor:'constants'! |
26 |
86 |
503 ^ receiver copy |
620 ^ receiver copy |
504 ! ! |
621 ! ! |
505 |
622 |
506 !MethodFinderWindow methodsFor:'actions'! |
623 !MethodFinderWindow methodsFor:'actions'! |
507 |
624 |
508 argumentEditorsContents |
|
509 |
|
510 "Determine how many text editors of the arguments are used and store the result |
|
511 as argCounter. The result being the minimum between how many editors have |
|
512 expressions in and how many are displayed. |
|
513 |
|
514 Add each argument string (key)and the evaluated version (value) to an Ordered Dictionary |
|
515 from each of the text editors. |
|
516 |
|
517 Return the OrderedDictionary with the expressions from all the text editors. " |
|
518 |
|
519 | tempArguments argCounter tempArgument1Editor tempArgument2Editor tempArgument3Editor |
|
520 associationKey associationValue| |
|
521 |
|
522 argCounter:=0. |
|
523 |
|
524 tempArgument1Editor:= (self cleanInputs: argument1Editor contents). |
|
525 tempArgument2Editor:= (self cleanInputs: argument2Editor contents). |
|
526 tempArgument3Editor:= (self cleanInputs: argument3Editor contents). |
|
527 |
|
528 tempArgument1Editor = '' ifFalse:[argCounter:=argCounter +1]. |
|
529 tempArgument2Editor = '' ifFalse:[argCounter:=argCounter +1]. |
|
530 tempArgument3Editor = '' ifFalse:[argCounter:=argCounter +1]. |
|
531 |
|
532 |
|
533 argCounter:= (argCounter min: (self argCountHolder value -1)). |
|
534 tempArguments:= OrderedDictionary new:argCounter. |
|
535 |
|
536 (argCounter value >= 1) |
|
537 ifTrue:[associationValue:= (Compiler evaluate: tempArgument1Editor). |
|
538 ((self isExpression:tempArgument1Editor) or:[ associationValue isNil]) ifTrue:[ "looks if an expression is typed in" |
|
539 associationKey:=associationValue printString] |
|
540 ifFalse:[ |
|
541 associationKey:=tempArgument1Editor]. |
|
542 |
|
543 tempArguments add: associationKey-> associationValue. |
|
544 ]. |
|
545 (argCounter value >= 2) |
|
546 ifTrue:[ associationValue:= (Compiler evaluate: tempArgument2Editor). |
|
547 (((self isExpression:tempArgument2Editor) or:[ associationValue isNil])) ifTrue:[ "looks if an expression is typed in" |
|
548 associationKey:=associationValue printString] |
|
549 ifFalse:[ |
|
550 associationKey:=tempArgument2Editor]. |
|
551 |
|
552 tempArguments add: associationKey-> associationValue]. |
|
553 |
|
554 (argCounter value >= 3) |
|
555 ifTrue:[ associationValue:= (Compiler evaluate: tempArgument3Editor). |
|
556 ((self isExpression:tempArgument3Editor) or:[ associationValue isNil]) ifTrue:[ "looks if an expression is typed in" |
|
557 associationKey:=associationValue printString] |
|
558 ifFalse:[ |
|
559 associationKey:=tempArgument3Editor]. |
|
560 |
|
561 tempArguments add: associationKey-> associationValue]. |
|
562 |
|
563 |
|
564 ^tempArguments |
|
565 ! |
|
566 |
|
567 clear |
625 clear |
568 "Reset the contents of all the outputs. Return the receiver." |
626 "Reset the contents of all the outputs." |
569 |
627 |
570 receiverEditor contents:nil. |
628 receiverEditor contents:nil. |
571 argument1Editor contents:nil. |
629 argument1Editor contents:nil. |
572 argument2Editor contents:nil. |
630 argument2Editor contents:nil. |
573 argument3Editor contents:nil. |
631 argument3Editor contents:nil. |
575 self resultHolder value:nil. |
633 self resultHolder value:nil. |
576 self classOfResultHolder value: nil. |
634 self classOfResultHolder value: nil. |
577 codeHolder value:nil. |
635 codeHolder value:nil. |
578 ! |
636 ! |
579 |
637 |
580 extractClassAndSelectorFrom:anArgument |
|
581 "Opens browser on theArgument of a specific class. anArgument being a string with the |
|
582 Class and the selector upon which the browser is to be opened. Return the receiver." |
|
583 |
|
584 |aClass aSelector x theArgument marker| |
|
585 |
|
586 anArgument isNil ifTrue:[ |
|
587 ^ nil |
|
588 ]. |
|
589 marker := self class markerForImplementingClass. |
|
590 |
|
591 theArgument := anArgument string withoutPrefix:marker. |
|
592 aClass := theArgument copyUpTo:(Character space). |
|
593 x := aClass size + 2. |
|
594 aSelector := theArgument copyFrom:x. |
|
595 aClass := Smalltalk classNamed:aClass. |
|
596 (aSelector startsWith:'class ') ifTrue:[ |
|
597 aSelector := aSelector withoutPrefix:'class '. |
|
598 aClass := aClass class. |
|
599 ]. |
|
600 ^ aClass -> aSelector asSymbol |
|
601 |
|
602 " |
|
603 MethodFinderWindow new extractClassAndSelectorFrom: '*SmallInteger +' |
|
604 MethodFinderWindow new extractClassAndSelectorFrom: 'String ,' |
|
605 MethodFinderWindow new extractClassAndSelectorFrom: 'Number detentBy:atMultiplesOf:snap:' |
|
606 |
|
607 |
|
608 " |
|
609 |
|
610 "Modified: / 27-04-2012 / 15:05:53 / cg" |
|
611 ! |
|
612 |
|
613 isExpression:aString |
|
614 "Return true or false depending on if the subString includes certain characters" |
|
615 |
|
616 (aString includesSubString:': ') ifTrue:[ |
|
617 ^ true |
|
618 ]. |
|
619 (aString includes:$+) ifTrue:[ |
|
620 ^ true |
|
621 ]. |
|
622 (aString includes:$-) ifTrue:[ |
|
623 ^ true |
|
624 ]. |
|
625 (aString includes:$*) ifTrue:[ |
|
626 ^ true |
|
627 ]. |
|
628 (aString includes:$/) ifTrue:[ |
|
629 ^ true |
|
630 ]. |
|
631 (aString includes:$>) ifTrue:[ |
|
632 ^ true |
|
633 ]. |
|
634 (aString includes:$<) ifTrue:[ |
|
635 ^ true |
|
636 ]. |
|
637 (aString includesSubString:' new') ifTrue:[ |
|
638 ^ true |
|
639 ]. |
|
640 (aString includes:$[) |
|
641 & (aString includes:$]) |
|
642 & (aString includes:$.) ifTrue:[ ^ false ]. |
|
643 |
|
644 (aString includes:$.) ifTrue:[ |
|
645 ^ true |
|
646 ]. |
|
647 ^ false |
|
648 ! |
|
649 |
|
650 messageAnswerEditorContents |
638 messageAnswerEditorContents |
651 "Return a cleaned up version of message answer taken from the messageAnswerEditor |
639 "Return a cleaned up version of message answer taken from the messageAnswerEditor |
652 as an association. The association has cleanedAnswerString as a key and the |
640 as an association. The association has cleanedAnswerString as a key and the |
653 compiledAnswer as value." |
641 compiledAnswer as value." |
654 |
642 |
943 ]. |
888 ]. |
944 |
889 |
945 "Modified (comment): / 24-06-2012 / 18:41:45 / cg" |
890 "Modified (comment): / 24-06-2012 / 18:41:45 / cg" |
946 ! |
891 ! |
947 |
892 |
948 updateListAfterPatternSearch:resultList |
893 updateListAfterPatternSearch:resultList |
|
894 |searchPattern idx| |
|
895 |
949 self classOfResultHolder value:nil. |
896 self classOfResultHolder value:nil. |
950 self codeHolder value:nil. |
897 self codeHolder value:nil. |
951 self resultHolder value:resultList. |
898 self resultHolder value:resultList. |
952 |
899 |
953 "Created: / 01-06-2012 / 13:17:34 / cg" |
900 searchPattern := self selectorPatternHolder value. |
954 ! |
901 "/ is the search pattern in the list (i.e. a perfect match)? |
955 |
902 "/ Then select it. |
956 waitForBackgroundSearchFinished |
903 idx := resultSelectors indexOf:searchPattern. |
957 | p | |
904 idx ~~ 0 ifTrue:[ |
958 |
905 self selectedImplementorsHolder setValue:idx; changed |
959 (p := searchProcess) isNil ifTrue:[^ self]. |
906 ]. |
960 p isDead ifTrue:[^ self]. |
|
961 p waitUntilTerminated |
|
962 ! ! |
907 ! ! |
963 |
908 |
964 !MethodFinderWindow methodsFor:'aspects'! |
909 !MethodFinderWindow methodsFor:'aspects'! |
965 |
910 |
966 arg1BoxVisible |
911 arg1BoxVisible |
967 "Determines if the box should be visble or not. Return true or false" |
912 "Determines if the box should be visible or not. |
|
913 Return a holder providing true or false" |
|
914 |
968 arg1BoxVisible isNil ifTrue:[ |
915 arg1BoxVisible isNil ifTrue:[ |
969 arg1BoxVisible := BlockValue |
916 arg1BoxVisible := BlockValue |
970 with:[:vh | vh value >= 2 ] |
917 with:[:vh | vh value >= 2 ] |
971 argument:(self argCountHolder) |
918 argument:(self argCountHolder) |
972 ]. |
919 ]. |
973 ^ arg1BoxVisible. |
920 ^ arg1BoxVisible. |
974 ! |
921 ! |
975 |
922 |
976 arg2BoxVisible |
923 arg2BoxVisible |
977 "Determines if the box should be visble or not. Return true or false" |
924 "Determines if the box should be visible or not. |
|
925 Return a holder providing true or false" |
|
926 |
978 arg2BoxVisible isNil ifTrue:[ |
927 arg2BoxVisible isNil ifTrue:[ |
979 arg2BoxVisible := BlockValue |
928 arg2BoxVisible := BlockValue |
980 with:[:vh | vh value >= 3 ] |
929 with:[:vh | vh value >= 3 ] |
981 argument:(self argCountHolder) |
930 argument:(self argCountHolder) |
982 ]. |
931 ]. |
983 ^ arg2BoxVisible. |
932 ^ arg2BoxVisible. |
984 ! |
933 ! |
985 |
934 |
986 arg3BoxVisible |
935 arg3BoxVisible |
987 "Determines if the box should be visble or not. Return true or false" |
936 "Determines if the box should be visible or not. |
|
937 Return a holder providing true or false" |
|
938 |
988 arg3BoxVisible isNil ifTrue:[ |
939 arg3BoxVisible isNil ifTrue:[ |
989 arg3BoxVisible := BlockValue |
940 arg3BoxVisible := BlockValue |
990 with:[:vh | vh value >= 4 ] |
941 with:[:vh | vh value >= 4 ] |
991 argument:(self argCountHolder) |
942 argument:(self argCountHolder) |
992 ]. |
943 ]. |
993 ^ arg3BoxVisible. |
944 ^ arg3BoxVisible. |
994 ! |
945 ! |
995 |
946 |
996 arg4BoxVisible |
947 arg4BoxVisible |
997 "Determines if the box should be visble or not. Return true or false" |
948 "Determines if the box should be visible or not. |
|
949 Return a holder providing true or false" |
|
950 |
998 arg4BoxVisible isNil ifTrue:[ |
951 arg4BoxVisible isNil ifTrue:[ |
999 arg4BoxVisible := BlockValue |
952 arg4BoxVisible := BlockValue |
1000 with:[:vh | vh value >= 5 ] |
953 with:[:vh | vh value >= 5 ] |
1001 argument:(self argCountHolder) |
954 argument:(self argCountHolder) |
1002 ]. |
955 ]. |
1003 ^ arg4BoxVisible. |
956 ^ arg4BoxVisible. |
1004 ! |
957 ! |
1005 |
958 |
1006 argCountHolder |
959 argCountHolder |
1007 "Return the value of argCounterHolder which is initialized at 2." |
960 "Return an argCounterHolder which is initialized at 2." |
|
961 |
1008 argCountHolder isNil ifTrue:[ |
962 argCountHolder isNil ifTrue:[ |
1009 argCountHolder := 2 asValue. |
963 argCountHolder := 2 asValue. |
1010 ]. |
964 ]. |
1011 ^ argCountHolder. |
965 ^ argCountHolder. |
1012 ! |
966 ! |
1013 |
967 |
1014 argCountList |
968 argCountList |
1015 "Return the argCountList" |
969 "Return the argCountList (shown in the combo)" |
|
970 |
1016 argCountList isNil ifTrue:[ |
971 argCountList isNil ifTrue:[ |
1017 argCountList := #('0 arguments' '1 argument' '2 arguments' '3 arguments') asValue |
972 argCountList := #('0 arguments' '1 argument' '2 arguments' '3 arguments') asValue |
1018 ]. |
973 ]. |
1019 ^ argCountList. |
974 ^ argCountList. |
1020 ! |
975 ! |
1021 |
976 |
1022 classOfResultHolder |
977 classOfResultHolder |
1023 "Return a valueHolder which contains a collection with the names of the |
978 "Return a valueHolder which contains a collection with the names of the |
1024 implementors of a specific message. " |
979 implementors of a specific message. " |
1025 |
980 |
1026 |holder| |
981 classOfResultHolder isNil ifTrue:[ |
1027 (holder := builder bindingAt:#classOfResultHolder) isNil ifTrue:[ |
982 classOfResultHolder := ValueHolder new. |
1028 holder := ValueHolder new. |
983 ]. |
1029 builder aspectAt:#classOfResultHolder put:holder |
984 ^ classOfResultHolder |
1030 ]. |
|
1031 ^ holder |
|
1032 ! |
985 ! |
1033 |
986 |
1034 codeHolder |
987 codeHolder |
1035 codeHolder isNil ifTrue:[ |
988 codeHolder isNil ifTrue:[ |
1036 codeHolder := '' asValue. |
989 codeHolder := '' asValue. |
1066 ! |
1023 ! |
1067 |
1024 |
1068 selectedClassOfResultHolder |
1025 selectedClassOfResultHolder |
1069 "valueHolder which contains the index of the selected result class (right list)" |
1026 "valueHolder which contains the index of the selected result class (right list)" |
1070 |
1027 |
1071 |holder| |
1028 selectedClassOfResultHolder isNil ifTrue:[ |
1072 |
1029 selectedClassOfResultHolder := ValueHolder new. |
1073 (holder := builder bindingAt:#selectedClassOfResultHolder) isNil ifTrue:[ |
1030 ]. |
1074 holder := ValueHolder new. |
1031 ^ selectedClassOfResultHolder |
1075 builder aspectAt:#selectedClassOfResultHolder put:holder |
|
1076 ]. |
|
1077 ^ holder |
|
1078 |
1032 |
1079 "Modified (comment): / 21-09-2012 / 11:10:29 / cg" |
1033 "Modified (comment): / 21-09-2012 / 11:10:29 / cg" |
1080 ! |
1034 ! |
1081 |
1035 |
1082 selectedImplementorsHolder |
1036 selectedImplementorsHolder |
1083 "valueHolder which contains the index of the selected implementors list (left list)" |
1037 "valueHolder which contains the index of the selected implementors list (left list)" |
1084 |
1038 |
1085 |holder| |
1039 selectedImplementorsHolder isNil ifTrue:[ |
1086 |
1040 selectedImplementorsHolder := ValueHolder new. |
1087 (holder := builder bindingAt:#selectedImplementorsHolder) isNil ifTrue:[ |
1041 selectedImplementorsHolder onChangeEvaluate:[self updateImplementorsOf:selectedImplementorsHolder value]. |
1088 holder := ValueHolder new. |
1042 ]. |
1089 holder onChangeEvaluate:[self updateImplementorsOf:holder value]. |
1043 ^ selectedImplementorsHolder |
1090 builder aspectAt:#selectedImplementorsHolder put:holder |
|
1091 ]. |
|
1092 ^ holder |
|
1093 |
1044 |
1094 "Created: / 21-09-2012 / 11:10:13 / cg" |
1045 "Created: / 21-09-2012 / 11:10:13 / cg" |
1095 ! |
1046 ! |
1096 |
1047 |
1097 selectorPattern |
1048 selectorPatternHolder |
1098 |holder| |
1049 selectorPatternHolder isNil ifTrue:[ |
1099 (holder := builder bindingAt:#selectorPattern) isNil ifTrue:[ |
1050 selectorPatternHolder := ValueHolder new. |
1100 holder := ValueHolder new. |
1051 selectorPatternHolder onChangeSend:#selectorPatternChanged to:self. |
1101 builder aspectAt:#selectorPattern put:holder. |
1052 ]. |
1102 holder onChangeSend:#searchPatternChanged to:self. |
1053 ^ selectorPatternHolder |
1103 ]. |
|
1104 ^ holder |
|
1105 |
1054 |
1106 "Created: / 27-04-2012 / 14:44:01 / cg" |
1055 "Created: / 27-04-2012 / 14:44:01 / cg" |
1107 ! ! |
|
1108 |
|
1109 !MethodFinderWindow methodsFor:'callBacks'! |
|
1110 |
|
1111 argument1WidgetCreated: aWidget |
|
1112 "Store the widget as an instance variable. Return the receiver" |
|
1113 |
|
1114 |
|
1115 argument1Editor := aWidget scrolledView. |
|
1116 aWidget tabMeansNextField:true. |
|
1117 |
|
1118 "Modified: / 13.11.2001 / 12:21:41 / cg" |
|
1119 ! |
|
1120 |
|
1121 argument2WidgetCreated: aWidget |
|
1122 "Store the widget as an instance variable. Return the receiver" |
|
1123 |
|
1124 |
|
1125 argument2Editor := aWidget scrolledView. |
|
1126 aWidget tabMeansNextField:true. |
|
1127 |
|
1128 "Modified: / 13.11.2001 / 12:21:45 / cg" |
|
1129 ! |
|
1130 |
|
1131 argument3WidgetCreated: aWidget |
|
1132 "Store the widget as an instance variable. Return the receiver" |
|
1133 |
|
1134 |
|
1135 argument3Editor := aWidget scrolledView. |
|
1136 aWidget tabMeansNextField:true. |
|
1137 |
|
1138 "Modified: / 13.11.2001 / 12:21:49 / cg" |
|
1139 ! |
|
1140 |
|
1141 messageAnswerWidgetCreated: aWidget |
|
1142 "Store the widget as an instance variable. Return the receiver" |
|
1143 |
|
1144 messageAnswerEditor := aWidget scrolledView. |
|
1145 aWidget tabMeansNextField:true. |
|
1146 |
|
1147 "Modified: / 13.11.2001 / 12:24:55 / cg" |
|
1148 ! |
|
1149 |
|
1150 openHTMLDocumentation |
|
1151 HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#METHODFINDER' |
|
1152 ! |
|
1153 |
|
1154 receiverWidgetCreated: aWidget |
|
1155 "Store the widget as an instance variable. Return the receiver" |
|
1156 |
|
1157 receiverEditor := aWidget scrolledView. |
|
1158 aWidget tabMeansNextField:true. |
|
1159 |
|
1160 "Modified: / 13.11.2001 / 12:24:49 / cg" |
|
1161 ! |
|
1162 |
|
1163 sourceCodeWidgetCreated: aWidget |
|
1164 aWidget acceptAction:nil. |
|
1165 aWidget readOnly:true |
|
1166 |
|
1167 "Created: / 13.11.2001 / 12:50:27 / cg" |
|
1168 "Modified: / 13.11.2001 / 12:51:23 / cg" |
|
1169 ! ! |
1056 ! ! |
1170 |
1057 |
1171 !MethodFinderWindow methodsFor:'controlInput'! |
1058 !MethodFinderWindow methodsFor:'controlInput'! |
1172 |
1059 |
1173 cleanInputs:aDirtyString |
1060 cleanInputs:aDirtyString |
1296 |
1183 |
1297 ]. |
1184 ]. |
1298 ^receiverWithArgument |
1185 ^receiverWithArgument |
1299 ! ! |
1186 ! ! |
1300 |
1187 |
1301 !MethodFinderWindow methodsFor:'misc'! |
1188 !MethodFinderWindow methodsFor:'initialization'! |
|
1189 |
|
1190 argument1WidgetCreated: aWidget |
|
1191 "UI post creation hook. remember the widget as an instance variable." |
|
1192 |
|
1193 argument1Editor := aWidget scrolledView. |
|
1194 aWidget tabMeansNextField:true. |
|
1195 |
|
1196 "Modified: / 13.11.2001 / 12:21:41 / cg" |
|
1197 ! |
|
1198 |
|
1199 argument2WidgetCreated: aWidget |
|
1200 "UI post creation hook. remember the widget as an instance variable." |
|
1201 |
|
1202 argument2Editor := aWidget scrolledView. |
|
1203 aWidget tabMeansNextField:true. |
|
1204 |
|
1205 "Modified: / 13.11.2001 / 12:21:45 / cg" |
|
1206 ! |
|
1207 |
|
1208 argument3WidgetCreated: aWidget |
|
1209 "UI post creation hook. remember the widget as an instance variable" |
|
1210 |
|
1211 argument3Editor := aWidget scrolledView. |
|
1212 aWidget tabMeansNextField:true. |
|
1213 |
|
1214 "Modified: / 13.11.2001 / 12:21:49 / cg" |
|
1215 ! |
|
1216 |
|
1217 messageAnswerWidgetCreated: aWidget |
|
1218 "UI post creation hook. remember the widget as an instance variable." |
|
1219 |
|
1220 messageAnswerEditor := aWidget scrolledView. |
|
1221 aWidget tabMeansNextField:true. |
|
1222 |
|
1223 "Modified: / 13.11.2001 / 12:24:55 / cg" |
|
1224 ! |
|
1225 |
|
1226 receiverWidgetCreated: aWidget |
|
1227 "UI post creation hook. remember the widget as an instance variable." |
|
1228 |
|
1229 receiverEditor := aWidget scrolledView. |
|
1230 aWidget tabMeansNextField:true. |
|
1231 |
|
1232 "Modified: / 13.11.2001 / 12:24:49 / cg" |
|
1233 ! |
|
1234 |
|
1235 sourceCodeWidgetCreated: aWidget |
|
1236 "UI post creation hook. make the codeView readonly" |
|
1237 |
|
1238 aWidget acceptAction:nil. |
|
1239 aWidget readOnly:true |
|
1240 |
|
1241 "Created: / 13.11.2001 / 12:50:27 / cg" |
|
1242 "Modified: / 13.11.2001 / 12:51:23 / cg" |
|
1243 ! ! |
|
1244 |
|
1245 !MethodFinderWindow methodsFor:'menu actions'! |
1302 |
1246 |
1303 aboutThisApplicationText |
1247 aboutThisApplicationText |
1304 |msg| |
1248 |msg| |
1305 |
1249 |
1306 msg := super aboutThisApplicationText. |
1250 msg := super aboutThisApplicationText. |
1307 msg := msg , '\\Ported from Squeak to ST/X by James Hayes (james@exept.de). |
1251 msg := msg , '\\Original written by Ted Kaehler, Scott Wallace and Dan Ingalls. |
1308 Original written by Ted Kaehler, Scott Wallace and Dan Ingalls.'. |
1252 Ported from Squeak to ST/X by James Hayes (2001 james@exept.de). |
|
1253 Improved by Claus Gittinger. |
|
1254 '. |
1309 ^msg withCRs. |
1255 ^msg withCRs. |
1310 |
1256 |
1311 "Modified: / 13.11.2001 / 12:56:44 / cg" |
1257 "Modified: / 13.11.2001 / 12:56:44 / cg" |
|
1258 ! |
|
1259 |
|
1260 openHTMLDocumentation |
|
1261 "about/help menu action" |
|
1262 |
|
1263 HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#METHODFINDER' |
|
1264 ! ! |
|
1265 |
|
1266 !MethodFinderWindow methodsFor:'private'! |
|
1267 |
|
1268 argumentEditorsContents |
|
1269 |
|
1270 "Determine how many text editors of the arguments are used and store the result |
|
1271 as argCounter. The result being the minimum between how many editors have |
|
1272 expressions in and how many are displayed. |
|
1273 |
|
1274 Add each argument string (key)and the evaluated version (value) to an Ordered Dictionary |
|
1275 from each of the text editors. |
|
1276 |
|
1277 Return the OrderedDictionary with the expressions from all the text editors. " |
|
1278 |
|
1279 | tempArguments argCounter tempArgument1Editor tempArgument2Editor tempArgument3Editor |
|
1280 associationKey associationValue| |
|
1281 |
|
1282 argCounter:=0. |
|
1283 |
|
1284 tempArgument1Editor:= (self cleanInputs: argument1Editor contents). |
|
1285 tempArgument2Editor:= (self cleanInputs: argument2Editor contents). |
|
1286 tempArgument3Editor:= (self cleanInputs: argument3Editor contents). |
|
1287 |
|
1288 tempArgument1Editor = '' ifFalse:[argCounter:=argCounter +1]. |
|
1289 tempArgument2Editor = '' ifFalse:[argCounter:=argCounter +1]. |
|
1290 tempArgument3Editor = '' ifFalse:[argCounter:=argCounter +1]. |
|
1291 |
|
1292 |
|
1293 argCounter:= (argCounter min: (self argCountHolder value -1)). |
|
1294 tempArguments:= OrderedDictionary new:argCounter. |
|
1295 |
|
1296 (argCounter value >= 1) |
|
1297 ifTrue:[associationValue:= (Compiler evaluate: tempArgument1Editor). |
|
1298 ((self isExpression:tempArgument1Editor) or:[ associationValue isNil]) ifTrue:[ "looks if an expression is typed in" |
|
1299 associationKey:=associationValue printString] |
|
1300 ifFalse:[ |
|
1301 associationKey:=tempArgument1Editor]. |
|
1302 |
|
1303 tempArguments add: associationKey-> associationValue. |
|
1304 ]. |
|
1305 (argCounter value >= 2) |
|
1306 ifTrue:[ associationValue:= (Compiler evaluate: tempArgument2Editor). |
|
1307 (((self isExpression:tempArgument2Editor) or:[ associationValue isNil])) ifTrue:[ "looks if an expression is typed in" |
|
1308 associationKey:=associationValue printString] |
|
1309 ifFalse:[ |
|
1310 associationKey:=tempArgument2Editor]. |
|
1311 |
|
1312 tempArguments add: associationKey-> associationValue]. |
|
1313 |
|
1314 (argCounter value >= 3) |
|
1315 ifTrue:[ associationValue:= (Compiler evaluate: tempArgument3Editor). |
|
1316 ((self isExpression:tempArgument3Editor) or:[ associationValue isNil]) ifTrue:[ "looks if an expression is typed in" |
|
1317 associationKey:=associationValue printString] |
|
1318 ifFalse:[ |
|
1319 associationKey:=tempArgument3Editor]. |
|
1320 |
|
1321 tempArguments add: associationKey-> associationValue]. |
|
1322 |
|
1323 |
|
1324 ^tempArguments |
|
1325 ! |
|
1326 |
|
1327 extractClassAndSelectorFrom:anArgument |
|
1328 "Opens browser on theArgument of a specific class. anArgument being a string with the |
|
1329 Class and the selector upon which the browser is to be opened. Return the receiver." |
|
1330 |
|
1331 |aClass aSelector x theArgument marker| |
|
1332 |
|
1333 anArgument isNil ifTrue:[ |
|
1334 ^ nil |
|
1335 ]. |
|
1336 marker := self class markerForImplementingClass. |
|
1337 |
|
1338 theArgument := anArgument string withoutPrefix:marker. |
|
1339 aClass := theArgument copyUpTo:(Character space). |
|
1340 x := aClass size + 2. |
|
1341 aSelector := theArgument copyFrom:x. |
|
1342 aClass := Smalltalk classNamed:aClass. |
|
1343 (aSelector startsWith:'class ') ifTrue:[ |
|
1344 aSelector := aSelector withoutPrefix:'class '. |
|
1345 aClass := aClass class. |
|
1346 ]. |
|
1347 ^ aClass -> aSelector asSymbol |
|
1348 |
|
1349 " |
|
1350 MethodFinderWindow new extractClassAndSelectorFrom: '*SmallInteger +' |
|
1351 MethodFinderWindow new extractClassAndSelectorFrom: 'String ,' |
|
1352 MethodFinderWindow new extractClassAndSelectorFrom: 'Number detentBy:atMultiplesOf:snap:' |
|
1353 |
|
1354 |
|
1355 " |
|
1356 |
|
1357 "Modified: / 27-04-2012 / 15:05:53 / cg" |
|
1358 ! |
|
1359 |
|
1360 isExpression:aString |
|
1361 "Return true or false depending on if the subString includes certain characters" |
|
1362 |
|
1363 "/ cg: this is naive - why not ask the parser, if it is a literal? |
|
1364 (aString includesSubString:': ') ifTrue:[ |
|
1365 ^ true |
|
1366 ]. |
|
1367 (aString includes:$+) ifTrue:[ |
|
1368 ^ true |
|
1369 ]. |
|
1370 (aString includes:$-) ifTrue:[ |
|
1371 ^ true |
|
1372 ]. |
|
1373 (aString includes:$*) ifTrue:[ |
|
1374 ^ true |
|
1375 ]. |
|
1376 (aString includes:$/) ifTrue:[ |
|
1377 ^ true |
|
1378 ]. |
|
1379 (aString includes:$>) ifTrue:[ |
|
1380 ^ true |
|
1381 ]. |
|
1382 (aString includes:$<) ifTrue:[ |
|
1383 ^ true |
|
1384 ]. |
|
1385 (aString includesSubString:' new') ifTrue:[ |
|
1386 ^ true |
|
1387 ]. |
|
1388 (aString includes:$[) |
|
1389 & (aString includes:$]) |
|
1390 & (aString includes:$.) ifTrue:[ ^ false ]. |
|
1391 |
|
1392 (aString includes:$.) ifTrue:[ |
|
1393 ^ true |
|
1394 ]. |
|
1395 ^ false |
|
1396 ! |
|
1397 |
|
1398 receiverEditorContents |
|
1399 "Return a cleaned up version of receiver taken from the receiverEditor |
|
1400 as an association. The association has aCleanedRecieverString as a key and the |
|
1401 compiledReceiver as value." |
|
1402 |
|
1403 |aCleanedRecieverString compiledReceiver| |
|
1404 |
|
1405 aCleanedRecieverString := self cleanInputs:(receiverEditor contents). |
|
1406 compiledReceiver := Compiler evaluate:aCleanedRecieverString. |
|
1407 ((self isExpression:aCleanedRecieverString) or:[ compiledReceiver isNil ]) ifTrue:[ |
|
1408 aCleanedRecieverString := compiledReceiver printString |
|
1409 ]. |
|
1410 ^ aCleanedRecieverString -> compiledReceiver. |
|
1411 ! |
|
1412 |
|
1413 waitForBackgroundSearchFinished |
|
1414 | p | |
|
1415 |
|
1416 (p := searchProcess) isNil ifTrue:[^ self]. |
|
1417 p isDead ifTrue:[^ self]. |
|
1418 p waitUntilTerminated |
|
1419 ! ! |
|
1420 |
|
1421 !MethodFinderWindow methodsFor:'user actions'! |
|
1422 |
|
1423 selectedClassOfResultHolderChanged |
|
1424 |sel classAndSelector mthd| |
|
1425 |
|
1426 sel := self selectedClassOfResultHolder value. |
|
1427 |
|
1428 classAndSelector := self extractClassAndSelectorFrom:sel. |
|
1429 classAndSelector isNil ifTrue:[ |
|
1430 ^ self |
|
1431 ]. |
|
1432 mthd := classAndSelector key >> classAndSelector value. |
|
1433 mthd notNil ifTrue:[ |
|
1434 self withWaitCursorDo:[ |
|
1435 self codeHolder value:mthd source |
|
1436 ] |
|
1437 ] ifFalse:[ |
|
1438 self codeHolder value:nil |
|
1439 ]. |
|
1440 |
|
1441 "Created: / 13.11.2001 / 12:43:43 / cg" |
|
1442 "Modified: / 13.11.2001 / 12:48:56 / cg" |
|
1443 ! |
|
1444 |
|
1445 selectorPatternChanged |
|
1446 self searchPatternMatchesInBackground |
|
1447 |
|
1448 "Created: / 01-06-2012 / 13:18:16 / cg" |
1312 ! ! |
1449 ! ! |
1313 |
1450 |
1314 !MethodFinderWindow class methodsFor:'documentation'! |
1451 !MethodFinderWindow class methodsFor:'documentation'! |
1315 |
1452 |
1316 version |
1453 version |