From 4c93ca8048ddc4bc4f8fd147c4c1b6b686ec6034 Mon Sep 17 00:00:00 2001 From: DEMAREY Christophe Date: Fri, 9 Aug 2024 17:01:30 +0200 Subject: [PATCH] implements method browsing. fixes #1583 --- .../SpCodePresenterTest.class.st | 25 +++++++++++++++++++ .../SpCodeSystemNavigationMock.class.st | 6 +++++ src/Spec2-Code/SpCodePresenter.class.st | 6 +++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/Spec2-Code-Tests/SpCodePresenterTest.class.st b/src/Spec2-Code-Tests/SpCodePresenterTest.class.st index c964aa2d..0efebcb5 100644 --- a/src/Spec2-Code-Tests/SpCodePresenterTest.class.st +++ b/src/Spec2-Code-Tests/SpCodePresenterTest.class.st @@ -177,6 +177,31 @@ SpCodePresenterTest >> testDoBrowseImplementors [ equals: { SpCodePresenterTest>>#testDoBrowseImplementors } ] +{ #category : 'tests - commands' } +SpCodePresenterTest >> testDoBrowseMethod [ + + | navigation | + navigation := SpCodeSystemNavigationMock new. + presenter systemNavigation: navigation. + presenter environment add: SpCodePresenterTest binding. + presenter environment add: SpCodeSystemNavigationMock binding. + presenter beForScripting. + self openInstance. + + + presenter text: 'Object'. + presenter doBrowseClass. + + self assert: navigation messageList isNil. + + navigation reset. + presenter text: 'selectAll'. + presenter doBrowseClass. + + self assert: navigation browseSelector notEmpty. + self assert: navigation browseSelector equals: #selectAll +] + { #category : 'tests - commands' } SpCodePresenterTest >> testDoBrowseMethodReferences [ diff --git a/src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st b/src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st index 8dfdaa2e..24b5b7e3 100644 --- a/src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st +++ b/src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st @@ -16,6 +16,12 @@ SpCodeSystemNavigationMock >> browse: aClass [ browseClass := aClass ] +{ #category : 'opening' } +SpCodeSystemNavigationMock >> browseAllImplementorsOf: aSelector [ + + browseSelector := aSelector +] + { #category : 'accessing' } SpCodeSystemNavigationMock >> browseClass [ diff --git a/src/Spec2-Code/SpCodePresenter.class.st b/src/Spec2-Code/SpCodePresenter.class.st index 2bff286a..67409430 100644 --- a/src/Spec2-Code/SpCodePresenter.class.st +++ b/src/Spec2-Code/SpCodePresenter.class.st @@ -283,8 +283,10 @@ SpCodePresenter >> doBrowseClass [ ifTrue: [ | classToBrowse | classToBrowse := self class environment at: result ifAbsent: [ nil ]. - classToBrowse ifNotNil: [ ^ self systemNavigation browse: classToBrowse ] ]. - self systemNavigation browse: result + classToBrowse ifNotNil: [ ^ self systemNavigation browse: classToBrowse ] ]. + result + ifNil: [ self systemNavigation browseAllImplementorsOf: self selectedTextOrLine asSymbol ] + ifNotNil: [ self systemNavigation browse: result ] ] { #category : 'commands' }