📜 ⬆️ ⬇️

Development of IntelliJ IDEA plugin. Part 6

In this part: refactorings, formatting, settings and other useful functions. The previous part.

Renaming refactoring


The rename operation in IntelliJ IDEA is similar to “Find Usages”, IDEA uses the same rules to search for elements to rename and the same word index to find files that can contain links to the element to be renamed.

When this refactoring is performed, the PsiNamedElement.setName () method is called on the target element, and the PsiReference.handleElementRename () method is called for all references to it. Both methods perform one main action - replacing the underlying AST node with a new one containing the text entered by the user. Creating a fully valid AST can be quite complicated, but you can use the following method: create a dummy custom language file containing the desired node, and then copy it.

Example: implementation of the setName () method in the Properties plugin.
')
Another interface related to renaming is the NamesValidator . This interface allows the plugin to check if the user has entered the identifier name correctly, i.e. corresponds to the naming rules in the user language and does not match the keyword. If the interface implementation is not provided by the plugin, then Java naming rules are used. The implementation must be registered at the expansion point com.intellij.lang.namesValidator.

Example: NamesValidator for Properties.

Further customization of the renaming process is possible at several levels. By providing the implementation of the RenameHandler interface, the plugin is able to completely replace the user interface and the logic of the renaming refactoring, which also implies the ability to work with something other than PsiElement.

Example: RenameHandler to rename a resource bundle.

If you do not need to override the standard UI, but you need to expand the renaming logic, you can provide your own implementation of the RenamePsiElementProcessor interface. What allow:

Example: RenamePsiElementProcesssor to rename Property.

Refactoring "Safe Delete"


Refactoring for safe removal is also built on top of the Find Usages framework. In order to use secure deletion, two things must be implemented:

If you want to customize the behavior of refactoring for certain types of elements, then the SafeDeleteProcessorDelegate interface can help.

Example: implementation of SafeDeleteProcessorDelegate for * .properties files.

Automatic code formatting


IntelliJ IDEA includes a powerful framework for creating custom formatters. In this framework, the plugin defines restrictions on whitespace between different syntax elements, then the formatting engine provided by IDEA calculates the smallest number of modifications to the gaps that must be made to satisfy the restrictions.

The process of formatting a file or fragment consists of the following basic steps:

The block structure usually follows the PSI file structure. The formatter modifies only the characters that are between blocks, so the tree of blocks must cover all non-blank characters in the file, otherwise everything that is between the blocks can be deleted.

If the formatting operation is not applied to the entire file (for example, when the formatter is called for the inserted block of text), the full block tree is not built - instead, the blocks covering the text range passed to formatting and its direct ancestor are used.

For each block, the plugin must define the following properties:

A special case of using a formatter is when the user of the plugin presses Enter while editing the source code. To determine the indentation value, the formatting engine calls the getChildAttributes () method either on the block immediately before the cursor, or on the parent, depending on the return value of the isIncomplete () method on the block before the cursor. If the block is completed, then getChildAttributes (); otherwise, the call occurs on the parent block.

Code Style Settings


To determine the default indent size and, for example, to allow the user to customize the size of tabs and indents, you can implement the FileTypeIndentOptionsProvider interface, which you need to register at the fileTypeIndentOptionsProvider extension fileTypeIndentOptionsProvider . The interface's createIndentOptions () method defines the default value for indents.

For more flexible settings management, it is possible to register at the expansion point com.intellij.applicationConfigurable implementation of the Configurable interface, which is a Java Swing form displayed in the Settings dialog.

Inspections


Source code inspections for user languages ​​use the same API as other inspections and are based on the LocalInspectionTool class.

The LocalInspectionTool functionality partially duplicates the Annotator, the main differences are the support for batch processing of the code (triggered by the “Analyze | Inspect Code ...” action), the ability to disable inspections and configure their options. If none of the above is required, for example, the analysis needs to be run only in the active editor, then the use of the Annotator is more beneficial, since it has better performance (thanks to the support of incremental analysis) and greater flexibility in highlighting errors.

Example: simple inspection for .properties files.

Custom Intentions (quickfix) also use the standard API, they must provide an implementation of the IntentionAction interface registered at the extension point plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory .

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .
plugin.xml.

: Intention Groovy.


. StructureView, . Structure View .
PsiStructureViewFactory com.intellij.lang.psiStructureViewFactory
.

: PsiStructureViewFactory .properties.

, TreeBasedStructureViewBuilder PsiStructureViewFactory.getStructureViewBuilder(). TextEditorBasedStructureViewModel , , .

: StructureViewModel .properties.

getRoot() StructureViewTreeElement . IDEA , .

Structure View PSI-. StructureViewTreeElement.getChildren() , . – getPresentation(), , , .., Structure View.

StructureViewTreeElement.getChildren() TextEditorBasedStructureViewModel.getSuitableClasses(). PsiElement, , "Autoscroll from source".

: StructureViewElement Property.

"Surround With"
"Code | Surround With...", SurroundDescriptor com.intellij.lang.surroundDescriptor . , - , , - . Surrounder , , (, "Surround With if", "Surround With for").

"Surround With...", IDEA , getElementsToSurround(). Surrounder.isApplicable() , . Surrounder , surroundElements().


, , IDEA, "Go to | Class..." "Go to | Symbol...".
, ChooseByNameContributor com.intellij.gotoSymbolContributor com.intellij.gotoClassContributor .
, IDEA . , NavigationItem , , .


( Ctrl-hover, Ctrl-Q), DocumentationProvider lang.documentationProvider . IDEA 10.5, AbstractDocumentationProvider .
getQuickNavigateInfo() Ctrl.

: DocumentationProvider Properties.


, - PairedBraceMatcher ( BracePair ). ( , , begin/end, ).

. , : , , .

FoldingBuilder . buildFoldRegions() , ( FoldingDescriptor ), getPlaceholderText(), - – isCollapsedByDefault(). : . FoldingGroup.newGroup(). lang.foldingBuilder .

– IDEA, . Commenter , , , . lang.commenter .

: Properties.

"To Do" - , ParserDefinition.getCommentTokens(). « // Todo », «To Do View» (Alt+6).

"View | Context Info" IDEA 10.5. Structure view, TreeBasedStructureViewBuilder DeclarationRangeHandler , declarationRangeHandler .

. Psi-. IntelliJ IDEA RelatedItemLineMarkerProvider .
codeInsight.lineMarkerProvider .

, . , ( : /, , / ..). , «Settings | File Templates». , IntelliJ IDEA API . FileTemplateGroupDescriptorFactory com.intellij.fileTemplateGroup .

: UI-.

: 1 , 2 , 3 , 4 , 5 , 6 , 7 .

Source: https://habr.com/ru/post/187474/


All Articles