如何使 eclipse“文件搜索”也搜索包含一些文本的源 jars?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5295889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make eclipse "File Search" to also search inside source jars containing some text?
提问by akjain
I am working on a (Java) project in which I have many jars which have a source-jar file attached.
我正在开发一个(Java)项目,在该项目中我有许多附加了源 jar 文件的 jar。
Is there any way to make the eclipse "File Search" search for Java files (and txt, xml etc. for that matter) containing some string literal inside these source jars, not just in the project folder?
有什么方法可以让 Eclipse 的“文件搜索”搜索包含这些源 jar 中的一些字符串文字的 Java 文件(以及 txt、xml 等),而不仅仅是在项目文件夹中?
Or is there any plugin by which this can be achieved?
或者是否有任何插件可以实现这一点?
回答by user2757811
Recently discovered the following plugin has beta support for searching into linked source jars: https://github.com/ajermakovics/eclipse-instasearch
最近发现以下插件具有用于搜索链接源 jar 的测试版支持:https: //github.com/ajermakovics/eclipse-instasearch
You have to enable searching source jars in the preferences as it is turned off by default. Depending on how much source you have, the indexing process is very slow, but then search is very fast.
您必须在首选项中启用搜索源 jar,因为默认情况下它是关闭的。根据您拥有的源数量,索引过程非常缓慢,但搜索速度非常快。
I have an Eclipse workspace with the enterprise versions of Alfresco (Explore, Share and SOLR) and Alfresco Workdesk (Vanilla, Office and Mobile). Indexing took about 8 minutes on my Early 2011 MacBook Pro. Search is almost instantanious.
我有一个带有企业版 Alfresco(探索、共享和 SOLR)和 Alfresco Workdesk(Vanilla、Office 和 Mobile)的 Eclipse 工作区。在我 2011 年初的 MacBook Pro 上编制索引大约需要 8 分钟。搜索几乎是瞬间的。
回答by tigersagar
Searching inside a jar or finding the class name which contains a particular text is very easy with WinRar search. Its efficient and always worked for me atleast.
使用 WinRar 搜索在 jar 中搜索或查找包含特定文本的类名非常容易。它的效率很高,至少总是对我有用。
just open any jar in winrar, click on ".." until you reach the top folder from where you want to start the search(including subfolders).
只需在 winrar 中打开任何 jar,单击“..”,直到到达要开始搜索的顶部文件夹(包括子文件夹)。
Make sure to check the below options:
请务必检查以下选项:
1.) Provide '*' in fields 'file names to find', 'Archive types'
1.) 在“要查找的文件名”、“存档类型”字段中提供“*”
2.) select check boxes 'find in subfolders', 'find in files', 'find in archives'.
2.) 选中复选框“在子文件夹中查找”、“在文件中查找”、“在档案中查找”。
回答by Federico Pugnali
You can search for code inside source-jars attached to your workspace. Just use ctrl+H / Java Search. However I couldn't find a way to search for comments and java-docs inside those sources.
您可以在附加到您的工作区的 source-jars 中搜索代码。只需使用 ctrl+H / Java 搜索。但是我找不到在这些来源中搜索评论和 java-docs 的方法。
回答by Tahir Malik
Is not possible, use Total Commander to search in jar/zip etc.
不可能,使用Total Commander在jar/zip等中搜索。
回答by RAS
You can achieve this by this way: There's a dropdown in the 'File Search' dialog. Its label is: 'File name patterns'. Here you can specify the whole filename as well as extension of file, that you want to search in.
您可以通过这种方式实现此目的:“文件搜索”对话框中有一个下拉列表。它的标签是:'文件名模式'。您可以在此处指定要搜索的整个文件名以及文件扩展名。
回答by wyz
Currently there is no Eclipse plugin can do this AFAIK. However you can write a simple utility to do the work:
目前没有 Eclipse 插件可以做到这一点 AFAIK。但是,您可以编写一个简单的实用程序来完成这项工作:
URL url = FindResourceMain.class.getResource("/" + filePath);
Where filePath is the path you are interested.
其中 filePath 是您感兴趣的路径。
Currently it will only find resources from root of class path. E.g. if there is a file config/settings.xml, you can find with using "config/settings.xml", but not "settings.xml".
目前它只会从类路径的根目录中找到资源。例如,如果有一个文件 config/settings.xml,您可以使用“config/settings.xml”找到,而不是“settings.xml”。
Hope it will help. And hopefully someone will enhance the code and create an Eclipse plugin.
希望它会有所帮助。希望有人会增强代码并创建一个 Eclipse 插件。
回答by Boris Hamanov
The most practical way of achieving this is to expand all the jars / other archives you need to search in - using simple script to automate if they are too many. Put the files in a folder and create a generic Eclipse project from it or just put it in a sub-folder to your existing java project (without making it a resource of course). Then you can use Ctrl-H to search in and Ctrl-R to find resources by name.
实现这一目标的最实用方法是扩展您需要搜索的所有 jars/其他档案 - 如果它们太多,请使用简单的脚本进行自动化。将文件放在一个文件夹中并从中创建一个通用的 Eclipse 项目,或者只是将它放在现有 java 项目的子文件夹中(当然不使其成为资源)。然后您可以使用 Ctrl-H 搜索并使用 Ctrl-R 按名称查找资源。
See the result:
查看结果:
回答by user9682312
you can do like this. press ctrl-h -- > java search(the tab like file search)--search for: Field limit to:all occurrences scope:workspace then press search button
你可以这样做。按 ctrl-h --> java 搜索(类似于文件搜索的选项卡)--搜索:字段限制为:所有出现范围:工作区然后按搜索按钮