do not highlight errors in return statements in debugger code fragments
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Tue, 12 Apr 2016 15:53:14 +0000 (18:53 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Tue, 12 Apr 2016 15:55:47 +0000 (18:55 +0300)
java/debugger/impl/src/com/intellij/debugger/engine/evaluation/DefaultCodeFragmentFactory.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java

index 830ecbb70a630992666c68d285c6cdb9c197f4e9..a69cd899f960e45cee42daa06bfd3823ce7ef664 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.debugger.engine.evaluation;
 import com.intellij.codeInsight.completion.CompletionParameters;
 import com.intellij.codeInsight.completion.CompletionService;
 import com.intellij.codeInsight.completion.JavaCompletionUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.debugger.DebuggerManagerEx;
 import com.intellij.debugger.codeinsight.RuntimeTypeEvaluator;
 import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilder;
@@ -75,6 +76,7 @@ public class DefaultCodeFragmentFactory extends CodeFragmentFactory {
     fragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
     //noinspection HardCodedStringLiteral
     fragment.putUserData(KEY, "DebuggerComboBoxEditor.IS_DEBUGGER_EDITOR");
+    fragment.putUserData(HighlightUtil.DISABLE_RETURN_CHECK_IN_CODE_FRAGMENT, true);
     fragment.putCopyableUserData(JavaCompletionUtil.DYNAMIC_TYPE_EVALUATOR, new PairFunction<PsiExpression, CompletionParameters, PsiType>() {
       public PsiType fun(PsiExpression expression, CompletionParameters parameters) {
         if (!RuntimeTypeEvaluator.isSubtypeable(expression)) {
index c061dba79582997ae68ee142c14d7f0b39d39e9e..0cda6140d70e7f577979a3329f20c523d410bd85 100644 (file)
@@ -87,6 +87,8 @@ public class HighlightUtil extends HighlightUtilBase {
   @NonNls private static final String SERIAL_PERSISTENT_FIELDS_FIELD_NAME = "serialPersistentFields";
   private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
 
+  public static final Key<Boolean> DISABLE_RETURN_CHECK_IN_CODE_FRAGMENT = Key.create("DISABLE_RETURN_CHECK_IN_CODE_FRAGMENT");
+
   private HighlightUtil() { }
 
   static {
@@ -594,6 +596,9 @@ public class HighlightUtil extends HighlightUtilBase {
       }
       parent = parent.getParent();
     }
+    if (parent instanceof PsiCodeFragment && parent.getUserData(DISABLE_RETURN_CHECK_IN_CODE_FRAGMENT) != null) {
+      return null;
+    }
     String description;
     HighlightInfo errorResult = null;
     if (method == null && lambda != null) {