Xcode中非传统JavaScript方法的函数列表
在xcode中处理.js文件时,方法浏览器工作并列出传统函数。例如:Xcode中非传统JavaScript方法的函数列表,javascript,xcode,Javascript,Xcode,在xcode中处理.js文件时,方法浏览器工作并列出传统函数。例如: function OBj (e){ for (var i in e) { enyo.log("element ", i, " is ", e[i]) } }; 或者 但是其他模式呢?。。。。例如: Obj.method({ init: function() {}, data: function() {}, }) 这就是xcode对我的不足之
function OBj (e){
for (var i in e) {
enyo.log("element ", i, " is ", e[i])
}
};
或者
但是其他模式呢?。。。。例如:
Obj.method({
init: function() {},
data: function() {},
})
这就是xcode对我的不足之处。因此,在这篇问答文章中,我介绍了一个shell脚本,我编写该脚本是为了提供我所使用的javascript模式类型所需的方法导航类型。利用xcode中的marker?
功能,shell脚本只需在指定文件夹中的所有.js文件中循环,并通过模式匹配查找符合模式的所有方法:
init: function() {},
它注入了一个带注释的匹配标记,因此您现在可以:
Obj.method({
//???:init
init: function() {},
//???:data
data: function() {},
})
它很高兴地显示在xcode的方法下拉列表中:
我已经提供了脚本作为我问题的答案部分。只需复制并粘贴到文件中。将该文件放在JS文件所在的文件夹中。从终端,
cd
到该文件夹并运行shell脚本:/scriptname
金色的
#!/bin/bash
# ***WARNING: BACK UP YOUR FILES BEFORE RUNING THIS SCRIPT ON THEM
# JS function pattern
v1=': function'
# Change these to point to the paths of your own JS files
temp_file='/Users/.../Documents/.../www/.../'
jsfolder='/Users/.../Documents/.../www/.../'
# Do not change anything below unless you know what you doing,
# as it will likely break the script.
v2="\/\/\?\?\?\:"
temploc='temp_file'
for i in "${jsfolder}"*.js
do
sed -e 's/'"${v2}"'.*//' -e 's/ *\([^: ]*\)'"${v1}"'.*/'"${v2}"'\1\
&/' $i > $temp_file$temploc
mv $temp_file$temploc $i
done
#!/bin/bash
# ***WARNING: BACK UP YOUR FILES BEFORE RUNING THIS SCRIPT ON THEM
# JS function pattern
v1=': function'
# Change these to point to the paths of your own JS files
temp_file='/Users/.../Documents/.../www/.../'
jsfolder='/Users/.../Documents/.../www/.../'
# Do not change anything below unless you know what you doing,
# as it will likely break the script.
v2="\/\/\?\?\?\:"
temploc='temp_file'
for i in "${jsfolder}"*.js
do
sed -e 's/'"${v2}"'.*//' -e 's/ *\([^: ]*\)'"${v1}"'.*/'"${v2}"'\1\
&/' $i > $temp_file$temploc
mv $temp_file$temploc $i
done