Eclipse - SPLessons

Eclipse Editing Code

Home > Lesson > Chapter 8
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Eclipse Editing Code

Eclipse Editing Code

shape Introduction

This chapter Eclipse Editing Code demonstrate the detailed view on text editor and multiple ways that Eclipse can improve the productivity and also about some of the options like customizing the layouts for the Editor view. Following are the concepts covered.
  • Editor Tabs
  • Code Folding
  • Marker Bars
  • Content Assist
  • Code Analysis

Editor Tabs

shape Description

The editor tab tiling feature is flexible, maybe even too flexible, but it is easy to use. The editor tab can be dragged and dropped either vertically or horizontally, user can split the editor tab as per the need either place the files side by side or one on each. While dragging and placing the files user can see some little vertical and horizontal Gray lines as shown in the image below. If user select a tab and go at the top of the tab the tab dragged will end up at the top and the other tabs will move to the bottom the images below show after effect of dragging the tabs. Similar to top and bottom, the left and right works. When user drag the tab to right will get the same behavior, the image below show the selected tab dragged to right and the other tabs to the left. User can divide the files into three sections, in order to do that select a file and drag to the bottom and select another file, drag it to the right side of the window, now the tab takes up all the vertical height as shown in the image below. In order to split the tabs in an asymmetrical view, select a tab and drag the file about a third in the bottom and two-thirds at the top as shown in the image below. The asymmetric view is a little complicated, user need to pay attention to the fine details and the rectangles.

shape More Info

Tabs have no loyalty, they won’t go back to the group where they were last opened. For example select any group i.e. either top, bottom or right and select a file to open, the file selected will be open in that particular group focused as shown in the image below. If large number of tabs are opened, user can easily view and select the required file by simply using the Show List icon, clicking the icon will explore a menu provided with list of files opened, user can select the required file by filtering as shown in the image below.

Code Folding

shape Description

The Code Folding region is near to the right of Marker Bar region in Eclipse. User can fold at import level in Java. Hover on Code Folding icon at import level will give a vertical line that shows what’s going to collapse as shown in the image below. User can also collapse at the comment level if having multiline comments, this code folding’s work only at header level but if put inside a method, folding’s are not supported the image below demonstrate the difference between the folding’s at header level and inside a method. The Code Folding’s are also available at the entire method level, when hover over on the collapsed folded icon, user can get right back to the code in the temporary pop-up window as shown in the image below.

Marker Bar

shape Description

The Marker Bars has a lot of capability, when hover over on any icon in the Marker Bar will give an explanation about that icon is for and why it is represented on the marker bar, user can also right click in the Marker Bar and get a context sensitive menu provided with some features as shown in the image below. Following are the three main key features of the Marker Bar.

Task

shape Description

In order to add the Task, select a preferred line from the code and right click on the Marker Bar, select the Add Task option from the explored window as shown in the image below. Now, a popup window appears automatically adding that selected line or user can enter something manually if it is a blank line. Click Ok Button after doing all the required changes as shown in the image below. User can notice that it put Task icon in the Marker Bar and also added the Task view in Marker views as shown in the image below. In order to remove the created task, right click on the Task icon and select Remove Task option as shown in the image below.

Bookmarks

shape Description

Bookmarks are quite similar to tasks, in order to deal with bookmarks right click on the Marker Bar and select Add Bookmark from the explored window as shown in the image below. Now, a popup window appears for adding a bookmark, enter the name for the Bookmark and click OK button as shown in the image below. User can notice that it put Bookmark icon in the Marker Bar and also added the Bookmark view in views at the bottom as shown in the image below. In order to remove the created Bookmark, right click on the Bookmark icon and select Remove Bookmark option as shown in the image below.

Breakpoints

shape Description

The most continent thing about the Marker Bar is that user can set Breakpoints for the debugger. In order to see a Breakpoints double click on the Marker Bar and a Breakpoint icon shows up as indicated in the image below. Now, hold down Control key and double click on the existing Breakpoint will produce a popup window which allows user to set various breakpoints properties as shown in the image below.

Content Assist

shape Description

There have been two great productivity aids in the history of software development, caffeine and intelligent context aware code editors and maybe compilers too. Content Assist is the name Eclipse uses for the feature, and knowing the proper name is helpful when looking into customization options. If the code is wrong, that can often adversely affect the usefulness of Content Assist. If user not getting the help needed should see, take a look at the code and make sure it's correct. Content Assist can prevent typos and really increase the productivity, in order to deal with Content Assist open up a file from Source folder and call a method in the existing class, type a method which already known and then hold down Control key and hit the Space key (i.e. Control key + Space key). Now, user can see a list that matches with that method called as shown in the image below.

Code Analysis

shape Description

The JDT support Code Analysis and quick fix capabilities. Eclipse uses the term code analysis instead of static analysis. The static analysis as a separate analysis step, and code analysis in Eclipse happens as user type, and that can really increase the productivity. The JDT implement code analysis in significantly different ways. This is not that surprising given the differences in the languages and that fact that the Java compiler target is an intermediate language. User can customize the behavior of what happens while typing by customizing the error and warning settings for the compiler itself. Although the settings can allow user flag legal, but suspect code, the building options only go so far. Some people prefer to have the compiler or IDE in this case do as much of the heavy lifting as possible. There are many plug-ins for Eclipse that extend its code analysis capabilities. Just three for Java are as follows. Click on the plug-ins in order to know in detail about each plug-in.

Summary

shape Key Points

  • Editors tab has a flexible feature and is easy to use.
  • The tabs can be dragged and dropped either from top to bottom or side by side as per the user need.
  • Code folding work only in header level and not supported inside the method.
  • Marker Bars have different icons such as Tasks, Bookmarks and Breakpoints.
  • The Content Assist and Code Analysis are used to increase the productivity.