Last active
February 16, 2018 14:58
-
-
Save rebolek/8e404c02c4b94e186f496c9d54adab85 to your computer and use it in GitHub Desktop.
Find where function is defined
This file contains 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[ | |
Title: "Where" | |
Purpose: "Find where function is defined" | |
Author: "Boleslav Březovský" | |
] | |
where: function [ | |
"Return file where function is defined or NONE, if the definition can't be found" | |
'name | |
/in | |
path "Start search in this path (default is current directory)" | |
][ | |
name: form name | |
root: any [path %./] | |
find-where: function [ | |
path | |
name | |
][ | |
files: read path | |
foreach file files [ | |
file: rejoin [path file] | |
case [ | |
%.red = suffix? file [ | |
content: read file | |
if find content rejoin [name ": func"][return file] | |
] | |
dir? file [ | |
if result: find-where file name [return result] | |
] | |
] | |
] | |
none | |
] | |
find-where root name | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment