Cyril a meta remark\ Better define the block as a method so that we can reuse it.
Hi,
Here is the implémentation of FAMIXFile>>numberOfCharacters
numberOfCharacters <MSEProperty: #numberOfCharacters type: #Number> <MSEComment: 'Number of characters in a file.'>
<derived> ^ self lookUpPropertyNamed: #numberOfCharacters computedAs: [ | result | result := self fileExists ifTrue: [ self sourceText size - self totalNumberOfLinesOfText + 1 ] ifFalse: [ 0 ]. result max: 0 ]
I see some problems on this implémentation.
IIUC, we take the size of the source text and we remove 1 for each line return. This is wrong because in case of CRLF the lines returns are two characters long. I think that it would be better to have:
self sourceText lines ifEmpty: [ 0 ] ifNotEmpty: [ :lines | lines sum: #size ]
if lines handles it. Now you should pay attention that the plafform may have a different concept of lines than the sources (if this has been extracted on Windows and analysed on a linux server).
But, I do not agree with the fact that we should remove the lines returns to the number of characters. They are characters, why should we remove them?
Indeed curious. At the end this is really the question of the definition of the “metrics”
I propose this implémentation:
numberOfCharacters <MSEProperty: #numberOfCharacters type: #Number> <MSEComment: 'Number of characters in a file.'>
<derived> ^ self lookUpPropertyNamed: #numberOfCharacters computedAs: [ self sourceText size ]
This is because #sourceText already manage the case where the file exist or not.
If I have no complain, I'll do this change.
-- Cyril Ferlicot https://ferlicot.fr
http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France _______________________________________________ Moose-dev mailing list Moose-dev@list.inf.unibe.ch https://www.list.inf.unibe.ch/listinfo/moose-dev
-------------------------------------------- Stéphane Ducasse http://stephane.ducasse.free.fr http://www.synectique.eu / http://www.pharo.org 03 59 35 87 52 Assistant: Julie Jonas FAX 03 59 57 78 50 TEL 03 59 35 86 16 S. Ducasse - Inria 40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park Plaza Villeneuve d'Ascq 59650 France