Last active
February 4, 2022 07:23
-
-
Save toomasv/6953d4b98b5357859e93aeb218294ddc to your computer and use it in GitHub Desktop.
Get overview of refinements' usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Purpose: "Get overview of refinement usage" | |
Date: 15-Nov-2021 | |
Update: 4-Feb-2022 | |
Author: @toomasv | |
] | |
context [ | |
refs: make block! 100 | |
add-ref: func [ref fn][ | |
either got: refs/:ref [append got fn][repend refs [ref compose [(fn)]]] | |
] | |
set 'get-refinements function [ | |
"Get all funcs using given refinement" | |
ref [refinement! word!] "`all` or refinement to get info on" | |
/sorted "Sort the result" | |
/type | |
/extern refs | |
][ | |
if all [word? ref ref <> 'all][cause-error 'user 'message "Of words, only `all` is supported!"] | |
funcs: clear [] | |
foreach fn reduce [function! native! action! routine!][ | |
append funcs parse help-string fn [collect any [copy _ to "=>" keep (to word! trim _) thru [newline | end]]] | |
] | |
either word? ref [ | |
clear refs | |
foreach fn funcs [ | |
parse spec-of get fn [any [[/local | /extern] thru end | s: refinement! (add-ref s/1 fn) | skip]] | |
] | |
if sorted [sort/skip refs 2] | |
new-line/skip refs true 2 | |
][ | |
refs: collect [ | |
foreach fn funcs [ | |
if found: find/tail/case spec-of get fn ref [ | |
keep fn keep ref | |
either string? first found [keep first found found: next found][keep "?"] | |
if type [keep/only parse found [collect some [keep word! opt keep block! opt keep string!]]] | |
] | |
] | |
] | |
offset: pick [4 3] type | |
if sorted [sort/skip refs offset] | |
new-line/skip refs true offset | |
] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment