From a9d3c2cc278cd0b40335f72044943af874c208bd Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 3 Feb 2010 16:02:09 +0300 Subject: [PATCH] IDEA-51944 --- .../daemon/impl/analysis/HighlightUtil.java | 25 ---------------------- .../daemon/impl/analysis/HighlightVisitorImpl.java | 1 - .../ex/StandardInspectionToolsProvider.java | 2 ++ .../codeInsight/daemon/impl/HighlightInfoType.java | 1 - .../com/intellij/codeInspection/ex/Descriptor.java | 4 ++-- .../util/src/com/intellij/util/ResourceUtil.java | 6 +++--- 6 files changed, 7 insertions(+), 32 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index 775cf7597b..9aaed86e9c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -68,7 +68,6 @@ public class HighlightUtil { private static final Map> ourClassInitializerIncompatibleModifiers; private static final Set ourConstructorNotAllowedModifiers; - private static final Key HAS_OVERFLOW_IN_CHILD = Key.create("HAS_OVERFLOW_IN_CHILD"); @NonNls private static final String SERIAL_VERSION_UID_FIELD_NAME = "serialVersionUID"; @NonNls private static final String SERIAL_PERSISTENT_FIELDS_FIELD_NAME = "serialPersistentFields"; private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance(); @@ -1766,30 +1765,6 @@ public class HighlightUtil { } - static HighlightInfo checkConstantExpressionOverflow(PsiExpression expr) { - boolean overflow = false; - try { - if (expr.getUserData(HAS_OVERFLOW_IN_CHILD) == null && TypeConversionUtil.isNumericType(expr.getType())) { - JavaPsiFacade.getInstance(expr.getProject()).getConstantEvaluationHelper().computeConstantExpression(expr, true); - } - else { - overflow = true; - } - } - catch (ConstantEvaluationOverflowException e) { - overflow = true; - return HighlightInfo.createHighlightInfo(HighlightInfoType.OVERFLOW_WARNING, expr, JavaErrorMessages.message("numeric.overflow.in.expression")); - } - finally { - PsiElement parent = expr.getParent(); - if (overflow && parent instanceof PsiExpression) { - parent.putUserData(HAS_OVERFLOW_IN_CHILD, ""); - } - } - - return null; - } - @NonNls private static String redIfNotMatch(PsiType type, boolean matches) { if (matches) return getFQName(type, false); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java index aabd791320..393f3f2046 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java @@ -354,7 +354,6 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkAssertOperatorTypes(expression)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkSynchronizedExpressionType(expression)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkConditionalExpressionBranchTypesMatch(expression)); - if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkConstantExpressionOverflow(expression)); if (!myHolder.hasErrorResults() && expression.getParent() instanceof PsiThrowStatement && ((PsiThrowStatement)expression.getParent()).getException() == expression) { diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/StandardInspectionToolsProvider.java b/java/java-impl/src/com/intellij/codeInspection/ex/StandardInspectionToolsProvider.java index 5ced11509a..9978aecbd1 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ex/StandardInspectionToolsProvider.java +++ b/java/java-impl/src/com/intellij/codeInspection/ex/StandardInspectionToolsProvider.java @@ -17,6 +17,7 @@ package com.intellij.codeInspection.ex; import com.intellij.codeInspection.InspectionToolProvider; import com.intellij.codeInspection.LossyEncodingInspection; +import com.intellij.codeInspection.NumericOverflowInspection; import com.intellij.codeInspection.RedundantSuppressInspection; import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance; import com.intellij.codeInspection.canBeFinal.CanBeFinalInspection; @@ -79,6 +80,7 @@ public class StandardInspectionToolsProvider implements InspectionToolProvider { DataFlowInspection.class, DefUseInspection.class, + NumericOverflowInspection.class, RedundantCastInspection.class, RedundantTypeArgsInspection.class, RedundantArrayForVarargsCallInspection.class, diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java index 53b8675f05..38ce5af8e1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java @@ -87,7 +87,6 @@ public interface HighlightInfoType { HighlightInfoType WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES); HighlightInfoType INFO = new HighlightInfoTypeImpl(HighlightSeverity.INFO, CodeInsightColors.INFO_ATTRIBUTES); - HighlightInfoType OVERFLOW_WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.ERRORS_ATTRIBUTES); HighlightInfoType INFORMATION = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.INFORMATION_ATTRIBUTES); HighlightSeverity INJECTED_FRAGMENT_SEVERITY = new HighlightSeverity("INJECTED_FRAGMENT_SEVERITY", HighlightSeverity.INFORMATION.myVal-1); HighlightInfoType INJECTED_LANGUAGE_FRAGMENT = new HighlightInfoTypeImpl(INJECTED_FRAGMENT_SEVERITY, CodeInsightColors.INFORMATION_ATTRIBUTES); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java index 96f30670f4..a9b2ce6a04 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java @@ -37,10 +37,10 @@ public class Descriptor { private final HighlightDisplayKey myKey; private final Element myConfig; - private InspectionProfileEntry myTool; + private final InspectionProfileEntry myTool; private final HighlightDisplayLevel myLevel; private boolean myEnabled = false; - private NamedScope myScope; + private final NamedScope myScope; private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.Descriptor"); private final ScopeToolState myState; diff --git a/platform/util/src/com/intellij/util/ResourceUtil.java b/platform/util/src/com/intellij/util/ResourceUtil.java index 16e8f08f41..0ba7cc955f 100644 --- a/platform/util/src/com/intellij/util/ResourceUtil.java +++ b/platform/util/src/com/intellij/util/ResourceUtil.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.net.URLConnection; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -47,7 +46,7 @@ public class ResourceUtil { if (url == null) continue; try { - final URLConnection connection = url.openConnection(); + url.openConnection(); } catch (IOException e) { continue; @@ -105,7 +104,8 @@ public class ResourceUtil { return result; } - public static @NotNull String loadText(@NotNull URL url) throws IOException { + @NotNull + public static String loadText(@NotNull URL url) throws IOException { InputStream inputStream = new BufferedInputStream(URLUtil.openStream(url)); InputStreamReader reader = null; -- 2.11.4.GIT