don't skip style/script content when there's no token type to parse them as correspon...
authorDennis Ushakov <dennis.ushakov@gmail.com>
Fri, 25 Mar 2016 11:33:32 +0000 (14:33 +0300)
committerDennis Ushakov <dennis.ushakov@gmail.com>
Fri, 25 Mar 2016 11:45:54 +0000 (14:45 +0300)
#IDEA-141736 fixed

xml/xml-psi-impl/src/com/intellij/lexer/HtmlLexer.java

index 2d99d4f93a14e99a560cbe2c33c48557dd567cec..3fffc456970770ecc3243285eb7f46a7d9de4533 100644 (file)
@@ -74,10 +74,11 @@ public class HtmlLexer extends BaseHtmlLexer {
     if (hasSeenStyle()) {
       if (hasSeenTag() && isStartOfEmbeddmentTagContent(tokenType)) {
         Language stylesheetLanguage = getStyleLanguage();
-        if (stylesheetLanguage == null || LanguageUtil.isInjectableLanguage(stylesheetLanguage)) {
+        IElementType currentStylesheetElementType;
+        if ((stylesheetLanguage == null || LanguageUtil.isInjectableLanguage(stylesheetLanguage)) &&
+            (currentStylesheetElementType = getCurrentStylesheetElementType()) != null) {
           myTokenEnd = skipToTheEndOfTheEmbeddment();
-          IElementType currentStylesheetElementType = getCurrentStylesheetElementType();
-          tokenType = currentStylesheetElementType == null ? XmlTokenType.XML_DATA_CHARACTERS : currentStylesheetElementType;
+          tokenType = currentStylesheetElementType;
         }
       } else if (ourInlineStyleElementType!=null && isStartOfEmbeddmentAttributeValue(tokenType) && hasSeenAttribute()) {
         tokenType = ourInlineStyleElementType;
@@ -85,10 +86,11 @@ public class HtmlLexer extends BaseHtmlLexer {
     } else if (hasSeenScript()) {
       if (hasSeenTag() && isStartOfEmbeddmentTagContent(tokenType)) {
         Language scriptLanguage = getScriptLanguage();
-        if (scriptLanguage == null || LanguageUtil.isInjectableLanguage(scriptLanguage)) {
+        IElementType currentScriptElementType;
+        if ((scriptLanguage == null || LanguageUtil.isInjectableLanguage(scriptLanguage)) &&
+            (currentScriptElementType = getCurrentScriptElementType()) != null) {
           myTokenEnd = skipToTheEndOfTheEmbeddment();
-          IElementType currentScriptElementType = getCurrentScriptElementType();
-          tokenType = currentScriptElementType == null ? XmlTokenType.XML_DATA_CHARACTERS : currentScriptElementType;
+          tokenType = currentScriptElementType;
         }
       } else if (hasSeenAttribute() && isStartOfEmbeddmentAttributeValue(tokenType) && ourInlineScriptElementType!=null) {
         myTokenEnd = skipToTheEndOfTheEmbeddment();