Skip to content

Commit

Permalink
Merge 8af9a48
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajKubelka committed Jul 17, 2024
2 parents 0f1e095 + 8af9a48 commit f5f7c69
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 148 deletions.
40 changes: 14 additions & 26 deletions src/GToolkit-Pharo-Coder-AddOns/GtPharoMethodCoder.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -204,41 +204,29 @@ GtPharoMethodCoder >> addExtractToWrappedMethodObjectMenuForAst: anAst to: coder
{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtPharoMethodCoder >> addHierarchyImplementorsMenuAddOnsAst: anAst to: coderAddOns from: aCoderViewModel [
<gtCoderContextMenuAddOns: 11>

(self nodeFrom: aCoderViewModel)
ifNotNil: [ :node |
| highlightNode |
(node isMessage or: [ node isMessageSend or: [ node isMethodPattern ] ])
ifTrue: [ highlightNode := node isMessageSend ifTrue: [ node message ] ifFalse: [ node ].
coderAddOns
addContextMenuItem: (self
createLabel: 'Browse hierarchy implementors'
description: node selector)
hover: (self highlightNodeBlock: highlightNode)
leave: self removeHighlightBlock
action: [ :aTextualViewModel |
self
browseHierarchyImplementorsAt: highlightNode startPosition
requesterObject: aTextualViewModel ] ] ]
self
addLinkMenuAddOnsTo: coderAddOns
node: node
selector: #browseHierarchyImplementorsAt:requesterObject:
label: 'Browse hierarchy implementors'
requesterObject: aCoderViewModel ]
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtPharoMethodCoder >> addHierarchyMessageReferencesMenuAddOnsAst: anAst to: coderAddOns from: aCoderViewModel [
<gtCoderContextMenuAddOns: 16>

(self nodeFrom: aCoderViewModel)
ifNotNil: [ :node |
| highlightNode |
(node isMessage or: [ node isMessageSend or: [ node isMethodPattern ] ])
ifTrue: [ highlightNode := node isMessageSend ifTrue: [ node message ] ifFalse: [ node ].
coderAddOns
addContextMenuItem: (self
createLabel: 'Browse hierarchy references'
description: node selector)
hover: (self highlightNodeBlock: highlightNode)
leave: self removeHighlightBlock
action: [ :aTextualViewModel |
self
browseHierarchyReferencesAt: highlightNode startPosition
requesterObject: aCoderViewModel ] ] ]
self
addLinkMenuAddOnsTo: coderAddOns
node: node
selector: #browseHierarchyReferencesAt:requesterObject:
label: 'Browse hierarchy references'
requesterObject: aCoderViewModel ]
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
Expand Down
77 changes: 45 additions & 32 deletions src/GToolkit-Pharo-Coder-AddOns/GtPharoSourceCoder.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,54 @@ GtPharoSourceCoder >> addBaselinePackageMenuItemsFor: anAst to: coderAddOns from
{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtPharoSourceCoder >> addClassMenuAddOnsAst: anAst to: coderAddOns from: aCoderViewModel [
<gtCoderContextMenuAddOns: 13>

(self extractableNodesFrom: aCoderViewModel)
ifNotEmpty: [ :nodes |
self
addClassNodeLinkMenuAddOnsTo: coderAddOns
node: nodes first
selector: #browseBehaviorAt:requesterObject:
shortcut: GtSourceCoderBrowseBehaviorShortcut new
requesterObject: aCoderViewModel ]
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtPharoSourceCoder >> addClassNodeLinkMenuAddOnsTo: coderAddOns node: node selector: sel shortcut: aShortcut requesterObject: aRequester [
| foundClass |


node isVariable ifFalse: [ ^ self ].
self
variableNodeToBehavior: node
ifFound: [ :aClass | foundClass := aClass ]
ifNone: [ ^ self ].

coderAddOns
addContextMenuItem: (self
createLabel: aShortcut name
description: foundClass name)
hover: (self highlightNodeBlock: node)
leave: self removeHighlightBlock
action: [ :aTextualViewModel |
self
perform: sel
with: node startPosition
with: aRequester ]
shortcutKey: aShortcut combinationForPlatform gtDisplayString
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtPharoSourceCoder >> addClassReferencesMenuAddOnsAst: anAst to: coderAddOns from: aCoderViewModel [
<gtCoderContextMenuAddOns: 13>

(self extractableNodesFrom: aCoderViewModel)
ifNotEmpty: [ :nodes |
| node |
node := nodes first.
node isVariable ifFalse: [ ^ self ].
self
variableNodeToBehavior: node
ifFound: [ :aClass | foundClass := aClass ]
ifNone: [ ^ self ].
coderAddOns
addContextMenuItem: (self
createLabel: 'Browse class'
description: foundClass name)
hover: (self highlightNodeBlock: node)
leave: self removeHighlightBlock
action: [ :aTextualViewModel |
self browseBehaviorAt: node startPosition requesterObject: nil ]
shortcutKey: GtSourceCoderBrowseBehaviorShortcut new combinationForPlatform gtDisplayString ]
self
addClassNodeLinkMenuAddOnsTo: coderAddOns
node: nodes first
selector: #browseReferencesAt:requesterObject:
shortcut: GtSourceCoderBrowseReferencesShortcut new
requesterObject: aCoderViewModel ]
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
Expand Down Expand Up @@ -157,22 +186,6 @@ GtPharoSourceCoder >> addInstanceVariableReferencesMenuAddOnsAst: anAst to: code
combinationForPlatform gtDisplayString ]
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtPharoSourceCoder >> addLinkMenuAddOnsTo: coderAddOns node: node selector: sel shortcut: aShortcut requesterObject: aRequester [
| highlightNode |
(node isMessage or: [ node isMessageSend or: [ node isMethodPattern ] ])
ifFalse: [ ^ self ].
highlightNode := node isMessageSend ifTrue: [ node message ] ifFalse: [ node ].
coderAddOns
addContextMenuItem: (self
createLabel: aShortcut name
description: node selector)
hover: (self highlightNodeBlock: highlightNode)
leave: self removeHighlightBlock
action: [ :aTextualViewModel | self perform: sel with: highlightNode startPosition with: aRequester ]
shortcutKey: aShortcut combinationForPlatform gtDisplayString
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtPharoSourceCoder >> addMessageReferencesMenuAddOnsAst: anAst to: coderAddOns from: aCoderViewModel [
<gtCoderContextMenuAddOns: 15>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,57 @@
Extension { #name : #GtSmalltalkSourceCoder }

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtSmalltalkSourceCoder >> addLinkMenuAddOnsTo: coderAddOns node: node selector: sel label: aLabel requesterObject: aRequester [
self
addLinkMenuAddOnsTo: coderAddOns
node: node
selector: sel
label: aLabel
shortcut: nil
requesterObject: aRequester
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtSmalltalkSourceCoder >> addLinkMenuAddOnsTo: coderAddOns node: node selector: sel label: aLabel shortcut: aShortcut requesterObject: aRequester [
| highlightNode nodeDescription |

(node isMessage or: [
node isMessageSend or: [
node isMethodPattern or: [
node isSymbol ] ] ])
ifFalse: [ ^ self ].

highlightNode := node isMessageSend
ifTrue: [ node message ] ifFalse: [ node ].
nodeDescription := node isSymbol
ifTrue: [ node literalValue ] ifFalse: [ node selector ].

coderAddOns
addContextMenuItem: (self
createLabel: aLabel
description: nodeDescription)
hover: (self highlightNodeBlock: highlightNode)
leave: self removeHighlightBlock
action: [ :aTextualViewModel |
self
perform: sel
with: highlightNode startPosition
with: aRequester ]
shortcutKey: (aShortcut ifNotNil: [
aShortcut combinationForPlatform gtDisplayString ])
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtSmalltalkSourceCoder >> addLinkMenuAddOnsTo: coderAddOns node: node selector: sel shortcut: aShortcut requesterObject: aRequester [
self
addLinkMenuAddOnsTo: coderAddOns
node: node
selector: sel
label: aShortcut name
shortcut: aShortcut
requesterObject: aRequester
]

{ #category : #'*GToolkit-Pharo-Coder-AddOns' }
GtSmalltalkSourceCoder >> expandCascadeSelection: aSelectionInterval at: position directionOffset: offset in: aSourceCoderViewModel [
| cascade siblings messageNode index |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ GtSearchMethodsContainedInClassFilterExamples >> inheritedMethodsWithTraits [
shouldExclude: {(Smalltalk at: #TraitedClass) >> #rebuildMethodDictionary}
]

{ #category : #examples }
GtSearchMethodsContainedInClassFilterExamples >> methodOnlyIncludedOnceInFilter [
<gtExample>
| filter |
filter := (GtSearchMethodsInClassFilter forClass: Object) withSuperclasses
withSubclasses & thisContext method selector gtImplementors.
self assert: filter contents size equals: 1.
^ filter
]

{ #category : #examples }
GtSearchMethodsContainedInClassFilterExamples >> methodsInClassFilter [
<gtExample>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ GtPharoPackageCoderElement >> buildPackageLabel [
to: packageNameEditor text asString} ];
cancelBlock: [ packageNameEditor text: packageCoder package name ];
when: GtRefactoringsAppliedEvent
do: [ :anEvent | anEvent currentTarget visibility: BlVisibility hidden ].
do: [ :anEvent | anEvent currentTarget visibility: BlVisibility gone ].

packageNameEditor editor
when: BrTextEditorModifiedEvent
Expand Down
55 changes: 29 additions & 26 deletions src/GToolkit-Pharo-Coder-UI/GtPharoPackageTagCoderElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,44 @@ GtPharoPackageTagCoderElement >> buildContentTabs [
{ #category : #'build ui' }
GtPharoPackageTagCoderElement >> buildPackageTagLabel [
| tagNameEditor container previewButton unloadButton |

container := BrHorizontalPane new
hMatchParent;
alignCenterLeft;
vFitContent.
hMatchParent;
alignCenterLeft;
vFitContent.

tagNameEditor := BrEditableLabel new
aptitude: (BrGlamorousEditableLabelAptitude new
defaultBackground: Color transparent;
glamorousCodeFont;
bold;
fontSize: 18);
inputFilter: BrTextEditorAlphaNumericInputFilter new;
text: packageTagCoder packageTag name;
margin: (BlInsets all: 0).
aptitude: (BrGlamorousEditableLabelAptitude new
defaultBackground: Color transparent;
glamorousCodeFont;
bold;
fontSize: 18);
inputFilter: BrTextEditorAlphaNumericInputFilter new;
text: packageTagCoder packageTag name;
margin: (BlInsets all: 0).

previewButton := GtRefactoringsPreviewButton new
margin: (BlInsets left: 5);
visibility: BlVisibility gone;
refactorings: [ { GtRBRenamePackageTagRefactoring packageName: packageTagCoder package name from: packageTagCoder packageTag gtTagName to: tagNameEditor text asString } ];
cancelBlock: [ tagNameEditor text: packageTagCoder packageTag name];
when: GtRefactoringsAppliedEvent do: [ :anEvent | anEvent currentTarget visibility: BlVisibility hidden ].

margin: (BlInsets left: 5);
visibility: BlVisibility gone;
refactorings: [ {GtRBRenamePackageTagRefactoring
packageName: packageTagCoder package name
from: packageTagCoder packageTag gtTagName
to: tagNameEditor text asString} ];
cancelBlock: [ tagNameEditor text: packageTagCoder packageTag name ];
when: GtRefactoringsAppliedEvent
do: [ :anEvent | anEvent currentTarget visibility: BlVisibility gone ].

tagNameEditor editor
when: BrTextEditorModifiedEvent
do: [ :anEvent |
when: BrTextEditorModifiedEvent
do: [ :anEvent |
anEvent text asString = packageTagCoder packageTag name
ifTrue: [ previewButton visibility: BlVisibility gone ]
ifFalse: [ previewButton visibility: BlVisibility visible ] ].
ifFalse: [ previewButton visibility: BlVisibility visible ] ].

unloadButton := GtPreviewChangeButton new
icon: BrGlamorousVectorIcons remove;
label: 'Unload';
changeAction: [ self unloadPackageTag ];
changeStencil: [ self buildRemovePackageTagLabel ].
icon: BrGlamorousVectorIcons remove;
label: 'Unload';
changeAction: [ self unloadPackageTag ];
changeStencil: [ self buildRemovePackageTagLabel ].

container addChild: tagNameEditor.
container addChild: previewButton.
Expand Down
20 changes: 10 additions & 10 deletions src/GToolkit-Pharo-Coder/GtClassMethodsCoder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ GtClassMethodsCoder >> addNewCoder [
^ aCoder
]

{ #category : #accessing }
GtClassMethodsCoder >> classOrMetaClass [
^ class
]

{ #category : #private }
GtClassMethodsCoder >> classesFilter [
| filter |
Expand All @@ -56,11 +61,6 @@ GtClassMethodsCoder >> classesFilter [
^ filter
]

{ #category : #accessing }
GtClassMethodsCoder >> classOrMetaClass [
^ class
]

{ #category : #accessing }
GtClassMethodsCoder >> codeGeneratorsAvailableFor: aMethodsCoderViewModel [
^ (self codeGeneratorsFor: aMethodsCoderViewModel) size > 0
Expand All @@ -85,11 +85,6 @@ GtClassMethodsCoder >> combinedFilter [
[ :filter | combined ifNil: [ filter ] ifNotNil: [ filter & combined ] ]
]

{ #category : #testing }
GtClassMethodsCoder >> filteredClass: aBehavior [
^ filteredClasses includes: aBehavior
]

{ #category : #elements }
GtClassMethodsCoder >> filterTypes [
^ GtPhlowViewsCollector new
Expand All @@ -98,6 +93,11 @@ GtClassMethodsCoder >> filterTypes [
collect
]

{ #category : #testing }
GtClassMethodsCoder >> filteredClass: aBehavior [
^ filteredClasses includes: aBehavior
]

{ #category : #initialize }
GtClassMethodsCoder >> forClass: aBehavior [
class := aBehavior.
Expand Down
Loading

0 comments on commit f5f7c69

Please sign in to comment.