search for line within specific package in eclipse - eclipse

I'm working with eclipse and want to find a specific line that is being output in an error message. The line is not in any code I've written, but I believe it's comeing from a specific library I've included. Eclipse is able to navigated through classes within the library so it has the source from somewhere, the jars were fetched from Mavin and I assume the jar it fetched was a source jar?
The problem is that, by default, the simple java search does not search inside of jar's for lines, and I didn't see an obvious way to tell it to. IN addition I don't want to search all the jars, or even all the code within the one suspected jar, for a line as it could take awhile. Is there a way I can tell eclipse to do a text search of every file within a specific package only? Failing that how would I tell it to do a text search of all code within a specific jar?
Thanks.

Eclipse's 'File Search' which you'd need to find arbitrary text in files doesn't "look into" JARs. Its 'Java Search' on the other hand doesn't look at source code specifically but allows to search types, methods, fields etc. (i.e. things Eclipse doesn't need source code for). Hence, Eclipse can't help you here.
You weren't asking for alternatives but on Unix there's zipgrep and for Windows I believe Actual Search & Replace does the same.

Related

Go To File with directory in NetBeans

The "Go to File" dialog is handy (Alt-Shift-o), but my project has a hundred files called index.phtml. Is there any way to include the directory? Say, search for docs/index.phtml?
Or do I just have to fix/wait for https://netbeans.org/bugzilla/show_bug.cgi?id=222697?
I'm using NetBeans PHP 7.3.
No, only file names can be searched for.
When looking at the code of the Jump To module, you can notice that a org.netbeans.modules.parsing.spi.indexing.CustomIndexerFactory gets registered which only keeps record of file names including their extension. So currently there is no way to to search for files with a path specified.
However, I think it shouldn't be too difficult to change the indexer of the Jump To module to not omit the path, I'd worry about the performance though.

Eclipse: quick search on filename

Very often while working in Eclipse I realize that I remember class name, but forgot in which package this class is. Using Search is not very convenient. Too many clicks and key presses. I wonder, is there a plugin to simplify this process? For example, would be great if there was text-edit box in the top of package explorer which could filter showing packages and .java files depending of entered text. Anyone knows something like that?
Eclipse does provide similar functions:
Open Resource Shift+Ctrl+R for all resource files (including Java files)
Open Type Shift+Ctrl+T for all Java classes in classpath.
They also filter the list as you type.
Note that they search all files of all opened projects in current workspace.

InstaSearch (eclipse plugin) functionality in intelliJ v11.x?

One thing I miss about moving from eclipse to intelliJ is the InstaSearch plugin that would let you to search the source code codes of your entire project very quickly, really simple and effective.
Is there such a functionality in intelliJ either baked in or added via a plugin?
IntelliJ supports search and replace in your entire project.
To find a text in all files within the specified path
1. On the main menu, choose Edit | Find | Find in Path, or press Ctrl+Shift+F.
2. In the Find In Path Dialog, specify the following options:
Text to find (you can select one from the recent history drop-down list).
Search scope (project, module or directory).
Search options (case sensitivity, whole words, and regular expressions).
See instructions here.

Any way to disable syntax checking for a project?

I created a project "Sample Code"... here I just paste sample code... much of it is snippets that won't compile.
Is there some project-specific setting I can make so that Eclipse doesn't try to compile it?
I would prefer not to have the source code littered with red error markers.
Put your code in a non-java project, ie a general project.
Downside: you will have to create package directory structure (unless you can copy and paste from somewhere else).
Upside: it won't try to compile.
MY SOLUTION
ok, this is not an exact solution to my problem... but it is another way to do it and I kinda like it now...
I simply forget about using Eclipse to store the sample java files!
I found a good program CodeBox for Mac to store code snippets and I'm sure there exist such things for Windows, Linux too...
there interesting thing is that when I choose from this program to open the java snippet file (.java) in an external editor (Eclipse), it will open in Eclipse without any Syntax checking... wohoo! no squiggly lines
Because of this, it is not full blown code highlighting... classes and variables same color... but that's ok.. still quite readable. Much more than if it was in Eclipse with syntax highlighting running on it...
So basically, if you want to get rid of these red squiggles... one way to do it is don't keep sample .java (or other language) files in a project in Eclipse... simply keep them in the filesystem or code storage app and open them with Eclipse when you want to view them.
Depending on how you prefer to structure your project:
you could put your java files into a separate folder that is not configured as a source folder. There is an entry in the eclipse help on how to configure your build path.
or you can set exclusion-patterns in the build configuration, so that specific packages or files that follow a pattern you define don't get compiled.
Yet another way to handle your snippets could be to use a Scrapbook page.
Eclipse won't highlight anything in a scrapbook page but you can select code parts inside the page and execute them isolated. That's nice if you're experimenting and don't want to set up a whole class with imports and methods just to see if a specific snippet works as expected.

How to Change Netbeans Fonts and Colors Preview Document?

Within the Netbeans 6.5's Tools -> Options -> Fonts & Colors -> Syntax dialog, you have the ability to change the look and feel of the Netbeans text editor. When you select a language, you are presented with a preview of your font/color scheme. However, when I preview Java, there are far more options for syntax changes than are being displayed in that preview window. If I were able to view a more robust piece of code, I'd be able to see the immediate effect of more of the options.
How can I supply a preview document to view my font/color changes?
UPDATE:
After looking into this some more, I've been able to narrow down the problem a bit. From what I can tell, everything in Netbeans is considered a plugin. The GUI editor is a plugin, and even the text editor is a plugin. This means that what ever piece of Netbeans that actually analyzes Java code and does syntax highlights is also a plugin (since Java is just one of many languages Netbeans highlights, it makes sense this is a plugin).
I think fromvega is on the right track with his suggestion. The tutorial for creating a manifest file editing plugin pointed me in the right direction. The tutorial eludes to a file used as a sample document used for font/color previews. It tells you how to create one inside this new plugin project. (Located in "Registering the Options in the NetBeans System Filesystem", part 4. About 4/5 of the way down the page.)
My next line of thought was to look for the Java syntax editing mode plugin and find this file and update it with a richer example file. I looked in the installation directory and came up empty, but I found what looks like the appropriate files within my user settings directory. There is a config directory with a lot of subfolders within my user directory (Windows: C:\Documents and Settings\saterus.netbeans\config).
I've been poking around inside this directory a bit, but have only found the xml files the manifest tutorial talks about. I have been unable to find the extensionless sample file for the Java plugin that I believe should be there.
Since I've hit a brick wall for the moment, I thought I'd toss it back to the SO community and see if you guys might make the last leap and find the solution.
Just for anyone who wants to alter this themselves it is possible on a unix machine to use grep to locate the file i.e.
grep -lr "some part of the current sample code" /path/to/netbeans
I used this method to locate the ruby example filename and from that identified that it is kept in org-netbeans-modules-ruby.jar as a file called RubyExample. By simply altering that file I was able to construct a better sample file for my own use.
Hope this helps someone!
The document which is displayed (for each mime type) is specified in a particular folder in the "system file system" (which is a NetBeans concept which is a virtual file system composed from contributions from individual modules; this is how functionality is dynamically registered in NetBeans).
Modules typically specify their system file system contributions in a file named "layer.xml" in the plugin. The create plugin templates typically offer to create this for you.
For example, here's how the Python example is registered:
<filesystem>
...
<folder name="OptionsDialog">
<folder name="PreviewExamples">
<folder name="text">
<file name="x-python" url="PythonExample.py"/>
</folder>
</folder>
...
Here, PythonExample.py is a sample file in the same directory as the layer file.
Therefore, what you need to do is create a plugin which overrides the existing registration(s) for the mime type(s) you care about and provide alternate sample documents. You may need to hide the existing registration first (see the _hidden
part from http://doc.javanb.com/netbeans-api-javadoc-5-0-0/org-openide-filesystems/org/openide/filesystems/MultiFileSystem.html ).
Hopefully this guides you in the right direction.
However, in thinking about it, we probably ought to make the preview area editable - so people can cut & paste whatever codefragment they care about right in there. This wouldn't be persistent, so whenever you change languages you get the original samples back - but it provides a quick way to see your own code. This shouldn't be just for the Fonts & Colors customization, but for the Formatting preview panels as well.
I've filed an issue against NetBeans for this:
http://www.netbeans.org/issues/show_bug.cgi?id=155964
-- Tor
I think you can only accomplish that with a new plugin, since you need somekind of parsing to define what is what.
Give a look a these tutorials, I haven't read them in details but they seem to show you how to do what you want:
http://platform.netbeans.org/tutorials/nbm-mfsyntax.html
http://www.antonioshome.net/kitchen/netbeans/nbms-coloring.php