mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-6287 Changes to settings of inspections applied via quickfix are not persisted
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.profile.Profile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -31,15 +32,19 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface InspectionProfile extends Profile {
|
||||
|
||||
HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey inspectionToolKey, PsiElement element);
|
||||
|
||||
|
||||
/**
|
||||
* If you need to modify tool's settings, please use {@link #modifyProfile(com.intellij.util.Consumer)}
|
||||
*/
|
||||
InspectionProfileEntry getInspectionTool(@NotNull String shortName, @NotNull PsiElement element);
|
||||
|
||||
@Nullable
|
||||
InspectionProfileEntry getInspectionTool(@NotNull String shortName);
|
||||
|
||||
/** Returns (unwrapped) inspection */
|
||||
InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element);
|
||||
|
||||
@Nullable
|
||||
@Deprecated
|
||||
InspectionProfileEntry getInspectionTool(@NotNull String shortName);
|
||||
void modifyProfile(Consumer<ModifiableModel> modelConsumer);
|
||||
|
||||
/**
|
||||
* @param element context element
|
||||
@@ -50,6 +55,9 @@ public interface InspectionProfile extends Profile {
|
||||
|
||||
void cleanup(Project project);
|
||||
|
||||
/**
|
||||
* @see #modifyProfile(com.intellij.util.Consumer)
|
||||
*/
|
||||
@NotNull
|
||||
ModifiableModel getModifiableModel();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.profile.Profile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -65,8 +66,14 @@ public interface ModifiableModel extends Profile {
|
||||
|
||||
void resetToEmpty();
|
||||
|
||||
/**
|
||||
* @return {@link com.intellij.codeInspection.ex.InspectionToolWrapper}
|
||||
* @see #getUnwrappedTool(String, com.intellij.psi.PsiElement)
|
||||
*/
|
||||
InspectionProfileEntry getInspectionTool(String shortName, PsiElement element);
|
||||
|
||||
InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element);
|
||||
|
||||
InspectionProfileEntry[] getInspectionTools(PsiElement element);
|
||||
|
||||
void copyFrom(InspectionProfile profile);
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.SeverityProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.StringInterner;
|
||||
@@ -338,6 +339,18 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
return tool instanceof InspectionToolWrapper ? ((InspectionToolWrapper)tool).getTool() : tool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyProfile(Consumer<ModifiableModel> modelConsumer) {
|
||||
ModifiableModel model = getModifiableModel();
|
||||
modelConsumer.consume(model);
|
||||
try {
|
||||
model.commit();
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public InspectionProfileEntry getInspectionTool(@NotNull String shortName) {
|
||||
@@ -812,6 +825,9 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
getTools(toolId).moveScope(idx, dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null if it has no base profile
|
||||
*/
|
||||
@Nullable
|
||||
private Map<String, Boolean> getDisplayLevelMap() {
|
||||
if (myBaseProfile == null) return null;
|
||||
|
||||
Reference in New Issue
Block a user