mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: ad1122b3a1518593b52de8d697dc787190ebd9cc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a08e5d62dd
commit
da927e7803
+1
-1
@@ -99,7 +99,7 @@ public class DefaultInspectionToolResultExporter implements InspectionToolResult
|
||||
protected void writeOutput(CommonProblemDescriptor @NotNull [] descriptions, @NotNull RefEntity refElement) throws IOException {
|
||||
InspectionEP inspectionEP = myToolWrapper.getExtension();
|
||||
synchronized (inspectionEP != null ? inspectionEP : WRITER_LOCK) {
|
||||
Path file = InspectionsResultUtil.getInspectionResultFile(myContext.getOutputPath(), myToolWrapper.getShortName());
|
||||
Path file = InspectionsResultUtil.getInspectionResultPath(myContext.getOutputPath(), myToolWrapper.getShortName());
|
||||
boolean exists = Files.exists(file);
|
||||
if (!exists && !Files.isDirectory(file.getParent())) {
|
||||
Files.createDirectories(file.getParent());
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.analysis.AnalysisBundle;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static org.jetbrains.annotations.Nls.Capitalization.Sentence;
|
||||
|
||||
@@ -16,11 +18,13 @@ public final class DeprecationUtil {
|
||||
|
||||
public static final @NonNls String FOR_REMOVAL_ID = "removal";
|
||||
|
||||
public static @Nls(capitalization = Sentence) String getDeprecationDisplayName() {
|
||||
@Contract(pure = true)
|
||||
public static @Nls(capitalization = Sentence) @NotNull String getDeprecationDisplayName() {
|
||||
return AnalysisBundle.message("inspection.deprecated.display.name");
|
||||
}
|
||||
|
||||
public static @Nls(capitalization = Sentence) String getForRemovalDisplayName() {
|
||||
@Contract(pure = true)
|
||||
public static @Nls(capitalization = Sentence) @NotNull String getForRemovalDisplayName() {
|
||||
return AnalysisBundle.message("inspection.marked.for.removal.display.name");
|
||||
}
|
||||
}
|
||||
@@ -66,13 +66,13 @@ public final class InspectionEngine {
|
||||
}
|
||||
}
|
||||
|
||||
private static @NotNull List<ProblemDescriptor> inspect(final @NotNull List<? extends LocalInspectionToolWrapper> toolWrappers,
|
||||
final @NotNull PsiFile file,
|
||||
final @NotNull InspectionManager iManager,
|
||||
final @NotNull ProgressIndicator indicator) {
|
||||
final Map<String, List<ProblemDescriptor>> problemDescriptors = inspectEx(toolWrappers, file, iManager, false, indicator);
|
||||
private static @NotNull List<ProblemDescriptor> inspect(@NotNull List<? extends LocalInspectionToolWrapper> toolWrappers,
|
||||
@NotNull PsiFile file,
|
||||
@NotNull InspectionManager iManager,
|
||||
@NotNull ProgressIndicator indicator) {
|
||||
Map<String, List<ProblemDescriptor>> problemDescriptors = inspectEx(toolWrappers, file, iManager, false, indicator);
|
||||
|
||||
final List<ProblemDescriptor> result = new ArrayList<>();
|
||||
List<ProblemDescriptor> result = new ArrayList<>();
|
||||
for (List<ProblemDescriptor> group : problemDescriptors.values()) {
|
||||
result.addAll(group);
|
||||
}
|
||||
@@ -81,11 +81,11 @@ public final class InspectionEngine {
|
||||
|
||||
// public for Upsource
|
||||
// returns map (toolName -> problem descriptors)
|
||||
public static @NotNull Map<String, List<ProblemDescriptor>> inspectEx(final @NotNull List<? extends LocalInspectionToolWrapper> toolWrappers,
|
||||
final @NotNull PsiFile file,
|
||||
final @NotNull InspectionManager iManager,
|
||||
final boolean isOnTheFly,
|
||||
final @NotNull ProgressIndicator indicator) {
|
||||
public static @NotNull Map<String, List<ProblemDescriptor>> inspectEx(@NotNull List<? extends LocalInspectionToolWrapper> toolWrappers,
|
||||
@NotNull PsiFile file,
|
||||
@NotNull InspectionManager iManager,
|
||||
boolean isOnTheFly,
|
||||
@NotNull ProgressIndicator indicator) {
|
||||
if (toolWrappers.isEmpty()) return Collections.emptyMap();
|
||||
|
||||
TextRange range = file.getTextRange();
|
||||
@@ -101,17 +101,17 @@ public final class InspectionEngine {
|
||||
|
||||
// returns map tool.shortName -> list of descriptors found
|
||||
static @NotNull Map<String, List<ProblemDescriptor>> inspectElements(@NotNull List<? extends LocalInspectionToolWrapper> toolWrappers,
|
||||
final @NotNull PsiFile file,
|
||||
final @NotNull InspectionManager iManager,
|
||||
final boolean isOnTheFly,
|
||||
@NotNull PsiFile file,
|
||||
@NotNull InspectionManager iManager,
|
||||
boolean isOnTheFly,
|
||||
@NotNull ProgressIndicator indicator,
|
||||
final @NotNull List<? extends PsiElement> elements,
|
||||
final @NotNull Set<String> elementDialectIds) {
|
||||
@NotNull List<? extends PsiElement> elements,
|
||||
@NotNull Set<String> elementDialectIds) {
|
||||
TextRange range = file.getTextRange();
|
||||
final LocalInspectionToolSession session = new LocalInspectionToolSession(file, range.getStartOffset(), range.getEndOffset());
|
||||
LocalInspectionToolSession session = new LocalInspectionToolSession(file, range.getStartOffset(), range.getEndOffset());
|
||||
|
||||
toolWrappers = filterToolsApplicableByLanguage(toolWrappers, elementDialectIds);
|
||||
final Map<String, List<ProblemDescriptor>> resultDescriptors = new ConcurrentHashMap<>();
|
||||
Map<String, List<ProblemDescriptor>> resultDescriptors = new ConcurrentHashMap<>();
|
||||
Processor<LocalInspectionToolWrapper> processor = wrapper -> {
|
||||
ProblemsHolder holder = new ProblemsHolder(iManager, file, isOnTheFly);
|
||||
LocalInspectionTool tool = wrapper.getTool();
|
||||
@@ -133,10 +133,10 @@ public final class InspectionEngine {
|
||||
return resultDescriptors;
|
||||
}
|
||||
|
||||
public static @NotNull List<ProblemDescriptor> runInspectionOnFile(final @NotNull PsiFile file,
|
||||
public static @NotNull List<ProblemDescriptor> runInspectionOnFile(@NotNull PsiFile file,
|
||||
@NotNull InspectionToolWrapper<?, ?> toolWrapper,
|
||||
final @NotNull GlobalInspectionContext inspectionContext) {
|
||||
final InspectionManager inspectionManager = InspectionManager.getInstance(file.getProject());
|
||||
@NotNull GlobalInspectionContext inspectionContext) {
|
||||
InspectionManager inspectionManager = InspectionManager.getInstance(file.getProject());
|
||||
toolWrapper.initialize(inspectionContext);
|
||||
RefManagerImpl refManager = (RefManagerImpl)inspectionContext.getRefManager();
|
||||
refManager.inspectionReadActionStarted();
|
||||
@@ -145,8 +145,8 @@ public final class InspectionEngine {
|
||||
return inspect(Collections.singletonList((LocalInspectionToolWrapper)toolWrapper), file, inspectionManager, new EmptyProgressIndicator());
|
||||
}
|
||||
if (toolWrapper instanceof GlobalInspectionToolWrapper) {
|
||||
final GlobalInspectionTool globalTool = ((GlobalInspectionToolWrapper)toolWrapper).getTool();
|
||||
final List<ProblemDescriptor> descriptors = new ArrayList<>();
|
||||
GlobalInspectionTool globalTool = ((GlobalInspectionToolWrapper)toolWrapper).getTool();
|
||||
List<ProblemDescriptor> descriptors = new ArrayList<>();
|
||||
if (globalTool instanceof GlobalSimpleInspectionTool) {
|
||||
GlobalSimpleInspectionTool simpleTool = (GlobalSimpleInspectionTool)globalTool;
|
||||
ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, file, false);
|
||||
@@ -182,7 +182,7 @@ public final class InspectionEngine {
|
||||
return descriptors;
|
||||
}
|
||||
RefElement fileRef = refManager.getReference(file);
|
||||
final AnalysisScope scope = new AnalysisScope(file);
|
||||
AnalysisScope scope = new AnalysisScope(file);
|
||||
assert fileRef != null;
|
||||
fileRef.accept(new RefVisitor(){
|
||||
@Override
|
||||
@@ -279,7 +279,7 @@ public final class InspectionEngine {
|
||||
|
||||
public static @NotNull Set<String> calcElementDialectIds(@NotNull List<? extends PsiElement> inside, @NotNull List<? extends PsiElement> outside) {
|
||||
Set<String> dialectIds = new HashSet<>();
|
||||
Set<Language> processedLanguages = new HashSet();
|
||||
Set<Language> processedLanguages = new HashSet<>();
|
||||
addDialects(inside, processedLanguages, dialectIds);
|
||||
addDialects(outside, processedLanguages, dialectIds);
|
||||
return dialectIds;
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.function.Function;
|
||||
public final class InspectionsResultUtil {
|
||||
@NonNls public static final String DESCRIPTIONS = ".descriptions";
|
||||
@NonNls public static final String XML_EXTENSION = ".xml";
|
||||
static final Logger LOG = Logger.getInstance(InspectionsResultUtil.class);
|
||||
private static final Logger LOG = Logger.getInstance(InspectionsResultUtil.class);
|
||||
|
||||
@NonNls public static final String PROFILE = "profile";
|
||||
@NonNls public static final String INSPECTIONS_NODE = "inspections";
|
||||
@@ -100,7 +100,7 @@ public final class InspectionsResultUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isToolEnabled(@NotNull InspectionProfile profile, String shortName) {
|
||||
private static boolean isToolEnabled(@NotNull InspectionProfile profile, @NotNull String shortName) {
|
||||
if (profile instanceof InspectionProfileImpl) {
|
||||
ToolsImpl tools = ((InspectionProfileImpl)profile).getToolsOrNull(shortName, null);
|
||||
if (tools != null) {
|
||||
@@ -110,16 +110,12 @@ public final class InspectionsResultUtil {
|
||||
return profile.isToolEnabled(HighlightDisplayKey.find(shortName));
|
||||
}
|
||||
|
||||
public static @NotNull Path getInspectionResultPath(@NotNull Path outputDir, String name) {
|
||||
return outputDir.resolve(name + XML_EXTENSION);
|
||||
}
|
||||
|
||||
public static @NotNull Path getInspectionResultFile(@NotNull Path outputDirectory, @NotNull String name) {
|
||||
return outputDirectory.resolve(name + XML_EXTENSION);
|
||||
public static @NotNull Path getInspectionResultPath(@NotNull Path outputDir, @NotNull String shortName) {
|
||||
return outputDir.resolve(shortName + XML_EXTENSION);
|
||||
}
|
||||
|
||||
public static @NotNull BufferedWriter getWriter(@NotNull Path outputDirectory, @NotNull String name) throws IOException {
|
||||
Path file = getInspectionResultFile(outputDirectory, name);
|
||||
Path file = getInspectionResultPath(outputDirectory, name);
|
||||
Files.createDirectories(outputDirectory);
|
||||
return Files.newBufferedWriter(file);
|
||||
}
|
||||
@@ -188,13 +184,12 @@ public final class InspectionsResultUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Writer writer = myFileWriter;
|
||||
try (writer) {
|
||||
endWritingXml();
|
||||
}
|
||||
finally {
|
||||
Writer fileWriter = myFileWriter;
|
||||
myFileWriter = null;
|
||||
fileWriter.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public final class SuppressionUtil extends SuppressionUtilCore {
|
||||
&& commentText.endsWith(prefixSuffixPair.second);
|
||||
}
|
||||
|
||||
private static boolean startsWithSuppressionTag(String commentText, String prefix) {
|
||||
private static boolean startsWithSuppressionTag(@NotNull String commentText, @NotNull String prefix) {
|
||||
if (!commentText.startsWith(prefix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-3
@@ -198,7 +198,7 @@ public class GlobalInspectionContextEx extends GlobalInspectionContextBase {
|
||||
}
|
||||
}
|
||||
if (toolWrapper instanceof LocalInspectionToolWrapper) {
|
||||
hasProblems = Files.exists(InspectionsResultUtil.getInspectionResultFile(outputDir, toolWrapper.getShortName()));
|
||||
hasProblems = Files.exists(InspectionsResultUtil.getInspectionResultPath(outputDir, toolWrapper.getShortName()));
|
||||
}
|
||||
else {
|
||||
presentation.updateContent();
|
||||
@@ -248,8 +248,8 @@ public class GlobalInspectionContextEx extends GlobalInspectionContextBase {
|
||||
@NotNull Path outputPath) {
|
||||
for (Tools tools : toolsWithResultsToAggregate) {
|
||||
String inspectionName = tools.getShortName();
|
||||
inspectionsResults.add(InspectionsResultUtil.getInspectionResultFile(outputPath, inspectionName));
|
||||
inspectionsResults.add(InspectionsResultUtil.getInspectionResultFile(outputPath, inspectionName + InspectionsResultUtil.AGGREGATE));
|
||||
inspectionsResults.add(InspectionsResultUtil.getInspectionResultPath(outputPath, inspectionName));
|
||||
inspectionsResults.add(InspectionsResultUtil.getInspectionResultPath(outputPath, inspectionName + InspectionsResultUtil.AGGREGATE));
|
||||
try {
|
||||
List<? extends InspectionToolWrapper<?, ?>> wrappers = ContainerUtil.map(tools.getTools(), ScopeToolState::getTool);
|
||||
InspectionsResultUtil.writeInspectionResult(getProject(), inspectionName, wrappers, outputPath, this::getPresentation);
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInspection.ui.actions;
|
||||
|
||||
import com.intellij.codeInspection.InspectionsResultUtil;
|
||||
import com.intellij.configurationStore.JbXmlOutputter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Path;
|
||||
|
||||
final class XmlWriterWrapper implements Closeable {
|
||||
private final Project myProject;
|
||||
private final Path myOutputDirectory;
|
||||
private final String myName;
|
||||
private final String myRootTagName;
|
||||
|
||||
private Writer myFileWriter;
|
||||
private JbXmlOutputter myOutputter;
|
||||
|
||||
XmlWriterWrapper(@NotNull Project project,
|
||||
@NotNull Path outputDirectory,
|
||||
@NotNull String name,
|
||||
@NotNull String rootTagName) {
|
||||
myProject = project;
|
||||
myOutputDirectory = outputDirectory;
|
||||
myName = name;
|
||||
myRootTagName = rootTagName;
|
||||
}
|
||||
|
||||
void writeElement(@NotNull Element element) {
|
||||
try {
|
||||
checkOpen();
|
||||
myFileWriter.write('\n');
|
||||
myOutputter.output(element, myFileWriter);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
void checkOpen() throws IOException {
|
||||
if (myFileWriter == null) {
|
||||
myFileWriter = openFile(myOutputDirectory, myName);
|
||||
myOutputter = JbXmlOutputter.createOutputter(myProject);
|
||||
startWritingXml();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (myFileWriter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
endWritingXml();
|
||||
}
|
||||
finally {
|
||||
Writer fileWriter = myFileWriter;
|
||||
myFileWriter = null;
|
||||
fileWriter.close();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Writer openFile(@NotNull Path outputDirectory, @NotNull String name) throws IOException {
|
||||
return InspectionsResultUtil.getWriter(outputDirectory, name);
|
||||
}
|
||||
|
||||
private void startWritingXml() throws IOException {
|
||||
myFileWriter.write('<');
|
||||
myFileWriter.write(myRootTagName);
|
||||
myFileWriter.write('>');
|
||||
}
|
||||
|
||||
private void endWritingXml() throws IOException {
|
||||
try {
|
||||
myFileWriter.write("\n");
|
||||
myFileWriter.write('<');
|
||||
myFileWriter.write('/');
|
||||
myFileWriter.write(myRootTagName);
|
||||
myFileWriter.write('>');
|
||||
}
|
||||
finally {
|
||||
myFileWriter.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user