From af3ccb23bdf6e60eef7a4f31a2a1cba0793149e1 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Tue, 27 Aug 2024 17:37:04 -0300 Subject: [PATCH] Abstract away SearchMethodsForLocalizationMessagesRule (#130) --- ...NaturalLanguageTranslationScanner.class.st | 10 +---- ...ethodsForLocalizationMessagesRule.class.st | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 source/Buoy-Development-Tools-Pharo-12/SearchMethodsForLocalizationMessagesRule.class.st diff --git a/source/Buoy-Development-Tools-Pharo-12/NaturalLanguageTranslationScanner.class.st b/source/Buoy-Development-Tools-Pharo-12/NaturalLanguageTranslationScanner.class.st index a27c63a..6556a10 100644 --- a/source/Buoy-Development-Tools-Pharo-12/NaturalLanguageTranslationScanner.class.st +++ b/source/Buoy-Development-Tools-Pharo-12/NaturalLanguageTranslationScanner.class.st @@ -82,12 +82,6 @@ NaturalLanguageTranslationScanner >> projectName [ { #category : 'private' } NaturalLanguageTranslationScanner >> scanProjectMethodsCollectingTranslationsIn: stringsToTranslate [ - | searchRule | - searchRule := RBParseTreeLintRule new. - searchRule matcher - matches: '`#string localized' - do: [ :node :answer | stringsToTranslate add: node receiver value ]; - matches: '`#string localizedWithAll: `@values' - do: [ :node :answer | stringsToTranslate add: node receiver value ]. - searchRule runOnEnvironment: environment + ( SearchMethodsForLocalizationMessagesRule collectingTranslationsIn: stringsToTranslate ) + runOnEnvironment: environment ] diff --git a/source/Buoy-Development-Tools-Pharo-12/SearchMethodsForLocalizationMessagesRule.class.st b/source/Buoy-Development-Tools-Pharo-12/SearchMethodsForLocalizationMessagesRule.class.st new file mode 100644 index 0000000..fb13395 --- /dev/null +++ b/source/Buoy-Development-Tools-Pharo-12/SearchMethodsForLocalizationMessagesRule.class.st @@ -0,0 +1,38 @@ +Class { + #name : 'SearchMethodsForLocalizationMessagesRule', + #superclass : 'RBParseTreeLintRule', + #instVars : [ + 'stringsToTranslate' + ], + #category : 'Buoy-Development-Tools-Pharo-12', + #package : 'Buoy-Development-Tools-Pharo-12' +} + +{ #category : 'instance creation' } +SearchMethodsForLocalizationMessagesRule class >> collectingTranslationsIn: aCollection [ + + ^ self new initializeCollectingTranslationsIn: aCollection +] + +{ #category : 'initialization' } +SearchMethodsForLocalizationMessagesRule >> initialize [ + + super initialize. + matcher + matches: '`#string localized' + do: [ :node :answer | stringsToTranslate add: node receiver value ]; + matches: '`#string localizedWithAll: `@values' + do: [ :node :answer | stringsToTranslate add: node receiver value ] +] + +{ #category : 'initialization' } +SearchMethodsForLocalizationMessagesRule >> initializeCollectingTranslationsIn: aCollection [ + + stringsToTranslate := aCollection +] + +{ #category : 'accessing' } +SearchMethodsForLocalizationMessagesRule >> name [ + + ^ 'Search methods for localization messages' +]