From 2db4d12c5e0a0df59a35007b4807a6457d3b6842 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 16 Nov 2010 11:11:19 +0300 Subject: [PATCH 1/2] IDEA-61299: XSLT: completion of xsl:choose generates red code (no namespace prefix) --- .../codeInsight/completion/XmlTagInsertHandler.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java index 92712675435c..6d82bf4cd60e 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java @@ -35,6 +35,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; @@ -48,6 +49,7 @@ import com.intellij.xml.XmlElementDescriptor; import com.intellij.xml.XmlElementDescriptorWithCDataContent; import com.intellij.xml.XmlExtension; import com.intellij.xml.actions.GenerateXmlTagAction; +import com.intellij.xml.impl.schema.XmlElementDescriptorImpl; import com.intellij.xml.util.HtmlUtil; import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.Nullable; @@ -76,7 +78,6 @@ public class XmlTagInsertHandler implements InsertHandler { if (XmlUtil.getTokenOfType(tag, XmlTokenType.XML_TAG_END) == null && XmlUtil.getTokenOfType(tag, XmlTokenType.XML_EMPTY_ELEMENT_END) == null) { - Template t = TemplateManager.getInstance(project).getActiveTemplate(editor); if (descriptor != null) { insertIncompleteTag(context.getCompletionChar(), editor, project, descriptor, tag); } @@ -307,7 +308,14 @@ public class XmlTagInsertHandler implements InsertHandler { template.addVariable(new MacroCallNode(new CompleteSmartMacro()), true); continue; } - template.addTextSegment("<" + subTag.getName()); + String qname = subTag.getName(); + if (subTag instanceof XmlElementDescriptorImpl) { + String prefixByNamespace = context.getPrefixByNamespace(((XmlElementDescriptorImpl)subTag).getNamespace()); + if (StringUtil.isNotEmpty(prefixByNamespace)) { + qname = prefixByNamespace + ":" + subTag.getName(); + } + } + template.addTextSegment("<" + qname); addRequiredAttributes(subTag, null, template, file); completeTagTail(template, subTag, file, context, false); } From 5d1b82e8c7b8fbd0af6dc265abc693353ff478bc Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 16 Nov 2010 18:57:08 +0300 Subject: [PATCH 2/2] IDEA-59593: Strange errors in mxml document --- xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java b/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java index c9a8d6583bc0..905e06b8c115 100644 --- a/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java +++ b/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java @@ -45,6 +45,8 @@ public class XMLExternalAnnotator implements ExternalAnnotator, Validator.Valida XmlNSDescriptor nsDescriptor = rootTag == null ? null : rootTag.getNSDescriptor(rootTag.getNamespace(), false); if (nsDescriptor instanceof Validator && !HtmlUtil.isHtml5Document(document)) { + XmlFile descriptorFile = nsDescriptor.getDescriptorFile(); + if (descriptorFile != null && !descriptorFile.isPhysical()) return; ((Validator)nsDescriptor).validate(document, this); } }