Comparing source code declarations with #=

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Comparing source code declarations with #=

hernanmd
Hi,

I want to compare Pharo (8) source code definitions. One source is already "filed in" the image and the other source is in a .st file in chunk format (the result of a file out). I've attached in this mail an example for reproducibility. In my search for a simple equality operator, I found that MCSnapshot(s) understand #= so it could be used like this:

| imageSnapshot fileSnapshot |

'MySampleClass.st' asFileReference fileIn.
imageSnapshot := (RPackageOrganizer default packageOf: MySampleClass) mcPackage snapshot.
fileSnapshot := (MCStReader on: 'MySampleClass.st' asFileReference readStream) snapshot.
imageSnapshot = fileSnapshot.

But to my surprise, the file snapshot from MCStReader is not reading the class definitions, so comparing them should answer <true> (assuming nothing has been modified) but it always returns <false>.

I've also seen that both Ring chunk importers do not read methods.

(RingChunkImporter fromStream: 'MySampleClass.st' asFileReference readStream) packages collect: #allMethods.
(RGChunkImporter fromStream: 'MySampleClass.st' asFileReference readStream) packages collect: #allMethods.

The only "solution" I've found so far is to read into CodeChunk's and then implement the #=

CodeImporter chunksFromFileNamed: 'MySampleClass.st'.

But I don't like it and also I think there should be a clever way to compare source between image and .st declarations.

Any ideas?

HernĂ¡n




MySampleClass.st (684 bytes) Download Attachment