<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Depth-First: Tag quickfix</title>
    <link>http://depth-first.com/articles/tag/quickfix</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>My Favorite Eclipse Shortcut: Quick Fix</title>
      <description>&lt;p&gt;&lt;a href="http://eclipse.org"&gt;&lt;img src="http://depth-first.com/demo/20080111/eclipse_logo.jpg" align="right"&gt;&lt;/img&gt;&lt;/img&gt;&lt;a href="http://www.eclipse.org/"&gt;Eclipse&lt;/a&gt; is one of those great tools that is both easy to learn and extremely powerful. Eclipse's power comes, in part, from the number of features it offers, which seems to grow with every new release. This creates a problem though; the more features that are added to Eclipse, the more difficult it is to find them. This article focuses on one feature that every Eclipse user should know about: &lt;a href="http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/tasks-175.htm"&gt;Quick Fix&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let's say you're creating a class from scratch and you need to add a variable. Because you're working in Java, you'll also need to specify a type. If that type is one that doesn't already appear in the file you're working on, you'll either need to create it or import it. It may not seem like a big deal to scroll to the top of your file, add an &lt;tt&gt;import&lt;/tt&gt; statement, and scroll back down to continue writing, but it can really break the flow of concentration - especially considering that it may need to be done several times in just one method.&lt;/p&gt;

&lt;p&gt;Wouldn't it be great if Eclipse could handle this tedium for you?&lt;/p&gt;

&lt;p&gt;Enter &lt;a href="http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/tasks-175.htm"&gt;Quick Fix&lt;/a&gt;. In this example, we're creating a class called &lt;tt&gt;Molecule&lt;/tt&gt; and need to add a &lt;tt&gt;List&lt;/tt&gt; to hold its atoms. We begin by declaring the &lt;tt&gt;atoms&lt;/tt&gt; variable:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080111/list_error.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Eclipse recognizes that &lt;tt&gt;List&lt;/tt&gt; is a new type. Instead of manually inserting an &lt;tt&gt;import&lt;/tt&gt; statement at the top of the file, let's use Quick Fix.&lt;/p&gt;

&lt;p&gt;Highlighting the error and pressing [Ctrl-1] opens Quick Fix and gives us a list of options to choose from:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080111/list_options.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Quick Fix can also create a class or interface template instead of importing a class, as the screenshot above suggests.&lt;/p&gt;

&lt;p&gt;We need to import the &lt;tt&gt;java.util.List&lt;/tt&gt; interface. Double clicking on the &lt;tt&gt;Import 'List'(java.util)&lt;/tt&gt; option inserts the import statement and allows us to continue writing:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20080111/list_fix.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Eclipse is packed with these kinds of useful but hard to find features. Future Depth-First articles will highlight some of them.&lt;/p&gt;</description>
      <pubDate>Fri, 11 Jan 2008 10:27:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:e67b05db-06a5-4172-b39b-9fd0ea28e3e1</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/01/11/my-favorite-eclipse-shortcut-quick-fix</link>
      <category>Tools</category>
      <category>eclipse</category>
      <category>quickfix</category>
      <category>designingtheobvious</category>
    </item>
  </channel>
</rss>
