![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Overview of implementationImplementation OverviewThe refactored VersionsBrowser collaborated with four new concrete classes: MethodSourceCode, SourceCodeStore, SourceCodeStream, and SourceCodeLocation. A VersionsBrowser displays a list of MethodSourceCode objects. MethodSourceCode objects encapsulate the source code text for a particular method name (aka selector) for a particular class. The list is ordered from the most current version of the method’s source code to the oldest version. A VersionsBrowser gets the list of MethodSourceCode object from the default SourceCodeStore using the method #versionsFor: aSelector in: aClass. The default SourceCodeStore object encapsulates all of Squeak’s source code. Source code is stored locally in the changes and sources files, and also stored remotely in a source code repository. A SourceCodeStore object manages all these resources. It also manages the condensing and archiving of the previous versions of the method source code. When a SourceCodeStore object receives a request for the versions of a method, it uses a SourceCodeStream to iterate over each version. A SourceCodeStream’s #next method returns a MethodSourceCode object. When a SourceCodeStore object want to save a version of a method’s source code, it writes a MethodSourceCode object to a SourceCodeStream using #nextPut:. SourceCodeStreams act as a decorator to a FileStream. While the elements of a FileStreams are characters, the elements of a SourceCodeStream are whole MethodSourceCode objects. Method source code in the source files is no longer an actual object but simply dumb text data. A MethodSourceCode object’s external location in file is encapsulated using a SourceCodeLocation. A SourceCodeLocation references the file name and a file position of a MethodSourceCode object. The SourceCodeLocation class is also able to make instances directly from a CompiledMethod’s source code pointer, or a selector and a class. Link to this Page
|