[md] safe delete refactoring extracted

This commit is contained in:
Anna Bulenkova 2015-04-16 15:47:14 +02:00
parent 56417cb07a
commit 108e1f712d
3 changed files with 36 additions and 30 deletions

View File

@ -55,6 +55,7 @@
* [Code Completion](code_completion.html)
* [Find Usages](find_usages.html)
* [Rename Refactoring](rename_refactoring.html)
* [Safe Delete Refactoring](safe_delete_refactoring.html)
* [XML DOM API](xml_dom_api.html)
* [Spring API](spring_api.html)
* [VCS Integration Plugins](vcs_integration_for_plugins.html)

View File

@ -27,38 +27,9 @@ Providing custom language support includes the following major steps:
* [Code Completion](code_completion.html)
* [Find Usages](find_usages.html)
* [Rename Refactoring](rename_refactoring.html)
* [Safe Delete Refactoring](safe_delete_refactoring.html)
## Safe Delete Refactoring
The ```Safe Delete``` refactoring also builds on the same ```Find Usages``` framework as ```Rename```.
In addition to that, in order to support ```Safe Delete```, a plugin needs to implement two things:
* The
[RefactoringSupportProvider](https://github.com/JetBrains/intellij-community/blob/master/platform/lang-api/src/com/intellij/lang/refactoring/RefactoringSupportProvider.java)
interface, registered in the `com.intellij.lang.refactoringSupport` extension point, and the `isSafeDeleteAvailable()` method, which checks if the ```Safe Delete``` refactoring is available for a specific PSI element
* The
[PsiElement.delete()](https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/psi/PsiElement.java#L371)
method for the
[PsiElement](https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/psi/PsiElement.java)
subclasses for which ```Safe Delete``` is available.
Deleting PSI elements is implemented by deleting the underlying AST nodes from the AST tree (which, in turn, causes the text ranges corresponding to the AST nodes to be deleted from the document).
**Example:**
[delete()](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/psi/impl/PropertyImpl.java#L363)
implementation for a
[Property language plugin](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/)
If needed, it's possible to further customize how Safe Delete is performed for a particular type of element (how references are searched, etc).
This is done by implementing the `SafeDeleteProcessorDelegate` interface.
**Example**:
[SafeDeleteProcessorDelegate](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/src/com/intellij/lang/properties/refactoring/PropertiesFilesSafeDeleteProcessor.java)
implementation for a .properties file

View File

@ -0,0 +1,34 @@
---
layout: editable
title: Safe Delete Refactoring
---
The ```Safe Delete``` refactoring also builds on the same ```Find Usages``` framework as ```Rename```.
In addition to that, in order to support ```Safe Delete```, a plugin needs to implement two things:
* The
[RefactoringSupportProvider](https://github.com/JetBrains/intellij-community/blob/master/platform/lang-api/src/com/intellij/lang/refactoring/RefactoringSupportProvider.java)
interface, registered in the `com.intellij.lang.refactoringSupport` extension point, and the `isSafeDeleteAvailable()` method, which checks if the ```Safe Delete``` refactoring is available for a specific PSI element
* The
[PsiElement.delete()](https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/psi/PsiElement.java#L371)
method for the
[PsiElement](https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/psi/PsiElement.java)
subclasses for which ```Safe Delete``` is available.
Deleting PSI elements is implemented by deleting the underlying AST nodes from the AST tree (which, in turn, causes the text ranges corresponding to the AST nodes to be deleted from the document).
**Example:**
[delete()](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/psi/impl/PropertyImpl.java#L363)
implementation for a
[Property language plugin](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/)
If needed, it's possible to further customize how Safe Delete is performed for a particular type of element (how references are searched, etc).
This is done by implementing the `SafeDeleteProcessorDelegate` interface.
**Example**:
[SafeDeleteProcessorDelegate](https://github.com/JetBrains/intellij-community/blob/master/plugins/properties/src/com/intellij/lang/properties/refactoring/PropertiesFilesSafeDeleteProcessor.java)
implementation for a .properties file