From 377a606aefdbf826387dd46d6660646f5dbcce49 Mon Sep 17 00:00:00 2001 From: "Irina.Chernushina" Date: Tue, 30 Jan 2018 12:04:06 +0100 Subject: [PATCH] vue: in .vue files tags get preprocessed anyway, so allow any tag policy = vue tags can have empty body and be self-closing WEB-30808 Some of the vue components may have an empty body --- .../xml/util/CheckEmptyTagInspection.java | 22 +++------------- .../src/com/intellij/xml/XmlExtension.java | 25 ++++++++----------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/xml/xml-analysis-impl/src/com/intellij/xml/util/CheckEmptyTagInspection.java b/xml/xml-analysis-impl/src/com/intellij/xml/util/CheckEmptyTagInspection.java index e01fcecb6e87..7889d6eefb13 100644 --- a/xml/xml-analysis-impl/src/com/intellij/xml/util/CheckEmptyTagInspection.java +++ b/xml/xml-analysis-impl/src/com/intellij/xml/util/CheckEmptyTagInspection.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2013 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-2018 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.xml.util; @@ -53,7 +39,7 @@ public class CheckEmptyTagInspection extends XmlSuppressableInspectionTool { public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) { return new XmlElementVisitor() { @Override public void visitXmlTag(final XmlTag tag) { - if (!isTagWithEmptyEndNotAllowed(tag)) { + if (XmlExtension.shouldIgnoreSelfClosingTag(tag) || !isTagWithEmptyEndNotAllowed(tag)) { return; } final ASTNode child = XmlChildRole.EMPTY_TAG_END_FINDER.findChild(tag.getNode()); @@ -84,8 +70,8 @@ public class CheckEmptyTagInspection extends XmlSuppressableInspectionTool { (language.isKindOf(HTMLLanguage.INSTANCE) && !HtmlUtil.isSingleHtmlTagL(tagName) && - tagName.indexOf(':') == -1 - && !XmlExtension.isCollapsible(tag)); + tagName.indexOf(':') == -1 && + !XmlExtension.isCollapsible(tag)); } @Override diff --git a/xml/xml-psi-impl/src/com/intellij/xml/XmlExtension.java b/xml/xml-psi-impl/src/com/intellij/xml/XmlExtension.java index e7818d949aea..2caa19441237 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/XmlExtension.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/XmlExtension.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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-2018 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.xml; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; @@ -202,6 +188,15 @@ public abstract class XmlExtension { return false; } + public boolean isSelfClosingTagAllowed(@NotNull XmlTag tag) { + return false; + } + + public static boolean shouldIgnoreSelfClosingTag(@NotNull XmlTag tag) { + final XmlExtension extension = getExtensionByElement(tag); + return extension != null && extension.isSelfClosingTagAllowed(tag); + } + public static boolean isCollapsible(XmlTag tag) { final XmlExtension extension = getExtensionByElement(tag); return extension == null || extension.isCollapsibleTag(tag);