From 107d6e49b5b45cd58ae2c2fda12e433c0ff2c710 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 12 Jul 2022 11:58:51 +0200 Subject: [PATCH] [intentions preview] ampersand escaping GitOrigin-RevId: 5fb2f22152d2a6fdedac3bebe1ba93fb9929c4f1 --- .../analysis/XmlErrorQuickFixProvider.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java index 0c3670c21b1a..d2954a38bdec 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.daemon.impl.HighlightInfo; @@ -22,7 +8,6 @@ import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiErrorElement; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiTreeUtil; @@ -45,6 +30,7 @@ public class XmlErrorQuickFixProvider implements ErrorQuickFixProvider { private static void registerXmlErrorQuickFix(final PsiErrorElement element, final HighlightInfo highlightInfo) { final String text = element.getErrorDescription(); if (text.equals(XmlPsiBundle.message("xml.parsing.unescaped.ampersand.or.nonterminated.character.entity.reference"))) { + final int textOffset = element.getTextOffset(); QuickFixAction.registerQuickFixAction(highlightInfo, new IntentionAction() { @Override @NotNull @@ -66,9 +52,8 @@ public class XmlErrorQuickFixProvider implements ErrorQuickFixProvider { @Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) { PsiFile topLevelFile = InjectedLanguageManager.getInstance(project).getTopLevelFile(file); - Document document = PsiDocumentManager.getInstance(project).getDocument(topLevelFile); + Document document = topLevelFile.getViewProvider().getDocument(); assert document != null; - final int textOffset = element.getTextOffset(); document.replaceString(textOffset, textOffset + 1, AMP_ENTITY); }