SUBSCRIBE to this channel: http://goo.gl/EV6Kwv
Website: http://www.luv2code.com
—
Website: http://www.luv2code.com
YouTube: http://goo.gl/EV6Kwv
Twitter: http://goo.gl/ALMzLG
Facebook: http://goo.gl/8pDRdA
View more videos on my “Eclipse Playlist”: http://goo.gl/R3p3m8
—
In this video tutorial, I will show you how to use Eclipse to search and navigate your source code. I’ll discuss the following topics:
– Searching for plain text
– Searching by Java type
– Searching by method name
– Opening a method declaration
– Find references for a method
– Tracing the call hierarchy
—
Video Transcript
Time – 00:00
Hi, this is Chad (shod) for luv2code.com. Welcome back to another tutorial on Eclipse. In this video you will learn how to use Eclipse to navigate and search through your source code. We’ll cover the following topics. You’ll learn how to search and find code, you’ll also learn how to find references for a class or method, we’ll also discuss how to open a method declaration, and finally, you’ll learn how to view the call stack.
Time – 00:25
Let’s get started. A common thing you need to do whenever you’re using job or development is searching for strings or searching for text. Eclipse allows you to search by simply using the CTRL + F feature, and this brings up the find and replace window. You can type in whatever text that you want to search for and Eclipse will go through and find it. You can set various options, case sensitive, whole word, and this works like a normal text editor. I’m searching for demo and I’m going to just walk through and it’ll show me all instances for demo in this actual file. If you want to make use of replace you can say, “Replace the word demo with foobar and then go through and do replace find or replace all, and again, it works like a normal text editor.
Time – 01:11
Also, when you have a large code base you may need to search for text in other files. Other than just a local file you need to search all of the files in your project. Eclipse offers a very robust search mechanism. You can search for plain text or Java specific constructs. To open the search item, select Search, Search. If you can see this brings up the search dialog. This search dialog has a lot of information. Let’s go through it one piece at a time.
Time – 01:41
There is a file search where you can search for plain text across multiple files, you can give the actual text you’re searching and the file name pattern. You can also search for task that are available in Mylyn. Mylyn is a to-do list or task list item. There is also a Git search. Git is a repository or version control system and it can search against a repo. There is also the Java search, where you can search for a specific Java constructs like types, packages or fields, that is our constructors.
Time – 02:16
All right. Let’s try out the Java search. In this example, I want to search for a class that makes use of the J button class. I’ll set the type here, and I’ll say the string I’m searching for is JButton, and that’s the actual type. I’m searching for the JButton that’s used in all of the files within this project. I hit search and at the bottom it gives me the search results. It’ll show you all of the files that are making use of JButton and you can easily expand and explore and drill down and get the actual details for it.
Time – 02:55
All right. Another thing I want to do here is I actually want to search by method name. I want to find methods that begin with a certain string. We, here I’ll just pull this down a bit. I’ll go back to my search and I’ll choose the search again. This will bring up the search window. I have the Java search. I’m going to search for an actual method name and I’m going to find a method name that starts with create.
Time – 03:19
I’ll say, create star. I’m going to use the wild card to match on any string and then I’ll hit search. At the bottom it will give me a list again, of all the methods, I’m sorry, all of the classes or files that have a method called create inside of it. So I can go through and I’ll see the match there. I’m going down some more, and I’ll see more matches. You may see other methods here referenced. It means that these methods actually use the create method inside of it. If I double click on one of these I’m going to go in and see that this method is using a create call accordingly. It’s just a very nice way of going through and finding all methods that have the name create or calls to methods with a name create.
Complete Transcript available here: http://www.luv2code.com/?p=854