The implementors of Eclipse plug-in programming

Source: Internet
Author: User
Tags contains implement interface return
Programming This article describes how to use the Eclipse plug-in implementors in Eclipse.

Eclipse is a very popular development platform, and the open architecture allows many programmers to find their own personalized work environment.

questions raised:

If you want to see the implementation of a class or method, generally CTRL + the left mouse button, click to open the class or method of the specific implementation code. But if you touch an interface, you just reach the interface and you can't get to the specific implementation class.

WORKAROUND: Take advantage of Eclipse's implementors plug-in.

When tracing the method code, Eclipse defaults to the interface class of the method, and the interface only has no specific implementation code for the method name, which provides the ability to trace the implementation code to the specific implementation class.

There is also the call Hierarchy plugin: It shows the invocation hierarchy of a method, from which methods it is called, and what methods it calls, which is a useful tool for code tracking. Eclipse 3.1 already has this feature in its own. This plugin is not subject to additional introduction.

Installation


jdk:1.5.0 from http://java.sun.comGo up and download the installation
eclipse:3.1.1 from http://www.eclipse.orgGo up and download the decompression
Implementors from http://eclipse-tools.sourceforge.net/implementors/

Skill


Eclipse Usage tips for plug-in management

Hint: New Download plugin plugin must not be placed in the original Eclipse directory, a lot of tired you.
    1. If you have already installed the Eclipse tools, such as installing in the E:\OpenSource\Eclipse\ directory, the following directory is represented by%eclipse_home%;
    2. at this time the default plugin is in% A directory in the Eclipse_home%\plugins directory in which
    3. creates a pluginsnew under%eclipse_home%;
      For example: E:\OpenSource\Eclipse\PlugInsNew\
    4. you have downloaded a new plugin, such as: XYZ

      , to create the XYZ directory in the%eclipse_home%\pluginsnew\ directory, which is the ECLIPSE directory, The ECLIPSE directory contains features and plugins two subdirectories; the structure is shown in the following illustration:



    5. put the downloaded new plug-in's files in the appropriate directory

      %eclipse_home%\ Pluginsnew\xyz\eclipse\features
      %eclipse_home%\pluginsnew\ xyz\eclipse\plugins

    6. to establish a related. Link file

      and then create a Xyz.link file in the%eclipse_home%\links directory

      as follows: path=e:/opensource/eclipse/pluginsnew/ XYZ is just one line of such path instructions.

      This way, if you download a number of plug-ins can be done to create multiple link files, want to load which plug-ins to put the plug-in link file into the%eclipse_home%\links directory, the use and management are very convenient, It is recommended that you do not put it in the default installation directory;
      If your%eclipse_home% is different, please modify the path in Xyz.link file

    7. Delete, close ECLIPSE

      Delete%eclipse_ Home%\links\xyz.link file

      Delete%eclipse_home%\pluginsnew\xyz entire directory and file

    8. restart ECLIPSE
Use

Implementors plug-in installation method in the previous section, "Eclipse Usage techniques Plug-in Management"

After you restart Eclipse, in the code editing area, right-click, you can see an increase of two right-click menu Open Interface and open implementation, as shown in the following figure:



We simply create an example project that contains an interface class and a method for demonstrating the two implementation classes that implement the interface.
Interface class: Ihelloworld.java public interface Ihelloworld {  
Implementation Class One: Helloworld1.java public class HelloWorld1 implements Ihelloworld {public HelloWorld1 () { super (); } Public String SayHelloWorld () {return ' Hello world HelloWorld1 '; } Implementation Class Two: Helloworld2.java public class HelloWorld2 implements Ihelloworld {public HelloWorld2 () { super ( ); } Public String SayHelloWorld () {return ' Hello World HelloWorld2 ';
In the interface class Ihelloworld.java method SayHelloWorld () above the right button, in the pop-up menu select Open Implementation, as shown in the following figure:




Click the menu open implementation, it will pop up the relevant implementation class of the interface method for you to choose, if the interface method of the implementation class only one, it will jump directly to the implementation of the class code up, will not appear prompted to select the box.



We first select the implementation class HelloWorld1, so the cursor is positioned on the SayHelloWorld () method that implements the class Helloworld1.java, and is highlighted, as shown in the following figure:




Then go back to the interface class Ihelloworld.java method SayHelloWorld () above the right button, in the pop-up menu select Open Implementation, as shown in the following figure:



This time we choose to implement the class HelloWorld2, so the cursor will be positioned on the SayHelloWorld () method that implements the class Helloworld2.java, and will be highlighted, as shown in the following figure:




In the interface can find a specific implementation, that in the implementation of the class how to check the definition of the interface?

The operation is as follows: In the interface implementation class Helloworld2.java method SayHelloWorld () above the right button, selects open Interface in the pop-up menu, as shown in the following image:



The cursor then navigates to the SayHelloWorld () method of the interface class Ihelloworld.java and highlights the following figure:



Of course, if your method does not have the corresponding interface will not go to the jump.

Summary


The functionality of this plug-in is small, but much easier, and it is estimated that this functionality will be integrated into the future Eclipse version, just like the call hierarchy plug-in.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.