diff options
author | Tor Norbye <tnorbye@google.com> | 2013-05-07 20:09:46 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-05-07 20:09:46 -0700 |
commit | 934b9431b0b827a132df794e307fe5a2b70de00b (patch) | |
tree | dadfd1ccaeb2ce0403d306a59b35711531481e2b /xml | |
parent | f56a0fff1a336635c966bffc25e16af9a4e6e988 (diff) | |
download | idea-934b9431b0b827a132df794e307fe5a2b70de00b.tar.gz |
Snapshot 5220ac5242aadc343c995ec9a49d09765db4a0c7 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I2494d92b34f89102885b2f39d7552747fafdafec
Diffstat (limited to 'xml')
17 files changed, 115 insertions, 10 deletions
diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java index 965f1bd7d121..01c0bf7ec468 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java @@ -64,7 +64,7 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T return new RootAnchor<T>(fileElement.getFile(), fileElement.getRootElementClass()); } - final DomAnchorImpl<DomElement> parentAnchor = (DomAnchorImpl<DomElement>)createAnchor(parent); + final DomAnchor<DomElement> parentAnchor = createAnchor(parent); final String name = t.getGenericInfo().getElementName(t); final AbstractDomChildrenDescription description = t.getChildDescription(); final List<? extends DomElement> values = description.getValues(parent); @@ -146,12 +146,12 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T public abstract XmlFile getContainingFile(); private static class NamedAnchor<T extends DomElement> extends DomAnchorImpl<T> { - private final DomAnchorImpl myParent; + private final DomAnchor myParent; private final AbstractDomChildrenDescription myDescr; private final String myName; private final int myIndex; - private NamedAnchor(final DomAnchorImpl parent, final AbstractDomChildrenDescription descr, final String id, int index) { + private NamedAnchor(final DomAnchor parent, final AbstractDomChildrenDescription descr, final String id, int index) { myParent = parent; myDescr = descr; myName = id; @@ -209,11 +209,11 @@ public abstract class DomAnchorImpl<T extends DomElement> implements DomAnchor<T } private static class IndexedAnchor<T extends DomElement> extends DomAnchorImpl<T> { - private final DomAnchorImpl myParent; + private final DomAnchor myParent; private final AbstractDomChildrenDescription myDescr; private final int myIndex; - private IndexedAnchor(final DomAnchorImpl parent, final AbstractDomChildrenDescription descr, final int index) { + private IndexedAnchor(final DomAnchor parent, final AbstractDomChildrenDescription descr, final int index) { myParent = parent; myDescr = descr; myIndex = index; diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/AddCustomTagOrAttributeIntentionAction.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/AddCustomTagOrAttributeIntentionAction.java index ba84b96d3f62..5c21f37b1ce4 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/AddCustomTagOrAttributeIntentionAction.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/AddCustomTagOrAttributeIntentionAction.java @@ -41,6 +41,7 @@ public class AddCustomTagOrAttributeIntentionAction implements LocalQuickFix { myType = type; } + @Override @NotNull public String getName() { if (myType == XmlEntitiesInspection.UNKNOWN_TAG) { @@ -58,11 +59,13 @@ public class AddCustomTagOrAttributeIntentionAction implements LocalQuickFix { return getFamilyName(); } + @Override @NotNull public String getFamilyName() { return XmlBundle.message("fix.html.family"); } + @Override public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java index 78366a2c0ab1..9a575b59c212 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/AddHtmlTagOrAttributeToCustomsIntention.java @@ -43,6 +43,7 @@ public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction myType = type; } + @Override @NotNull public String getText() { if (myType == XmlEntitiesInspection.UNKNOWN_TAG) { @@ -60,15 +61,18 @@ public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction return getFamilyName(); } + @Override @NotNull public String getFamilyName() { return XmlBundle.message("fix.html.family"); } + @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return true; } + @Override public void invoke(@NotNull Project project, Editor editor, final PsiFile file) throws IncorrectOperationException { InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile(); profile.modifyToolSettings(myInspectionKey, file, new Consumer<InspectionProfileEntry>() { @@ -80,6 +84,7 @@ public class AddHtmlTagOrAttributeToCustomsIntention implements IntentionAction }); } + @Override public boolean startInWriteAction() { return false; } diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlExtraClosingTagInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlExtraClosingTagInspection.java index 923866ef700f..efc3d3a353e4 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlExtraClosingTagInspection.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlExtraClosingTagInspection.java @@ -35,23 +35,27 @@ import org.jetbrains.annotations.NotNull; */ public class HtmlExtraClosingTagInspection extends HtmlLocalInspectionTool { + @Override @Nls @NotNull public String getDisplayName() { return XmlBundle.message("html.inspection.extra.closing.tag"); } + @Override @NonNls @NotNull public String getShortName() { return "HtmlExtraClosingTag"; } + @Override @NotNull public HighlightDisplayLevel getDefaultLevel() { return HighlightDisplayLevel.ERROR; } + @Override protected void checkTag(@NotNull final XmlTag tag, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) { final XmlToken endTagName = XmlTagUtil.getEndTagNameElement(tag); diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java index 6d444291d576..188c75414e62 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlLocalInspectionTool.java @@ -36,12 +36,14 @@ import org.jetbrains.annotations.NotNull; */ public abstract class HtmlLocalInspectionTool extends XmlSuppressableInspectionTool { + @Override @Nls @NotNull public String getGroupDisplayName() { return XmlInspectionGroupNames.HTML_INSPECTIONS; } + @Override public boolean isEnabledByDefault() { return true; } @@ -54,6 +56,7 @@ public abstract class HtmlLocalInspectionTool extends XmlSuppressableInspectionT // should be overridden } + @Override @NotNull public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new XmlElementVisitor() { diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownAttributeInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownAttributeInspection.java index 58617e8d1b29..20bc651ce537 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownAttributeInspection.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownAttributeInspection.java @@ -51,35 +51,42 @@ public class HtmlUnknownAttributeInspection extends HtmlUnknownTagInspection { super(""); } + @Override @Nls @NotNull public String getDisplayName() { return XmlBundle.message("html.inspections.unknown.attribute"); } + @Override @NonNls @NotNull public String getShortName() { return ATTRIBUTE_SHORT_NAME; } + @Override protected String getCheckboxTitle() { return XmlBundle.message("html.inspections.unknown.tag.attribute.checkbox.title"); } + @Override protected String getPanelTitle() { return XmlBundle.message("html.inspections.unknown.tag.attribute.title"); } + @Override @NotNull protected Logger getLogger() { return LOG; } + @Override protected void checkTag(@NotNull final XmlTag tag, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) { // does nothing! this method should be overridden empty! } + @Override protected void checkAttribute(@NotNull final XmlAttribute attribute, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) { final XmlTag tag = attribute.getParent(); diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTagInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTagInspection.java index 38a54cd7d944..577d9d0026a3 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTagInspection.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/HtmlUnknownTagInspection.java @@ -73,18 +73,21 @@ public class HtmlUnknownTagInspection extends HtmlLocalInspectionTool { myValues = reparseProperties(defaultValues); } + @Override @Nls @NotNull public String getDisplayName() { return XmlBundle.message("html.inspections.unknown.tag"); } + @Override @NonNls @NotNull public String getShortName() { return TAG_SHORT_NAME; } + @Override @Nullable public JComponent createOptionsPanel() { final JPanel result = new JPanel(new BorderLayout()); @@ -94,6 +97,7 @@ public class HtmlUnknownTagInspection extends HtmlLocalInspectionTool { final FieldPanel additionalAttributesPanel = new FieldPanel(null, getPanelTitle(), null, null); additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { + @Override protected void textChanged(DocumentEvent e) { final Document document = e.getDocument(); try { @@ -111,6 +115,7 @@ public class HtmlUnknownTagInspection extends HtmlLocalInspectionTool { final JCheckBox checkBox = new JCheckBox(getCheckboxTitle()); checkBox.setSelected(myCustomValuesEnabled); checkBox.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { final boolean b = checkBox.isSelected(); if (b != myCustomValuesEnabled) { @@ -207,6 +212,7 @@ public class HtmlUnknownTagInspection extends HtmlLocalInspectionTool { return HtmlUtil.SVG_NAMESPACE.equals(ns) || HtmlUtil.MATH_ML_NAMESPACE.endsWith(ns); } + @Override protected void checkTag(@NotNull final XmlTag tag, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) { if (!(tag instanceof HtmlTag) || !XmlHighlightVisitor.shouldBeValidated(tag) || isInSpecialHtml5Namespace(tag)) { return; diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/RemoveAttributeIntentionAction.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/RemoveAttributeIntentionAction.java index c8984d4220c7..c5aee9d703e3 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/RemoveAttributeIntentionAction.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/RemoveAttributeIntentionAction.java @@ -38,16 +38,19 @@ public class RemoveAttributeIntentionAction implements LocalQuickFix { myLocalName = localName; } + @Override @NotNull public String getName() { return XmlErrorMessages.message("remove.attribute.quickfix.text", myLocalName); } + @Override @NotNull public String getFamilyName() { return XmlErrorMessages.message("remove.attribute.quickfix.family"); } + @Override public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { PsiElement e = descriptor.getPsiElement(); final XmlAttribute myAttribute = PsiTreeUtil.getParentOfType(e, XmlAttribute.class); @@ -58,6 +61,7 @@ public class RemoveAttributeIntentionAction implements LocalQuickFix { } new WriteCommandAction(project) { + @Override protected void run(final Result result) throws Throwable { myAttribute.delete(); } diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/RemoveExtraClosingTagIntentionAction.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/RemoveExtraClosingTagIntentionAction.java index 2d311610cef4..af3dc6c93f1f 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/RemoveExtraClosingTagIntentionAction.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/RemoveExtraClosingTagIntentionAction.java @@ -41,26 +41,31 @@ import org.jetbrains.annotations.NotNull; * @author spleaner */ public class RemoveExtraClosingTagIntentionAction implements LocalQuickFix, IntentionAction { + @Override @NotNull public String getFamilyName() { return XmlErrorMessages.message("remove.extra.closing.tag.quickfix"); } + @Override @NotNull public String getName() { return XmlErrorMessages.message("remove.extra.closing.tag.quickfix"); } + @Override @NotNull public String getText() { return getName(); } + @Override public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { return true; } + @Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { final int offset = editor.getCaretModel().getOffset(); final PsiElement psiElement = file.findElementAt(offset); @@ -72,6 +77,7 @@ public class RemoveExtraClosingTagIntentionAction implements LocalQuickFix, Inte doFix(psiElement); } + @Override public boolean startInWriteAction() { return true; } @@ -98,12 +104,14 @@ public class RemoveExtraClosingTagIntentionAction implements LocalQuickFix, Inte } } + @Override public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); if (!element.isValid() || !(element instanceof XmlToken)) return; if (!FileModificationService.getInstance().prepareFileForWrite(element.getContainingFile())) return; new WriteCommandAction(project) { + @Override protected void run(final Result result) throws Throwable { doFix(element); } diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/RenameTagBeginOrEndIntentionAction.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/RenameTagBeginOrEndIntentionAction.java index e64e867f0d4a..d33c482729d0 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/RenameTagBeginOrEndIntentionAction.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/RenameTagBeginOrEndIntentionAction.java @@ -50,20 +50,24 @@ public class RenameTagBeginOrEndIntentionAction implements IntentionAction { myStart = start; } + @Override @NotNull public String getFamilyName() { return getName(); } + @Override @NotNull public String getText() { return getName(); } + @Override public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { return true; } + @Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { final int offset = editor.getCaretModel().getOffset(); PsiElement psiElement = file.findElementAt(offset); @@ -118,6 +122,7 @@ public class RenameTagBeginOrEndIntentionAction implements IntentionAction { } } + @Override public boolean startInWriteAction() { return true; } diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspection.java index bde145d007a8..fe0541196115 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspection.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/RequiredAttributesInspection.java @@ -47,22 +47,26 @@ public class RequiredAttributesInspection extends XmlSuppressableInspectionTool @NonNls public static final String SHORT_NAME = "RequiredAttributes"; @NonNls public static final Key<InspectionProfileEntry> SHORT_NAME_KEY = Key.create(SHORT_NAME); + @Override @NotNull public String getGroupDisplayName() { return XmlInspectionGroupNames.HTML_INSPECTIONS; } + @Override @NotNull public String getDisplayName() { return InspectionsBundle.message("inspection.required.attributes.display.name"); } + @Override @NotNull @NonNls public String getShortName() { return SHORT_NAME; } + @Override @Nullable public JComponent createOptionsPanel() { JPanel panel = new JPanel(new BorderLayout()); @@ -72,6 +76,7 @@ public class RequiredAttributesInspection extends XmlSuppressableInspectionTool panel.add(additionalAttributesPanel, BorderLayout.NORTH); additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { + @Override protected void textChanged(DocumentEvent e) { final Document document = e.getDocument(); try { @@ -89,18 +94,22 @@ public class RequiredAttributesInspection extends XmlSuppressableInspectionTool return panel; } + @Override public IntentionAction getIntentionAction(String name, int type) { return new AddHtmlTagOrAttributeToCustomsIntention(SHORT_NAME_KEY, name, type); } + @Override public String getAdditionalEntries(int type) { return myAdditionalRequiredHtmlAttributes; } + @Override public void setAdditionalEntries(int type, String additionalEntries) { myAdditionalRequiredHtmlAttributes = additionalEntries; } + @Override public boolean isEnabledByDefault() { return true; } diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java index 39119e027004..15c45a88fb30 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java @@ -44,6 +44,7 @@ import org.jetbrains.annotations.Nullable; */ public class XmlWrongClosingTagNameInspection implements Annotator { + @Override public void annotate(final PsiElement psiElement, final AnnotationHolder holder) { if (psiElement instanceof XmlToken) { final PsiElement parent = psiElement.getParent(); @@ -65,7 +66,7 @@ public class XmlWrongClosingTagNameInspection implements Annotator { else if (parent instanceof PsiErrorElement) { if (XmlTokenType.XML_NAME == ((XmlToken)psiElement).getTokenType()) { final PsiFile psiFile = psiElement.getContainingFile(); - + if (psiFile != null && (HTMLLanguage.INSTANCE == psiFile.getViewProvider().getBaseLanguage() || HTMLLanguage.INSTANCE == parent.getLanguage())) { final String message = XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing"); diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongRootElementInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongRootElementInspection.java index f3039bebd343..82bbdb456f10 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongRootElementInspection.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongRootElementInspection.java @@ -40,29 +40,34 @@ import org.jetbrains.annotations.NotNull; */ public class XmlWrongRootElementInspection extends HtmlLocalInspectionTool { + @Override @Nls @NotNull public String getGroupDisplayName() { return XmlInspectionGroupNames.XML_INSPECTIONS; } + @Override @Nls @NotNull public String getDisplayName() { return XmlBundle.message("xml.inspection.wrong.root.element"); } + @Override @NonNls @NotNull public String getShortName() { return "XmlWrongRootElement"; } + @Override @NotNull public HighlightDisplayLevel getDefaultLevel() { return HighlightDisplayLevel.ERROR; } + @Override protected void checkTag(@NotNull final XmlTag tag, @NotNull final ProblemsHolder holder, final boolean isOnTheFly) { if (!(tag.getParent() instanceof XmlTag)) { final PsiFile psiFile = tag.getContainingFile(); @@ -134,16 +139,19 @@ public class XmlWrongRootElementInspection extends HtmlLocalInspectionTool { myText = text; } + @Override @NotNull public String getName() { return XmlBundle.message("change.root.element.to", myText); } + @Override @NotNull public String getFamilyName() { return getName(); } + @Override public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final XmlTag myTag = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), XmlTag.class); @@ -152,6 +160,7 @@ public class XmlWrongRootElementInspection extends HtmlLocalInspectionTool { } new WriteCommandAction(project) { + @Override protected void run(final Result result) throws Throwable { myTag.setName(myText); } diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java b/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java index de520f9add66..3f01ad53da9d 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java @@ -42,10 +42,7 @@ import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; -import com.intellij.xml.XmlElementDescriptor; -import com.intellij.xml.XmlElementDescriptorAwareAboutChildren; -import com.intellij.xml.XmlExtension; -import com.intellij.xml.XmlNSDescriptor; +import com.intellij.xml.*; import com.intellij.xml.impl.schema.AnyXmlElementDescriptor; import com.intellij.xml.impl.schema.XmlElementDescriptorImpl; import com.intellij.xml.util.HtmlUtil; @@ -232,6 +229,9 @@ public class TagNameReference implements PsiReference { } elements.add(lookupElement.withInsertHandler(XmlTagInsertHandler.INSTANCE)); } + for (XmlTagNameProvider tagNameProvider : XmlTagNameProvider.EP_NAME.getExtensions()) { + tagNameProvider.addTagNameVariants(elements, tag, prefix); + } return elements.toArray(new LookupElement[elements.size()]); } diff --git a/xml/impl/src/com/intellij/xml/XmlTagNameProvider.java b/xml/impl/src/com/intellij/xml/XmlTagNameProvider.java new file mode 100644 index 000000000000..a0b5809d7277 --- /dev/null +++ b/xml/impl/src/com/intellij/xml/XmlTagNameProvider.java @@ -0,0 +1,34 @@ +/* + * 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. + */ +package com.intellij.xml; + +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.psi.xml.XmlTag; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * Provides custom tag names. + * + * @see HtmlCustomTagNameProvider + */ +public interface XmlTagNameProvider { + ExtensionPointName<XmlTagNameProvider> EP_NAME = new ExtensionPointName<XmlTagNameProvider>("com.intellij.xml.tagNameProvider"); + + void addTagNameVariants(List<LookupElement> elements, @NotNull XmlTag tag, String prefix); +} diff --git a/xml/impl/src/com/intellij/xml/util/HtmlUtil.java b/xml/impl/src/com/intellij/xml/util/HtmlUtil.java index a52b879d90d4..f687b6aacf3e 100644 --- a/xml/impl/src/com/intellij/xml/util/HtmlUtil.java +++ b/xml/impl/src/com/intellij/xml/util/HtmlUtil.java @@ -29,6 +29,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypeManager; +import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; @@ -609,6 +610,11 @@ public class HtmlUtil { return language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE; } + public static boolean isHtmlFile(@NotNull VirtualFile file) { + FileType fileType = file.getFileType(); + return fileType == StdFileTypes.HTML || fileType == StdFileTypes.XHTML; + } + public static boolean isHtmlTagContainingFile(PsiElement element) { if (element == null) { return false; diff --git a/xml/tests/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java b/xml/tests/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java index aa576def52f7..1728ff9d8e8e 100644 --- a/xml/tests/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java +++ b/xml/tests/src/com/intellij/codeInspection/htmlInspections/XmlInspectionToolProvider.java @@ -23,6 +23,7 @@ import com.intellij.xml.util.*; * @author yole */ public class XmlInspectionToolProvider implements InspectionToolProvider { + @Override public Class[] getInspectionClasses() { return new Class[] { CheckTagEmptyBodyInspection.class, |