mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+2
-11
@@ -23,12 +23,9 @@ import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.SuppressForTestsScopeFix;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SystemOutErrInspection extends BaseInspection {
|
||||
public class SystemOutErrInspectionBase extends BaseInspection {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@@ -50,12 +47,6 @@ public class SystemOutErrInspection extends BaseInspection {
|
||||
"use.system.out.err.problem.descriptor");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
return new SuppressForTestsScopeFix(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new SystemOutErrVisitor();
|
||||
@@ -84,7 +75,7 @@ public class SystemOutErrInspection extends BaseInspection {
|
||||
if (!"java.lang.System".equals(className)) {
|
||||
return;
|
||||
}
|
||||
registerError(expression);
|
||||
registerError(expression, expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-11
@@ -20,13 +20,10 @@ import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.SuppressForTestsScopeFix;
|
||||
import com.siyeh.ig.psiutils.MethodCallUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ThrowablePrintStackTraceInspection extends BaseInspection {
|
||||
public class ThrowablePrintStackTraceInspectionBase extends BaseInspection {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@@ -46,12 +43,6 @@ public class ThrowablePrintStackTraceInspection extends BaseInspection {
|
||||
return InspectionGadgetsBundle.message("printstacktrace.call.problem.descriptor");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
return new SuppressForTestsScopeFix(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new ThrowablePrintStackTraceVisitor();
|
||||
@@ -82,7 +73,7 @@ public class ThrowablePrintStackTraceInspection extends BaseInspection {
|
||||
if (!CommonClassNames.JAVA_LANG_THROWABLE.equals(name)) {
|
||||
return;
|
||||
}
|
||||
registerMethodCallError(expression);
|
||||
registerMethodCallError(expression, expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
-3
@@ -20,14 +20,21 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.openapi.command.undo.BasicUndoableAction;
|
||||
import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.command.undo.UnexpectedUndoException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.psiutils.TestUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
@@ -36,10 +43,18 @@ public class SuppressForTestsScopeFix extends InspectionGadgetsFix {
|
||||
|
||||
private final BaseInspection myInspection;
|
||||
|
||||
public SuppressForTestsScopeFix(BaseInspection inspection) {
|
||||
private SuppressForTestsScopeFix(BaseInspection inspection) {
|
||||
myInspection = inspection;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SuppressForTestsScopeFix build(BaseInspection inspection, PsiElement context) {
|
||||
if (!TestUtils.isInTestSourceContent(context)) {
|
||||
return null;
|
||||
}
|
||||
return new SuppressForTestsScopeFix(inspection);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -58,7 +73,23 @@ public class SuppressForTestsScopeFix extends InspectionGadgetsFix {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor) {
|
||||
protected void doFix(final Project project, ProblemDescriptor descriptor) {
|
||||
addRemoveTestsScope(project, true);
|
||||
final VirtualFile vFile = descriptor.getPsiElement().getContainingFile().getVirtualFile();
|
||||
UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction(vFile) {
|
||||
@Override
|
||||
public void undo() throws UnexpectedUndoException {
|
||||
addRemoveTestsScope(project, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo() throws UnexpectedUndoException {
|
||||
addRemoveTestsScope(project, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addRemoveTestsScope(Project project, boolean add) {
|
||||
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
|
||||
final InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getInspectionProfile();
|
||||
final String shortName = myInspection.getShortName();
|
||||
@@ -69,6 +100,12 @@ public class SuppressForTestsScopeFix extends InspectionGadgetsFix {
|
||||
final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests");
|
||||
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
|
||||
final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project);
|
||||
profile.addScope(tool, namedScope, level, false, project);
|
||||
if (add) {
|
||||
profile.addScope(tool, namedScope, level, false, project);
|
||||
}
|
||||
else {
|
||||
profile.removeScope(shortName, 0, project);
|
||||
}
|
||||
profile.scopesChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
*/
|
||||
package com.siyeh.ig.maturity;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.SuppressForTestsScopeFix;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class SystemOutErrInspection extends SystemOutErrInspectionBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
final PsiElement context = (PsiElement)infos[0];
|
||||
return SuppressForTestsScopeFix.build(this, context);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
*/
|
||||
package com.siyeh.ig.maturity;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.SuppressForTestsScopeFix;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class ThrowablePrintStackTraceInspection extends ThrowablePrintStackTraceInspectionBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
final PsiElement context = (PsiElement)infos[0];
|
||||
return SuppressForTestsScopeFix.build(this, context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user