From 19cd24a00fc152524d5b787a1b38c8fe6ad6e15e Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Thu, 16 Oct 2025 14:57:40 +0200 Subject: [PATCH] Reduce code duplication cleanMultilineComments: is duplicated code --- .../FamixRepSmalltalkCleaner.class.st | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/FamixReplication-Smalltalk/FamixRepSmalltalkCleaner.class.st b/src/FamixReplication-Smalltalk/FamixRepSmalltalkCleaner.class.st index cb30348..c1d7f99 100644 --- a/src/FamixReplication-Smalltalk/FamixRepSmalltalkCleaner.class.st +++ b/src/FamixReplication-Smalltalk/FamixRepSmalltalkCleaner.class.st @@ -6,7 +6,7 @@ I am a cleaner to clean smalltalk method code for replication detection " Class { #name : 'FamixRepSmalltalkCleaner', - #superclass : 'FamixRepSourcesCleaner', + #superclass : 'FamixRepPairedCommentsCleaner', #category : 'FamixReplication-Smalltalk', #package : 'FamixReplication-Smalltalk' } @@ -22,28 +22,6 @@ FamixRepSmalltalkCleaner >> cleanLine: aText [ ^ (super cleanLine: aText) copyWithRegex: '\".*\"' matchesReplacedWith: '' ] -{ #category : 'actions' } -FamixRepSmalltalkCleaner >> cleanMultilineComments: aText [ - "removes all comments possibly spanning several lines without changing the number of lines - (a multi line comment becomes a set of empty lines)" - - | current commentStart commentEnd | - current := 1. - ^ String streamContents: [ :stream | - [ - commentStart := aText indexOf: $" startingAt: current. - commentEnd := aText indexOf: $" startingAt: commentStart + 1. - (commentStart > 0) and: [ commentEnd > 0 ] - ] whileTrue: [ - self copy: aText from: current to: commentStart - 1 into: stream. - current := commentStart + 1. - self copyAsEmptyLines: aText from: current to: commentEnd - 1 into: stream. - current := commentEnd + 1 - ]. - self copy: aText from: current toEndInto: stream -] -] - { #category : 'actions' } FamixRepSmalltalkCleaner >> isComment: aLine [ "we could have defined comment as @@ -52,3 +30,15 @@ FamixRepSmalltalkCleaner >> isComment: aLine [ ^ false ] + +{ #category : 'actions' } +FamixRepSmalltalkCleaner >> multilineCommentCloser [ + + ^ '"' +] + +{ #category : 'actions' } +FamixRepSmalltalkCleaner >> multilineCommentOpener [ + + ^ '"' +]