mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-159262 Incorrect treating of the <link> element in the jsp page
fix collapse HTML tag in JSP
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -82,9 +83,17 @@ public class CollapseTagIntention implements LocalQuickFix, IntentionAction {
|
||||
}
|
||||
|
||||
private static XmlTag getTag(Editor editor, PsiFile file) {
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
FileViewProvider provider = file.getViewProvider();
|
||||
PsiElement element = provider.findElementAt(editor.getCaretModel().getOffset(), provider.getBaseLanguage());
|
||||
return PsiTreeUtil.getParentOfType(element, XmlTag.class, false);
|
||||
for (Language language : provider.getLanguages()) {
|
||||
PsiElement element = provider.findElementAt(offset, language);
|
||||
XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
|
||||
if (tag != null && XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode()) != null) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +101,7 @@ public class CollapseTagIntention implements LocalQuickFix, IntentionAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void applyFix(@NotNull final Project project, final PsiElement tag) {
|
||||
private static void applyFix(@NotNull final Project project, @NotNull final PsiElement tag) {
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(tag.getContainingFile())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user