Don't show "pattern does not match anything" hint if pattern contains red code (IDEA-216176)

GitOrigin-RevId: c3a898267ebd46f02e3e5c229da0f7f1a0517292
This commit is contained in:
Bas Leijdekkers
2019-06-14 20:07:17 +03:00
committed by intellij-monorepo-bot
parent e7ba450557
commit b7099e8b7a
3 changed files with 23 additions and 24 deletions
@@ -10,7 +10,6 @@ import com.intellij.dupLocator.util.NodeFilter;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.lang.Language;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
@@ -656,10 +655,6 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
@Override
public void visitErrorElement(PsiErrorElement element) {
super.visitErrorElement(element);
if (Registry.is("ssr.in.editor.problem.highlighting") && Registry.is("ssr.use.new.search.dialog") &&
!ApplicationManager.getApplication().isUnitTestMode()) {
return;
}
final PsiElement parent = element.getParent();
final String errorDescription = element.getErrorDescription();
if (parent instanceof PsiClass && "Identifier expected".equals(errorDescription)) {
@@ -685,7 +680,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
return;
}
}
throw new MalformedPatternException(errorDescription);
throw new MalformedPatternException(element);
}
void setCurrent(PsiElement current) {
@@ -1,23 +1,23 @@
/*
* 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.
* 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.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.structuralsearch;
import com.intellij.psi.PsiErrorElement;
public class MalformedPatternException extends StructuralSearchException {
public MalformedPatternException() {}
public final boolean isErrorElement;
public MalformedPatternException() {
isErrorElement = false;
}
public MalformedPatternException(String msg) {
super(msg);
isErrorElement = false;
}
public MalformedPatternException(PsiErrorElement errorElement) {
super(errorElement.getErrorDescription());
isErrorElement = true;
}
}
@@ -760,7 +760,9 @@ public class StructuralSearchDialog extends DialogWrapper {
return null;
}
catch (MalformedPatternException ex) {
reportMessage(SSRBundle.message("malformed.replacement.pattern.message", ex.getMessage()), true, myReplaceCriteriaEdit);
if (!ex.isErrorElement || !Registry.is("ssr.in.editor.problem.highlighting")) {
reportMessage(SSRBundle.message("malformed.replacement.pattern.message", ex.getMessage()), true, myReplaceCriteriaEdit);
}
return null;
}
}
@@ -772,7 +774,9 @@ public class StructuralSearchDialog extends DialogWrapper {
final String message = isEmpty(matchOptions.getSearchPattern())
? null
: SSRBundle.message("this.pattern.is.malformed.message", (e.getMessage() != null) ? e.getMessage() : "");
reportMessage(message, true, mySearchCriteriaEdit);
if (!e.isErrorElement || !Registry.is("ssr.in.editor.problem.highlighting")) {
reportMessage(message, true, mySearchCriteriaEdit);
}
return null;
}
catch (UnsupportedPatternException e) {