-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Package as a possible scope for 'find with scope'. Thanks Hilaire.
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
CoreUpdates/6958-isEditingMethod-fix-JuanVuletich-2024Dec30-13h02m-jmv.001.cs.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'From Cuis7.3 [latest update: #6957] on 30 December 2024 at 1:04:30 pm'! | ||
|
||
!MethodSet methodsFor: 'testing' stamp: 'jmv 12/30/2024 13:04:04'! | ||
isEditingMethod | ||
|
||
^selectedMessage notNil and: [ selectedMessage selector ~~ #Comment ]! ! | ||
|
75 changes: 75 additions & 0 deletions
75
CoreUpdates/6959-findWithScope-PackageScope-HilaireFernandes-2024Dec30-13h04m-hlsf.001.cs.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'From Cuis7.3 [latest update: #6957] on 30 December 2024 at 1:06:16 pm'! | ||
|
||
!SystemDictionary methodsFor: 'browsing' stamp: 'hlsf 12/30/2024 12:55:18'! | ||
browseMethodsWithSourceString: aString in: aPackage | ||
" Browse all methods in aPackage whose source code contains aString as a substring." | ||
|
||
| matchingMethods | | ||
matchingMethods := Set new. | ||
aPackage classesDo: [ :aPackageClass | | ||
(aPackageClass organization classComment | ||
findString: aString | ||
startingAt: 1 | ||
caseSensitive: false) > 0 ifTrue: [ | ||
matchingMethods add: (MethodReference class: aPackageClass selector: #Comment) ]]. | ||
aPackage methods do: [ :methodReference | | ||
(methodReference sourceCode | ||
findString: aString | ||
startingAt: 1 | ||
caseSensitive: false) > 0 ifTrue: [ | ||
matchingMethods add: methodReference ]]. | ||
|
||
^ self | ||
browseMessageList: matchingMethods asArray sort | ||
name: 'Methods containing ' , aString printString, ' in package: ', aPackage packageName | ||
autoHighlight: aString | ||
allOccurrences: true.! ! | ||
|
||
|
||
!SmalltalkEditor methodsFor: 'menu & kbd shortcuts' stamp: 'hlsf 12/30/2024 12:57:55'! | ||
findMethodSourceContainingIt | ||
"Open a browser on methods which contain the current selection in their source (case-sensitive full-text search of source). Slow!!" | ||
| searchString selection scopeClass scopeClassName includeSubclasses includeSuperclasses labelList package | | ||
|
||
searchString := StringRequestMorph | ||
request: 'Enter search text:' | ||
initialAnswer: self selectedString | ||
orCancel: [^self]. | ||
|
||
scopeClass := self codeProvider selectedClass. | ||
scopeClassName := scopeClass name asString. | ||
includeSubclasses := false. | ||
includeSuperclasses := false. | ||
|
||
labelList := { | ||
'This method'. | ||
'All methods in image'. } asOrderedCollection. | ||
(scopeClass notNil) | ||
ifTrue: [ | ||
labelList addAll: { | ||
'Class ', scopeClassName printString. | ||
'Class ', scopeClassName printString, ' and subclasses'. | ||
'Class ', scopeClassName printString, ', subclasses, and superclasses'.}. | ||
package := self codeProvider isEditingMethod | ||
ifTrue: [CodePackage packageOfMethod: self codeProvider currentCompiledMethod asMethodReference ifNone: []] | ||
ifFalse: [CodePackage packageOfClass: scopeClass ifNone: []]. | ||
package ifNotNil: [labelList add: 'In my package: ', package packageName]]. | ||
|
||
selection := (SelectionMenu labelList: labelList selections: nil) startUpWithCaption: 'Search Scope'. | ||
|
||
(selection = 0) ifTrue:[^self]. | ||
(selection = 1) "This method" | ||
ifTrue:[^self find: searchString]. | ||
(selection = 2) "All methods in image" | ||
ifTrue:[scopeClass := nil]. | ||
"(selection = 3) ifTrue:[]. ""Class only - nothing to do" | ||
(selection = 4) "Class and subclasses" | ||
ifTrue:[includeSubclasses := true]. | ||
(selection = 5) "Class, subclasses, and superclasses" | ||
ifTrue:[ | ||
includeSubclasses := true. | ||
includeSuperclasses := true]. | ||
(selection = 6) "In my package if any " | ||
ifTrue: [^ Smalltalk browseMethodsWithSourceString: searchString in: package]. | ||
Smalltalk browseMethodsWithSourceString: searchString scopeClass: scopeClass includeSubclasses: includeSubclasses includeSuperclasses: includeSuperclasses! ! | ||
|