mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: preview for safe delete quick-fix
GitOrigin-RevId: ecc86cac9a859eb5c1b580f780d343a7dafb14da
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1f7adc4631
commit
9eae75c034
+10
-16
@@ -1,23 +1,10 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil;
|
||||
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
|
||||
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -26,6 +13,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
|
||||
import com.intellij.refactoring.safeDelete.SafeDeleteProcessor;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
@@ -69,9 +57,15 @@ public class SafeDeleteFix extends LocalQuickFixAndIntentionActionOnPsiElement {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
|
||||
PsiElement element = PsiTreeUtil.findSameElementInCopy(getStartElement(), file);
|
||||
element.delete();
|
||||
return IntentionPreviewInfo.DIFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Safe delete 'i'" "true"
|
||||
// "Safe delete 'i'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Safe delete 'i'" "true"
|
||||
// "Safe delete 'i'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Safe delete 'i'" "true"
|
||||
// "Safe delete 'i'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Safe delete 'i'" "true"
|
||||
// "Safe delete 'i'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
|
||||
Reference in New Issue
Block a user