IntelliJ IDEAプラグイン開発。 パート6

このパートでは、リファクタリング、フォーマット、設定、その他の便利な機能。 前の部分。

「名前変更」のリファクタリング


IntelliJ IDEAの名前変更操作は「使用状況の検索」に似ています。IDEAは、名前変更する要素の検索に同じルールを使用し、名前を変更する要素へのリンクを含むファイルの検索に同じ単語のインデックスを使用します。

このリファクタリングが実行されると、PsiNamedElement.setName()メソッドがターゲット要素で呼び出され、PsiReference.handleElementRename()メソッドがすべての参照に対して呼び出されます。 両方のメソッドは1つの主要なアクションを実行します-基礎となるASTノードをユーザーが入力したテキストを含む新しいノードに置き換えます。 完全に有効なASTを作成することは非常に困難ですが、次の方法を使用できます。必要なノードを含むダミーのユーザー言語ファイルを作成し、それをコピーします。

例:プロパティプラグインでsetName()メソッドを実装します。

リファクタリングの名前変更に関連するもう1つのインターフェイスはNamesValidatorです。 このインターフェースにより、プラグインは、ユーザーが識別子名を正しく入力したかどうか、つまり、 カスタム言語の命名規則に準拠しており、キーワードとは一致しません。 インターフェースの実装がプラグインによって提供されない場合、Java命名規則が使用されます。 実装は、拡張ポイントcom.intellij.lang.namesValidatorで登録する必要があります。

例:プロパティのNamesValidator

名前変更プロセスのさらなるカスタマイズは、いくつかのレベルで可能です。 RenameHandlerインターフェースの実装を提供することにより、プラグインはユーザーインターフェースと名前変更リファクタリングロジックを完全に置き換えることができます。これは、PsiElement以外のものと連携できることも意味します。

例:リソースバンドルの名前を変更するRenameHandler

標準UIをオーバーライドする必要はないが、名前変更ロジックを拡張する必要がある場合は、 RenamePsiElementProcessorインターフェイスの独自の実装を提供できます。 できること:

例: RenamePsiElementProcesssorを使用して、プロパティの名前を変更します。

安全な除去リファクタリング


安全な削除のリファクタリングは、Find Usagesフレームワークの上に構築されています。 安全な削除を使用するには、2つのことを実装する必要があります。

特定のタイプの要素のリファクタリング動作を構成する場合、 SafeDeleteProcessorDelegateインターフェースがこれに役立ちます。

例:* .propertiesファイルのSafeDeleteProcessorDelegate 実装

自動コードフォーマット


IntelliJ IDEAには、カスタムフォーマッタを作成するための強力なフレームワークが含まれています。 このフレームワークでは、プラグインはさまざまな構文要素間の空白の制限を定義し、IDEAが提供するフォーマットエンジンは、制限を満たすために実行する必要がある最小のスペース変更数を計算します。

ファイルまたはフラグメントをフォーマットするプロセスは、次の基本的な手順で構成されます。

通常、ブロック構造はPSIファイル構造に従います。 フォーマッタはブロック間にある文字のみを変更するため、ブロックツリーはファイルのすべての非空白文字をカバーする必要があります。そうしないと、ブロック間にあるすべてのものを削除できます。

書式設定操作がファイル全体に適用されない場合(たとえば、フォーマッタが挿入されたテキストブロックに対して呼び出される場合)、ブロックの完全なツリーは構築されません-代わりに、書式設定とその直接の祖先に渡されるテキスト範囲をカバーするブロックが使用されます。

各ブロックに対して、プラグインは次のプロパティを定義する必要があります。

フォーマッタを使用する特殊なケースは、プラグインユーザーがソースコードの編集中にEnterキーを押す場合です。 インデント値を決定するために、書式設定エンジンは、カーソルの直前のブロックのisIncomplete()メソッドの戻り値に応じて、カーソルの直前のブロックまたは親でgetChildAttributes()メソッドを呼び出します。 ブロックが完了すると、getChildAttributes()が呼び出されます。 それ以外の場合、呼び出しは親ブロックで発生します。

コードスタイル設定


デフォルトのインデント値を決定し、たとえば、ユーザーがタブのサイズとインデントを調整できるようにするには、 fileTypeIndentOptionsProvider拡張fileTypeIndentOptionsProviderで登録する必要があるFileTypeIndentOptionsProviderインターフェイスを実装できます。 createIndentOptions()インターフェイスメソッドは、インデントのデフォルト値を定義します。

より柔軟な構成管理のために、設定ダイアログに表示されるJava Swingフォームであるcom.intellij.applicationConfigurable拡張ポイントでConfigurableインターフェースの実装を登録できます。

検査


カスタム言語のソースコード検査は、残りの検査と同じAPIを使用し、LocalInspectionToolクラスに基づいています。

LocalInspectionToolの機能はAnnotatorを部分的に複製します。主な違いは、バッチコード処理のサポート(「分析|コードの検査...」アクションによってトリガーされます)、検査を無効にしてオプションを構成する機能です。 たとえば、上記のいずれも必要ない場合、アクティブなエディターでのみ分析を実行する必要がある場合は、Annotatorを使用する方がより有益です。 パフォーマンスの向上(インクリメンタル分析のサポートのおかげ)とエラーの強調表示の柔軟性が向上しています。

例:.propertiesファイルの簡単な検査

ユーザーインテンション(クイックフィックス)も標準APIを使用し、拡張ポイントに登録されたIntentionActionインターフェースの実装を提供する必要があります 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/J187474/


All Articles