https://github.com/olekscode/deprecationvisitor
A visitor for collecting deprecations from Pharo methods
https://github.com/olekscode/deprecationvisitor
Last synced: 3 months ago
JSON representation
A visitor for collecting deprecations from Pharo methods
- Host: GitHub
- URL: https://github.com/olekscode/deprecationvisitor
- Owner: olekscode
- License: mit
- Created: 2021-06-30T13:52:43.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-06T13:53:14.000Z (almost 4 years ago)
- Last Synced: 2025-02-11T11:41:41.603Z (5 months ago)
- Language: Smalltalk
- Size: 21.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeprecationVisitor
[](https://github.com/olekscode/DeprecationVisitor/actions/workflows/test.yml)
[](https://coveralls.io/github/olekscode/DeprecationVisitor?branch=master)
[](https://raw.githubusercontent.com/olekscode/DeprecationVisitor/master/LICENSE)A simple visitor that can collect deprecations from Pharo methods. Developed for research purposes, to analyse method deprecations in Pharo images. `DeprecationModel` is a static version of `Deprecation` which stores all the information about the deprecation such as message, date, version, etc., but does not require a dynamic execution context.
## How to install it?
To install `DeprecationVisitor`, go to the Playground (Ctrl+OW) in your [Pharo](https://pharo.org/) image and execute the following Metacello script (select it and press Do-it button or Ctrl+D):
```Smalltalk
Metacello new
baseline: 'DeprecationVisitor';
repository: 'github://olekscode/DeprecationVisitor/src';
load.
```## How to depend on it?
If you want to add a dependency on `DeprecationVisitor` to your project, include the following lines into your baseline method:
```Smalltalk
spec
baseline: 'DeprecationVisitor'
with: [ spec repository: 'github://olekscode/DeprecationVisitor/src' ].
```If you are new to baselines and Metacello, check out the [Baselines](https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/Baselines.md) tutorial on Pharo Wiki.
## How to use it?
Consider that you have a deprecated method:
```Smalltalk
FFIStructure >> address
self
deprecated: 'Use #getHandle'
on: '27 October 2015'
in: 'Pharo5'
transformWith: '`@rec address' -> '`@rec getHandle'.
^ self getHandle
````DeprecationVisitor` can be used to collect all deprecations from a given method:
```Smalltalk
visitor := DeprecationVisitor new.
method := FFIStructure >> #address.
method ast acceptVisitor: visitor.
visitor deprecations. "an OrderedCollection(a DeprecationModel)"
```The collected deprecation will be equivalent to the following one:
```Smalltalk
DeprecationModel new
message: 'Use #getHandle';
date: '27 October 2015';
version: 'Pharo5';
transformationRule: (TransformationRule
antecedent: '`@rec address'
consequent: '`@rec getHandle').
```A simple example of collecting all method deprecations from a Pharo image:
```Smalltalk
methods := Smalltalk image packages flatCollect: [ :package | package methods ].visitor := DeprecationVisitor new.
methods do: [ :method |
method ast acceptVisitor: visitor ].visitor deprecations.
```