Search in sources :

Example 1 with PsiImportStaticStatement

use of com.intellij.psi.PsiImportStaticStatement in project intellij-community by JetBrains.

the class InlineStaticImportHandler method inlineElement.

@Override
public void inlineElement(Project project, Editor editor, PsiElement element) {
    final PsiImportStaticStatement staticStatement = PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class);
    final List<PsiJavaCodeReferenceElement> referenceElements = collectReferencesThrough(element.getContainingFile(), null, staticStatement);
    RefactoringEventData data = new RefactoringEventData();
    data.addElement(element);
    project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(REFACTORING_ID, data);
    new WriteCommandAction(project, REFACTORING_NAME) {

        @Override
        protected void run(@NotNull Result result) throws Throwable {
            replaceAllAndDeleteImport(referenceElements, null, staticStatement);
        }
    }.execute();
    project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(REFACTORING_ID, null);
}
Also used : WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) PsiImportStaticStatement(com.intellij.psi.PsiImportStaticStatement) PsiJavaCodeReferenceElement(com.intellij.psi.PsiJavaCodeReferenceElement) RefactoringEventData(com.intellij.refactoring.listeners.RefactoringEventData) Result(com.intellij.openapi.application.Result)

Aggregations

Result (com.intellij.openapi.application.Result)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 PsiImportStaticStatement (com.intellij.psi.PsiImportStaticStatement)1 PsiJavaCodeReferenceElement (com.intellij.psi.PsiJavaCodeReferenceElement)1 RefactoringEventData (com.intellij.refactoring.listeners.RefactoringEventData)1