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:
+17
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2017 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package com.siyeh.ig.bugs;
|
||||
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiExpressionStatement;
|
||||
import com.intellij.psi.PsiNewExpression;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.containers.OrderedSet;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
@@ -25,6 +24,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ResultOfObjectAllocationIgnoredInspectionBase extends BaseInspection {
|
||||
|
||||
@SuppressWarnings("PublicField") public OrderedSet<String> ignoredClasses = new OrderedSet<>();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
@@ -42,7 +43,7 @@ public class ResultOfObjectAllocationIgnoredInspectionBase extends BaseInspectio
|
||||
return new ResultOfObjectAllocationIgnoredVisitor();
|
||||
}
|
||||
|
||||
private static class ResultOfObjectAllocationIgnoredVisitor extends BaseInspectionVisitor {
|
||||
private class ResultOfObjectAllocationIgnoredVisitor extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitExpressionStatement(@NotNull PsiExpressionStatement statement) {
|
||||
@@ -53,10 +54,19 @@ public class ResultOfObjectAllocationIgnoredInspectionBase extends BaseInspectio
|
||||
}
|
||||
final PsiNewExpression newExpression = (PsiNewExpression)expression;
|
||||
final PsiExpression[] arrayDimensions = newExpression.getArrayDimensions();
|
||||
if (arrayDimensions.length != 0) {
|
||||
if (arrayDimensions.length != 0 || newExpression.getArrayInitializer() != null) {
|
||||
return;
|
||||
}
|
||||
if (newExpression.getArrayInitializer() != null) {
|
||||
final PsiJavaCodeReferenceElement reference = newExpression.getClassOrAnonymousClassReference();
|
||||
if (reference == null) {
|
||||
return;
|
||||
}
|
||||
final PsiElement target = reference.resolve();
|
||||
if (!(target instanceof PsiClass)) {
|
||||
return;
|
||||
}
|
||||
final PsiClass aClass = (PsiClass)target;
|
||||
if (!(expression instanceof PsiAnonymousClass) && ignoredClasses.contains(aClass.getQualifiedName())) {
|
||||
return;
|
||||
}
|
||||
registerNewExpressionError(newExpression, newExpression);
|
||||
|
||||
+3
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -26,7 +26,6 @@ import com.intellij.codeInspection.ui.ConventionOptionsPanel;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiPackageStatement;
|
||||
import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseGlobalInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
@@ -120,13 +119,11 @@ public class PackageNamingConventionInspection extends BaseGlobalInspection {
|
||||
if (m_maxLength > 0 && length > m_maxLength) {
|
||||
return false;
|
||||
}
|
||||
if (HardcodedMethodConstants.SERIAL_VERSION_UID.equals(name)) {
|
||||
return true;
|
||||
}
|
||||
final Matcher matcher = m_regexPattern.matcher(name);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public LocalInspectionTool getSharedLocalInspectionTool() {
|
||||
return new LocalPackageNamingConventionInspection(this);
|
||||
@@ -176,7 +173,7 @@ public class PackageNamingConventionInspection extends BaseGlobalInspection {
|
||||
index = text.indexOf('.', start);
|
||||
}
|
||||
final String lastName = text.substring(start);
|
||||
if (!mySettingsDelegate.isValid(lastName)) {
|
||||
if (!lastName.isEmpty() && !mySettingsDelegate.isValid(lastName)) {
|
||||
registerErrorAtOffset(reference, start, lastName.length(), lastName);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -18,13 +18,22 @@ package com.siyeh.ig.bugs;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.SuppressForTestsScopeFix;
|
||||
import com.siyeh.ig.ui.UiUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class ResultOfObjectAllocationIgnoredInspection extends ResultOfObjectAllocationIgnoredInspectionBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
return UiUtils.createTreeClassChooserList(ignoredClasses, "Ignored classes", "Choose class for which object allocation can be ignored");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ public class ResultOfObjectAllocationIgnored {
|
||||
|
||||
public static void foo() {
|
||||
new <warning descr="Result of 'new Integer()' is ignored">Integer</warning>(3);
|
||||
new javax.swing.JFrame();
|
||||
}
|
||||
|
||||
void boom() {
|
||||
|
||||
+3
-1
@@ -31,6 +31,8 @@ public class ResultOfObjectAllocationIgnoredInspectionTest extends LightInspecti
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new ResultOfObjectAllocationIgnoredInspection();
|
||||
final ResultOfObjectAllocationIgnoredInspection inspection = new ResultOfObjectAllocationIgnoredInspection();
|
||||
inspection.ignoredClasses.add("javax.swing.JFrame");
|
||||
return inspection;
|
||||
}
|
||||
}
|
||||
+5
@@ -28,6 +28,11 @@ public class PackageNamingConventionInspectionTest extends LightInspectionTestCa
|
||||
"class X {}");
|
||||
}
|
||||
|
||||
public void testNoAssertion() {
|
||||
doTest("package /*Package name 'a' is too short*/a/**/./*!Identifier expected*/;/*!*/" +
|
||||
"class X {}");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new PackageNamingConventionInspection();
|
||||
|
||||
Reference in New Issue
Block a user