Eclipse/myeclipse Adding custom Comment variables

Source: Internet
Author: User

When using eclipse for Pydev, Chinese is shown in the auto-generated comment's time {timeframe} variable, similar to the following:

[Python]View PlainCopy
  1. " "  
  2. created on 2014 July 20  
  3. @author: Memray
  4. " "   

I thought this template variable is very simple to change, how to get it.

Reprinted from: http://blog.163.com/liangge_sky/blog/static/210500188201361112327287/


There are several comment variable names in eclipse/myeclipse. These names can help us add something useful and repetitive in the comments. But the name it provides is limited, often we need to add some other names on it, then how to add it, after searching the network for a period of time, found the practice. The following article will take MyEclipse 2013, add a custom myversion variable name as an example, describes the steps to do:

1. In the Myeclipse/plugins directory, find 2 jar packages similar to the following structure:

Org.eclipse.text.XXXX.jar

Org.eclipse.jdt.ui_XXXX.jar, where XXXX is the version number followed by the jar package when Ecilpse/myeclipse is released. A similar jar package can be found by looking in front of the content.

2, under the Org.eclipse.text_3.5.200.v20120523-1310.jar\org\eclipse\jface\text\templates directory structure, Add a resource tip message in the Texttemplatemessages.properties file:

globalvariables.variable.description.myversion= Version of the Code

This resource will be prompted when a variable is added to the annotation template.

3. Modify the class under Org.eclipse.text_3.5.200.v20120523-1310.jar\org\eclipse\jface\text\templates directory package: GlobalTemplateVariables , this kind of anti-compilation (after the compilation of the compiler will need to rely on the last picture, a little more than the three classes depend on the package, there are other east-dependent packages, too lazy) after the code to add the definition of the variable class (refer to its user Class):

It is best to use a new class, no need to decompile globaltemplatevariables modification.

4, modify the Org.eclipse.jdt.ui_3.8.2.v20130107-165834.jar\org\eclipse\jdt\internal\corext\template\ Class under the Java Directory Package: Codetemplatecontexttype, add a myversion instance to the constructor in this class of anti-compilation code to support ${myversion} variables:

5. Modify the two jar packages found in step 1th: Copy the Modified class and properties file into the original jar package, replacing the original class: Globaltemplatevariables, Texttemplatemessages.properties, Codetemplatecontexttype, and copy the modified two jar package to the Myeclipse/plugins directory, replace the original jar package (it is best to replace the original jar package, and replace it, to ensure that the myeclipse does not have a branch ; The reason is not explained):

6, use: Add the environment variable name in Myeclispe.ini:-dmyversion=self 1.0, and start MyEclipse.

and add our custom variables in the annotation template and generate the generated comments, and you can see that self 1.0 has been automatically added to the comments of the class (this is not my manual addition of yo ...). )。

Eclipse/myeclipse Adding custom Comment variables

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.