To automatically generate the class name and method name for the code template for Eclipse or Androidstudio

Source: Internet
Author: User

Print Log in the development process always indicate the class and method where log is located ,

Like what:

LOG.E (TAG, "Mainactivity.onresume. Is you OK? ");

Before every time is hand-hit or copy, the previous period of time with Androidstudio, found that can be directly in the livetemplate using variables to import class and function name, suddenly found himself before too young too naive ...

After learning a few, the Eclipse and Androidstudio code templates automatically generate classes and method names in the following ways.

The eclipse example is as follows:

${:import (com.itcast.videotest.utils.LogUtils)}logutils.e (TAG, "${primary_type_name}.${enclosing_method}.${msg} ");//${primary_type_name} indicates the class name//${enclosing_method} represents the method name//Other usage free play, such as creating a Create_tag template, the content is://private static Final String TAG = "${primary_type_name}";

On

The Androidstudio example is as follows:

The first, the latest version is 1.3, hurriedly go to upgrade, and then go to live templates See, big surprise ~ ~ Official gave a bunch of template code, just looked, cool a little control urine, including automatically generated log and tag~~

Learn to customize the following ~

The code is as follows:

LOG.E (TAG, "$CLASS _name$. $METHOD _name$. $content $");

As follows:

1, select Add Live Template

2, fill in the template name, template code body, select template role context, Android development is to put Java hook

3, click "Edit variables", pop-up dialog can be seen to show three variables, that is, our code $$ surrounded by three values, expression column drop-down list has classname () and MethodName (), respectively corresponding good can.

(Clss_name and Method_name "Skip if defined" is recommended, when the generated name value is not empty, the code cursor can automatically stay in the Content section, the input is more convenient.) )

The rest please free play ~ ~ ~

To automatically generate the class name and method name for the code template for Eclipse or Androidstudio

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.