{"id":15951738,"url":"https://github.com/peteruhnak/metalinks-toolkit","last_synced_at":"2025-06-14T20:33:29.855Z","repository":{"id":93122019,"uuid":"58440684","full_name":"peteruhnak/metalinks-toolkit","owner":"peteruhnak","description":"A toolkit simplifying the installation and reinstallation of MetaLinks","archived":false,"fork":false,"pushed_at":"2018-07-06T10:42:56.000Z","size":95,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T11:11:08.889Z","etag":null,"topics":["metalinks","metaprogramming","pharo"],"latest_commit_sha":null,"homepage":"","language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peteruhnak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-10T07:51:06.000Z","updated_at":"2022-01-31T21:59:15.000Z","dependencies_parsed_at":"2023-06-05T00:15:38.385Z","dependency_job_id":null,"html_url":"https://github.com/peteruhnak/metalinks-toolkit","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"6297588d103b3ab9269aab84d64ac59612f5eedc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/peteruhnak/metalinks-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fmetalinks-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fmetalinks-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fmetalinks-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fmetalinks-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peteruhnak","download_url":"https://codeload.github.com/peteruhnak/metalinks-toolkit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fmetalinks-toolkit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259879836,"owners_count":22925840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["metalinks","metaprogramming","pharo"],"created_at":"2024-10-07T13:03:55.898Z","updated_at":"2025-06-14T20:33:29.835Z","avatar_url":"https://github.com/peteruhnak.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MetaLinks Toolkit\n[![Build Status](https://travis-ci.org/peteruhnak/metalinks-toolkit.svg?branch=master)](https://travis-ci.org/peteruhnak/metalinks-toolkit) [![Coverage Status](https://coveralls.io/repos/github/peteruhnak/metalinks-toolkit/badge.svg?branch=master)](https://coveralls.io/github/peteruhnak/metalinks-toolkit?branch=master)\n\nA toolkit simplifying the installation and reinstallation of MetaLinks.\n\nTOC:\n\n* [Installation](#installation)\n* [Persistent MetaLinks](#permanent-installer)\n  * [Installing to a selector](#installing-selector)\n  * [Installing to an attribute](#installing-attribute)\n* [Change Observer Installer](#change-installer)\n* [Observation Inference](#inference)\n* [Nautilus Extensions](#nautilus)\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\n```smalltalk\nMetacello new\n\tbaseline: 'MetaLinksToolkit';\n\trepository: 'github://peteruhnak/metalinks-toolkit/repository';\n\tload.\n```\n\n\nMetaLinks themselves provide only very basic operations, e.g.:\n\n```smalltalk\nlink uninstall.\n\nlink := MetaLink new\n\tmetaObject: [ :object :selector :args |\n\t\tTranscript\n\t\t\tlog: object className; log: '\u003e\u003e'; log: selector; logCr: args.\n\t];\n\tselector: #value:value:value:;\n\targuments: #(object selector arguments);\n\tcontrol: #before.\n\n(MTElement\u003e\u003e#name:) ast link: link.\n\nobj := MTElement new.\nobj name: 'new name'.\n```\n\n\nthe line above will execute the installed link, an in Transcript I will see\n\n```MTElement\u003e\u003ename:#('new name')```\n\nNow install the link to every method in the class, and every time you trigger a method recompile (method change, instance variable rename, ...), you can do the reinstallation all over again…\n\nThis toolkit does that automatically and much more.\n\n\u003ca name=\"permanent-installer\"\u003e\u003c/a\u003e\n## MTMetaLinksInstaller — persistent MetaLinks\n\nClass `MTMetaLinksInstaller` provides an API for permanently installing metalinks to a class. As the AST of a methods can very drastically between changes, this API does not permit installation to arbitrary nodes.\n\nInstead we recognize two primary targets:\n* selector (method)\n* attribute (instance variable)\n\n\u003ca name=\"installing-selector\"\u003e\u003c/a\u003e\n### Installing to a selector\n\nTargetting a selector will always keep the MetaLink installed. You also maintain the control of the metalink itself.\n\n```st\nlink := MetaLink new. \"setup as previously as you require\"\n\ninstaller := MTMetaLinksInstaller new.\ninstaller installPermanent: metaLink toMethod: #name: of: MTElement.\n```\n\nEven if you remove the method and then add it again, the metalink will add itself back. Instead you get rid of it via the installer.\n\n```smalltalk\ninstaller uninstallMethod: #name: of: MTElement.\n```\n\nor more aggresively (removing all permanent metalinks in th class including attribute ones)\n\n```smalltalk\ninstaller uninstallAllPermanentLinksIn: MTElement.\n```\n\n\u003ca name=\"installing-attribute\"\u003e\u003c/a\u003e\n### Installing to an attribute\n\nAn attribute link will be added to all assignment nodes in the entire class **except** the `initialize` method. Similarly to a method, if you add a new assignment (or a new method with an assignment), it will be (re)added.\n\n```smalltalk\ninstaller installPermanent: metaLink toAttribute: #name of: MTElement.\n```\n\nand to uninstall\n\n```smalltalk\ninstaller uninstallAttribute: #name of: MTElement.\n```\n\n\u003ca name=\"change-installer\"\u003e\u003c/a\u003e\n## MTMetaLinksChangeInstaller\n\nThe primary purpose of this is class is to ease the observation of changes in models without touching the code itself.\n\n![](figures/model-metalinks.png)\n\nIn the model above I would like to fire on the element's announcer:\n* `ValueAdded` announcement every time an element is added to a container\n* `ValueRemoved` announcement every time an element is removed from a container\n* `ValueChanged` announcement every time an element's attribute has changed\n\nThe first two can be handled by *selector* permalinks and the last one by *attribute* permalink.\n\n`MTMetaLinksChangeInstaller` aim is to encapsulate this.\n\n```smalltalk\nobservations := {\n\tMTObservationSet\n\t\ttarget: MTElement\n\t\tchange: #(name owner uuid)\n\t\tadd: #()\n\t\tremove: #().\n\n\tMTObservationSet\n\t\ttarget: MTContainer\n\t\tchange: #()\n\t\tadd: #(add:)\n\t\tremove: #(remove:)\n}.\nci := MTMetaLinksChangeInstaller new.\nci install: observations.\nelement := MTElement new.\ncontainer := MTContainer new.\n\n\"Now we can use normal Announcement propagation\"\nelement when: ValueChanged do: [ :oldValue :newValue | ... ].\ncontainer when: ValueAdded do: [:newValue | ... ].\ncontainer when: valueRemoved do: [:newValue | ... ].\n```\n\nThe default behavior of the class is to fire the announcement, more specifically\n\n```smalltalk\nchangeMetaObjectBlock := [ :object :newValue |\n\tobject announcer announce: (ValueChanged newValue: newValue)\n].\n```\n\nNaturally this behavior can be customized\n\n```smalltalk\n\"A block [ :object :newValue | ],\nwhere `object` is the observed object, and `newValue` the newly assigned value.\"\nci changeMetaObjectBlock: [ :object :newValue | ... ]\n```\n\n\u003ca name=\"inference\"\u003e\u003c/a\u003e\n## MTMetaLinksInference\n\nFinal tool in the toolkit is an automatic inferencer. This will scan through the source code of the provided methods and will guess what places should be observed.\n\nThe result will be a dictionary of `MTObservationSet` as was seen in previous section.\n```smalltalk\nMTMetaLinksInference new inferClasses: { MTElement . MTContainer }\n \"a Dictionary(MTContainer-\u003ea MTObservationSet(\n\t#change -\u003e #(#elements).\n\t#add -\u003e #(#add:).\n\t#remove -\u003e #(#remove:)\n) MTElement-\u003ea MTObservationSet(\n\t#change -\u003e #(#name #owner #uuid).\n\t#add -\u003e #().\n\t#remove -\u003e #()\n) )\"\n```\n\n\u003ca name=\"nautilus\"\u003e\u003c/a\u003e\n## Nautilus Extensions\n\nTwo simple extensions are added for Nautilus. One is an enabled copy of already existing method styler that shows where in the ast are installed metalinks.\n\n![](figures/metamethod1.png)\n![](figures/metamethod2.png)\n\nAnd the second one with similar behavior that shows a flag in Nautilus that a method has a metalink installed.\n\n![](figures/metamethod3.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeteruhnak%2Fmetalinks-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeteruhnak%2Fmetalinks-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeteruhnak%2Fmetalinks-toolkit/lists"}