Julia มี @edit
, @less
ฯลฯ ซึ่งมีประโยชน์มากสำหรับการอ่านการใช้งานฟังก์ชั่นต่างๆ อย่างไรก็ตาม คุณต้องระบุชุดพารามิเตอร์ (ประเภท) ที่ "ดีเพียงพอ" เพื่อค้นหาตำแหน่งของโค้ด
InteractiveCodeSearch
จะให้มาโครสองสามตัวเพื่อเลือกโค้ดที่คุณต้องการอ่านแบบโต้ตอบแทน
@search show
, นิพจน์การเรียกใช้ฟังก์ชัน @search show(stdout, "hello")
, ลายเซ็นการเรียกใช้ฟังก์ชัน @search show(::IO, ::String)
, ชื่อโมดูล @search Base
ค่าอาร์กิวเมนต์ @searchmethods 1
และประเภทอาร์กิวเมนต์ @searchmethods ::Int
using InteractiveCodeSearch
@search show # search method definitions
@searchmethods 1 # search methods defined for integer
@searchhistory # search history (Julia ≥ 0.7)
คำสั่งจับคู่แบบโต้ตอบ ตัวอย่างเช่น:
@search
@search x [:shallow | :s | :recursive | :r]
แสดงรายการตำแหน่งไฟล์ที่มีการกำหนด x
ในตัวจับคู่แบบโต้ตอบ จากนั้นเปิดตำแหน่งที่เลือกในตัวแก้ไข
เมื่อ x
เป็นโมดูล ระบบจะค้นหาเฉพาะคำจำกัดความระดับบนสุดเท่านั้น หากต้องการค้นหาคำจำกัดความทั้งหมดในโมดูลย่อย ให้ส่งแฟล็ก :recursive
หรือ :r
@search
หากไม่มีการระบุนิพจน์ ให้ค้นหาวิธีที่ส่งคืนโดยการดำเนินการครั้งก่อน คือ x
ค่าเริ่มต้นเป็น ans
ตัวอย่าง
@search show # all method definitions
@search @time # all macro definitions
@search Base . Enums # methods and macros in a module
@search REPL :r # search the module recursively
@search * ( :: Integer , :: Integer ) # methods with specified types
@search dot (π, ℯ) # methods with inferred types
โปรดทราบว่า @search
ประเมินนิพจน์ที่ซับซ้อนด้วย .
และ []
ดังต่อไปนี้และค้นหาค่าที่ส่งคืนหรือประเภทของมัน:
@search Base . Multimedia . displays[ 2 ] . repl
@searchmethods
@searchmethods x
@searchmethods ::X
ค้นหาแบบโต้ตอบผ่าน methodswith(typeof(x))
หรือ methodswith(X)
ตัวอย่าง
@searchmethods 1 # search methods defined for integer
@searchmethods :: Int # search methods defined for a specified type
@searchhistory
@searchhistory
ประวัติการค้นหาแบบโต้ตอบ จำกัดโค้ดที่คุณกำลังมองหาจากประวัติ REPL ให้แคบลงแบบโต้ตอบ
ข้อจำกัด/คุณลักษณะใน IJulia : ใน IJulia @searchhistory
จะค้นหาประวัติของเทอร์มินัล REPL ไม่ใช่ประวัติของเซสชัน IJulia ปัจจุบัน
InteractiveCodeSearch.CONFIG
อินเทอร์เฟซการกำหนดค่าสำหรับ InteractiveCodeSearch
ตัวอย่าง
using InteractiveCodeSearch
InteractiveCodeSearch . CONFIG . interactive_matcher = ` fzf ... ` # default in terminal
InteractiveCodeSearch . CONFIG . interactive_matcher = ` peco `
InteractiveCodeSearch . CONFIG . interactive_matcher = ` percol `
InteractiveCodeSearch . CONFIG . interactive_matcher =
` rofi -dmenu -i -p "?" ` # use GUI matcher (default in non-terminal
# environment like IJulia)
InteractiveCodeSearch . CONFIG . interactive_matcher =
` rofi -dmenu -i -p "?" -fullscreen ` # bigger screen
InteractiveCodeSearch . CONFIG . open = edit # default
InteractiveCodeSearch . CONFIG . open = less # use Base.less to read code
InteractiveCodeSearch . CONFIG . auto_open = true # default
InteractiveCodeSearch . CONFIG . auto_open = false # open matcher even when there
# is only one candidate
InteractiveCodeSearch . CONFIG . trigger_key = ' ) ' # insert "@search" on ')' (default)
InteractiveCodeSearch . CONFIG . trigger_key = nothing # disable shortcut
ใช้ InteractiveCodeSearch.jl เป็นค่าเริ่มต้น
ใส่รหัสต่อไปนี้ใน ~/.julia/config/startup.jl
(≥ Julia 0.7) หรือ ~/.juliarc.jl
(Julia 0.6):
using InteractiveCodeSearch
# InteractiveCodeSearch.CONFIG.interactive_matcher = ...