do not invoke zen coding inside comments and literals
authorEugene Kudelevsky <Eugene.Kudelevsky@jetbrains.com>
Wed, 31 Mar 2010 15:41:03 +0000 (19:41 +0400)
committerEugene Kudelevsky <Eugene.Kudelevsky@jetbrains.com>
Wed, 31 Mar 2010 15:44:01 +0000 (19:44 +0400)
xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java

index 4c177487d934421b5841cc27eeef76cacfba37ed..8fd9f2583659e516621a8ce8781b2ee4f1b949cf 100644 (file)
@@ -35,9 +35,8 @@ import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiFileFactory;
-import com.intellij.psi.xml.XmlDocument;
-import com.intellij.psi.xml.XmlFile;
-import com.intellij.psi.xml.XmlTag;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.xml.*;
 import com.intellij.util.LocalTimeCounter;
 import com.intellij.util.containers.HashSet;
 import com.intellij.xml.XmlBundle;
@@ -356,7 +355,16 @@ public class XmlZenCodingTemplate implements CustomLiveTemplate {
     }
     if (file.getLanguage() instanceof XMLLanguage) {
       PsiElement element = file.findElementAt(offset > 0 ? offset - 1 : offset);
-      if (element == null || element.getLanguage() instanceof XMLLanguage) {
+      if (element == null) {
+        return true;
+      }
+      if (element.getLanguage() instanceof XMLLanguage) {
+        if (PsiTreeUtil.getParentOfType(element, XmlAttributeValue.class) != null) {
+          return false;
+        }
+        if (PsiTreeUtil.getParentOfType(element, XmlComment.class) != null) {
+          return false;
+        }
         return true;
       }
     }