[IDEA & amp; Eclipse] 3. IntelliJ IDEA features that 20 codes are automatically completed, intellijidea

Source: Internet
Author: User

[IDEA & Eclipse] 3. IntelliJ IDEA features that 20 codes are automatically completed, intellijidea

In this article, I want to show you the top 20 automatically completed Code features in IntelliJ IDEA to make Java coding more efficient. For any integrated development environment, Automatic completion of code is the most important function. It pre-judges based on the content you enter and helps you automatically complete the code you want to enter, sometimes you don't even know what you want to input, such as some class names, members, methods, or other content.

I am so impressed by the automatic completion of code in IntelliJ IDEA because IDEA really understands your code and your current context. Next we will briefly describe these most important features, which make IDEA show better performance than other ides.

Immediate completion of Instant completion

The first and most attractive feature is the "instant completion" feature. Unlike other ides, IDEA can provide this feature anywhere, not only when you want to access a member of a class. You only need to enter the first letter of a word, IntelliJ IDEA will immediately give you the most relevant options that best suit the code editing needs here.

To learn how effective "complete now" is, you can browse this demo video.

Type-aware Automatic completion Type-aware completion

Another feature breaks the conventional method of automatic code completion, which is called Intelligent Automatic completion. You may already know that IDEA includes more than one automatically completed function, includingThe primary Space is automatically completed.AndIntelligent and Automatic completion of strongswan Space.

When you call outSmart Automatic completionIt filters out unsuitable entries in the recommendation list and only displays available classes, variables, attributes, or methods. This improves performance and avoids unnecessary errors, if you try this function, you will always think of it.

Static attributes and methods Static fields and methods

As I said earlier, IDEA has always been ahead of your ideas. If you do not remember the class names of some static members, you only need to enter the name of the static member and then call "auto-completion" twice ", IDEA will provide you with a correct list of options, or even a method that comes in through static import. If you callIntention action execution failed.

Again, if you useSmart Automatic completionIt only provides the correct options.

Chain auto-Complete Chain completion

The next Automatic completion feature that enables you to improve the encoding efficiency is calledChain completion). If you need to enter the call method getModule (). getProject (), you only need to useSmart completionYou can. In this case, IDEA will scan variables, attributes, and methods, as well as the visibility in the current context, and provide you with available options.

You may know that Eclipse Juno has a plug-in named Code Recommenders. This is a very interesting plug-in that provides the functions mentioned here, but it works in completely different ways, only suggestions in the Eclipse sdk api class are provided, while IDEA provides automatic completion suggestions for all classes in your code.

Data flow analysis

IntelliJ IDEA is called the most intelligent Java IDE because the various functions provided by IDEA are based on the analysis results of your code. Data Stream analysis is one of them. IDEA analyzes the data stream to guess the variable type in the running environment, and provides automatic completion based on this type and automatic addition of forced type conversion of classes.

Constant automatically completes Constants completion

Many APIs use the original Java type instead of Enumeration type to define constants. IDEA can analyze these constants in the project and provide selection and quick input in the automatically completed recommendation list.

The parent class automatically completes Super completion.

You may have noticed that calling a parent class constructor with many parameters is annoying, and IDEA can understand what you want and provide a list of suggestions for you to choose from.

The statement automatically completes Statements completion

Another smart feature of IntelliJ IDEA isComplete statement completion statementBegin, which can help you complete the rest of the input statement, automatically add missing braces and necessary formatting.

You may think this is a small feature, but you will be surprised to find that when you get used to it, it saves you a lot of time.

If you want to try this feature, you can try to input if in the code and then pressZookeeperOptional. You can also use it when selecting from the suggestion list.

Parameter info

I believe that most ides provide parameter suggestions when you call a method or constructor, and how to provide them is also very important.

IntelliJ IDEA will display the parameter information of each overload method or constructor, and highlight the best matching parameter type. This helps you select the appropriate method based on the input and expected content.

You can also use parameter P to display parameter information.

Quick definition

Another feature you may not know isQuick definition I. It will pop up the content of the method definition in the suggestion list. More often, the definition of the method is more useful than the document, especially when you are not sure which method to use.

Exclude from completion excluded from Automatic completion

I'm sure everyone will encounter this situation at least once. A repetition that you never use always appears in the auto suggestion list repeatedly. For example, com. sun or java. awt package.

IntelliJ IDEA can help you exclude these options. You only need to callIntention Upload FailedAnd confirm, you can alsoSettings.

Inject Injected ages into other languages

The next step is as simple as Automatic Code Completion. This function can be used to open a new article for details, but here we will only introduce the sections related to Automatic Code completion.

Language injection in other languagesIs an advanced code assistant provided by IntelliJ IDEA. It can automatically complete string expressions in Java code. These expressions can be SQL, JPQL, XPath expression, HTML, CSS, JavaScript fragments, and other languages.

Before IntelliJ IDEA can automatically complete these expressions, you must specify the corresponding language. You can callIntention action execution failedBefore you can use it.

For example, if you define a data source in IDEA, you can use an SQL expression based on the table name automatically, the IDE analyzes all files in the project and provides advanced automatic completion for Supported languages.

Use the Tab key to automatically complete the Completion with Tab

Another feature isUsing ompletion with Tab, That is, you can use the Tab key to achieve automatic completion. When you select an entry in the recommended list and click "hide", the selected content will overwrite the cursor identifier instead of insert. This is useful when editing identifiers such as file names.

Negative boolean result Negating boolean results

Not everyone knows that it is used from the suggestion list! When you select a Boolean option, IntelliJ IDEA automatically adds the non-value of the option (for example, if it is true to false ).

Middle matching

Another efficient method isMiddle matching. When you enter an identifier at the beginning, IntelliJ IDEA will provide you with a list of suggestions to choose from. This feature can significantly improve the coding efficiency, especially when you only remember a part of a name.

Case sensitivity settings

As you may already know, a common method to complete code is to use the hump rule to match the corresponding class name based on your input. Although you need to enter at least one letter in size to give some clues to the IDE. IntelliJ IDEA has improved this rule. It does not require uppercase or lowercase letters, that is, you do not need to press the limit when using this function.

IntelliJ IDEA is case sensitive by default. You canSettingsModify this setting.

Automatic completion of resource properties, file names, and resources

IDEA can also determine whether resources are being loaded and provide a list of available resources.

Some Class names in non-Java files automatically complete Class name completion in non-Java files

IntelliJ IDEA also provides some non-Java files, such as the class names in the XML configuration file.

Completion in other places is automatically completed elsewhere

Another feature that you can hardly see in other ides is that it is not just in the code editor, it can also be used in debugger, expression simulation, monitoring, file selector, search input, and many other places.

Automatic completion in expression evaluation and monitoring tools is very valuable.

Summary

I hope this article will help you better understand and benefit from IntelliJ IDEA's Automatic Code Completion features.

You can useHelpProductivity GuideTo learn more about Automatic completion types and how much time IDEA has helped you save (this is a bit interesting)

 

Original English, OSCHINA Original translation

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.