eclim CSearch macro 问题的解决过程备忘录

来源:互联网 发布:淘宝 官网 编辑:程序博客网 时间:2024/05/23 15:20
问题: CSearch 宏时,
RuntimeException: Could not find file with URI because it is a relative path, and no base URI was provided.

调试准备
"verbose message
let g:EclimLogLevel = 10
"重定向vim messages
:redir >xx.txt
:cmd
:redir END

修改和编译
git clone git://github.com/ervandew/eclim.git
cd eclim
ant "-Declipse.home=E:/eclipse" "-Dvim.files=E:/Program Files/Vim/vimfiles"
Unattended (automated) install
java -Dvim.files=$HOME/.vim -Declipse.home=/opt/eclipse -jar eclim_2.3.4.jar 

解决过程
我对比了函数是可以的:
(0s) system: "/mnt/eclipse/plugins/org.eclim_2.3.4/bin/eclim" --nailgun-port 9091 -editor vim -command c_search -n "test_cdt" -f "mod.c" -o 75 -l 4 -e utf-8 
但是宏就不行:
(0s) system: "/mnt/eclipse/plugins/org.eclim_2.3.4/bin/eclim" --nailgun-port 9091 -editor vim -command c_search -n "test_cdt" -f "mod.c" -o 106 -l 3 -e utf-8 
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: File '/test_cdt/mod.c' not found.
^Iat org.eclim.util.file.Position.fromOffset(Position.java:78)
^Iat org.eclim.plugin.cdt.command.search.SearchCommand.executeElementSearch(SearchCommand.java:191)
^Iat org.eclim.plugin.cdt.command.search.SearchCommand.execute(SearchCommand.java:148)
...
在windows xp上运行:
(0s) nailgun.py (port: 9091): -editor vim -command c_search -n "test_cdt" -f "mod.c" -o 106 -l 3 -e utf-8 

"(0s) nailgun.py (port: 9091): " 前缀是client/python/nailgun.vim里面加上的,里面关键的一句:
(retcode, result) = client.send(command)
是把命令消息发给eclimd (todo: 如何与这个daemon交互的)。
-o -l 参数的含义是在lang.vim/eclim#lang#Search里面(引用utils.vim [1]),意思是磁盘文件中当前word的偏移字节和长度。
CSsearch 的其他参数请参考[2]。

两个命令行没有本质差异。那在vimfiles层面应该没有问题了,应该到eclim
java文件里面找,于是git 下载了代码,grep了 c_search, 找到一个
SearchCommandTest.java 里面有个"-t macro"! 我赶紧试了下:
:CSearch MY_MACRO -t macro 果然可以了!

grep MACRO , [3].getType()引用了TYPE_MACRO,JavaSearch跟到executePatternSearch()最终被./org.eclim/java/org/eclim/command/Main.java调。
executePatternSearch() 调cdt的 query.run() --> 取IIndex index =
CCorePlugin.getIndexManager().getIndex(projects,
IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH)。然后回调
CSearchPatternQuery.runWithIndex()[4] 根据-t 比如 FIND_FUNCTION 过滤结果。

我打算跟踪到cdt.jar里面,大致了解index什么。不过cdt又是另一个大工程,暂且打住,以后有机会再探究;我只知道在[3]里面,FIND_MACRO和FIND_FUNCTION的处理路径不同。

其他: [5] 里面给了一种办法,不过我数了要改5-6处,况且不一定有效。

参考
[1] vim 内置函数 http://bbs.chinaunix.net/thread-2192634-1-1.html
[2] Search 参数 vimfiles/./eclim/autoload/eclim/c/search.vim

[3] eclim/plugin/cdt/command/search/SearchCommand.java

[4] org\eclipse\cdt\internal\ui\search\CSearchPatternQuery.java

[5]http://stackoverflow.com/questions/7998574/apache-commons-vfs-cannot-resolvefile


0 0
原创粉丝点击