"I want to know the caller of the XX function, so list it." When I was told to count
Since it was there, it seemed difficult to search 150 times using the IDE, so I managed to do it with a batch file. Don't ask why it's not bash or why you have to do that.
bat
file and execution resultgrepCallHierarchy.bat
@echo off
setlocal enabledelayedexpansion
set i=0
for /f %%a in (targetList.txt) do (
set /a i+=1
echo !i! %%a
call set Arr[!i!]=%%a
)
pause
for /r %%a in (*.java) do (
for /f "tokens=1,2,3 delims= " %%b in (%%a) do (
for /l %%j in (1,1,%i%) do (
if !Arr[%%j]!==%%c (
echo %%a %%b %%c %%d
)
)
)
)
targetList.txt
NantokaComponent
KantokaComponent
output
C:\path\to\file1.java private NantokaComponent nantokaComponent;
C:\path\to\file2.java private KantokaComponent kantokaComponent;
It became a practice of various for sentences.
for /r %%a in (*.java) do
for /f "tokens=1,2,3 delims= " %%b in (%%a) do
for /l %%j in (1,1,148) do
call set Arr[!i!]=%%a
As I learned for the first time, batch files do not have arrays.
It seems that they are just creating the variable ʻArr [1]ʻArr [2]
...
setlocal enabledelayedexpansion
When you want to loop an array with subscripts, it seems that it will always be ʻArr [1] `(initial value) unless lazy evaluation is performed. It's difficult. ..
The part you want to lazy-evaluate is surrounded by a surprise mark like ʻArr [! I!] Instead of ʻArr [% i%]
.
I was surprised.
was fun. (Small feeling) While I was making it, I thought that there was also PowerShell. Next time I want to play with PowerShell.
Recommended Posts