From 1f2369c041e02256e97100233bdff12725fa828f Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Thu, 6 Feb 2025 13:26:00 +0100 Subject: [PATCH 1/9] add cmd on browser + better halt before breackpoint --- ...BreakOnComponentActivationCommand.class.st | 35 ++++++++++ ...kOnComponentInitializationCommand.class.st | 35 ++++++++++ .../MolComponentImpl.extension.st | 65 ++++++++++++++++++- .../MolComponentToRoassal.class.st | 17 +++-- src/Molecule-IDE/MolHomeServices.extension.st | 1 + src/Molecule-IDE/MolRSContractModel.class.st | 40 ++++++++++-- .../MolRSContractModelSource.class.st | 10 +-- .../MolRSContractModelTarget.class.st | 10 +-- 8 files changed, 188 insertions(+), 25 deletions(-) create mode 100644 src/Molecule-IDE/MolBreakOnComponentActivationCommand.class.st create mode 100644 src/Molecule-IDE/MolBreakOnComponentInitializationCommand.class.st diff --git a/src/Molecule-IDE/MolBreakOnComponentActivationCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentActivationCommand.class.st new file mode 100644 index 0000000..2088c29 --- /dev/null +++ b/src/Molecule-IDE/MolBreakOnComponentActivationCommand.class.st @@ -0,0 +1,35 @@ +Class { + #name : #MolBreakOnComponentActivationCommand, + #superclass : #MolClassesCmdCommand, + #category : #'Molecule-IDE-Menus' +} + +{ #category : #activation } +MolBreakOnComponentActivationCommand class >> browserMenuActivation [ + + ^CmdContextMenuActivation byItemOf: MolCmdMenuGroup for: ClyFullBrowserClassContext. +] + +{ #category : #accessing } +MolBreakOnComponentActivationCommand >> defaultMenuIconName [ + + ^ 'halt' +] + +{ #category : #accessing } +MolBreakOnComponentActivationCommand >> defaultMenuItemName [ + + ^ 'Break once on #componentActivate' +] + +{ #category : #accessing } +MolBreakOnComponentActivationCommand >> description [ + + ^ 'Add a breakpoint that trigger once when #componentInitialize is call' +] + +{ #category : #accessing } +MolBreakOnComponentActivationCommand >> execute [ + + self selectedComponentClasses do: #haltOnComponentActivate +] diff --git a/src/Molecule-IDE/MolBreakOnComponentInitializationCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentInitializationCommand.class.st new file mode 100644 index 0000000..b18b270 --- /dev/null +++ b/src/Molecule-IDE/MolBreakOnComponentInitializationCommand.class.st @@ -0,0 +1,35 @@ +Class { + #name : #MolBreakOnComponentInitializationCommand, + #superclass : #MolClassesCmdCommand, + #category : #'Molecule-IDE-Menus' +} + +{ #category : #activation } +MolBreakOnComponentInitializationCommand class >> browserMenuActivation [ + + ^CmdContextMenuActivation byItemOf: MolCmdMenuGroup for: ClyFullBrowserClassContext. +] + +{ #category : #accessing } +MolBreakOnComponentInitializationCommand >> defaultMenuIconName [ + + ^ 'halt' +] + +{ #category : #accessing } +MolBreakOnComponentInitializationCommand >> defaultMenuItemName [ + + ^ 'Break once on #componentInitialize' +] + +{ #category : #accessing } +MolBreakOnComponentInitializationCommand >> description [ + + ^ 'Add a breakpoint that trigger once when #componentInitialize is call' +] + +{ #category : #accessing } +MolBreakOnComponentInitializationCommand >> execute [ + + self selectedComponentClasses haltOnComponentInitialize +] diff --git a/src/Molecule-IDE/MolComponentImpl.extension.st b/src/Molecule-IDE/MolComponentImpl.extension.st index 71cf0d9..f5b1742 100644 --- a/src/Molecule-IDE/MolComponentImpl.extension.st +++ b/src/Molecule-IDE/MolComponentImpl.extension.st @@ -49,11 +49,74 @@ MolComponentImpl >> asRSMoleculeShape [ add: 'Browse component' target: self selector: #browse - argument: #( )) icon: (Smalltalk ui icons iconNamed: #nautilus) ]). + argument: #( )) icon: (Smalltalk ui icons iconNamed: #nautilus). + aMenuMorph addSeparator. + (aMenuMorph + add: 'Halt Once when new component #initialize' + target: self + selector: #haltOnComponentInitialize) icon: + (Smalltalk ui icons iconNamed: #halt). + (aMenuMorph + add: 'Halt Once when new component #activate' + target: self + selector: #haltOnComponentActivate) icon: + (Smalltalk ui icons iconNamed: #halt). + (aMenuMorph + add: 'Halt when #passivate' + target: self + selector: #haltOnComponentPassivate) icon: + (Smalltalk ui icons iconNamed: #halt). + (aMenuMorph + add: 'Halt when #remove' + target: self + selector: #haltOnComponentRemove) icon: + (Smalltalk ui icons iconNamed: #halt) ]). ^ composite ] +{ #category : #'*Molecule-IDE' } +MolComponentImpl classSide >> haltOnComponentActivate [ + + ^ DebugPointManager + installNew: BreakDebugPoint + on: (self compiledMethodAt: #componentActivate) ast + withBehaviors: { OnceBehavior } +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> haltOnComponentActivate [ + + ^ self class haltOnComponentActivate +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl classSide >> haltOnComponentInitialize [ + + ^ DebugPointManager + installNew: BreakDebugPoint + on: (self class compiledMethodAt: #componentInitialize) ast + withBehaviors: { OnceBehavior } +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> haltOnComponentInitialize [ + + ^ self class haltOnComponentInitialize +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> haltOnComponentPassivate [ + + ^ self haltOnceOnCallTo: #componentPassivate +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> haltOnComponentRemove [ + + ^ self haltOnceOnCallTo: #componentRemove +] + { #category : #'*Molecule-IDE' } MolComponentImpl >> inspectionComponent [ diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index 725d076..7ea15cd 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -393,15 +393,14 @@ MolComponentToRoassal class >> makeSingleContractShapeFor: aMolRSContractModel [ selector: #browse argument: #( )) icon: (Smalltalk ui icons iconNamed: #nautilus). aMolRSContractModel eventClass selectors do: [ :selector | - (aMolRSContractModel canBreakOn: selector) ifTrue: [ - separator ifFalse: [ - separator := true. - aMenuMorph addSeparator ]. - (aMenuMorph - add: 'Halt once on #' , selector - target: aMolRSContractModel - selector: #breakOnceOnSelector: - argument: selector) icon: (Smalltalk ui icons iconNamed: #halt) ] ] ]). + separator ifFalse: [ + separator := true. + aMenuMorph addSeparator ]. + (aMenuMorph + add: (aMolRSContractModel breakpointLabelFor: selector) + target: aMolRSContractModel + selector: #addBreakpointFor: + argument: selector) icon: (Smalltalk ui icons iconNamed: #halt) ] ]). ^ composite ] diff --git a/src/Molecule-IDE/MolHomeServices.extension.st b/src/Molecule-IDE/MolHomeServices.extension.st index 87c5386..dc768ea 100644 --- a/src/Molecule-IDE/MolHomeServices.extension.st +++ b/src/Molecule-IDE/MolHomeServices.extension.st @@ -5,6 +5,7 @@ MolHomeServices >> inspectionDeployedComponentsGraph [ | canvas components | + self deployedComponents ifNil: [ ^ SpNullPresenter new ]. components := self deployedComponents flatCollect: #values. canvas := MolComponentToRoassal canvasFromMultipleComponents: components. diff --git a/src/Molecule-IDE/MolRSContractModel.class.st b/src/Molecule-IDE/MolRSContractModel.class.st index 9f6c097..df5add7 100644 --- a/src/Molecule-IDE/MolRSContractModel.class.st +++ b/src/Molecule-IDE/MolRSContractModel.class.st @@ -32,17 +32,41 @@ MolRSContractModel >> <= aMolRSContractModel [ ^ self eventClass name < aMolRSContractModel eventClass name ] +{ #category : #adding } +MolRSContractModel >> addBreakpointFor: aSelector [ + + self shouldBreakOnCall + ifTrue: [ self breakOnceOn: aSelector ] + ifFalse: [ self breakOnceOnBeforeSend: aSelector ] +] + { #category : #debug } -MolRSContractModel >> breakOnceOnSelector: aSelector [ +MolRSContractModel >> breakOnceOn: aSelector [ - (self component breakOnceOnCallTo: aSelector) + self component breakOnceOnCallTo: aSelector +] +{ #category : #'as yet unclassified' } +MolRSContractModel >> breakOnceOnBeforeSend: aSelector [ + + | allSenders allASTSenderNodes | + allSenders := aSelector senders select: [ :method | + method methodClass isComponentClass ]. + allASTSenderNodes := allSenders flatCollect: [ :method | + method ast sendNodes select: [ :node | + node selector = aSelector ] ]. + allASTSenderNodes do: [ :node | + DebugPointManager + installNew: BreakDebugPoint + on: node + withBehaviors: { OnceBehavior } ] ] -{ #category : #debug } -MolRSContractModel >> canBreakOn: aString [ +{ #category : #'as yet unclassified' } +MolRSContractModel >> breakpointLabelFor: aSelector [ - ^ self explicitRequirement + self shouldBreakOnCall ifTrue: [ ^ 'Halt once on #' , aSelector ] + ifFalse: [ ^ 'Halt once before send #' , aSelector ] ] { #category : #accessing } @@ -86,3 +110,9 @@ MolRSContractModel >> name: anObject [ name := anObject ] + +{ #category : #asserting } +MolRSContractModel >> shouldBreakOnCall [ + + ^ self explicitRequirement +] diff --git a/src/Molecule-IDE/MolRSContractModelSource.class.st b/src/Molecule-IDE/MolRSContractModelSource.class.st index 8e88907..bcb46b7 100644 --- a/src/Molecule-IDE/MolRSContractModelSource.class.st +++ b/src/Molecule-IDE/MolRSContractModelSource.class.st @@ -8,14 +8,14 @@ Class { } { #category : #testing } -MolRSContractModelSource >> canBreakOn: aString [ - - ^ (self eventClass includesTrait: MolComponentServices) or: [ self eventClass includesTrait: MolComponentParameters ] +MolRSContractModelSource >> isContractSource [ + ^ true ] { #category : #testing } -MolRSContractModelSource >> isContractSource [ +MolRSContractModelSource >> shouldBreakOnCall [ - ^ true + ^ (self eventClass includesTrait: MolComponentServices) or: [ + self eventClass includesTrait: MolComponentParameters ] ] diff --git a/src/Molecule-IDE/MolRSContractModelTarget.class.st b/src/Molecule-IDE/MolRSContractModelTarget.class.st index 5bdead7..3f29ce7 100644 --- a/src/Molecule-IDE/MolRSContractModelTarget.class.st +++ b/src/Molecule-IDE/MolRSContractModelTarget.class.st @@ -8,13 +8,13 @@ Class { } { #category : #testing } -MolRSContractModelTarget >> canBreakOn: aString [ - ^ self eventClass includesTrait: MolComponentEvents - +MolRSContractModelTarget >> isContractSource [ + + ^ false ] { #category : #testing } -MolRSContractModelTarget >> isContractSource [ +MolRSContractModelTarget >> shouldBreakOnCall [ - ^ false + ^ self eventClass includesTrait: MolComponentEvents ] From 4ff015dc6105e4a00c6ce0f3758562612e3331f6 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Fri, 7 Feb 2025 15:03:13 +0100 Subject: [PATCH 2/9] WIP - DO NOT MERGE --- ...olBreakOnComponentActivateCommand.class.st | 39 +++++++++++++++ ...BreakOnComponentActivationCommand.class.st | 35 ------------- ...kOnComponentInitializationCommand.class.st | 35 ------------- ...BreakOnComponentInitializeCommand.class.st | 39 +++++++++++++++ ...lBreakOnComponentPassivateCommand.class.st | 39 +++++++++++++++ .../MolBreakOnComponentRemoveCommand.class.st | 39 +++++++++++++++ .../MolClassesCmdCommand.class.st | 34 ++++++------- src/Molecule-IDE/MolCmdCommand.class.st | 49 ------------------- src/Molecule-IDE/MolCmdMenuGroup.class.st | 2 +- .../MolCodeMetricsCmdCommand.class.st | 35 +++++++------ .../MolComponentImpl.extension.st | 23 ++++++++- .../MolDefineComponentCmdCommand.class.st | 32 +++++++----- ...mponentRunningInstancesCmdCommand.class.st | 26 +++++----- ...terfacesImplementationsCmdCommand.class.st | 20 ++------ ...pectTypeImplementationsCmdCommand.class.st | 20 ++------ .../MolInterfaceCmdCommand.class.st | 31 +++++++----- .../MolPackagesCmdCommand.class.st | 20 ++++---- src/Molecule-IDE/MolTypeCmdCommand.class.st | 17 ++++--- 18 files changed, 299 insertions(+), 236 deletions(-) create mode 100644 src/Molecule-IDE/MolBreakOnComponentActivateCommand.class.st delete mode 100644 src/Molecule-IDE/MolBreakOnComponentActivationCommand.class.st delete mode 100644 src/Molecule-IDE/MolBreakOnComponentInitializationCommand.class.st create mode 100644 src/Molecule-IDE/MolBreakOnComponentInitializeCommand.class.st create mode 100644 src/Molecule-IDE/MolBreakOnComponentPassivateCommand.class.st create mode 100644 src/Molecule-IDE/MolBreakOnComponentRemoveCommand.class.st delete mode 100644 src/Molecule-IDE/MolCmdCommand.class.st diff --git a/src/Molecule-IDE/MolBreakOnComponentActivateCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentActivateCommand.class.st new file mode 100644 index 0000000..874e74a --- /dev/null +++ b/src/Molecule-IDE/MolBreakOnComponentActivateCommand.class.st @@ -0,0 +1,39 @@ +Class { + #name : #MolBreakOnComponentActivateCommand, + #superclass : #MolClassesCmdCommand, + #category : #'Molecule-IDE-Commands' +} + +{ #category : #activation } +MolBreakOnComponentActivateCommand class >> browserMenuActivation [ + + + ^ CmdContextMenuActivation + byItemOf: MolCmdMenuGroup + order: 51 + for: ClyFullBrowserClassContext +] + +{ #category : #accessing } +MolBreakOnComponentActivateCommand >> defaultMenuIconName [ + + ^ #halt +] + +{ #category : #accessing } +MolBreakOnComponentActivateCommand >> defaultMenuItemName [ + + ^ 'Break once on #componentActivate' +] + +{ #category : #accessing } +MolBreakOnComponentActivateCommand >> description [ + + ^ 'Add a breakpoint that trigger once when #componentActivate is call for this specific class.' +] + +{ #category : #accessing } +MolBreakOnComponentActivateCommand >> execute [ + + self selectedComponentClasses do: #haltOnComponentActivate +] diff --git a/src/Molecule-IDE/MolBreakOnComponentActivationCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentActivationCommand.class.st deleted file mode 100644 index 2088c29..0000000 --- a/src/Molecule-IDE/MolBreakOnComponentActivationCommand.class.st +++ /dev/null @@ -1,35 +0,0 @@ -Class { - #name : #MolBreakOnComponentActivationCommand, - #superclass : #MolClassesCmdCommand, - #category : #'Molecule-IDE-Menus' -} - -{ #category : #activation } -MolBreakOnComponentActivationCommand class >> browserMenuActivation [ - - ^CmdContextMenuActivation byItemOf: MolCmdMenuGroup for: ClyFullBrowserClassContext. -] - -{ #category : #accessing } -MolBreakOnComponentActivationCommand >> defaultMenuIconName [ - - ^ 'halt' -] - -{ #category : #accessing } -MolBreakOnComponentActivationCommand >> defaultMenuItemName [ - - ^ 'Break once on #componentActivate' -] - -{ #category : #accessing } -MolBreakOnComponentActivationCommand >> description [ - - ^ 'Add a breakpoint that trigger once when #componentInitialize is call' -] - -{ #category : #accessing } -MolBreakOnComponentActivationCommand >> execute [ - - self selectedComponentClasses do: #haltOnComponentActivate -] diff --git a/src/Molecule-IDE/MolBreakOnComponentInitializationCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentInitializationCommand.class.st deleted file mode 100644 index b18b270..0000000 --- a/src/Molecule-IDE/MolBreakOnComponentInitializationCommand.class.st +++ /dev/null @@ -1,35 +0,0 @@ -Class { - #name : #MolBreakOnComponentInitializationCommand, - #superclass : #MolClassesCmdCommand, - #category : #'Molecule-IDE-Menus' -} - -{ #category : #activation } -MolBreakOnComponentInitializationCommand class >> browserMenuActivation [ - - ^CmdContextMenuActivation byItemOf: MolCmdMenuGroup for: ClyFullBrowserClassContext. -] - -{ #category : #accessing } -MolBreakOnComponentInitializationCommand >> defaultMenuIconName [ - - ^ 'halt' -] - -{ #category : #accessing } -MolBreakOnComponentInitializationCommand >> defaultMenuItemName [ - - ^ 'Break once on #componentInitialize' -] - -{ #category : #accessing } -MolBreakOnComponentInitializationCommand >> description [ - - ^ 'Add a breakpoint that trigger once when #componentInitialize is call' -] - -{ #category : #accessing } -MolBreakOnComponentInitializationCommand >> execute [ - - self selectedComponentClasses haltOnComponentInitialize -] diff --git a/src/Molecule-IDE/MolBreakOnComponentInitializeCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentInitializeCommand.class.st new file mode 100644 index 0000000..3a4d015 --- /dev/null +++ b/src/Molecule-IDE/MolBreakOnComponentInitializeCommand.class.st @@ -0,0 +1,39 @@ +Class { + #name : #MolBreakOnComponentInitializeCommand, + #superclass : #MolClassesCmdCommand, + #category : #'Molecule-IDE-Commands' +} + +{ #category : #activation } +MolBreakOnComponentInitializeCommand class >> browserMenuActivation [ + + + ^ CmdContextMenuActivation + byItemOf: MolCmdMenuGroup + order: 50 + for: ClyFullBrowserClassContext +] + +{ #category : #accessing } +MolBreakOnComponentInitializeCommand >> defaultMenuIconName [ + + ^ #halt +] + +{ #category : #accessing } +MolBreakOnComponentInitializeCommand >> defaultMenuItemName [ + + ^ 'Break once on #componentInitialize' +] + +{ #category : #accessing } +MolBreakOnComponentInitializeCommand >> description [ + + ^ 'Add a breakpoint that trigger once when #componentInitialize is call for this specific class.' +] + +{ #category : #accessing } +MolBreakOnComponentInitializeCommand >> execute [ + + self selectedComponentClasses do: #haltOnComponentInitialize +] diff --git a/src/Molecule-IDE/MolBreakOnComponentPassivateCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentPassivateCommand.class.st new file mode 100644 index 0000000..83f558d --- /dev/null +++ b/src/Molecule-IDE/MolBreakOnComponentPassivateCommand.class.st @@ -0,0 +1,39 @@ +Class { + #name : #MolBreakOnComponentPassivateCommand, + #superclass : #MolClassesCmdCommand, + #category : #'Molecule-IDE-Commands' +} + +{ #category : #activation } +MolBreakOnComponentPassivateCommand class >> browserMenuActivation [ + + + ^ CmdContextMenuActivation + byItemOf: MolCmdMenuGroup + order: 52 + for: ClyFullBrowserClassContext +] + +{ #category : #accessing } +MolBreakOnComponentPassivateCommand >> defaultMenuIconName [ + + ^ #halt +] + +{ #category : #accessing } +MolBreakOnComponentPassivateCommand >> defaultMenuItemName [ + + ^ 'Break once on #componentPassivate' +] + +{ #category : #accessing } +MolBreakOnComponentPassivateCommand >> description [ + + ^ 'Add a breakpoint that trigger once when #componentPassivate is call for this specific class.' +] + +{ #category : #accessing } +MolBreakOnComponentPassivateCommand >> execute [ + + self selectedComponentClasses do: #haltOnComponentPassivate +] diff --git a/src/Molecule-IDE/MolBreakOnComponentRemoveCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentRemoveCommand.class.st new file mode 100644 index 0000000..922603f --- /dev/null +++ b/src/Molecule-IDE/MolBreakOnComponentRemoveCommand.class.st @@ -0,0 +1,39 @@ +Class { + #name : #MolBreakOnComponentRemoveCommand, + #superclass : #MolClassesCmdCommand, + #category : #'Molecule-IDE-Commands' +} + +{ #category : #activation } +MolBreakOnComponentRemoveCommand class >> browserMenuActivation [ + + + ^ CmdContextMenuActivation + byItemOf: MolCmdMenuGroup + order: 53 + for: ClyFullBrowserClassContext +] + +{ #category : #accessing } +MolBreakOnComponentRemoveCommand >> defaultMenuIconName [ + + ^ #halt +] + +{ #category : #accessing } +MolBreakOnComponentRemoveCommand >> defaultMenuItemName [ + + ^ 'Break once on #componentRemove' +] + +{ #category : #accessing } +MolBreakOnComponentRemoveCommand >> description [ + + ^ 'Add a breakpoint that trigger once when #componentRemove is call for this specific class.' +] + +{ #category : #accessing } +MolBreakOnComponentRemoveCommand >> execute [ + + self selectedComponentClasses do: #haltOnComponentRemove +] diff --git a/src/Molecule-IDE/MolClassesCmdCommand.class.st b/src/Molecule-IDE/MolClassesCmdCommand.class.st index 781e5ec..97d245b 100644 --- a/src/Molecule-IDE/MolClassesCmdCommand.class.st +++ b/src/Molecule-IDE/MolClassesCmdCommand.class.st @@ -1,26 +1,19 @@ Class { #name : #MolClassesCmdCommand, - #superclass : #MolCmdCommand, - #category : #'Molecule-IDE-Menus' + #superclass : #CmdCommand, + #instVars : [ + 'selectedComponentClasses' + ], + #category : #'Molecule-IDE-Commands' } { #category : #testing } MolClassesCmdCommand class >> canBeExecutedInContext: aToolContext [ - | list selectedItem selected | - - (super canBeExecutedInContext: aToolContext) ifFalse:[ ^ false ]. - aToolContext selectedItems ifEmpty:[ ^ false ]. - - selectedItem := aToolContext selectedItems at: 1. - selected := selectedItem browserItem actualObject name. - - "find all components" - list := SystemNavigation default allClasses select: [ :c | - c isTrait not and: [ - (c allSuperclasses includes: Object) and: [ c isComponentClass ] ] ]. - - "return if selected object is in list of component" - ^list includes: (self class environment at: selected asSymbol) . + + (super canBeExecutedInContext: aToolContext) ifFalse: [ ^ false ]. + aToolContext selectedItems ifEmpty: [ ^ false ]. + ^ aToolContext selectedItems first actualObject isComponentClass. + ] { #category : #testing } @@ -30,13 +23,14 @@ MolClassesCmdCommand class >> isAbstract [ ] { #category : #execution } -MolClassesCmdCommand >> selectedClasses [ +MolClassesCmdCommand >> prepareFullExecutionInContext: aToolContext [ - ^ selectedItems collect:[ :p | p browserItem actualObject ] + super prepareFullExecutionInContext: aToolContext. + selectedComponentClasses := aToolContext selectedItems collect: [ :p | p browserItem actualObject ] thenSelect: #isComponentClass ] { #category : #execution } MolClassesCmdCommand >> selectedComponentClasses [ - ^ self selectedClasses select:[ :c | c isComponentClass ]. + ^ selectedComponentClasses ] diff --git a/src/Molecule-IDE/MolCmdCommand.class.st b/src/Molecule-IDE/MolCmdCommand.class.st deleted file mode 100644 index e4f868e..0000000 --- a/src/Molecule-IDE/MolCmdCommand.class.st +++ /dev/null @@ -1,49 +0,0 @@ -" -super class for menu system browser -" -Class { - #name : #MolCmdCommand, - #superclass : #CmdCommand, - #instVars : [ - 'selectedItems', - 'executionResult' - ], - #category : #'Molecule-IDE-Menus' -} - -{ #category : #activation } -MolCmdCommand class >> browserMenuActivation [ - - ^self class subclassResponsibility. -] - -{ #category : #activation } -MolCmdCommand class >> isAbstract [ - - ^ self = MolCmdCommand -] - -{ #category : #accessing } -MolCmdCommand >> executionResult [ - - ^ executionResult -] - -{ #category : #accessing } -MolCmdCommand >> executionResult: anObject [ - - executionResult := anObject -] - -{ #category : #execution } -MolCmdCommand >> prepareFullExecutionInContext: aToolContext [ - - super prepareFullExecutionInContext: aToolContext. - selectedItems := aToolContext selectedItems -] - -{ #category : #execution } -MolCmdCommand >> readParametersFromContext: aToolContext [ - - super readParametersFromContext: aToolContext -] diff --git a/src/Molecule-IDE/MolCmdMenuGroup.class.st b/src/Molecule-IDE/MolCmdMenuGroup.class.st index 8e61919..eea6da7 100644 --- a/src/Molecule-IDE/MolCmdMenuGroup.class.st +++ b/src/Molecule-IDE/MolCmdMenuGroup.class.st @@ -4,7 +4,7 @@ Class for the menu => right click on a component Class { #name : #MolCmdMenuGroup, #superclass : #CmdMenuGroup, - #category : #'Molecule-IDE-Menus' + #category : #'Molecule-IDE-Commands' } { #category : #accessing } diff --git a/src/Molecule-IDE/MolCodeMetricsCmdCommand.class.st b/src/Molecule-IDE/MolCodeMetricsCmdCommand.class.st index 442e910..c74ca88 100644 --- a/src/Molecule-IDE/MolCodeMetricsCmdCommand.class.st +++ b/src/Molecule-IDE/MolCodeMetricsCmdCommand.class.st @@ -1,7 +1,7 @@ Class { #name : #MolCodeMetricsCmdCommand, #superclass : #MolPackagesCmdCommand, - #category : #'Molecule-IDE-Menus' + #category : #'Molecule-IDE-Commands' } { #category : #activation } @@ -19,7 +19,7 @@ MolCodeMetricsCmdCommand >> aboutText [ { #category : #accessing } MolCodeMetricsCmdCommand >> defaultMenuIconName [ - ^'smallLanguage' + ^ #smallLanguage ] { #category : #accessing } @@ -36,28 +36,35 @@ MolCodeMetricsCmdCommand >> description [ { #category : #accessing } MolCodeMetricsCmdCommand >> execute [ + | presenter stream metrics | presenter := SpTextPresenter new. - + stream := ReadWriteStream on: String new. - stream - nextPutAll: 'Nb packages: '; - nextPutAll: self selectedPackages size asString; - cr; cr. - - metrics := MolSourceCodeMetrics classes: self selectedPackagesClasses. + stream + nextPutAll: 'Nb packages: '; + nextPutAll: self selectedPackages size asString; + cr; + cr. + + metrics := MolSourceCodeMetrics classes: (self selectedPackages flatCollect: #classes). metrics printOn: stream. - + presenter text: stream contents. - + presenter open. - presenter withWindowDo: [ :w | w title: self titleForSelectedItems; aboutText: self aboutText ]. + presenter withWindowDo: [ :w | + w + title: self titleForSelectedItems; + aboutText: self aboutText ] ] { #category : #private } MolCodeMetricsCmdCommand >> titleForSelectedItems [ | nbPackages | - nbPackages := selectedItems size. - ^ 'Molecule metrics for ' , nbPackages asString , ' package' , (nbPackages > 1 ifTrue:[ 's' ] ifFalse: [ '' ]). + nbPackages := self selectedPackages size. + ^ 'Molecule metrics for <1p> package<2?s:>' + expandMacrosWith: nbPackages + with: nbPackages > 1 ] diff --git a/src/Molecule-IDE/MolComponentImpl.extension.st b/src/Molecule-IDE/MolComponentImpl.extension.st index f5b1742..b14bb80 100644 --- a/src/Molecule-IDE/MolComponentImpl.extension.st +++ b/src/Molecule-IDE/MolComponentImpl.extension.st @@ -95,7 +95,7 @@ MolComponentImpl classSide >> haltOnComponentInitialize [ ^ DebugPointManager installNew: BreakDebugPoint - on: (self class compiledMethodAt: #componentInitialize) ast + on: (self compiledMethodAt: #componentInitialize) ast withBehaviors: { OnceBehavior } ] @@ -105,12 +105,33 @@ MolComponentImpl >> haltOnComponentInitialize [ ^ self class haltOnComponentInitialize ] +{ #category : #'*Molecule-IDE' } +MolComponentImpl classSide >> haltOnComponentPassivate [ + + ^ DebugPointManager + installNew: BreakDebugPoint + on: (self compiledMethodAt: #componentPassivate) ast + withBehaviors: { OnceBehavior } +] + { #category : #'*Molecule-IDE' } MolComponentImpl >> haltOnComponentPassivate [ ^ self haltOnceOnCallTo: #componentPassivate ] +{ #category : #'*Molecule-IDE' } +MolComponentImpl classSide >> haltOnComponentRemove [ + + self compiledMethodAt: #componentRemove ifPresent: [ :m | + ^ DebugPointManager + installNew: BreakDebugPoint + on: m ast + withBehaviors: { OnceBehavior . ConditionBehavior new condition: 'self=MolMyAlarmComponentImpl' } ]. + self halt. + self superclass isComponentClass ifTrue: [ self superclass haltOnComponentRemove ]. +] + { #category : #'*Molecule-IDE' } MolComponentImpl >> haltOnComponentRemove [ diff --git a/src/Molecule-IDE/MolDefineComponentCmdCommand.class.st b/src/Molecule-IDE/MolDefineComponentCmdCommand.class.st index ce23d7f..0316438 100644 --- a/src/Molecule-IDE/MolDefineComponentCmdCommand.class.st +++ b/src/Molecule-IDE/MolDefineComponentCmdCommand.class.st @@ -1,13 +1,17 @@ Class { #name : #MolDefineComponentCmdCommand, #superclass : #MolClassesCmdCommand, - #category : #'Molecule-IDE-Menus' + #category : #'Molecule-IDE-Commands' } { #category : #activation } MolDefineComponentCmdCommand class >> browserMenuActivation [ + - ^CmdContextMenuActivation byItemOf: MolCmdMenuGroup for: ClyFullBrowserClassContext. + ^ CmdContextMenuActivation + byItemOf: MolCmdMenuGroup + order: 10 + for: ClyFullBrowserClassContext ] { #category : #accessing } @@ -30,17 +34,21 @@ MolDefineComponentCmdCommand >> description [ { #category : #execution } MolDefineComponentCmdCommand >> execute [ + | componentsToDefine nbOfDefinedComponents text | - componentsToDefine := self selectedComponentClasses. - componentsToDefine do:[ :c | MolComponentFactory defineComponent: c ]. - + componentsToDefine do: [ :c | MolComponentFactory defineComponent: c ]. + nbOfDefinedComponents := componentsToDefine size. - self executionResult: nbOfDefinedComponents. - - text := nbOfDefinedComponents = 1 - ifTrue:[ 'Define component: ', componentsToDefine first printString ] - ifFalse:[ nbOfDefinedComponents asString, ' component', (nbOfDefinedComponents > 1 ifTrue:['s'] ifFalse:['']) ,' defined' ]. - - MolUtils showInformation: text. + + text := nbOfDefinedComponents = 1 + ifTrue: [ + 'Define component: ' , componentsToDefine first printString ] + ifFalse: [ + nbOfDefinedComponents asString , ' component' + , (nbOfDefinedComponents > 1 + ifTrue: [ 's' ] + ifFalse: [ '' ]) , ' defined' ]. + + MolUtils showInformation: text ] diff --git a/src/Molecule-IDE/MolInspectComponentRunningInstancesCmdCommand.class.st b/src/Molecule-IDE/MolInspectComponentRunningInstancesCmdCommand.class.st index e7ed7a8..42eee42 100644 --- a/src/Molecule-IDE/MolInspectComponentRunningInstancesCmdCommand.class.st +++ b/src/Molecule-IDE/MolInspectComponentRunningInstancesCmdCommand.class.st @@ -1,13 +1,17 @@ Class { #name : #MolInspectComponentRunningInstancesCmdCommand, #superclass : #MolClassesCmdCommand, - #category : #'Molecule-IDE-Menus' + #category : #'Molecule-IDE-Commands' } { #category : #activation } MolInspectComponentRunningInstancesCmdCommand class >> browserMenuActivation [ + - ^CmdContextMenuActivation byItemOf: MolCmdMenuGroup for: ClyFullBrowserClassContext. + ^ CmdContextMenuActivation + byItemOf: MolCmdMenuGroup + order: 20 + for: ClyFullBrowserClassContext ] { #category : #accessing } @@ -30,16 +34,16 @@ MolInspectComponentRunningInstancesCmdCommand >> description [ { #category : #accessing } MolInspectComponentRunningInstancesCmdCommand >> execute [ - | selectedComponents instanceList | - selectedComponents := self selectedComponentClasses. + | selectedComponents instanceList | + selectedComponents := self selectedComponentClasses. instanceList := Set new. - selectedComponents do:[ :c | | running | - running := (MolComponentManager default homeServices deployedComponents at: c ifAbsent:[ Dictionary new ]) copy. - running isEmpty ifFalse:[ instanceList add: running ]. - ]. - - self executionResult: instanceList. - ^ self executionResult inspect + selectedComponents do: [ :c | + | running | + running := (MolComponentManager default homeServices + deployedComponents at: c ifAbsent: [ Dictionary new ]) + copy. + running isEmpty ifFalse: [ instanceList add: running ] ]. + ^ instanceList inspect ] diff --git a/src/Molecule-IDE/MolInspectInterfacesImplementationsCmdCommand.class.st b/src/Molecule-IDE/MolInspectInterfacesImplementationsCmdCommand.class.st index 9298173..4fbc19f 100644 --- a/src/Molecule-IDE/MolInspectInterfacesImplementationsCmdCommand.class.st +++ b/src/Molecule-IDE/MolInspectInterfacesImplementationsCmdCommand.class.st @@ -1,7 +1,7 @@ Class { #name : #MolInspectInterfacesImplementationsCmdCommand, #superclass : #MolInterfaceCmdCommand, - #category : #'Molecule-IDE-Tools' + #category : #'Molecule-IDE-Commands' } { #category : #activation } @@ -13,7 +13,7 @@ MolInspectInterfacesImplementationsCmdCommand class >> browserMenuActivation [ { #category : #accessing } MolInspectInterfacesImplementationsCmdCommand >> defaultMenuIconName [ - ^ 'glamorousInspect' + ^ #inspect ] { #category : #accessing } @@ -31,17 +31,7 @@ MolInspectInterfacesImplementationsCmdCommand >> description [ { #category : #accessing } MolInspectInterfacesImplementationsCmdCommand >> execute [ - | selectedInterface emptyArray interface | - selectedInterface := self selectedInterfaceClass. - - interface := MolInterfacesPresenter new. - emptyArray := Array new: 0. - - "condition and ifTrue: are executed only if multiple Traits were/are selected in the System Browser, since this option only supports one Type selected at a time" - selectedInterface = emptyArray - ifFalse: [ selectedInterface := selectedInterface at: 1 ] - ifTrue: [ - selectedInterface := (selectedItems at: 1) browserItem actualObject ]. - interface interface: selectedInterface. - interface open + MolInterfacesPresenter new + interface: self selectedInterfaceClasses first; + open ] diff --git a/src/Molecule-IDE/MolInspectTypeImplementationsCmdCommand.class.st b/src/Molecule-IDE/MolInspectTypeImplementationsCmdCommand.class.st index 051ddfc..8473894 100644 --- a/src/Molecule-IDE/MolInspectTypeImplementationsCmdCommand.class.st +++ b/src/Molecule-IDE/MolInspectTypeImplementationsCmdCommand.class.st @@ -1,7 +1,7 @@ Class { #name : #MolInspectTypeImplementationsCmdCommand, #superclass : #MolTypeCmdCommand, - #category : #'Molecule-IDE-Tools' + #category : #'Molecule-IDE-Commands' } { #category : #activation } @@ -13,7 +13,7 @@ MolInspectTypeImplementationsCmdCommand class >> browserMenuActivation [ { #category : #accessing } MolInspectTypeImplementationsCmdCommand >> defaultMenuIconName [ - ^ 'glamorousInspect' + ^ #inspect ] { #category : #accessing } @@ -31,17 +31,7 @@ MolInspectTypeImplementationsCmdCommand >> description [ { #category : #accessing } MolInspectTypeImplementationsCmdCommand >> execute [ - | selectedType implem emptyArray | - selectedType := self selectedTypeClass. - - implem := MolImplementationsPresenter new. - emptyArray := Array new: 0. - - "condition and ifTrue: are executed only if multiple Traits were/are selected in the System Browser, since this option only supports one Type selected at a time" - selectedType = emptyArray - ifFalse: [ selectedType := selectedType at: 1 ] - ifTrue: [ - selectedType := (selectedItems at: 1) browserItem actualObject ]. - implem type: selectedType. - implem open + MolImplementationsPresenter new + type: self selectedTypeClass first; + open ] diff --git a/src/Molecule-IDE/MolInterfaceCmdCommand.class.st b/src/Molecule-IDE/MolInterfaceCmdCommand.class.st index 9e270e5..1642293 100644 --- a/src/Molecule-IDE/MolInterfaceCmdCommand.class.st +++ b/src/Molecule-IDE/MolInterfaceCmdCommand.class.st @@ -1,7 +1,10 @@ Class { #name : #MolInterfaceCmdCommand, - #superclass : #MolCmdCommand, - #category : #'Molecule-IDE-Tools' + #superclass : #CmdCommand, + #instVars : [ + 'selectedInterfaceClasses' + ], + #category : #'Molecule-IDE-Commands' } { #category : #testing } @@ -24,17 +27,21 @@ MolInterfaceCmdCommand class >> canBeExecutedInContext: aToolContext [ ^ list includes: (self class environment at: selected asSymbol) ] -{ #category : #'api - accessing' } -MolInterfaceCmdCommand >> selectedClass [ - - ^ (selectedItems collect: [ :p | p browserItem actualObject ]) +{ #category : #execution } +MolInterfaceCmdCommand >> prepareFullExecutionInContext: aToolContext [ + + super prepareFullExecutionInContext: aToolContext. + selectedInterfaceClasses := aToolContext selectedItems + collect: [ :p | + p browserItem actualObject ] + thenSelect: [ :c | + c isTrait and: [ + c isComponentEvents or: [ + c isComponentParameters or: [ + c isComponentServices ] ] ] ] ] { #category : #'as yet unclassified' } -MolInterfaceCmdCommand >> selectedInterfaceClass [ - "this method returns the class in the System Browser that is an interface (Events/Parameters/Services)" - - ^ self selectedClass select: [ :c | - c isComponentEvents or: - (c isComponentParameters or: c isComponentServices) ] +MolInterfaceCmdCommand >> selectedInterfaceClasses [ + ^ selectedInterfaceClasses ] diff --git a/src/Molecule-IDE/MolPackagesCmdCommand.class.st b/src/Molecule-IDE/MolPackagesCmdCommand.class.st index 4c8a733..30cc419 100644 --- a/src/Molecule-IDE/MolPackagesCmdCommand.class.st +++ b/src/Molecule-IDE/MolPackagesCmdCommand.class.st @@ -1,7 +1,10 @@ Class { #name : #MolPackagesCmdCommand, - #superclass : #MolCmdCommand, - #category : #'Molecule-IDE-Menus' + #superclass : #CmdCommand, + #instVars : [ + 'selectedPackages' + ], + #category : #'Molecule-IDE-Commands' } { #category : #activation } @@ -36,16 +39,15 @@ MolPackagesCmdCommand class >> isAbstract [ ] { #category : #execution } -MolPackagesCmdCommand >> selectedPackages [ +MolPackagesCmdCommand >> prepareFullExecutionInContext: aToolContext [ - ^ selectedItems collect: [ :p | p browserItem actualObject ] + super prepareFullExecutionInContext: aToolContext. + selectedPackages := aToolContext selectedItems collect: [ :p | + p browserItem actualObject ] ] { #category : #execution } -MolPackagesCmdCommand >> selectedPackagesClasses [ +MolPackagesCmdCommand >> selectedPackages [ - | classes | - classes := Set new. - self selectedPackages do: [ :p | classes addAll: p classes ]. - ^ classes + ^ selectedPackages ] diff --git a/src/Molecule-IDE/MolTypeCmdCommand.class.st b/src/Molecule-IDE/MolTypeCmdCommand.class.st index 329d5c6..9a8d7f0 100644 --- a/src/Molecule-IDE/MolTypeCmdCommand.class.st +++ b/src/Molecule-IDE/MolTypeCmdCommand.class.st @@ -1,10 +1,10 @@ Class { #name : #MolTypeCmdCommand, - #superclass : #MolCmdCommand, + #superclass : #CmdCommand, #instVars : [ - 'typeName' + 'selectedTypeClass' ], - #category : #'Molecule-IDE-Tools' + #category : #'Molecule-IDE-Commands' } { #category : #testing } @@ -25,15 +25,18 @@ MolTypeCmdCommand class >> canBeExecutedInContext: aToolContext [ ^ list includes: (self class environment at: selected asSymbol) ] -{ #category : #'as yet unclassified' } -MolTypeCmdCommand >> selectedClass [ +{ #category : #execution } +MolTypeCmdCommand >> prepareFullExecutionInContext: aToolContext [ - ^ selectedItems collect: [ :p | p browserItem actualObject ] + super prepareFullExecutionInContext: aToolContext. + selectedTypeClass := aToolContext selectedItems + collect: [ :item | item browserItem actualObject ] + thenSelect: [ :each | each isTrait and: [ each isComponentType ]] ] { #category : #'as yet unclassified' } MolTypeCmdCommand >> selectedTypeClass [ "this method returns the class selected in the System Browser that is a Type" - ^ self selectedClass select: [ :c | c isComponentType ] + ^ selectedTypeClass ] From d319053a338ea721d51acdf7b45e7e151d84c3a4 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Mon, 10 Feb 2025 10:13:22 +0100 Subject: [PATCH 3/9] Add lookup method --- .../MolComponentImpl.extension.st | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Molecule-IDE/MolComponentImpl.extension.st b/src/Molecule-IDE/MolComponentImpl.extension.st index b14bb80..5690e56 100644 --- a/src/Molecule-IDE/MolComponentImpl.extension.st +++ b/src/Molecule-IDE/MolComponentImpl.extension.st @@ -78,10 +78,7 @@ MolComponentImpl >> asRSMoleculeShape [ { #category : #'*Molecule-IDE' } MolComponentImpl classSide >> haltOnComponentActivate [ - ^ DebugPointManager - installNew: BreakDebugPoint - on: (self compiledMethodAt: #componentActivate) ast - withBehaviors: { OnceBehavior } + ^ self haltOnComponentLifeCycle: #componentActivate ] { #category : #'*Molecule-IDE' } @@ -93,10 +90,8 @@ MolComponentImpl >> haltOnComponentActivate [ { #category : #'*Molecule-IDE' } MolComponentImpl classSide >> haltOnComponentInitialize [ - ^ DebugPointManager - installNew: BreakDebugPoint - on: (self compiledMethodAt: #componentInitialize) ast - withBehaviors: { OnceBehavior } + ^ self haltOnComponentLifeCycle: #componentInitialize + ] { #category : #'*Molecule-IDE' } @@ -105,13 +100,27 @@ MolComponentImpl >> haltOnComponentInitialize [ ^ self class haltOnComponentInitialize ] +{ #category : #'*Molecule-IDE' } +MolComponentImpl classSide >> haltOnComponentLifeCycle: aSymbol [ + + | debugPoint condition | + "We need to use the lookup to access the method if it is present in the super class or the trait." + debugPoint := DebugPointManager + installNew: BreakDebugPoint + on: (self lookupSelector: aSymbol) ast + withBehaviors: { OnceBehavior }. + "We need to add a condition that check the class since the lookup will trigger for any class that have the targeted method, including all the trait users that may implement MolComponentImpl trait." + condition := ConditionBehavior new + condition: + ('self class = <1s>' expandMacrosWith: self name); + yourself. + debugPoint addBehavior: condition +] + { #category : #'*Molecule-IDE' } MolComponentImpl classSide >> haltOnComponentPassivate [ - ^ DebugPointManager - installNew: BreakDebugPoint - on: (self compiledMethodAt: #componentPassivate) ast - withBehaviors: { OnceBehavior } + ^ self haltOnComponentLifeCycle: #componentPassivate ] { #category : #'*Molecule-IDE' } @@ -123,13 +132,7 @@ MolComponentImpl >> haltOnComponentPassivate [ { #category : #'*Molecule-IDE' } MolComponentImpl classSide >> haltOnComponentRemove [ - self compiledMethodAt: #componentRemove ifPresent: [ :m | - ^ DebugPointManager - installNew: BreakDebugPoint - on: m ast - withBehaviors: { OnceBehavior . ConditionBehavior new condition: 'self=MolMyAlarmComponentImpl' } ]. - self halt. - self superclass isComponentClass ifTrue: [ self superclass haltOnComponentRemove ]. + ^ self haltOnComponentLifeCycle: #componentRemove ] { #category : #'*Molecule-IDE' } From 533a8ebc9612136e8e2004af25523415dfb6e68c Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Mon, 10 Feb 2025 10:30:25 +0100 Subject: [PATCH 4/9] apply molecule naming convention for cmd breakpoint --- ...olBreakOnComponentActivateCommand.class.st | 4 +- ...BreakOnComponentInitializeCommand.class.st | 6 +-- ...lBreakOnComponentPassivateCommand.class.st | 6 +-- .../MolBreakOnComponentRemoveCommand.class.st | 6 +-- .../MolComponentImpl.extension.st | 51 ++++++++++--------- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/Molecule-IDE/MolBreakOnComponentActivateCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentActivateCommand.class.st index 874e74a..d3cfadc 100644 --- a/src/Molecule-IDE/MolBreakOnComponentActivateCommand.class.st +++ b/src/Molecule-IDE/MolBreakOnComponentActivateCommand.class.st @@ -23,7 +23,7 @@ MolBreakOnComponentActivateCommand >> defaultMenuIconName [ { #category : #accessing } MolBreakOnComponentActivateCommand >> defaultMenuItemName [ - ^ 'Break once on #componentActivate' + ^ 'Break once when state switch to #activate' ] { #category : #accessing } @@ -35,5 +35,5 @@ MolBreakOnComponentActivateCommand >> description [ { #category : #accessing } MolBreakOnComponentActivateCommand >> execute [ - self selectedComponentClasses do: #haltOnComponentActivate + self selectedComponentClasses do: #breakOnceOnComponentActivate ] diff --git a/src/Molecule-IDE/MolBreakOnComponentInitializeCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentInitializeCommand.class.st index 3a4d015..8a8de5f 100644 --- a/src/Molecule-IDE/MolBreakOnComponentInitializeCommand.class.st +++ b/src/Molecule-IDE/MolBreakOnComponentInitializeCommand.class.st @@ -23,17 +23,17 @@ MolBreakOnComponentInitializeCommand >> defaultMenuIconName [ { #category : #accessing } MolBreakOnComponentInitializeCommand >> defaultMenuItemName [ - ^ 'Break once on #componentInitialize' + ^ 'Break once when state switch to #initialize' ] { #category : #accessing } MolBreakOnComponentInitializeCommand >> description [ - ^ 'Add a breakpoint that trigger once when #componentInitialize is call for this specific class.' + ^ 'Add a breakpoint that trigger once when #componentInitialize is call for any instances of this specific class.' ] { #category : #accessing } MolBreakOnComponentInitializeCommand >> execute [ - self selectedComponentClasses do: #haltOnComponentInitialize + self selectedComponentClasses do: #breakOnceOnComponentInitialize ] diff --git a/src/Molecule-IDE/MolBreakOnComponentPassivateCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentPassivateCommand.class.st index 83f558d..4849a99 100644 --- a/src/Molecule-IDE/MolBreakOnComponentPassivateCommand.class.st +++ b/src/Molecule-IDE/MolBreakOnComponentPassivateCommand.class.st @@ -23,17 +23,17 @@ MolBreakOnComponentPassivateCommand >> defaultMenuIconName [ { #category : #accessing } MolBreakOnComponentPassivateCommand >> defaultMenuItemName [ - ^ 'Break once on #componentPassivate' + ^ 'Break once when state switch to #passivate' ] { #category : #accessing } MolBreakOnComponentPassivateCommand >> description [ - ^ 'Add a breakpoint that trigger once when #componentPassivate is call for this specific class.' + ^ 'Add a breakpoint that trigger once when #componentPassivate is call for any instances of this specific class.' ] { #category : #accessing } MolBreakOnComponentPassivateCommand >> execute [ - self selectedComponentClasses do: #haltOnComponentPassivate + self selectedComponentClasses do: #breakOnceOnComponentPassivate ] diff --git a/src/Molecule-IDE/MolBreakOnComponentRemoveCommand.class.st b/src/Molecule-IDE/MolBreakOnComponentRemoveCommand.class.st index 922603f..5134715 100644 --- a/src/Molecule-IDE/MolBreakOnComponentRemoveCommand.class.st +++ b/src/Molecule-IDE/MolBreakOnComponentRemoveCommand.class.st @@ -23,17 +23,17 @@ MolBreakOnComponentRemoveCommand >> defaultMenuIconName [ { #category : #accessing } MolBreakOnComponentRemoveCommand >> defaultMenuItemName [ - ^ 'Break once on #componentRemove' + ^ 'Break once when state switch to #remove' ] { #category : #accessing } MolBreakOnComponentRemoveCommand >> description [ - ^ 'Add a breakpoint that trigger once when #componentRemove is call for this specific class.' + ^ 'Add a breakpoint that trigger once when #componentRemove is call for any instances of this specific class.' ] { #category : #accessing } MolBreakOnComponentRemoveCommand >> execute [ - self selectedComponentClasses do: #haltOnComponentRemove + self selectedComponentClasses do: #breakOnceOnComponentRemove ] diff --git a/src/Molecule-IDE/MolComponentImpl.extension.st b/src/Molecule-IDE/MolComponentImpl.extension.st index 5690e56..5aa01a3 100644 --- a/src/Molecule-IDE/MolComponentImpl.extension.st +++ b/src/Molecule-IDE/MolComponentImpl.extension.st @@ -76,32 +76,19 @@ MolComponentImpl >> asRSMoleculeShape [ ] { #category : #'*Molecule-IDE' } -MolComponentImpl classSide >> haltOnComponentActivate [ +MolComponentImpl classSide >> breakOnceOnComponentActivate [ - ^ self haltOnComponentLifeCycle: #componentActivate + ^ self breakOnceOnComponentLifeCycle: #componentActivate ] { #category : #'*Molecule-IDE' } -MolComponentImpl >> haltOnComponentActivate [ - - ^ self class haltOnComponentActivate -] - -{ #category : #'*Molecule-IDE' } -MolComponentImpl classSide >> haltOnComponentInitialize [ - - ^ self haltOnComponentLifeCycle: #componentInitialize +MolComponentImpl classSide >> breakOnceOnComponentInitialize [ + ^ self breakOnceOnComponentLifeCycle: #componentInitialize ] { #category : #'*Molecule-IDE' } -MolComponentImpl >> haltOnComponentInitialize [ - - ^ self class haltOnComponentInitialize -] - -{ #category : #'*Molecule-IDE' } -MolComponentImpl classSide >> haltOnComponentLifeCycle: aSymbol [ +MolComponentImpl classSide >> breakOnceOnComponentLifeCycle: aSymbol [ | debugPoint condition | "We need to use the lookup to access the method if it is present in the super class or the trait." @@ -109,30 +96,44 @@ MolComponentImpl classSide >> haltOnComponentLifeCycle: aSymbol [ installNew: BreakDebugPoint on: (self lookupSelector: aSymbol) ast withBehaviors: { OnceBehavior }. + "We need to add a condition that check the class since the lookup will trigger for any class that have the targeted method, including all the trait users that may implement MolComponentImpl trait." condition := ConditionBehavior new condition: ('self class = <1s>' expandMacrosWith: self name); yourself. - debugPoint addBehavior: condition + debugPoint addBehavior: condition. + ^ debugPoint ] { #category : #'*Molecule-IDE' } -MolComponentImpl classSide >> haltOnComponentPassivate [ +MolComponentImpl classSide >> breakOnceOnComponentPassivate [ - ^ self haltOnComponentLifeCycle: #componentPassivate + ^ self breakOnceOnComponentLifeCycle: #componentPassivate ] { #category : #'*Molecule-IDE' } -MolComponentImpl >> haltOnComponentPassivate [ +MolComponentImpl classSide >> breakOnceOnComponentRemove [ - ^ self haltOnceOnCallTo: #componentPassivate + ^ self breakOnceOnComponentLifeCycle: #componentRemove ] { #category : #'*Molecule-IDE' } -MolComponentImpl classSide >> haltOnComponentRemove [ +MolComponentImpl >> haltOnComponentActivate [ + + ^ self class haltOnComponentActivate +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> haltOnComponentInitialize [ - ^ self haltOnComponentLifeCycle: #componentRemove + ^ self class haltOnComponentInitialize +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> haltOnComponentPassivate [ + + ^ self haltOnceOnCallTo: #componentPassivate ] { #category : #'*Molecule-IDE' } From d733828847147197f3f3c037a5fa8705261ed55f Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Mon, 10 Feb 2025 10:42:36 +0100 Subject: [PATCH 5/9] Update the molecule world menu to display a graph icon and an inspect icon. --- src/Molecule-IDE/MolWorld.class.st | 37 ++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/Molecule-IDE/MolWorld.class.st b/src/Molecule-IDE/MolWorld.class.st index 5d62719..9f5c495 100644 --- a/src/Molecule-IDE/MolWorld.class.st +++ b/src/Molecule-IDE/MolWorld.class.st @@ -88,22 +88,39 @@ MolWorld class >> menu00MoleculeOn: aBuilder [ { #category : #menu } MolWorld class >> menu10SystemStatusOn: aBuilder [ + - (aBuilder item: #InspectComponents) parent: #MoleculeStatus; order: 1.0; action: [ - MolComponentManager isRunningComponents ifTrue:[ - "Inspect home services" - MolComponentManager default homeServices inspect - ] ifFalse:[ - "No component are running" - self inform: 'No components are running' - ]. - ]; + MolComponentManager isRunningComponents + ifTrue: [ "Inspect home services" + MolComponentManager default homeServices openRoassalView ] + ifFalse: [ "No component are running" + self inform: 'No components are running' ] ]; icon: MolIcon moleculeComponentIcon; - help: 'Component System Status, click to inspect running components. If no components are running there is an popup on the bottom left of the main Pharo windows.'; + help: + 'Click to open a graph of the deployed components. If no components are deployed there is an popup on the bottom left of the main Pharo windows.'; + label: 'Graph of deployed Components' +] + +{ #category : #menu } +MolWorld class >> menu11SystemStatusOn: aBuilder [ + + + (aBuilder item: #InspectComponents) + parent: #MoleculeStatus; + order: 1.1; + action: [ + MolComponentManager isRunningComponents + ifTrue: [ "Inspect home services" + MolComponentManager default homeServices inspect ] + ifFalse: [ "No component are running" + self inform: 'No components are running' ] ]; + icon: (self iconNamed: #inspect); + help: + 'Component System Status, click to inspect running components. If no components are running there is an popup on the bottom left of the main Pharo windows.'; label: 'Inspect running Components' ] From 479cd50a02a6869bbe07fe57d06db9df7f39ceae Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Mon, 10 Feb 2025 10:44:53 +0100 Subject: [PATCH 6/9] move the graph in the inspector of all component at the last position --- .../MolMyClockSystem.class.st | 49 +++++++++++-------- src/Molecule-IDE/MolHomeServices.extension.st | 2 +- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/Molecule-Examples/MolMyClockSystem.class.st b/src/Molecule-Examples/MolMyClockSystem.class.st index 4eb6c46..00556cf 100644 --- a/src/Molecule-Examples/MolMyClockSystem.class.st +++ b/src/Molecule-Examples/MolMyClockSystem.class.st @@ -44,45 +44,54 @@ MolMyClockSystem class >> start [ { #category : #launcher } MolMyClockSystem class >> startAlarmExample [ "Start Clock System example : simulate a clock alarm for sleeping !" + | now alarm alarmParameters alarmActivationServices isLogActive | - "Activate the Molecule log for display results" isLogActive := MolUtils isLogActive. - isLogActive ifFalse:[MolUtils toggleLog]. - + isLogActive ifFalse: [ MolUtils toggleLog ]. + "Dialog to inform user to open a Transcript to see results" - (UIManager default confirm: 'This example displays results in a transcript and stop after 10 seconds. + (UIManager default + confirm: + 'This example displays results in a transcript and stop after 10 seconds. Do you want to open a transcript window ?' - label: 'Molecule - Clock System Example') ifTrue:[Transcript open]. - + label: 'Molecule - Clock System Example') ifTrue: [ + Transcript open ]. + "Clean up the Component Manager in case of previous example running" MolComponentManager cleanUp. - + "Start the system" self start. - + "Configure an alarm in 5 seconds" now := Time now. - alarm := Time hour: now hour minute: now minute second: now second + 5. - + alarm := Time + hour: now hour + minute: now minute + second: now second + 5. + "The alarm is configured by MolMyClockSystem, we need to get manualy each services and parameters because MolMyClockSystem is not a Molecule component" "First : setup the time of the alarm" - alarmParameters := MolComponentManager default locatorServices searchParametersProviderFor: MolMyAlarmParameters. + alarmParameters := MolComponentManager default locatorServices + searchParametersProviderFor: MolMyAlarmParameters. alarmParameters setTime: alarm. - + "Second : activate the alarm" - alarmActivationServices := MolComponentManager default locatorServices searchServicesProviderFor: MolMyAlarmActivationServices. + alarmActivationServices := MolComponentManager default + locatorServices + searchServicesProviderFor: + MolMyAlarmActivationServices. alarmActivationServices activate. - + "Stop the system in 10 seconds" [ - (Duration seconds: 10) wait. - self stop. - "Clean up the Component Manager in case of next example running" - MolComponentManager cleanUp. - isLogActive ifFalse:[MolUtils toggleLog]. - ] fork. + (Duration seconds: 10000) wait. + self stop. + "Clean up the Component Manager in case of next example running" + MolComponentManager cleanUp. + isLogActive ifFalse: [ MolUtils toggleLog ] ] fork ] { #category : #'start-stop' } diff --git a/src/Molecule-IDE/MolHomeServices.extension.st b/src/Molecule-IDE/MolHomeServices.extension.st index dc768ea..be9f1c0 100644 --- a/src/Molecule-IDE/MolHomeServices.extension.st +++ b/src/Molecule-IDE/MolHomeServices.extension.st @@ -3,7 +3,7 @@ Extension { #name : #MolHomeServices } { #category : #'*Molecule-IDE' } MolHomeServices >> inspectionDeployedComponentsGraph [ - + | canvas components | self deployedComponents ifNil: [ ^ SpNullPresenter new ]. components := self deployedComponents flatCollect: #values. From 5aa12a48e45eac379e19fb8e8d92344980b3a7cc Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Mon, 10 Feb 2025 11:42:20 +0100 Subject: [PATCH 7/9] add object oriented breakpoint through the correct api for component --- .../MolComponentImpl.extension.st | 100 +++++++++++------- .../MolComponentToRoassal.class.st | 27 ++++- src/Molecule-IDE/MolHomeServices.extension.st | 2 +- ...terfacesImplementationsCmdCommand.class.st | 15 ++- .../MolInterfaceCmdCommand.class.st | 13 +-- src/Molecule-IDE/MolRSContractModel.class.st | 8 ++ 6 files changed, 117 insertions(+), 48 deletions(-) diff --git a/src/Molecule-IDE/MolComponentImpl.extension.st b/src/Molecule-IDE/MolComponentImpl.extension.st index 5aa01a3..be03c90 100644 --- a/src/Molecule-IDE/MolComponentImpl.extension.st +++ b/src/Molecule-IDE/MolComponentImpl.extension.st @@ -51,30 +51,78 @@ MolComponentImpl >> asRSMoleculeShape [ selector: #browse argument: #( )) icon: (Smalltalk ui icons iconNamed: #nautilus). aMenuMorph addSeparator. - (aMenuMorph - add: 'Halt Once when new component #initialize' - target: self - selector: #haltOnComponentInitialize) icon: + (aMenuMorph + add: 'Break once when state switch to #initialize' + target: self class + selector: #breakOnceOnComponentInitialize) icon: (Smalltalk ui icons iconNamed: #halt). - (aMenuMorph - add: 'Halt Once when new component #activate' - target: self - selector: #haltOnComponentActivate) icon: + (aMenuMorph + add: 'Break once when state switch to #activate' + target: self class + selector: #breakOnceOnComponentActivate) icon: (Smalltalk ui icons iconNamed: #halt). (aMenuMorph - add: 'Halt when #passivate' - target: self - selector: #haltOnComponentPassivate) icon: + add: 'Break once when state switch to #passivate' + target: self class + selector: #breakOnceOnComponentPassivate) icon: (Smalltalk ui icons iconNamed: #halt). (aMenuMorph - add: 'Halt when #remove' + add: 'Break once when state switch to #remove' + target: self class + selector: #breakOnceOnComponentRemove) icon: + (Smalltalk ui icons iconNamed: #halt). + (aMenuMorph + add: 'Break once when this component state switch to #activate' + target: self + selector: #breakObjectOrientedOnceOnComponentActivate) icon: + (Smalltalk ui icons iconNamed: #bug). + (aMenuMorph + add: 'Break once when state this component switch to #passivate' + target: self + selector: #breakObjectOrientedOnceOnComponentPassivate) icon: + (Smalltalk ui icons iconNamed: #bug). + (aMenuMorph + add: 'Break once when state this component switch to #remove' target: self - selector: #haltOnComponentRemove) icon: - (Smalltalk ui icons iconNamed: #halt) ]). + selector: #breakObjectOrientedOnceOnComponentRemove) icon: + (Smalltalk ui icons iconNamed: #bug) + + ]). + ^ composite ] +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> breakObjectOrientedOnceOnComponentActivate [ + + ^ self breakObjectOrientedOnceOnComponentLifeCycle: #componentActivate +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> breakObjectOrientedOnceOnComponentLifeCycle: aSymbol [ + + "We need to use the lookup to access the method if it is present in the super class or the trait." + ^ DebugPointManager + installNew: BreakDebugPoint + on: (self class lookupSelector: aSymbol) ast + forObject: self + withBehaviors: { OnceBehavior }. + +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> breakObjectOrientedOnceOnComponentPassivate [ + + ^ self breakObjectOrientedOnceOnComponentLifeCycle: #componentPassivate +] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> breakObjectOrientedOnceOnComponentRemove [ + + ^ self breakObjectOrientedOnceOnComponentLifeCycle: #componentRemove +] + { #category : #'*Molecule-IDE' } MolComponentImpl classSide >> breakOnceOnComponentActivate [ @@ -118,30 +166,6 @@ MolComponentImpl classSide >> breakOnceOnComponentRemove [ ^ self breakOnceOnComponentLifeCycle: #componentRemove ] -{ #category : #'*Molecule-IDE' } -MolComponentImpl >> haltOnComponentActivate [ - - ^ self class haltOnComponentActivate -] - -{ #category : #'*Molecule-IDE' } -MolComponentImpl >> haltOnComponentInitialize [ - - ^ self class haltOnComponentInitialize -] - -{ #category : #'*Molecule-IDE' } -MolComponentImpl >> haltOnComponentPassivate [ - - ^ self haltOnceOnCallTo: #componentPassivate -] - -{ #category : #'*Molecule-IDE' } -MolComponentImpl >> haltOnComponentRemove [ - - ^ self haltOnceOnCallTo: #componentRemove -] - { #category : #'*Molecule-IDE' } MolComponentImpl >> inspectionComponent [ diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index 7ea15cd..85897fb 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -92,6 +92,16 @@ MolComponentToRoassal class >> associationsAllUsedServicesAndTargetsFor: aMolCom ifNil: [ { } ] ] +{ #category : #color } +MolComponentToRoassal class >> browseLabelFor: aMolRSContractModel [ + + (aMolRSContractModel eventClass includesTrait: MolComponentEvents) + ifTrue: [ ^ 'Browse Events Trait' ]. + (aMolRSContractModel eventClass includesTrait: MolComponentServices) + ifTrue: [ ^ 'Browse Services Trait' ]. + ^ 'Browse Parameters Trait' +] + { #category : #'instance creation' } MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfComponents [ @@ -388,10 +398,15 @@ MolComponentToRoassal class >> makeSingleContractShapeFor: aMolRSContractModel [ | separator | separator := false. (aMenuMorph - add: 'Browse Trait' + add: (self browseLabelFor: aMolRSContractModel) target: aMolRSContractModel eventClass selector: #browse argument: #( )) icon: (Smalltalk ui icons iconNamed: #nautilus). + (aMenuMorph + add: (self usersLabelFor: aMolRSContractModel) + target: aMolRSContractModel + selector: #showContractUsers + argument: #( )) icon: (Smalltalk ui icons iconNamed: #references). aMolRSContractModel eventClass selectors do: [ :selector | separator ifFalse: [ separator := true. @@ -472,6 +487,16 @@ MolComponentToRoassal class >> serviceLogo [ rsLogoOut } ] +{ #category : #color } +MolComponentToRoassal class >> usersLabelFor: aMolRSContractModel [ + + (aMolRSContractModel eventClass includesTrait: MolComponentEvents) + ifTrue: [ ^ 'See Component Types that uses this Events' ]. + (aMolRSContractModel eventClass includesTrait: MolComponentServices) + ifTrue: [ ^ 'See Component Types that uses this Services' ]. + ^ 'See Component Types that uses this Parameters' +] + { #category : #'see class side' } MolComponentToRoassal >> seeClassSide [ ] diff --git a/src/Molecule-IDE/MolHomeServices.extension.st b/src/Molecule-IDE/MolHomeServices.extension.st index be9f1c0..a5df138 100644 --- a/src/Molecule-IDE/MolHomeServices.extension.st +++ b/src/Molecule-IDE/MolHomeServices.extension.st @@ -23,5 +23,5 @@ MolHomeServices >> openRoassalView [ canvas := MolComponentToRoassal canvasFromMultipleComponents: components. - ^ canvas openWithTitle: 'MolHomeService' + ^ canvas openWithTitle: 'All deployed components' ] diff --git a/src/Molecule-IDE/MolInspectInterfacesImplementationsCmdCommand.class.st b/src/Molecule-IDE/MolInspectInterfacesImplementationsCmdCommand.class.st index 4fbc19f..864af61 100644 --- a/src/Molecule-IDE/MolInspectInterfacesImplementationsCmdCommand.class.st +++ b/src/Molecule-IDE/MolInspectInterfacesImplementationsCmdCommand.class.st @@ -13,13 +13,24 @@ MolInspectInterfacesImplementationsCmdCommand class >> browserMenuActivation [ { #category : #accessing } MolInspectInterfacesImplementationsCmdCommand >> defaultMenuIconName [ - ^ #inspect + ^ #references ] { #category : #accessing } MolInspectInterfacesImplementationsCmdCommand >> defaultMenuItemName [ - ^ 'See Component users' + | contractType | + self selectedInterfaceClasses ifNil: [ ^ 'nothing' ]. + self selectedInterfaceClasses ifEmpty: [ ^ 'nothing' ]. + contractType := 'Unknow contract'. + (self selectedInterfaceClasses first usesTrait: MolComponentEvents) + ifTrue: [ contractType := 'Events' ]. + (self selectedInterfaceClasses first usesTrait: MolComponentServices) + ifTrue: [ contractType := 'Services' ]. + (self selectedInterfaceClasses first usesTrait: MolComponentParameters) + ifTrue: [ contractType := 'Parameters' ]. + ^ 'See Component Types that uses this <1s>' expandMacrosWith: + contractType ] { #category : #accessing } diff --git a/src/Molecule-IDE/MolInterfaceCmdCommand.class.st b/src/Molecule-IDE/MolInterfaceCmdCommand.class.st index 1642293..592f2bb 100644 --- a/src/Molecule-IDE/MolInterfaceCmdCommand.class.st +++ b/src/Molecule-IDE/MolInterfaceCmdCommand.class.st @@ -28,20 +28,21 @@ MolInterfaceCmdCommand class >> canBeExecutedInContext: aToolContext [ ] { #category : #execution } -MolInterfaceCmdCommand >> prepareFullExecutionInContext: aToolContext [ +MolInterfaceCmdCommand >> readParametersFromContext: aToolContext [ super prepareFullExecutionInContext: aToolContext. selectedInterfaceClasses := aToolContext selectedItems collect: [ :p | p browserItem actualObject ] thenSelect: [ :c | - c isTrait and: [ - c isComponentEvents or: [ - c isComponentParameters or: [ - c isComponentServices ] ] ] ] + c isTrait and: [ + c isComponentEvents or: [ + c isComponentParameters or: [ + c isComponentServices ] ] ] ] ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } MolInterfaceCmdCommand >> selectedInterfaceClasses [ + ^ selectedInterfaceClasses ] diff --git a/src/Molecule-IDE/MolRSContractModel.class.st b/src/Molecule-IDE/MolRSContractModel.class.st index df5add7..18bb1ba 100644 --- a/src/Molecule-IDE/MolRSContractModel.class.st +++ b/src/Molecule-IDE/MolRSContractModel.class.st @@ -116,3 +116,11 @@ MolRSContractModel >> shouldBreakOnCall [ ^ self explicitRequirement ] + +{ #category : #'as yet unclassified' } +MolRSContractModel >> showContractUsers [ + + MolInterfacesPresenter new + interface: self eventClass; + open +] From 4841fd30d42fd4c8e035a73d495c23b260d7000e Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Mon, 10 Feb 2025 17:18:22 +0100 Subject: [PATCH 8/9] Add button on the Roassal view --- .../MolGeoPosExampleLauncher.class.st | 4 +++ .../MolMyClockSystem.class.st | 8 ++++- .../MolComponentImpl.extension.st | 36 ++++++++++++------- .../MolComponentToRoassal.class.st | 5 +-- src/Molecule-IDE/MolHomeServices.extension.st | 26 ++++++++++++-- ...pectTypeImplementationsCmdCommand.class.st | 2 +- src/Molecule-IDE/MolRSContractModel.class.st | 24 ++++++++++--- 7 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/Molecule-Examples/MolGeoPosExampleLauncher.class.st b/src/Molecule-Examples/MolGeoPosExampleLauncher.class.st index 88164e3..0d0d78c 100644 --- a/src/Molecule-Examples/MolGeoPosExampleLauncher.class.st +++ b/src/Molecule-Examples/MolGeoPosExampleLauncher.class.st @@ -98,3 +98,7 @@ MolGeoPosExampleLauncher class >> swapWiFi [ self stopCurrentGeoPosEquipment. MolWiFi start ] + +{ #category : #'see class side' } +MolGeoPosExampleLauncher >> seeClassSide [ +] diff --git a/src/Molecule-Examples/MolMyClockSystem.class.st b/src/Molecule-Examples/MolMyClockSystem.class.st index 00556cf..61f196e 100644 --- a/src/Molecule-Examples/MolMyClockSystem.class.st +++ b/src/Molecule-Examples/MolMyClockSystem.class.st @@ -87,7 +87,7 @@ MolMyClockSystem class >> startAlarmExample [ "Stop the system in 10 seconds" [ - (Duration seconds: 10000) wait. + (Duration seconds: 10) wait. self stop. "Clean up the Component Manager in case of next example running" MolComponentManager cleanUp. @@ -110,3 +110,9 @@ MolMyClockSystem class >> undeploy [ MolComponentManager default deploymentServices undeployComponentImplementation: MolMyAlarmComponentImpl. MolComponentManager default deploymentServices undeployComponentImplementation: MolMyUserFacadeComponentImpl. ] + +{ #category : #'see class side' } +MolMyClockSystem >> seeClassSide [ + + +] diff --git a/src/Molecule-IDE/MolComponentImpl.extension.st b/src/Molecule-IDE/MolComponentImpl.extension.st index be03c90..33aac10 100644 --- a/src/Molecule-IDE/MolComponentImpl.extension.st +++ b/src/Molecule-IDE/MolComponentImpl.extension.st @@ -50,6 +50,11 @@ MolComponentImpl >> asRSMoleculeShape [ target: self selector: #browse argument: #( )) icon: (Smalltalk ui icons iconNamed: #nautilus). + (aMenuMorph + add: 'Inspect component type implementors' + target: self + selector: #showComponentTypeImplementor + argument: #( )) icon: (Smalltalk ui icons iconNamed: #dropDown). aMenuMorph addSeparator. (aMenuMorph add: 'Break once when state switch to #initialize' @@ -71,24 +76,22 @@ MolComponentImpl >> asRSMoleculeShape [ target: self class selector: #breakOnceOnComponentRemove) icon: (Smalltalk ui icons iconNamed: #halt). - (aMenuMorph + (aMenuMorph add: 'Break once when this component state switch to #activate' target: self selector: #breakObjectOrientedOnceOnComponentActivate) icon: (Smalltalk ui icons iconNamed: #bug). - (aMenuMorph + (aMenuMorph add: 'Break once when state this component switch to #passivate' target: self selector: #breakObjectOrientedOnceOnComponentPassivate) icon: (Smalltalk ui icons iconNamed: #bug). - (aMenuMorph + (aMenuMorph add: 'Break once when state this component switch to #remove' target: self selector: #breakObjectOrientedOnceOnComponentRemove) icon: - (Smalltalk ui icons iconNamed: #bug) - - ]). - + (Smalltalk ui icons iconNamed: #bug) ]). + ^ composite ] @@ -101,14 +104,13 @@ MolComponentImpl >> breakObjectOrientedOnceOnComponentActivate [ { #category : #'*Molecule-IDE' } MolComponentImpl >> breakObjectOrientedOnceOnComponentLifeCycle: aSymbol [ - "We need to use the lookup to access the method if it is present in the super class or the trait." - ^ DebugPointManager - installNew: BreakDebugPoint - on: (self class lookupSelector: aSymbol) ast - forObject: self - withBehaviors: { OnceBehavior }. + ^ DebugPointManager + installNew: BreakDebugPoint + on: (self class lookupSelector: aSymbol) ast + forObject: self + withBehaviors: { OnceBehavior } ] { #category : #'*Molecule-IDE' } @@ -175,3 +177,11 @@ MolComponentImpl >> inspectionComponent [ canvas: (MolComponentToRoassal canvasFromSingleComponent: self); yourself ] + +{ #category : #'*Molecule-IDE' } +MolComponentImpl >> showComponentTypeImplementor [ + + ^ MolImplementationsPresenter new + type: self class componentType; + open +] diff --git a/src/Molecule-IDE/MolComponentToRoassal.class.st b/src/Molecule-IDE/MolComponentToRoassal.class.st index 85897fb..7dd296c 100644 --- a/src/Molecule-IDE/MolComponentToRoassal.class.st +++ b/src/Molecule-IDE/MolComponentToRoassal.class.st @@ -406,7 +406,8 @@ MolComponentToRoassal class >> makeSingleContractShapeFor: aMolRSContractModel [ add: (self usersLabelFor: aMolRSContractModel) target: aMolRSContractModel selector: #showContractUsers - argument: #( )) icon: (Smalltalk ui icons iconNamed: #references). + argument: #( )) icon: + (Smalltalk ui icons iconNamed: #references). aMolRSContractModel eventClass selectors do: [ :selector | separator ifFalse: [ separator := true. @@ -415,7 +416,7 @@ MolComponentToRoassal class >> makeSingleContractShapeFor: aMolRSContractModel [ add: (aMolRSContractModel breakpointLabelFor: selector) target: aMolRSContractModel selector: #addBreakpointFor: - argument: selector) icon: (Smalltalk ui icons iconNamed: #halt) ] ]). + argument: selector) icon: (Smalltalk ui icons iconNamed: #bug) ] ]). ^ composite ] diff --git a/src/Molecule-IDE/MolHomeServices.extension.st b/src/Molecule-IDE/MolHomeServices.extension.st index a5df138..2edda5a 100644 --- a/src/Molecule-IDE/MolHomeServices.extension.st +++ b/src/Molecule-IDE/MolHomeServices.extension.st @@ -18,10 +18,30 @@ MolHomeServices >> inspectionDeployedComponentsGraph [ { #category : #'*Molecule-IDE' } MolHomeServices >> openRoassalView [ - | components canvas | + | components canvas window | components := self deployedComponents flatCollect: #values. canvas := MolComponentToRoassal canvasFromMultipleComponents: components. - - ^ canvas openWithTitle: 'All deployed components' + canvas add: (RSLabel new + text: 'Inspect'; + isFixed: true; + position: 30 @ 10; + when: RSMouseClick do: [ :evt | self inspect ] for: self; + yourself). + canvas add: (RSLabel new + text: 'Refresh'; + isFixed: true; + position: 30 @ 30; + when: RSMouseClick do: [ :evt | + | extent position | + window ifNotNil: [ + extent := window extent. + position := window position. + window close. + self openRoassalView + extent: extent; + position: position ] ] + for: self; + yourself). + ^ window := canvas openWithTitle: 'All deployed components' ] diff --git a/src/Molecule-IDE/MolInspectTypeImplementationsCmdCommand.class.st b/src/Molecule-IDE/MolInspectTypeImplementationsCmdCommand.class.st index 8473894..6c85f22 100644 --- a/src/Molecule-IDE/MolInspectTypeImplementationsCmdCommand.class.st +++ b/src/Molecule-IDE/MolInspectTypeImplementationsCmdCommand.class.st @@ -13,7 +13,7 @@ MolInspectTypeImplementationsCmdCommand class >> browserMenuActivation [ { #category : #accessing } MolInspectTypeImplementationsCmdCommand >> defaultMenuIconName [ - ^ #inspect + ^ #dropDown ] { #category : #accessing } diff --git a/src/Molecule-IDE/MolRSContractModel.class.st b/src/Molecule-IDE/MolRSContractModel.class.st index 18bb1ba..557ea1b 100644 --- a/src/Molecule-IDE/MolRSContractModel.class.st +++ b/src/Molecule-IDE/MolRSContractModel.class.st @@ -43,7 +43,16 @@ MolRSContractModel >> addBreakpointFor: aSelector [ { #category : #debug } MolRSContractModel >> breakOnceOn: aSelector [ - self component breakOnceOnCallTo: aSelector + | method breakpoint | + method := self component class lookupSelector: aSelector. + breakpoint := BreakDebugPoint new. + breakpoint node: method ast. + breakpoint targetInstance: self component. + + DebugPointManager + installDebugPoint: breakpoint + withBehaviors: { OnceBehavior }. + ^ breakpoint ] { #category : #'as yet unclassified' } @@ -56,10 +65,15 @@ MolRSContractModel >> breakOnceOnBeforeSend: aSelector [ method ast sendNodes select: [ :node | node selector = aSelector ] ]. allASTSenderNodes do: [ :node | - DebugPointManager - installNew: BreakDebugPoint - on: node - withBehaviors: { OnceBehavior } ] + | breakpoint | + node methodNode methodClass = self component class ifTrue: [ + breakpoint := BreakDebugPoint new. + breakpoint node: node. + breakpoint targetInstance: self component. + + DebugPointManager + installDebugPoint: breakpoint + withBehaviors: { OnceBehavior } ] ] ] { #category : #'as yet unclassified' } From f1b38b9c1061f0173b3fbe67a80cf45b01909201 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Mon, 10 Feb 2025 17:26:33 +0100 Subject: [PATCH 9/9] Fix not passing test --- .../MolCmdCommandTest.class.st | 2 -- .../MolDefineComponentCmdCommand.class.st | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Molecule-IDE-Tests/MolCmdCommandTest.class.st b/src/Molecule-IDE-Tests/MolCmdCommandTest.class.st index 9d3a33c..ac5ae2c 100644 --- a/src/Molecule-IDE-Tests/MolCmdCommandTest.class.st +++ b/src/Molecule-IDE-Tests/MolCmdCommandTest.class.st @@ -55,14 +55,12 @@ MolCmdCommandTest >> testMolClassesCmdCommand [ menu prepareFullExecutionInContext: toolcontext. menu execute. self assert: menu executionResult equals: 0. - self assert: menu selectedClasses size equals: 0. self assert: menu selectedComponentClasses size equals: 0. self createToolContextForClasses: (Array with: MolGNSSGPS with: MolGNSSGalileo). menu prepareFullExecutionInContext: toolcontext. menu execute. self assert: menu executionResult equals: 2. - self assert: menu selectedClasses size equals: 2. self assert: menu selectedComponentClasses size equals: 2. ] diff --git a/src/Molecule-IDE/MolDefineComponentCmdCommand.class.st b/src/Molecule-IDE/MolDefineComponentCmdCommand.class.st index 0316438..9e71757 100644 --- a/src/Molecule-IDE/MolDefineComponentCmdCommand.class.st +++ b/src/Molecule-IDE/MolDefineComponentCmdCommand.class.st @@ -1,6 +1,9 @@ Class { #name : #MolDefineComponentCmdCommand, #superclass : #MolClassesCmdCommand, + #instVars : [ + 'executionResult' + ], #category : #'Molecule-IDE-Commands' } @@ -40,6 +43,7 @@ MolDefineComponentCmdCommand >> execute [ componentsToDefine do: [ :c | MolComponentFactory defineComponent: c ]. nbOfDefinedComponents := componentsToDefine size. + self executionResult: nbOfDefinedComponents. text := nbOfDefinedComponents = 1 ifTrue: [ @@ -52,3 +56,15 @@ MolDefineComponentCmdCommand >> execute [ MolUtils showInformation: text ] + +{ #category : #accessing } +MolDefineComponentCmdCommand >> executionResult [ + + ^ executionResult +] + +{ #category : #accessing } +MolDefineComponentCmdCommand >> executionResult: anObject [ + + executionResult := anObject +]