mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: fix error border after changing file type
put callback in current document instead of document from dialog creation GitOrigin-RevId: c81c5e63db08def242ffcc4846b07af5a6d67cf0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3db05bb20a
commit
01883f5e38
+1
-10
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2020 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.codeInsight.AnnotationUtil;
|
||||
@@ -495,17 +495,8 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean highlightProblemsInEditor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShowProblem(HighlightInfo highlightInfo, PsiFile file, PatternContext context) {
|
||||
if (!Registry.is("ssr.in.editor.problem.highlighting")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PsiErrorElement error = findErrorElementAt(file, highlightInfo.startOffset, highlightInfo.getDescription());
|
||||
if (error == null) {
|
||||
return false;
|
||||
|
||||
+2
-6
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2020 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.codeInsight.daemon.impl.HighlightInfo;
|
||||
@@ -174,12 +174,8 @@ public abstract class StructuralSearchProfile {
|
||||
throw new UnsupportedPatternException(SSRBundle.message("replacement.not.supported.for.filetype", fileType));
|
||||
}
|
||||
|
||||
public boolean highlightProblemsInEditor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean shouldShowProblem(HighlightInfo highlightInfo, PsiFile file, PatternContext context) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// only for nodes not filtered by lexical-nodes filter; they can be by default
|
||||
|
||||
+7
-17
@@ -1,7 +1,6 @@
|
||||
// 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.
|
||||
// Copyright 2000-2020 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.plugin.ui;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.codeInsight.template.TemplateBuilder;
|
||||
import com.intellij.codeInsight.template.impl.TemplateEditorUtil;
|
||||
@@ -262,21 +261,12 @@ public class StructuralSearchDialog extends DialogWrapper implements ProjectMana
|
||||
}
|
||||
}, myDisposable, replace);
|
||||
editor.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, myConfiguration);
|
||||
if (profile.highlightProblemsInEditor()) {
|
||||
document.putUserData(STRUCTURAL_SEARCH_ERROR_CALLBACK, () -> {
|
||||
putClientProperty("JComponent.outline", "error");
|
||||
repaint();
|
||||
getOKAction().setEnabled(false);
|
||||
removeMatchHighlights();
|
||||
});
|
||||
}
|
||||
else {
|
||||
final Project project = getProject();
|
||||
final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(getDocument());
|
||||
if (file != null) {
|
||||
DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(file, false);
|
||||
}
|
||||
}
|
||||
getDocument().putUserData(STRUCTURAL_SEARCH_ERROR_CALLBACK, () -> {
|
||||
putClientProperty("JComponent.outline", "error");
|
||||
repaint();
|
||||
getOKAction().setEnabled(false);
|
||||
removeMatchHighlights();
|
||||
});
|
||||
|
||||
TextCompletionUtil.installCompletionHint(editor);
|
||||
editor.putUserData(STRUCTURAL_SEARCH_DIALOG, StructuralSearchDialog.this);
|
||||
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
// 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.
|
||||
// Copyright 2000-2020 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.plugin.ui;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoFilter;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.structuralsearch.PatternContext;
|
||||
import com.intellij.structuralsearch.StructuralSearchProfile;
|
||||
@@ -38,6 +39,9 @@ public class StructuralSearchHighlightInfoFilter implements HighlightInfoFilter
|
||||
if (profile == null) {
|
||||
return true;
|
||||
}
|
||||
if (!Registry.is("ssr.in.editor.problem.highlighting")) {
|
||||
return false;
|
||||
}
|
||||
final PatternContext context = StructuralSearchUtil.findPatternContextByID(contextId, profile);
|
||||
final boolean result = profile.shouldShowProblem(highlightInfo, file, context);
|
||||
if (result) {
|
||||
|
||||
Reference in New Issue
Block a user