From ee20b95762d2e402626853eb9c3e505799fc1fc5 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 6 Jul 2012 16:24:12 +0200 Subject: [PATCH] IDEA-87673 (temp. suppress errors in/around lambda expressions) --- .../analysis/JavaHighlightInfoFilter.java | 58 + resources/src/META-INF/IdeaPlugin.xml | 2615 +++++++++-------- 2 files changed, 1366 insertions(+), 1307 deletions(-) create mode 100644 java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaHighlightInfoFilter.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaHighlightInfoFilter.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaHighlightInfoFilter.java new file mode 100644 index 000000000000..1707e17f4493 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaHighlightInfoFilter.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2012 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.intellij.codeInsight.daemon.impl.analysis; + +import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.codeInsight.daemon.impl.HighlightInfoFilter; +import com.intellij.lang.annotation.HighlightSeverity; +import com.intellij.psi.*; +import com.intellij.psi.util.PsiTreeUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A filter to temporarily suppress highlighting errors inside lambda expressions. + * todo[r.sh] stub; remove after implementing type inference + */ +public class JavaHighlightInfoFilter implements HighlightInfoFilter { + @Override + public boolean accept(@NotNull final HighlightInfo info, @Nullable final PsiFile file) { + if (!(file instanceof PsiJavaFile)) return true; + if (info.getSeverity() != HighlightSeverity.ERROR) return true; + if (description(info, "Lambda expressions are not supported at this language level")) return true; + + final PsiElement element = file.findElementAt(info.getStartOffset()); + if (element == null) return true; + + return !isInsideLambda(element) && + !isLambdaInAmbiguousCall(info, element); + } + + private static boolean isInsideLambda(final PsiElement element) { + return PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class, false) != null; + } + + private static boolean isLambdaInAmbiguousCall(final HighlightInfo info, final PsiElement element) { + if (!description(info, "Ambiguous method call")) return false; + final PsiElement exprList = element.getParent(); + if (!(exprList instanceof PsiExpressionList)) return false; + return PsiTreeUtil.getChildOfType(exprList, PsiLambdaExpression.class) != null; + } + + private static boolean description(final HighlightInfo info, final String prefix) { + return info.description != null && info.description.startsWith(prefix); + } +} diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 4fdfa0a83eb8..a206d420a80c 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1,1307 +1,1308 @@ - - com.intellij - IDEA CORE - - - - - - - - - - - com.intellij.util.xml.impl.JavaDomApplicationComponent - - - - - - com.intellij.psi.JavaPsiFacade - com.intellij.psi.impl.JavaPsiFacadeImpl - - - - - com.intellij.pom.java.PomJavaAspect - com.intellij.pom.java.impl.PomJavaAspectImpl - - - - - com.intellij.psi.impl.file.impl.JavaFileManager - com.intellij.psi.impl.file.impl.JavaFileManagerImpl - - - - - com.intellij.codeInsight.daemon.impl.PostHighlightingPassFactory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - com.intellij.codeInsight.intention.impl.SplitIfAction - Control Flow - - - com.intellij.codeInsight.intention.impl.InvertIfConditionAction - Control Flow - - - com.intellij.codeInsight.intention.impl.ExtractIfConditionAction - Control Flow - - - com.intellij.codeInsight.daemon.impl.quickfix.RemoveRedundantElseAction - Control Flow - - - com.intellij.codeInsight.intention.impl.AddNotNullAnnotationIntention - Control Flow - AddAnnotationFix - - - com.intellij.codeInsight.intention.impl.AddDeprecationAnnotationIntention - Control Flow - AddAnnotationFix - - - com.intellij.codeInsight.intention.impl.AddNullableAnnotationIntention - Control Flow - AddAnnotationFix - - - com.intellij.codeInsight.daemon.impl.quickfix.IterateOverIterableIntention - Control Flow - - - com.intellij.codeInsight.intention.impl.DeannotateIntentionAction - Control Flow - - - - com.intellij.codeInsight.intention.impl.CreateFieldFromParameterAction - Declaration - - - com.intellij.codeInsight.intention.impl.AssignFieldFromParameterAction - Declaration - - - com.intellij.codeInsight.intention.impl.BindFieldsFromParametersAction - Declaration - - - com.intellij.codeInsight.daemon.impl.quickfix.CreateLocalVarFromInstanceofAction - Declaration - - - com.intellij.codeInsight.daemon.impl.quickfix.CreateCastExpressionFromInstanceofAction - Declaration - - - com.intellij.testIntegration.createTest.CreateTestAction - Declaration - - - com.intellij.codeInsight.intention.impl.CreateSubclassAction - Declaration - - - com.intellij.codeInsight.intention.impl.ImplementAbstractMethodAction - Declaration - - - com.intellij.codeInsight.intention.impl.CopyAbstractMethodImplementationAction - Declaration - - - com.intellij.codeInsight.intention.impl.SplitDeclarationAction - Declaration - - - com.intellij.codeInsight.intention.impl.MoveInitializerToConstructorAction - Declaration - - - com.intellij.testIntegration.intention.MoveInitializerToSetUpMethodAction - Declaration - - - com.intellij.codeInsight.intention.impl.MoveFieldAssignmentToInitializerAction - Declaration - - - com.intellij.codeInsight.daemon.impl.quickfix.AddRuntimeExceptionToThrowsAction - Declaration - - - com.intellij.codeInsight.intention.impl.MakeTypeGenericAction - Declaration - - - com.intellij.codeInsight.intention.impl.AddOverrideAnnotationAction - Declaration - - - com.intellij.codeInsight.daemon.impl.quickfix.DelegateWithDefaultParamValueIntentionAction - Declaration - - - - com.intellij.codeInsight.intention.impl.IntroduceVariableIntentionAction - Refactorings - - - com.intellij.codeInsight.intention.impl.EncapsulateFieldAction - Refactorings - - - - com.intellij.codeInsight.intention.impl.SimplifyBooleanExpressionAction - Boolean - - - - com.intellij.codeInsight.intention.impl.ConcatenationToMessageFormatAction - I18N - - - - com.intellij.codeInsight.intention.impl.ConvertToBasicLatinAction - I18N - - - - com.intellij.codeInsight.intention.impl.AddOnDemandStaticImportAction - Imports - - - com.intellij.codeInsight.intention.impl.AddSingleMemberStaticImportAction - Imports - - - com.intellij.codeInsight.intention.impl.ExpandStaticImportAction - Imports - - - - com.intellij.codeInspection.actions.UnimplementInterfaceAction - Declaration - - - - com.intellij.codeInspection.actions.ReplaceImplementsWithStaticImportAction - Declaration - - - - com.intellij.codeInsight.intention.impl.ColorChooserIntentionAction - Declaration - - - - com.intellij.codeInsight.intention.impl.ConvertColorRepresentationIntentionAction - Declaration - - - - com.intellij.codeInsight.intention.impl.ConvertAbsolutePathToRelativeIntentionAction - Other - - - - com.intellij.codeInsight.intention.impl.ConvertRelativePathToAbsoluteIntentionAction - Other - - - - com.intellij.codeInsight.intention.impl.ReplaceCastWithVariableAction - Other - - - - com.intellij.codeInsight.intention.impl.BreakStringOnLineBreaksIntentionAction - Other - - - - - - - com.intellij.codeInspection.concurrencyAnnotations.JCiPOrderEntryFix - - - - com.intellij.codeInsight.intention.impl.RemoveLiteralUnderscoresAction - Numbers - - - com.intellij.codeInsight.intention.impl.InsertLiteralUnderscoresAction - Numbers - - - - com.intellij.codeInsight.daemon.impl.quickfix.ConvertToStringLiteralAction - Strings - - - - com.intellij.codeInsight.intention.impl.SurroundAutoCloseableAction - Declaration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + com.intellij + IDEA CORE + + + + + + + + + + + com.intellij.util.xml.impl.JavaDomApplicationComponent + + + + + + com.intellij.psi.JavaPsiFacade + com.intellij.psi.impl.JavaPsiFacadeImpl + + + + + com.intellij.pom.java.PomJavaAspect + com.intellij.pom.java.impl.PomJavaAspectImpl + + + + + com.intellij.psi.impl.file.impl.JavaFileManager + com.intellij.psi.impl.file.impl.JavaFileManagerImpl + + + + + com.intellij.codeInsight.daemon.impl.PostHighlightingPassFactory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + com.intellij.codeInsight.intention.impl.SplitIfAction + Control Flow + + + com.intellij.codeInsight.intention.impl.InvertIfConditionAction + Control Flow + + + com.intellij.codeInsight.intention.impl.ExtractIfConditionAction + Control Flow + + + com.intellij.codeInsight.daemon.impl.quickfix.RemoveRedundantElseAction + Control Flow + + + com.intellij.codeInsight.intention.impl.AddNotNullAnnotationIntention + Control Flow + AddAnnotationFix + + + com.intellij.codeInsight.intention.impl.AddDeprecationAnnotationIntention + Control Flow + AddAnnotationFix + + + com.intellij.codeInsight.intention.impl.AddNullableAnnotationIntention + Control Flow + AddAnnotationFix + + + com.intellij.codeInsight.daemon.impl.quickfix.IterateOverIterableIntention + Control Flow + + + com.intellij.codeInsight.intention.impl.DeannotateIntentionAction + Control Flow + + + + com.intellij.codeInsight.intention.impl.CreateFieldFromParameterAction + Declaration + + + com.intellij.codeInsight.intention.impl.AssignFieldFromParameterAction + Declaration + + + com.intellij.codeInsight.intention.impl.BindFieldsFromParametersAction + Declaration + + + com.intellij.codeInsight.daemon.impl.quickfix.CreateLocalVarFromInstanceofAction + Declaration + + + com.intellij.codeInsight.daemon.impl.quickfix.CreateCastExpressionFromInstanceofAction + Declaration + + + com.intellij.testIntegration.createTest.CreateTestAction + Declaration + + + com.intellij.codeInsight.intention.impl.CreateSubclassAction + Declaration + + + com.intellij.codeInsight.intention.impl.ImplementAbstractMethodAction + Declaration + + + com.intellij.codeInsight.intention.impl.CopyAbstractMethodImplementationAction + Declaration + + + com.intellij.codeInsight.intention.impl.SplitDeclarationAction + Declaration + + + com.intellij.codeInsight.intention.impl.MoveInitializerToConstructorAction + Declaration + + + com.intellij.testIntegration.intention.MoveInitializerToSetUpMethodAction + Declaration + + + com.intellij.codeInsight.intention.impl.MoveFieldAssignmentToInitializerAction + Declaration + + + com.intellij.codeInsight.daemon.impl.quickfix.AddRuntimeExceptionToThrowsAction + Declaration + + + com.intellij.codeInsight.intention.impl.MakeTypeGenericAction + Declaration + + + com.intellij.codeInsight.intention.impl.AddOverrideAnnotationAction + Declaration + + + com.intellij.codeInsight.daemon.impl.quickfix.DelegateWithDefaultParamValueIntentionAction + Declaration + + + + com.intellij.codeInsight.intention.impl.IntroduceVariableIntentionAction + Refactorings + + + com.intellij.codeInsight.intention.impl.EncapsulateFieldAction + Refactorings + + + + com.intellij.codeInsight.intention.impl.SimplifyBooleanExpressionAction + Boolean + + + + com.intellij.codeInsight.intention.impl.ConcatenationToMessageFormatAction + I18N + + + + com.intellij.codeInsight.intention.impl.ConvertToBasicLatinAction + I18N + + + + com.intellij.codeInsight.intention.impl.AddOnDemandStaticImportAction + Imports + + + com.intellij.codeInsight.intention.impl.AddSingleMemberStaticImportAction + Imports + + + com.intellij.codeInsight.intention.impl.ExpandStaticImportAction + Imports + + + + com.intellij.codeInspection.actions.UnimplementInterfaceAction + Declaration + + + + com.intellij.codeInspection.actions.ReplaceImplementsWithStaticImportAction + Declaration + + + + com.intellij.codeInsight.intention.impl.ColorChooserIntentionAction + Declaration + + + + com.intellij.codeInsight.intention.impl.ConvertColorRepresentationIntentionAction + Declaration + + + + com.intellij.codeInsight.intention.impl.ConvertAbsolutePathToRelativeIntentionAction + Other + + + + com.intellij.codeInsight.intention.impl.ConvertRelativePathToAbsoluteIntentionAction + Other + + + + com.intellij.codeInsight.intention.impl.ReplaceCastWithVariableAction + Other + + + + com.intellij.codeInsight.intention.impl.BreakStringOnLineBreaksIntentionAction + Other + + + + + + + com.intellij.codeInspection.concurrencyAnnotations.JCiPOrderEntryFix + + + + com.intellij.codeInsight.intention.impl.RemoveLiteralUnderscoresAction + Numbers + + + com.intellij.codeInsight.intention.impl.InsertLiteralUnderscoresAction + Numbers + + + + com.intellij.codeInsight.daemon.impl.quickfix.ConvertToStringLiteralAction + Strings + + + + com.intellij.codeInsight.intention.impl.SurroundAutoCloseableAction + Declaration + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +