From f268748daf8bc89a5a362dfbff2d4a326abab519 Mon Sep 17 00:00:00 2001 From: anquetil Date: Thu, 2 Jan 2025 10:41:39 +0100 Subject: [PATCH] Made FamixRepPairedCommentsCleaner abstract so that it does not appear in cleaner menu in the settings of the DuplicationBrowser --- .../FamixRepConfiguration.class.st | 28 ++++---- .../FamixRepDetector.class.st | 34 +++++----- .../FamixRepPairedCommentsCleaner.class.st | 20 ++++-- .../FamixRepSourcesCleaner.class.st | 36 +++++----- src/FamixReplication/FamixReplica.class.st | 64 +++++++++--------- .../FamixReplicatedFragment.class.st | 66 ++++++++++--------- .../FamixReplicationManager.class.st | 32 ++++----- .../FamixTFileNavigation.extension.st | 6 +- .../FamixTHasImmediateSource.extension.st | 6 +- .../FamixTIndexedFileNavigation.extension.st | 6 +- .../FamixTMultipleFileAnchor.extension.st | 6 +- .../FamixTSourceAnchor.extension.st | 6 +- .../FamixTSourceEntity.extension.st | 18 ++--- .../ManifestFamixReplication.class.st | 10 +-- .../MiReplicatInspectorExtension.class.st | 20 +++--- src/FamixReplication/MooseEntity.extension.st | 4 +- src/FamixReplication/MooseModel.extension.st | 30 ++++----- src/FamixReplication/Object.extension.st | 4 +- .../SequenceableCollection.extension.st | 4 +- src/FamixReplication/String.extension.st | 4 +- src/FamixReplication/package.st | 2 +- 21 files changed, 215 insertions(+), 191 deletions(-) diff --git a/src/FamixReplication/FamixRepConfiguration.class.st b/src/FamixReplication/FamixRepConfiguration.class.st index 735fb19..c77d2b3 100644 --- a/src/FamixReplication/FamixRepConfiguration.class.st +++ b/src/FamixReplication/FamixRepConfiguration.class.st @@ -23,18 +23,20 @@ Internal Representation and Key Implementation Points. sourcesCleaner: The cleaner used to clean the code before detecting replication. " Class { - #name : #FamixRepConfiguration, - #superclass : #Object, + #name : 'FamixRepConfiguration', + #superclass : 'Object', #instVars : [ 'sourcesCleaner', 'minimumNumberOfReplicas', 'minimumNumberOfCharacters', 'minimumNumberOfLines' ], - #category : #'FamixReplication-Detection' + #category : 'FamixReplication-Detection', + #package : 'FamixReplication', + #tag : 'Detection' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } FamixRepConfiguration class >> sourcesCleaner: aSourcesCleaner minimumNumberOfReplicas: anInteger ofLines: anotherInteger ofCharacters: yetAnotherInteger [ ^ self new minimumNumberOfReplicas: anInteger; @@ -43,47 +45,47 @@ FamixRepConfiguration class >> sourcesCleaner: aSourcesCleaner minimumNumberOfRe sourcesCleaner: aSourcesCleaner ] -{ #category : #'ston-core' } +{ #category : 'ston-core' } FamixRepConfiguration class >> stonName [ ^ #ReplicationConfiguration ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepConfiguration >> minimumNumberOfCharacters [ ^ minimumNumberOfCharacters ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepConfiguration >> minimumNumberOfCharacters: anInteger [ minimumNumberOfCharacters := anInteger ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepConfiguration >> minimumNumberOfLines [ ^ minimumNumberOfLines ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepConfiguration >> minimumNumberOfLines: anInteger [ minimumNumberOfLines := anInteger ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepConfiguration >> minimumNumberOfReplicas [ ^ minimumNumberOfReplicas ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepConfiguration >> minimumNumberOfReplicas: anInteger [ minimumNumberOfReplicas := anInteger ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepConfiguration >> sourcesCleaner [ ^ sourcesCleaner ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepConfiguration >> sourcesCleaner: aSourceCleaner [ sourcesCleaner := aSourceCleaner ] diff --git a/src/FamixReplication/FamixRepDetector.class.st b/src/FamixReplication/FamixRepDetector.class.st index 4adf46f..ba482ad 100644 --- a/src/FamixReplication/FamixRepDetector.class.st +++ b/src/FamixReplication/FamixRepDetector.class.st @@ -22,44 +22,46 @@ Internal Representation and Key Implementation Points. " Class { - #name : #FamixRepDetector, - #superclass : #Object, + #name : 'FamixRepDetector', + #superclass : 'Object', #instVars : [ 'bucket', 'configuration' ], - #category : #'FamixReplication-Detection' + #category : 'FamixReplication-Detection', + #package : 'FamixReplication', + #tag : 'Detection' } -{ #category : #execution } +{ #category : 'execution' } FamixRepDetector class >> runOn: aMooseGroup with: aConfiguration [ ^ self new configuration: aConfiguration; runOn: aMooseGroup ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepDetector >> bucket [ ^ bucket ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepDetector >> configuration [ ^ configuration ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepDetector >> configuration: aRepConfiguration [ configuration := aRepConfiguration ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepDetector >> detectReplicatedFragmentsOf: aSourcedEntity [ configuration sourcesCleaner reset. aSourcedEntity allSourceAnchorsDo: [ :sourceAnchor | self detectReplicatedFragmentsOf: aSourcedEntity sourceAnchor: sourceAnchor ] ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepDetector >> detectReplicatedFragmentsOf: anEntity sourceAnchor: sourceAnchor [ (self sourcesCleaner cleanedTextLines: sourceAnchor sourceText) ifNotEmpty: [ :lines | @@ -75,12 +77,12 @@ FamixRepDetector >> detectReplicatedFragmentsOf: anEntity sourceAnchor: sourceAn for: anEntity ] ] ] -{ #category : #private } +{ #category : 'private' } FamixRepDetector >> getHashFor: aCollectionOfLines concatenated: concatenateLines [ ^ concatenateLines hash * 10000000000000 + (String streamContents: [ :s | 1 to: aCollectionOfLines size do: [ :ind | s << (aCollectionOfLines at: ind) first ] ]) hash ] -{ #category : #private } +{ #category : 'private' } FamixRepDetector >> getReplicatedFragments [ ('Select cloned fragments from a bucket of ' , bucket values size asString , ' clones.') record. @@ -89,13 +91,13 @@ FamixRepDetector >> getReplicatedFragments [ yourself ] -{ #category : #initialization } +{ #category : 'initialization' } FamixRepDetector >> initialize [ super initialize. bucket := Dictionary new ] -{ #category : #private } +{ #category : 'private' } FamixRepDetector >> registerToBucket: aCollectionOfLines from: firstLineIndex to: lastLineIndex in: fileAnchor for: anEntity [ aCollectionOfLines concatenatesStrings ifNotEmpty: [ :concatenatedLines | @@ -110,7 +112,7 @@ FamixRepDetector >> registerToBucket: aCollectionOfLines from: firstLineIndex to ifAbsentPut: [ FamixReplicatedFragment with: replica ] ] ] -{ #category : #execution } +{ #category : 'execution' } FamixRepDetector >> runOn: aCollection [ | manager | @@ -139,7 +141,7 @@ FamixRepDetector >> runOn: aCollection [ ^ manager ] -{ #category : #execution } +{ #category : 'execution' } FamixRepDetector >> selectEntitiesWithEnoughInformationFrom: aCollection [ "I reject the entities that does not have a source anchor or whose source anchor does not know the start or the end position of the source in a file because in that case we will read everything and display wrong informations." @@ -162,7 +164,7 @@ FamixRepDetector >> selectEntitiesWithEnoughInformationFrom: aCollection [ ^ res ] -{ #category : #accessing } +{ #category : 'accessing' } FamixRepDetector >> sourcesCleaner [ ^ configuration sourcesCleaner ] diff --git a/src/FamixReplication/FamixRepPairedCommentsCleaner.class.st b/src/FamixReplication/FamixRepPairedCommentsCleaner.class.st index 4b1b36e..4f9f5fc 100644 --- a/src/FamixReplication/FamixRepPairedCommentsCleaner.class.st +++ b/src/FamixReplication/FamixRepPairedCommentsCleaner.class.st @@ -4,12 +4,20 @@ I am an code cleaner for languages that have ""paired"" comments, i.e. multiline Subclasses should define #multilineCommentOpener and #multilineCommentCloser to return the string marking beginning (resp. end) of a paired comment " Class { - #name : #FamixRepPairedCommentsCleaner, - #superclass : #FamixRepSourcesCleaner, - #category : #'FamixReplication-Detection' + #name : 'FamixRepPairedCommentsCleaner', + #superclass : 'FamixRepSourcesCleaner', + #category : 'FamixReplication-Detection', + #package : 'FamixReplication', + #tag : 'Detection' } -{ #category : #actions } +{ #category : 'testing' } +FamixRepPairedCommentsCleaner class >> availableForUser [ + + ^ self ~= FamixRepPairedCommentsCleaner +] + +{ #category : 'actions' } FamixRepPairedCommentsCleaner >> 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)" @@ -35,13 +43,13 @@ FamixRepPairedCommentsCleaner >> cleanMultilineComments: aText [ ] ] -{ #category : #actions } +{ #category : 'actions' } FamixRepPairedCommentsCleaner >> multilineCommentCloser [ "string of a paired comment closer (ex: '*/')" self subclassResponsibility ] -{ #category : #actions } +{ #category : 'actions' } FamixRepPairedCommentsCleaner >> multilineCommentOpener [ "string of a paired comment opener (ex: '/*')" self subclassResponsibility diff --git a/src/FamixReplication/FamixRepSourcesCleaner.class.st b/src/FamixReplication/FamixRepSourcesCleaner.class.st index 375bac8..3330d72 100644 --- a/src/FamixReplication/FamixRepSourcesCleaner.class.st +++ b/src/FamixReplication/FamixRepSourcesCleaner.class.st @@ -6,28 +6,30 @@ I am an cleaner providing methods to cleaning code before passing to the replica " Class { - #name : #FamixRepSourcesCleaner, - #superclass : #Object, - #category : #'FamixReplication-Detection' + #name : 'FamixRepSourcesCleaner', + #superclass : 'Object', + #category : 'FamixReplication-Detection', + #package : 'FamixReplication', + #tag : 'Detection' } -{ #category : #accessing } +{ #category : 'accessing' } FamixRepSourcesCleaner class >> allAvailableCleaners [ ^self withAllSubclasses select: [:cleaner | cleaner availableForUser] ] -{ #category : #testing } +{ #category : 'testing' } FamixRepSourcesCleaner class >> availableForUser [ ^ self ~= FamixRepSourcesCleaner ] -{ #category : #displaying } +{ #category : 'displaying' } FamixRepSourcesCleaner class >> displayString [ self subclassResponsibility ] -{ #category : #private } +{ #category : 'private' } FamixRepSourcesCleaner >> addCleanedVersionOf: aLine at: index to: lines [ "I clean a line and add it to the collection of lines if it's useful." @@ -36,7 +38,7 @@ FamixRepSourcesCleaner >> addCleanedVersionOf: aLine at: index to: lines [ (self cleanLine: aLine) ifNotEmpty: [ :cleanedLine | (self isComment: cleanedLine) ifFalse: [ lines add: index -> cleanedLine ] ] ] -{ #category : #actions } +{ #category : 'actions' } FamixRepSourcesCleaner >> cleanCommentLines: aCollectionOfLines [ "Clean end-of-line comments and empty lines This could be more elegant but be careful, I need to be fast and doing a collect with index then a reject is longer." @@ -46,7 +48,7 @@ FamixRepSourcesCleaner >> cleanCommentLines: aCollectionOfLines [ ^ lines ] -{ #category : #private } +{ #category : 'private' } FamixRepSourcesCleaner >> cleanLine: text [ ^ {(String space). (String tab). @@ -55,7 +57,7 @@ FamixRepSourcesCleaner >> cleanLine: text [ (String crlf)} inject: text into: [ :crtLine :space | crtLine copyReplaceAll: space with: '' ] ] -{ #category : #actions } +{ #category : 'actions' } FamixRepSourcesCleaner >> cleanMultilineComments: aText [ "should remove all comments possibly spanning several lines without changing the number of lines (a multi line comment becomes a set of empty lines) @@ -63,24 +65,24 @@ FamixRepSourcesCleaner >> cleanMultilineComments: aText [ ^aText ] -{ #category : #actions } +{ #category : 'actions' } FamixRepSourcesCleaner >> cleanedTextLines: aText [ ^self cleanCommentLines: (self cleanMultilineComments: aText) lines ] -{ #category : #private } +{ #category : 'private' } FamixRepSourcesCleaner >> copy: aString from: start to: end into: aStream [ start to: end do: [ :i | aStream nextPut: (aString at: i) ]. ^aStream ] -{ #category : #private } +{ #category : 'private' } FamixRepSourcesCleaner >> copy: aString from: start toEndInto: aStream [ start to: aString size do: [ :i | aStream nextPut: (aString at: i) ]. ^aStream ] -{ #category : #private } +{ #category : 'private' } FamixRepSourcesCleaner >> copyAsEmptyLines: aString from: start to: end into: aStream [ start to: end do: [ :i || c | c := aString at: i. @@ -90,18 +92,18 @@ FamixRepSourcesCleaner >> copyAsEmptyLines: aString from: start to: end into: aS ^aStream ] -{ #category : #initialization } +{ #category : 'initialization' } FamixRepSourcesCleaner >> initialize [ super initialize. self reset ] -{ #category : #private } +{ #category : 'private' } FamixRepSourcesCleaner >> isComment: aLine [ self subclassResponsibility ] -{ #category : #initialization } +{ #category : 'initialization' } FamixRepSourcesCleaner >> reset [ "By default I do nothing. For some cleaner maybe we need to reset it between each cleaning." diff --git a/src/FamixReplication/FamixReplica.class.st b/src/FamixReplication/FamixReplica.class.st index d6167a5..1c73115 100644 --- a/src/FamixReplication/FamixReplica.class.st +++ b/src/FamixReplication/FamixReplica.class.st @@ -16,8 +16,8 @@ Internal Representation and Key Implementation Points. " Class { - #name : #FamixReplica, - #superclass : #MooseEntity, + #name : 'FamixReplica', + #superclass : 'MooseEntity', #instVars : [ 'startLine', 'endLine', @@ -25,16 +25,18 @@ Class { 'fileAnchor', 'replicatedFragment' ], - #category : #'FamixReplication-Entities' + #category : 'FamixReplication-Entities', + #package : 'FamixReplication', + #tag : 'Entities' } -{ #category : #meta } +{ #category : 'meta' } FamixReplica class >> annotation [ ] -{ #category : #ston } +{ #category : 'ston' } FamixReplica class >> entityCustomizer [ ^ STONCustomizer @@ -48,7 +50,7 @@ FamixReplica class >> entityCustomizer [ writeBlock: [ :fragment | fragment entity mooseName ] ] -{ #category : #ston } +{ #category : 'ston' } FamixReplica class >> fileAnchorCustomizer [ ^ STONCustomizer @@ -61,7 +63,7 @@ FamixReplica class >> fileAnchorCustomizer [ writeBlock: [ :fragment | fragment fileAnchor fileName ] ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } FamixReplica class >> from: start to: end for: anEntity [ "Adds clone location in entity setted in this location" | result | @@ -75,7 +77,7 @@ FamixReplica class >> from: start to: end for: anEntity [ ^ result. ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } FamixReplica class >> from: start to: end in: fileAnchor for: anEntity [ ^ self new startLine: start; @@ -85,7 +87,7 @@ FamixReplica class >> from: start to: end in: fileAnchor for: anEntity [ yourself ] -{ #category : #ston } +{ #category : 'ston' } FamixReplica class >> stonAllInstVarNames [ "Here we need to keep the order of the variables because entity needs to be before fileAnchor, else it might be a problem during the import since the FileAnchor need to be imported AFTER the entity." @@ -94,19 +96,19 @@ FamixReplica class >> stonAllInstVarNames [ ^ super stonAllInstVarNames reject: [ :each | toReject includes: each ] ] -{ #category : #ston } +{ #category : 'ston' } FamixReplica class >> stonName [ ^ #Location ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> codeText [ | text | text := self entitySourceCode. ^ text copyFrom: (text intervalOfLine: self startLine) first to: (text intervalOfLine: self endLine) last ] -{ #category : #testing } +{ #category : 'testing' } FamixReplica >> concernSameSubjectAs: anotherReplica [ "Return true if my entity and file containing the sources are the same as the onthe replica." @@ -115,52 +117,52 @@ FamixReplica >> concernSameSubjectAs: anotherReplica [ ^ self fileAnchor = anotherReplica fileAnchor ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> endLine [ ^ endLine ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> endLine: anObject [ endLine := anObject ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> entity [ ^ entity ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> entity: anEntity [ entity := anEntity. ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> entitySourceCode [ ^ self fileAnchor sourceText ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> fileAnchor [ ^ fileAnchor ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> fileAnchor: aFileAnchor [ fileAnchor := aFileAnchor ] -{ #category : #testing } +{ #category : 'testing' } FamixReplica >> hasReplicatedFragment [ "If a replica does not have a replicated fragment it might mean that it was removed form the replication system and should not be considered for analysis anymore." ^ self replicatedFragment isNotNil ] -{ #category : #testing } +{ #category : 'testing' } FamixReplica >> isContiguousWith: anotherLocation [ "Return true if the duplication fragment is in the same file and overlapping with the fragment passed as parameter." @@ -169,25 +171,25 @@ FamixReplica >> isContiguousWith: anotherLocation [ ^ self startLine <= (anotherLocation endLine + 1) and: [ self endLine + 1 >= anotherLocation startLine ] ] -{ #category : #testing } +{ #category : 'testing' } FamixReplica >> isSupersetOfReplica: aReplica [ (self concernSameSubjectAs: aReplica) ifFalse: [ ^ false ]. ^ (aReplica startLine between: self startLine and: self endLine) and: [ aReplica endLine between: self startLine and: self endLine ] ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> length [ ^ self endLine - self startLine + 1 ] -{ #category : #'as yet unclassified' } +{ #category : 'as yet unclassified' } FamixReplica >> miReplicaInspectorExtension [ ^MiReplicatInspectorExtension on: self ] -{ #category : #printing } +{ #category : 'printing' } FamixReplica >> mooseNameOn: stream [ stream nextPutAll: 'Replica in '; @@ -201,34 +203,34 @@ FamixReplica >> mooseNameOn: stream [ nextPut: $) ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> name [ ^ self entity ifNil: [ #undefined ] ifNotNil: #name ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> replicaFileName [ self fileAnchor ifNotNil: [ :anchor | anchor isFileAnchor ifTrue: [ ^ anchor fileName ] ]. ^ 'no replica file name' ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> replicatedFragment [ ^ replicatedFragment ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> replicatedFragment: aReplicatedFragment [ replicatedFragment := aReplicatedFragment ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> startLine [ ^ startLine ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplica >> startLine: anObject [ startLine := anObject ] diff --git a/src/FamixReplication/FamixReplicatedFragment.class.st b/src/FamixReplication/FamixReplicatedFragment.class.st index b96dcd9..e7064d9 100644 --- a/src/FamixReplication/FamixReplicatedFragment.class.st +++ b/src/FamixReplication/FamixReplicatedFragment.class.st @@ -13,84 +13,86 @@ Internal Representation and Key Implementation Points. " Class { - #name : #FamixReplicatedFragment, - #superclass : #MooseEntity, + #name : 'FamixReplicatedFragment', + #superclass : 'MooseEntity', #instVars : [ 'replicas', 'fragmentName' ], - #category : #'FamixReplication-Entities' + #category : 'FamixReplication-Entities', + #package : 'FamixReplication', + #tag : 'Entities' } -{ #category : #meta } +{ #category : 'meta' } FamixReplicatedFragment class >> annotation [ ] -{ #category : #ston } +{ #category : 'ston' } FamixReplicatedFragment class >> stonAllInstVarNames [ ^ super stonAllInstVarNames \ {#mooseID . #cache . #entityAttributes . #mooseName . #mooseModel} ] -{ #category : #ston } +{ #category : 'ston' } FamixReplicatedFragment class >> stonName [ ^ #Fragment ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } FamixReplicatedFragment class >> with: aReplica [ ^ self new addReplica: aReplica; yourself ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicatedFragment >> addReplica: aFragmentLocation [ self replicas add: aFragmentLocation. aFragmentLocation replicatedFragment: self ] -{ #category : #testing } +{ #category : 'testing' } FamixReplicatedFragment >> allReplicasConcernSameFilesAs: anotherFragment [ self replicas size <= anotherFragment replicas size ifFalse: [ ^ false ]. ^ self replicas allSatisfy: [ :aReplica | anotherFragment replicas anySatisfy: [ :anotherReplica | anotherReplica concernSameSubjectAs: aReplica ] ] ] -{ #category : #enumerating } +{ #category : 'enumerating' } FamixReplicatedFragment >> averageNumberOfLines [ self replicas ifEmpty: [ ^ MooseUnavailableMetric ]. ^ (self replicas sum: #length) / self replicas size ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicatedFragment >> codeText [ ^ replicas anyOne codeText ] -{ #category : #enumerating } +{ #category : 'enumerating' } FamixReplicatedFragment >> entitiesContainingFragment [ ^ self replicas collectAsSet: #entity ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicatedFragment >> fragmentName [ ^ fragmentName ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicatedFragment >> fragmentName: aString [ fragmentName := aString. ] -{ #category : #ston } +{ #category : 'ston' } FamixReplicatedFragment >> fromSton: stonReader [ super fromSton: stonReader. self replicas do: [ :member | member replicatedFragment: self ] ] -{ #category : #merge } +{ #category : 'merge' } FamixReplicatedFragment >> getReplicaCorrespondingTo: aReplica [ | possibleFragments | "We need to check the file anchor because an entity can have multiple fileAnchor." @@ -105,27 +107,27 @@ FamixReplicatedFragment >> getReplicaCorrespondingTo: aReplica [ ifNone: [ nil ] ] ] -{ #category : #testing } +{ #category : 'testing' } FamixReplicatedFragment >> hasContiguousReplicaWith: aReplica [ ^ self replicas anySatisfy: [ :anotherReplica | aReplica isContiguousWith: anotherReplica ] ] -{ #category : #testing } +{ #category : 'testing' } FamixReplicatedFragment >> hasReplicas [ ^ self replicas isNotEmpty ] -{ #category : #testing } +{ #category : 'testing' } FamixReplicatedFragment >> includesAllReplicasOf: anotherFragment [ ^ anotherFragment replicas allSatisfy: [ :replica | self replicas anySatisfy: [ :anotherReplica | anotherReplica isSupersetOfReplica: replica ] ] ] -{ #category : #testing } +{ #category : 'testing' } FamixReplicatedFragment >> isReplicatedFragment [ ^ true ] -{ #category : #merge } +{ #category : 'merge' } FamixReplicatedFragment >> mergeWith: anotherFragment [ "I try to merge with another fragment. If I fail I return false to signal the merge was not finished." @@ -140,7 +142,7 @@ FamixReplicatedFragment >> mergeWith: anotherFragment [ ^ anotherFragment hasReplicas not ] -{ #category : #testing } +{ #category : 'testing' } FamixReplicatedFragment >> mergeableWith: anotherFragment [ anotherFragment = self ifTrue: [ ^ false ]. @@ -148,7 +150,7 @@ FamixReplicatedFragment >> mergeableWith: anotherFragment [ and: [ anotherFragment replicas allSatisfy: [ :replica | self hasContiguousReplicaWith: replica ] ] ] -{ #category : #'as yet unclassified' } +{ #category : 'as yet unclassified' } FamixReplicatedFragment >> miReplicasInspectorExtension [ ^SpTablePresenter new @@ -161,7 +163,7 @@ FamixReplicatedFragment >> miReplicasInspectorExtension [ yourself ] -{ #category : #printing } +{ #category : 'printing' } FamixReplicatedFragment >> mooseNameOn: aStream [ aStream nextPutAll: 'Replicated fragment '; @@ -170,7 +172,7 @@ FamixReplicatedFragment >> mooseNameOn: aStream [ nextPut: $] ] -{ #category : #printing } +{ #category : 'printing' } FamixReplicatedFragment >> printOn: aStream [ super printOn: aStream. aStream @@ -180,20 +182,20 @@ FamixReplicatedFragment >> printOn: aStream [ nextPutAll: ' fragments]' ] -{ #category : #private } +{ #category : 'private' } FamixReplicatedFragment >> properties [ ^ {('Number of files' -> self replicas size asString). ('Number of cloned lines' -> self averageNumberOfLines asInteger asString)} ] -{ #category : #merge } +{ #category : 'merge' } FamixReplicatedFragment >> registerReplicasInEntities [ "By default the replicas are not registered in entities since we create false result during the detection. Once it is done, we can register the non false positives." self replicas do: [ :replica | replica entity addReplica: replica ] ] -{ #category : #merge } +{ #category : 'merge' } FamixReplicatedFragment >> remove: aReplica [ aReplica entity removeReplica: aReplica. aReplica entity: nil. @@ -202,18 +204,18 @@ FamixReplicatedFragment >> remove: aReplica [ ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicatedFragment >> replicas [ ^ replicas ifNil: [ replicas := OrderedCollection new ] ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicatedFragment >> replicas: anObject [ replicas := anObject. ] -{ #category : #merge } +{ #category : 'merge' } FamixReplicatedFragment >> tryToExpandWith: anotherFragment [ "If it's the same fragment, we don't need to do anything." self = anotherFragment ifTrue: [ ^ self ]. @@ -231,7 +233,7 @@ FamixReplicatedFragment >> tryToExpandWith: anotherFragment [ aReplica endLine: (aReplica endLine max: anotherReplica endLine) ] ] ] ] -{ #category : #merge } +{ #category : 'merge' } FamixReplicatedFragment >> unregisterReplicasInEntities [ self replicas do: [ :replica | replica entity removeReplica: replica ] ] diff --git a/src/FamixReplication/FamixReplicationManager.class.st b/src/FamixReplication/FamixReplicationManager.class.st index 436b4f8..102db34 100644 --- a/src/FamixReplication/FamixReplicationManager.class.st +++ b/src/FamixReplication/FamixReplicationManager.class.st @@ -20,31 +20,33 @@ Internal Representation and Key Implementation Points. " Class { - #name : #FamixReplicationManager, - #superclass : #Object, + #name : 'FamixReplicationManager', + #superclass : 'Object', #instVars : [ 'configuration', 'replicatedFragments' ], - #category : #'FamixReplication-Entities' + #category : 'FamixReplication-Entities', + #package : 'FamixReplication', + #tag : 'Entities' } -{ #category : #ston } +{ #category : 'ston' } FamixReplicationManager class >> stonName [ ^ #DuplicationSystem ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicationManager >> configuration [ ^ configuration ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicationManager >> configuration: aConfiguration [ configuration := aConfiguration ] -{ #category : #improving } +{ #category : 'improving' } FamixReplicationManager >> expandContiguousFragments [ ('Expand ' , self replicatedFragments size asString , ' fragments.') record. @@ -55,7 +57,7 @@ FamixReplicationManager >> expandContiguousFragments [ ('New number of fragments: ' , self replicatedFragments size asString) record ] -{ #category : #postProcess } +{ #category : 'postProcess' } FamixReplicationManager >> mergeClosestOverlappingFragments: aCollectionOfFragments [ "In this method I'll try to merge a maximum of fragments but it will not be possible all the time because some fragments can be part of the same duplication but not be contigious yet. I should return true if the merge is finished and false if I was not able to merge all the possible fragments." @@ -80,7 +82,7 @@ FamixReplicationManager >> mergeClosestOverlappingFragments: aCollectionOfFragme ^ unmergedFragments ] -{ #category : #postProcess } +{ #category : 'postProcess' } FamixReplicationManager >> mergeClosestOverlappingFragmentsOf: aCollectionOfEntities [ "In this method I'll try to merge a maximum of fragments but it will not be possible all the time because some fragments can be part of the same duplication but not be contigious yet. I should return true if the merge is finished and false if I was not able to merge all the possible fragments." @@ -97,7 +99,7 @@ FamixReplicationManager >> mergeClosestOverlappingFragmentsOf: aCollectionOfEnti ^ unmergedEntities ] -{ #category : #postProcess } +{ #category : 'postProcess' } FamixReplicationManager >> mergeOverlappingFragments [ "In this method I merge some duplication fragments because if I have a fragment in an entity from line 10 to 15 and one from line 13 to 17, at the end it can be a fragment from line 10 to 17. It is not sure that we can do it in one iteration so I'll repeat the operation until I am able to fully merge all the fragments." @@ -108,7 +110,7 @@ FamixReplicationManager >> mergeOverlappingFragments [ unmergedFragments isEmpty ] whileFalse ] -{ #category : #cleaning } +{ #category : 'cleaning' } FamixReplicationManager >> removeDuplicatedFragments [ "After expending fragments it is possible that some end up been contained in other ones. In that case, we remove them" @@ -121,24 +123,24 @@ FamixReplicationManager >> removeDuplicatedFragments [ (self replicatedFragments reject: [ :each | fragmentsToKeep includes: each]) do: [ :each | self removeReplicatedFragment: each ] ] -{ #category : #removing } +{ #category : 'removing' } FamixReplicationManager >> removeReplicatedFragment: aFragment [ self replicatedFragments remove: aFragment ifAbsent: [ ('Duplication - Fragment not found: ' , aFragment asString) record ]. aFragment unregisterReplicasInEntities ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicationManager >> replicatedFragments [ ^ replicatedFragments ifNil: [ replicatedFragments := OrderedCollection new ] ] -{ #category : #accessing } +{ #category : 'accessing' } FamixReplicationManager >> replicatedFragments: aCollection [ replicatedFragments := OrderedCollection newFrom: aCollection. self resetFragmentNames. ] -{ #category : #'fragment-names' } +{ #category : 'fragment-names' } FamixReplicationManager >> resetFragmentNames [ replicatedFragments doWithIndex: [ :each :index | each fragmentName: 'Code Fragment ' , index asString ] ] diff --git a/src/FamixReplication/FamixTFileNavigation.extension.st b/src/FamixReplication/FamixTFileNavigation.extension.st index 58911ec..db82e77 100644 --- a/src/FamixReplication/FamixTFileNavigation.extension.st +++ b/src/FamixReplication/FamixTFileNavigation.extension.st @@ -1,11 +1,11 @@ -Extension { #name : #FamixTFileNavigation } +Extension { #name : 'FamixTFileNavigation' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTFileNavigation >> knowsEnd [ ^ self endLine isNotNil ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTFileNavigation >> knowsStart [ ^ self startLine isNotNil ] diff --git a/src/FamixReplication/FamixTHasImmediateSource.extension.st b/src/FamixReplication/FamixTHasImmediateSource.extension.st index 5d34172..b4fb77b 100644 --- a/src/FamixReplication/FamixTHasImmediateSource.extension.st +++ b/src/FamixReplication/FamixTHasImmediateSource.extension.st @@ -1,11 +1,11 @@ -Extension { #name : #FamixTHasImmediateSource } +Extension { #name : 'FamixTHasImmediateSource' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTHasImmediateSource >> knowsEnd [ ^ self source isNotEmpty ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTHasImmediateSource >> knowsStart [ ^ self source isNotEmpty ] diff --git a/src/FamixReplication/FamixTIndexedFileNavigation.extension.st b/src/FamixReplication/FamixTIndexedFileNavigation.extension.st index f99967a..bd961e7 100644 --- a/src/FamixReplication/FamixTIndexedFileNavigation.extension.st +++ b/src/FamixReplication/FamixTIndexedFileNavigation.extension.st @@ -1,11 +1,11 @@ -Extension { #name : #FamixTIndexedFileNavigation } +Extension { #name : 'FamixTIndexedFileNavigation' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTIndexedFileNavigation >> knowsEnd [ ^ self endPos isNotNil ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTIndexedFileNavigation >> knowsStart [ ^ self startPos isNotNil ] diff --git a/src/FamixReplication/FamixTMultipleFileAnchor.extension.st b/src/FamixReplication/FamixTMultipleFileAnchor.extension.st index e178eba..54f8527 100644 --- a/src/FamixReplication/FamixTMultipleFileAnchor.extension.st +++ b/src/FamixReplication/FamixTMultipleFileAnchor.extension.st @@ -1,11 +1,11 @@ -Extension { #name : #FamixTMultipleFileAnchor } +Extension { #name : 'FamixTMultipleFileAnchor' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTMultipleFileAnchor >> knowsEnd [ ^ self allSourceAnchors allSatisfy: #knowsEnd ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTMultipleFileAnchor >> knowsStart [ ^ self allSourceAnchors allSatisfy: #knowsStart ] diff --git a/src/FamixReplication/FamixTSourceAnchor.extension.st b/src/FamixReplication/FamixTSourceAnchor.extension.st index 14caf04..392a73a 100644 --- a/src/FamixReplication/FamixTSourceAnchor.extension.st +++ b/src/FamixReplication/FamixTSourceAnchor.extension.st @@ -1,11 +1,11 @@ -Extension { #name : #FamixTSourceAnchor } +Extension { #name : 'FamixTSourceAnchor' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceAnchor >> knowsEnd [ ^ self explicitRequirement ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceAnchor >> knowsStart [ ^ self explicitRequirement ] diff --git a/src/FamixReplication/FamixTSourceEntity.extension.st b/src/FamixReplication/FamixTSourceEntity.extension.st index 1cd7a85..c48b953 100644 --- a/src/FamixReplication/FamixTSourceEntity.extension.st +++ b/src/FamixReplication/FamixTSourceEntity.extension.st @@ -1,23 +1,23 @@ -Extension { #name : #FamixTSourceEntity } +Extension { #name : 'FamixTSourceEntity' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceEntity >> addReplica: anObject [ self replicas add: anObject ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceEntity >> clearReplicationCache [ self propertyNamed: #replicas put: OrderedCollection new ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceEntity >> codeReplicationIntervals [ | text | text := self completeText. ^ self replicas collect: [ :aCloneLocation | (text intervalOfLine: aCloneLocation startLine) first to: (text intervalOfLine: aCloneLocation endLine) last ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceEntity >> containsReplicas [ @@ -27,7 +27,7 @@ FamixTSourceEntity >> containsReplicas [ ^ self children anySatisfy: #containsReplicas ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceEntity >> duplicationRate [ @@ -58,7 +58,7 @@ FamixTSourceEntity >> duplicationRate [ (accumulator + usefulCloneLocations anyOne length) / self numberOfLinesOfCode ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceEntity >> mergePossibleDuplications [ "I try to merge the duplication and if I fail I return false." @@ -71,12 +71,12 @@ FamixTSourceEntity >> mergePossibleDuplications [ ^ wasAbleToMergeAll ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceEntity >> removeReplica: aReplica [ self containsReplicas ifTrue: [ self replicas remove: aReplica ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } FamixTSourceEntity >> replicas [ diff --git a/src/FamixReplication/ManifestFamixReplication.class.st b/src/FamixReplication/ManifestFamixReplication.class.st index 2f98f8f..bc72d5d 100644 --- a/src/FamixReplication/ManifestFamixReplication.class.st +++ b/src/FamixReplication/ManifestFamixReplication.class.st @@ -2,12 +2,14 @@ I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser " Class { - #name : #ManifestFamixReplication, - #superclass : #PackageManifest, - #category : #'FamixReplication-Manifest' + #name : 'ManifestFamixReplication', + #superclass : 'PackageManifest', + #category : 'FamixReplication-Manifest', + #package : 'FamixReplication', + #tag : 'Manifest' } -{ #category : #asserting } +{ #category : 'asserting' } ManifestFamixReplication class >> shouldBeIncludedByDefaultInMetamodelsWith: aCollectionOfPackages [ ^ true ] diff --git a/src/FamixReplication/MiReplicatInspectorExtension.class.st b/src/FamixReplication/MiReplicatInspectorExtension.class.st index 3c933b7..c2b9dc9 100644 --- a/src/FamixReplication/MiReplicatInspectorExtension.class.st +++ b/src/FamixReplication/MiReplicatInspectorExtension.class.st @@ -1,15 +1,17 @@ Class { - #name : #MiReplicatInspectorExtension, - #superclass : #SpPresenter, + #name : 'MiReplicatInspectorExtension', + #superclass : 'SpPresenter', #instVars : [ 'sourceText', 'properties', 'replica' ], - #category : #'FamixReplication-Entities' + #category : 'FamixReplication-Entities', + #package : 'FamixReplication', + #tag : 'Entities' } -{ #category : #private } +{ #category : 'private' } MiReplicatInspectorExtension >> highlightedReplicaText [ | text start end | @@ -23,7 +25,7 @@ MiReplicatInspectorExtension >> highlightedReplicaText [ ^text ] -{ #category : #initialization } +{ #category : 'initialization' } MiReplicatInspectorExtension >> initializeLayout [ self layout: (SpBoxLayout newTopToBottom add: #properties height: (self propertyTableHeight); @@ -32,7 +34,7 @@ MiReplicatInspectorExtension >> initializeLayout [ ] -{ #category : #initialization } +{ #category : 'initialization' } MiReplicatInspectorExtension >> initializePresenters [ properties := self newTable. properties @@ -53,7 +55,7 @@ MiReplicatInspectorExtension >> initializePresenters [ self initializeLayout . ] -{ #category : #private } +{ #category : 'private' } MiReplicatInspectorExtension >> lineStart: line in: text [ | i pos | i := 1. @@ -65,12 +67,12 @@ MiReplicatInspectorExtension >> lineStart: line in: text [ ^pos > text size ifTrue: [ text size ] ifFalse: [ pos ] ] -{ #category : #accessing } +{ #category : 'accessing' } MiReplicatInspectorExtension >> propertyTableHeight [ ^self class toolbarHeight *4 ] -{ #category : #initialization } +{ #category : 'initialization' } MiReplicatInspectorExtension >> setModelBeforeInitialization: aDomainObject [ replica := aDomainObject ] diff --git a/src/FamixReplication/MooseEntity.extension.st b/src/FamixReplication/MooseEntity.extension.st index f994fc8..aa9fee7 100644 --- a/src/FamixReplication/MooseEntity.extension.st +++ b/src/FamixReplication/MooseEntity.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #MooseEntity } +Extension { #name : 'MooseEntity' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseEntity >> containsReplicas [ ^ false ] diff --git a/src/FamixReplication/MooseModel.extension.st b/src/FamixReplication/MooseModel.extension.st index 26fdaa7..81a5d7b 100644 --- a/src/FamixReplication/MooseModel.extension.st +++ b/src/FamixReplication/MooseModel.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #MooseModel } +Extension { #name : 'MooseModel' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> allBehaviouralsWithDuplicatedCode [ ^ self @@ -13,7 +13,7 @@ MooseModel >> allBehaviouralsWithDuplicatedCode [ self allModelBehaviourals select: #containsReplicas ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> allContainersWithDuplicatedCode [ ^ self @@ -26,13 +26,13 @@ MooseModel >> allContainersWithDuplicatedCode [ self allModelContainers select: #containsReplicas ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> allReplicatedFragments [ ^ self replicationManager ifNotNil: #replicatedFragments ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> clearReplicationManager [ 'Clear replication manager' record. self entitiesForReplicationDetection do: #clearReplicationCache. @@ -40,14 +40,14 @@ MooseModel >> clearReplicationManager [ self removeCache: #allContainersWithDuplicatedCode ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> defaultDetectionConfiguration [ "By default if we do not set a replication detection configuration, we do not run the detection" ^ nil ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> duplicationRate [ "I return a metric that correspond to the percentage of duplication in the code." @@ -60,14 +60,14 @@ MooseModel >> duplicationRate [ do: [ MooseUnavailableMetric ] ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> entitiesForReplicationDetection [ "Override this depending on your model." ^ self allModelContainers ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> exportReplicationTo: file [ self execute: [ self detectEncodingOfAllFileAnchors. @@ -75,7 +75,7 @@ MooseModel >> exportReplicationTo: file [ recordedAs: 'Duplication export' ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> importReplicationFrom: file [ self execute: [ file @@ -86,7 +86,7 @@ MooseModel >> importReplicationFrom: file [ recordedAs: 'Loading of duplication' ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> initializeReplicationManager [ self clearReplicationManager. @@ -98,12 +98,12 @@ MooseModel >> initializeReplicationManager [ (FamixRepDetector runOn: self entitiesForReplicationDetection with: config) in: [ :manager | self replicationManager: manager ] ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> replicationDetectionConfiguration [ ^ self attributeAt: #replicationManager ifAbsentPut: [ self defaultDetectionConfiguration ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> replicationDetectionConfiguration: aConfiguration [ "Example: @@ -118,12 +118,12 @@ MooseModel >> replicationDetectionConfiguration: aConfiguration [ self attributeAt: #replicationManager put: aConfiguration ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> replicationManager [ ^ self attributeAt: #replicationManager ifAbsent: [ self initializeReplicationManager ] ] -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } MooseModel >> replicationManager: anObject [ ^ self attributeAt: #replicationManager put: anObject ] diff --git a/src/FamixReplication/Object.extension.st b/src/FamixReplication/Object.extension.st index 2b00854..c87e2e4 100644 --- a/src/FamixReplication/Object.extension.st +++ b/src/FamixReplication/Object.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #Object } +Extension { #name : 'Object' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } Object >> isReplicatedFragment [ ^ false ] diff --git a/src/FamixReplication/SequenceableCollection.extension.st b/src/FamixReplication/SequenceableCollection.extension.st index ad48a8f..c04a040 100644 --- a/src/FamixReplication/SequenceableCollection.extension.st +++ b/src/FamixReplication/SequenceableCollection.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #SequenceableCollection } +Extension { #name : 'SequenceableCollection' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } SequenceableCollection >> concatenatesStrings [ "Takes as predicament that the collection contains only string and return the concatenation of all string. diff --git a/src/FamixReplication/String.extension.st b/src/FamixReplication/String.extension.st index 113db43..d01173c 100644 --- a/src/FamixReplication/String.extension.st +++ b/src/FamixReplication/String.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #String } +Extension { #name : 'String' } -{ #category : #'*FamixReplication' } +{ #category : '*FamixReplication' } String >> copyUpToSubString: aSubString [ "I am a fast way to copy a string up to a substring. If you remove me, do some benchmark of the new solution because I'm use heavily in FamixReplication and this might cause trouble with the performances." diff --git a/src/FamixReplication/package.st b/src/FamixReplication/package.st index b1647e8..f174af4 100644 --- a/src/FamixReplication/package.st +++ b/src/FamixReplication/package.st @@ -1 +1 @@ -Package { #name : #FamixReplication } +Package { #name : 'FamixReplication' }