Skip to content

Commit b316cef

Browse files
authored
Implement in-place rename (#513)
* Implement in-place rename Signed-off-by: Luna <[email protected]> * blank commit for signing Signed-off-by: Luna <[email protected]> * undo blank commit Signed-off-by: Luna <[email protected]>
1 parent 9d507af commit b316cef

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.antlr.intellij.plugin.refactor;
2+
3+
import com.intellij.lang.refactoring.RefactoringSupportProvider;
4+
import com.intellij.psi.PsiElement;
5+
import org.antlr.intellij.plugin.ANTLRv4Language;
6+
import org.antlr.intellij.plugin.psi.RuleSpecNode;
7+
import org.jetbrains.annotations.NotNull;
8+
import org.jetbrains.annotations.Nullable;
9+
10+
public class ANTLRv4RefactoringSupport extends RefactoringSupportProvider{
11+
12+
public boolean isAvailable(@NotNull PsiElement context){
13+
return context.getLanguage().isKindOf(ANTLRv4Language.INSTANCE);
14+
}
15+
16+
// variable in-place rename only applies to elements limited to one file
17+
public boolean isMemberInplaceRenameAvailable(@NotNull PsiElement element, @Nullable PsiElement context){
18+
return element instanceof RuleSpecNode;
19+
}
20+
}

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,6 @@ For really big files and slow grammars, there is an appreciable delay when displ
168168
displayName="ANTLR v4 default project settings"
169169
instance="org.antlr.intellij.plugin.configdialogs.ANTLRv4ProjectSettings"/>
170170
<projectService serviceImplementation="org.antlr.intellij.plugin.configdialogs.ANTLRv4GrammarPropertiesComponent"/>
171+
<lang.refactoringSupport language="ANTLRv4" implementationClass="org.antlr.intellij.plugin.refactor.ANTLRv4RefactoringSupport"/>
171172
</extensions>
172173
</idea-plugin>

0 commit comments

Comments
 (0)