diff options
Diffstat (limited to 'xml/xml-psi-impl/src/com/intellij')
11 files changed, 446 insertions, 193 deletions
diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java index 27b972887a83..1303d56d7591 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java @@ -84,6 +84,10 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { } } + public HtmlHighlightingLexer() { + this(null); + } + public HtmlHighlightingLexer(FileType styleFileType) { this(new MergingLexerAdapter(new FlexAdapter(new _HtmlLexer()), TOKENS_TO_MERGE), true, styleFileType); } diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex b/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex index 275c4c957d7e..a680682c9236 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex +++ b/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex @@ -89,6 +89,18 @@ CONDITIONAL_COMMENT_CONDITION=({ALPHA})({ALPHA}|{WHITE_SPACE_CHARS}|{DIGIT}|"."| <COMMENT> "[" { yybegin(C_COMMENT_START); return XmlTokenType.XML_CONDITIONAL_COMMENT_START; } <COMMENT> "<![" { yybegin(C_COMMENT_END); return XmlTokenType.XML_CONDITIONAL_COMMENT_END_START; } <COMMENT> {END_COMMENT} { yybegin(YYINITIAL); return XmlTokenType.XML_COMMENT_END; } +<COMMENT> ">" { + // according to HTML spec (http://www.w3.org/html/wg/drafts/html/master/syntax.html#comments) + // comments should start with <!-- and end with --> thus making <!--> absolutely valid comment + // please note that it's not true for XML (http://www.w3.org/TR/REC-xml/#sec-comments) + int loc = getTokenStart(); + char prev = zzBuffer.charAt(loc - 1); + char prevPrev = zzBuffer.charAt(loc - 2); + if (prev == '-' && prevPrev == '-') { + yybegin(YYINITIAL); return XmlTokenType.XML_COMMENT_END; + } + return XmlTokenType.XML_COMMENT_CHARACTERS; +} <COMMENT> [^] { return XmlTokenType.XML_COMMENT_CHARACTERS; } <C_COMMENT_START,C_COMMENT_END> {CONDITIONAL_COMMENT_CONDITION} { return XmlTokenType.XML_COMMENT_CHARACTERS; } diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.java index d1e78a6d366a..b8c8e1c09a64 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.java @@ -1,18 +1,17 @@ -/* The following code was generated by JFlex 1.4.3 on 9/8/13 3:03 PM */ +/* The following code was generated by JFlex 1.4.3 on 10/18/13 1:39 AM */ /* It's an automatically generated code. Do not modify it. */ package com.intellij.lexer; import com.intellij.psi.tree.IElementType; -import com.intellij.psi.*; -import com.intellij.psi.xml.*; +import com.intellij.psi.xml.XmlTokenType; /** * This class is a scanner generated by * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 - * on 9/8/13 3:03 PM from the specification file - * <tt>/Users/fedorkorotkov/workspaces/idea/community/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex</tt> + * on 10/18/13 1:39 AM from the specification file + * <tt>/Users/denofevil/Code/IDEA/tools/lexer/../../community/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex</tt> */ public class _HtmlLexer implements FlexLexer { /** initial size of the lookahead buffer */ @@ -126,17 +125,17 @@ public class _HtmlLexer implements FlexLexer { private static final String ZZ_ACTION_PACKED_0 = "\1\1\10\0\1\2\5\0\1\1\1\3\5\1\1\4"+ - "\1\5\4\4\1\6\1\4\4\7\1\10\1\11\1\12"+ - "\1\13\2\11\1\14\1\15\1\11\1\16\1\17\1\20"+ - "\1\21\2\17\1\22\1\23\4\22\1\2\1\24\1\4"+ - "\1\25\3\26\1\27\1\7\3\27\1\30\1\31\1\32"+ - "\1\0\1\33\1\34\15\0\1\34\1\35\2\17\3\0"+ - "\1\36\2\0\1\37\1\40\1\41\1\42\11\0\1\43"+ - "\1\44\1\0\1\45\1\17\1\45\1\46\1\0\1\47"+ - "\3\0\1\14\3\0\1\50\2\0\1\51"; + "\1\5\4\4\1\6\1\4\3\7\1\10\1\7\1\11"+ + "\1\12\1\13\1\14\2\12\1\15\1\16\1\12\1\17"+ + "\1\20\1\21\1\22\2\20\1\23\1\24\4\23\1\2"+ + "\1\25\1\4\1\26\3\27\1\30\1\7\3\30\1\31"+ + "\1\32\1\33\1\0\1\34\1\35\15\0\1\35\1\36"+ + "\2\20\3\0\1\37\2\0\1\40\1\41\1\42\1\43"+ + "\11\0\1\44\1\45\1\0\1\46\1\20\1\46\1\47"+ + "\1\0\1\50\3\0\1\15\3\0\1\51\2\0\1\52"; private static int [] zzUnpackAction() { - int [] result = new int[129]; + int [] result = new int[130]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -165,22 +164,22 @@ public class _HtmlLexer implements FlexLexer { "\0\u01a0\0\u01d4\0\u0208\0\u023c\0\u0270\0\u02a4\0\u02d8\0\u030c"+ "\0\u0340\0\u0374\0\u03a8\0\u03dc\0\u0410\0\u0444\0\u0374\0\u0478"+ "\0\u04ac\0\u04e0\0\u0514\0\u0548\0\u0374\0\u0410\0\u0374\0\u057c"+ - "\0\u05b0\0\u0410\0\u0374\0\u0374\0\u05e4\0\u0374\0\u0410\0\u0618"+ - "\0\u064c\0\u0374\0\u0680\0\u0374\0\u06b4\0\u0374\0\u0374\0\u06e8"+ - "\0\u071c\0\u0374\0\u0374\0\u0750\0\u0410\0\u0784\0\u07b8\0\u07ec"+ - "\0\u0374\0\u0820\0\u0854\0\u0374\0\u0410\0\u0680\0\u0374\0\u0888"+ - "\0\u057c\0\u0410\0\u08bc\0\u0374\0\u08f0\0\u0924\0\u0958\0\u0374"+ - "\0\u098c\0\u09c0\0\u09f4\0\u0a28\0\u0a5c\0\u0a90\0\u0ac4\0\u0af8"+ - "\0\u04ac\0\u04e0\0\u0b2c\0\u0b60\0\u0b94\0\u0bc8\0\u0374\0\u0374"+ - "\0\u0bfc\0\u0c30\0\u0c64\0\u0c98\0\u0ccc\0\u0374\0\u0d00\0\u0d34"+ - "\0\u0d68\0\u0d9c\0\u0374\0\u0374\0\u0dd0\0\u0e04\0\u0e38\0\u0e6c"+ - "\0\u0ea0\0\u0ed4\0\u0f08\0\u0f3c\0\u0f70\0\u0374\0\u0374\0\u0fa4"+ - "\0\u06b4\0\u0fd8\0\u0374\0\u0374\0\u100c\0\u0374\0\u1040\0\u1074"+ - "\0\u10a8\0\u0374\0\u10dc\0\u1110\0\u1144\0\u0374\0\u1178\0\u11ac"+ - "\0\u0374"; + "\0\u05b0\0\u0374\0\u0410\0\u0374\0\u0374\0\u05e4\0\u0374\0\u0410"+ + "\0\u0618\0\u064c\0\u0374\0\u0680\0\u0374\0\u06b4\0\u0374\0\u0374"+ + "\0\u06e8\0\u071c\0\u0374\0\u0374\0\u0750\0\u0410\0\u0784\0\u07b8"+ + "\0\u07ec\0\u0374\0\u0820\0\u0854\0\u0374\0\u0410\0\u0680\0\u0374"+ + "\0\u0888\0\u057c\0\u0410\0\u08bc\0\u0374\0\u08f0\0\u0924\0\u0958"+ + "\0\u0374\0\u098c\0\u09c0\0\u09f4\0\u0a28\0\u0a5c\0\u0a90\0\u0ac4"+ + "\0\u0af8\0\u04ac\0\u04e0\0\u0b2c\0\u0b60\0\u0b94\0\u0bc8\0\u0374"+ + "\0\u0374\0\u0bfc\0\u0c30\0\u0c64\0\u0c98\0\u0ccc\0\u0374\0\u0d00"+ + "\0\u0d34\0\u0d68\0\u0d9c\0\u0374\0\u0374\0\u0dd0\0\u0e04\0\u0e38"+ + "\0\u0e6c\0\u0ea0\0\u0ed4\0\u0f08\0\u0f3c\0\u0f70\0\u0374\0\u0374"+ + "\0\u0fa4\0\u06b4\0\u0fd8\0\u0374\0\u0374\0\u100c\0\u0374\0\u1040"+ + "\0\u1074\0\u10a8\0\u0374\0\u10dc\0\u1110\0\u1144\0\u0374\0\u1178"+ + "\0\u11ac\0\u0374"; private static int [] zzUnpackRowMap() { - int [] result = new int[129]; + int [] result = new int[130]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -206,77 +205,78 @@ public class _HtmlLexer implements FlexLexer { "\3\20\1\21\3\20\1\22\2\20\1\23\25\20\1\24"+ "\4\20\1\25\4\20\1\26\11\20\3\27\1\30\4\27"+ "\1\31\1\32\11\27\2\33\1\27\1\34\14\27\1\35"+ - "\1\27\1\36\16\27\6\37\1\40\3\37\1\41\32\37"+ - "\1\42\2\37\1\43\13\37\1\44\1\45\1\44\1\30"+ - "\1\45\5\44\1\46\1\44\24\45\5\44\1\47\7\44"+ - "\7\45\1\44\1\45\1\44\1\30\1\45\5\44\1\50"+ - "\1\44\24\45\5\44\1\47\7\44\7\45\1\44\1\51"+ - "\1\44\1\30\1\51\7\44\24\51\3\44\1\52\1\44"+ - "\1\47\1\44\1\53\3\44\1\54\1\44\7\51\3\55"+ - "\1\30\4\55\1\56\1\57\26\55\1\60\2\55\1\52"+ - "\3\55\1\61\14\55\10\62\1\63\27\62\1\64\4\62"+ - "\1\65\4\62\1\66\22\62\1\63\26\62\1\67\4\62"+ - "\1\65\4\62\1\66\11\62\43\70\1\71\2\70\1\72"+ - "\15\70\7\27\1\73\2\27\1\46\32\27\1\36\16\27"+ - "\3\44\1\30\3\44\1\51\2\44\1\50\30\44\1\52"+ - "\1\44\1\47\16\44\3\74\1\30\6\74\1\46\30\74"+ - "\1\52\1\74\1\75\1\74\1\76\14\74\1\77\1\100"+ - "\4\77\1\101\5\77\24\100\5\77\1\102\3\77\1\103"+ - "\3\77\7\100\1\77\1\100\4\77\1\101\5\77\24\100"+ - "\5\77\1\102\3\77\1\104\3\77\7\100\3\20\1\0"+ - "\3\20\1\0\2\20\1\0\25\20\1\0\4\20\1\0"+ - "\4\20\1\26\11\20\3\0\1\21\145\0\1\105\2\0"+ - "\1\105\2\0\1\106\3\0\1\107\24\105\6\0\1\110"+ - "\1\111\5\0\7\105\41\0\1\112\23\0\1\113\2\0"+ - "\1\113\2\0\1\114\4\0\16\113\1\115\5\113\15\0"+ - "\1\115\1\116\1\113\1\117\1\120\2\113\3\20\1\0"+ - "\6\20\1\0\32\20\1\0\4\20\1\26\11\20\3\0"+ - "\1\30\60\0\10\121\1\62\53\121\11\122\1\62\52\122"+ - "\33\0\2\123\47\0\2\124\50\0\1\125\70\0\1\126"+ - "\51\0\2\45\1\0\3\45\5\0\24\45\15\0\7\45"+ - "\47\0\1\127\15\0\2\51\1\0\3\51\5\0\24\51"+ - "\15\0\7\51\43\0\1\130\20\0\3\55\1\0\37\55"+ - "\1\0\3\55\1\131\17\55\1\0\35\55\1\132\1\55"+ - "\1\0\3\55\1\131\17\55\1\0\37\55\1\130\3\55"+ - "\1\131\14\55\41\0\1\133\62\0\1\62\64\0\1\134"+ - "\22\0\43\70\1\0\2\70\1\135\60\70\1\71\20\70"+ - "\1\0\2\73\1\0\3\73\5\0\24\73\15\0\7\73"+ - "\1\0\3\100\1\0\1\100\5\0\25\100\4\0\2\100"+ - "\7\0\7\100\43\0\1\136\21\0\2\105\1\0\3\105"+ - "\5\0\24\105\15\0\7\105\1\0\2\106\1\0\3\106"+ - "\5\0\24\106\15\0\7\106\6\0\1\137\5\0\1\140"+ - "\50\0\1\141\2\0\1\141\2\0\1\142\4\0\24\141"+ - "\15\0\7\141\42\112\1\143\21\112\1\0\2\113\1\0"+ - "\3\113\5\0\24\113\14\0\1\144\7\113\2\0\1\145"+ - "\57\0\1\146\2\0\2\113\1\0\3\113\5\0\5\113"+ - "\1\147\16\113\14\0\1\144\7\113\1\0\2\113\1\0"+ - "\3\113\5\0\10\113\1\150\3\113\1\151\7\113\14\0"+ - "\1\144\7\113\1\0\2\113\1\0\3\113\5\0\20\113"+ - "\1\152\3\113\14\0\1\144\7\113\1\0\2\113\1\0"+ - "\3\113\5\0\22\113\1\153\1\113\14\0\1\144\7\113"+ - "\35\0\2\154\54\0\2\155\36\0\1\125\37\0\1\156"+ - "\70\0\1\157\13\0\43\55\1\0\3\55\1\131\14\55"+ - "\3\132\1\160\36\132\1\161\1\160\3\132\1\162\14\132"+ - "\10\133\1\0\31\133\1\163\21\133\11\134\1\0\30\134"+ - "\1\163\21\134\43\70\1\0\20\70\6\0\1\164\72\0"+ - "\2\165\46\0\2\141\1\0\3\141\5\0\24\141\15\0"+ - "\7\141\1\0\2\142\1\0\3\142\5\0\24\142\15\0"+ - "\7\142\2\0\1\145\51\0\1\166\11\0\1\167\11\0"+ - "\1\167\2\0\1\167\5\0\1\167\7\0\2\167\17\0"+ - "\1\167\4\0\1\167\1\0\2\113\1\0\3\113\5\0"+ - "\24\113\14\0\1\166\7\113\1\0\2\113\1\0\3\113"+ - "\5\0\2\113\1\170\21\113\14\0\1\144\7\113\1\0"+ - "\2\113\1\0\3\113\5\0\10\113\1\147\13\113\14\0"+ - "\1\144\7\113\1\0\2\113\1\0\3\113\5\0\2\113"+ - "\1\115\21\113\14\0\1\144\7\113\1\0\2\113\1\0"+ - "\3\113\5\0\24\113\14\0\1\144\2\113\1\151\4\113"+ - "\31\0\2\171\62\0\2\172\31\0\42\160\1\163\21\160"+ - "\42\132\1\161\1\160\3\132\1\162\14\132\17\0\1\173"+ - "\46\0\1\167\11\0\1\167\2\0\1\167\5\0\1\167"+ - "\7\0\2\167\15\0\1\166\1\0\1\167\4\0\1\167"+ - "\1\0\2\113\1\0\3\113\5\0\24\113\14\0\1\144"+ - "\2\113\1\147\4\113\37\0\1\174\44\0\2\175\61\0"+ - "\1\176\66\0\1\177\64\0\2\200\64\0\1\201\36\0"; + "\1\27\1\36\16\27\6\37\1\40\3\37\1\41\30\37"+ + "\1\42\1\37\1\43\2\37\1\44\13\37\1\45\1\46"+ + "\1\45\1\30\1\46\5\45\1\47\1\45\24\46\5\45"+ + "\1\50\7\45\7\46\1\45\1\46\1\45\1\30\1\46"+ + "\5\45\1\51\1\45\24\46\5\45\1\50\7\45\7\46"+ + "\1\45\1\52\1\45\1\30\1\52\7\45\24\52\3\45"+ + "\1\53\1\45\1\50\1\45\1\54\3\45\1\55\1\45"+ + "\7\52\3\56\1\30\4\56\1\57\1\60\26\56\1\61"+ + "\2\56\1\53\3\56\1\62\14\56\10\63\1\64\27\63"+ + "\1\65\4\63\1\66\4\63\1\67\22\63\1\64\26\63"+ + "\1\70\4\63\1\66\4\63\1\67\11\63\43\71\1\72"+ + "\2\71\1\73\15\71\7\27\1\74\2\27\1\47\32\27"+ + "\1\36\16\27\3\45\1\30\3\45\1\52\2\45\1\51"+ + "\30\45\1\53\1\45\1\50\16\45\3\75\1\30\6\75"+ + "\1\47\30\75\1\53\1\75\1\76\1\75\1\77\14\75"+ + "\1\100\1\101\4\100\1\102\5\100\24\101\5\100\1\103"+ + "\3\100\1\104\3\100\7\101\1\100\1\101\4\100\1\102"+ + "\5\100\24\101\5\100\1\103\3\100\1\105\3\100\7\101"+ + "\3\20\1\0\3\20\1\0\2\20\1\0\25\20\1\0"+ + "\4\20\1\0\4\20\1\26\11\20\3\0\1\21\145\0"+ + "\1\106\2\0\1\106\2\0\1\107\3\0\1\110\24\106"+ + "\6\0\1\111\1\112\5\0\7\106\41\0\1\113\23\0"+ + "\1\114\2\0\1\114\2\0\1\115\4\0\16\114\1\116"+ + "\5\114\15\0\1\116\1\117\1\114\1\120\1\121\2\114"+ + "\3\20\1\0\6\20\1\0\32\20\1\0\4\20\1\26"+ + "\11\20\3\0\1\30\60\0\10\122\1\63\53\122\11\123"+ + "\1\63\52\123\33\0\2\124\47\0\2\125\50\0\1\126"+ + "\70\0\1\127\51\0\2\46\1\0\3\46\5\0\24\46"+ + "\15\0\7\46\47\0\1\130\15\0\2\52\1\0\3\52"+ + "\5\0\24\52\15\0\7\52\43\0\1\131\20\0\3\56"+ + "\1\0\37\56\1\0\3\56\1\132\17\56\1\0\35\56"+ + "\1\133\1\56\1\0\3\56\1\132\17\56\1\0\37\56"+ + "\1\131\3\56\1\132\14\56\41\0\1\134\62\0\1\63"+ + "\64\0\1\135\22\0\43\71\1\0\2\71\1\136\60\71"+ + "\1\72\20\71\1\0\2\74\1\0\3\74\5\0\24\74"+ + "\15\0\7\74\1\0\3\101\1\0\1\101\5\0\25\101"+ + "\4\0\2\101\7\0\7\101\43\0\1\137\21\0\2\106"+ + "\1\0\3\106\5\0\24\106\15\0\7\106\1\0\2\107"+ + "\1\0\3\107\5\0\24\107\15\0\7\107\6\0\1\140"+ + "\5\0\1\141\50\0\1\142\2\0\1\142\2\0\1\143"+ + "\4\0\24\142\15\0\7\142\42\113\1\144\21\113\1\0"+ + "\2\114\1\0\3\114\5\0\24\114\14\0\1\145\7\114"+ + "\2\0\1\146\57\0\1\147\2\0\2\114\1\0\3\114"+ + "\5\0\5\114\1\150\16\114\14\0\1\145\7\114\1\0"+ + "\2\114\1\0\3\114\5\0\10\114\1\151\3\114\1\152"+ + "\7\114\14\0\1\145\7\114\1\0\2\114\1\0\3\114"+ + "\5\0\20\114\1\153\3\114\14\0\1\145\7\114\1\0"+ + "\2\114\1\0\3\114\5\0\22\114\1\154\1\114\14\0"+ + "\1\145\7\114\35\0\2\155\54\0\2\156\36\0\1\126"+ + "\37\0\1\157\70\0\1\160\13\0\43\56\1\0\3\56"+ + "\1\132\14\56\3\133\1\161\36\133\1\162\1\161\3\133"+ + "\1\163\14\133\10\134\1\0\31\134\1\164\21\134\11\135"+ + "\1\0\30\135\1\164\21\135\43\71\1\0\20\71\6\0"+ + "\1\165\72\0\2\166\46\0\2\142\1\0\3\142\5\0"+ + "\24\142\15\0\7\142\1\0\2\143\1\0\3\143\5\0"+ + "\24\143\15\0\7\143\2\0\1\146\51\0\1\167\11\0"+ + "\1\170\11\0\1\170\2\0\1\170\5\0\1\170\7\0"+ + "\2\170\17\0\1\170\4\0\1\170\1\0\2\114\1\0"+ + "\3\114\5\0\24\114\14\0\1\167\7\114\1\0\2\114"+ + "\1\0\3\114\5\0\2\114\1\171\21\114\14\0\1\145"+ + "\7\114\1\0\2\114\1\0\3\114\5\0\10\114\1\150"+ + "\13\114\14\0\1\145\7\114\1\0\2\114\1\0\3\114"+ + "\5\0\2\114\1\116\21\114\14\0\1\145\7\114\1\0"+ + "\2\114\1\0\3\114\5\0\24\114\14\0\1\145\2\114"+ + "\1\152\4\114\31\0\2\172\62\0\2\173\31\0\42\161"+ + "\1\164\21\161\42\133\1\162\1\161\3\133\1\163\14\133"+ + "\17\0\1\174\46\0\1\170\11\0\1\170\2\0\1\170"+ + "\5\0\1\170\7\0\2\170\15\0\1\167\1\0\1\170"+ + "\4\0\1\170\1\0\2\114\1\0\3\114\5\0\24\114"+ + "\14\0\1\145\2\114\1\150\4\114\37\0\1\175\44\0"+ + "\2\176\61\0\1\177\66\0\1\200\64\0\2\201\64\0"+ + "\1\202\36\0"; private static int [] zzUnpackTrans() { int [] result = new int[4576]; @@ -321,16 +321,16 @@ public class _HtmlLexer implements FlexLexer { private static final String ZZ_ATTRIBUTE_PACKED_0 = "\1\1\10\0\1\1\5\0\2\1\1\11\4\1\1\11"+ - "\5\1\1\11\1\1\1\11\3\1\2\11\1\1\1\11"+ - "\3\1\1\11\1\1\1\11\1\1\2\11\2\1\2\11"+ - "\5\1\1\11\2\1\1\11\2\1\1\11\4\1\1\11"+ - "\2\1\1\0\1\11\1\1\15\0\2\11\2\1\3\0"+ - "\1\11\2\0\2\1\2\11\11\0\2\11\1\0\2\1"+ - "\2\11\1\0\1\11\3\0\1\11\3\0\1\11\2\0"+ - "\1\11"; + "\5\1\1\11\1\1\1\11\2\1\1\11\1\1\2\11"+ + "\1\1\1\11\3\1\1\11\1\1\1\11\1\1\2\11"+ + "\2\1\2\11\5\1\1\11\2\1\1\11\2\1\1\11"+ + "\4\1\1\11\2\1\1\0\1\11\1\1\15\0\2\11"+ + "\2\1\3\0\1\11\2\0\2\1\2\11\11\0\2\11"+ + "\1\0\2\1\2\11\1\0\1\11\3\0\1\11\3\0"+ + "\1\11\2\0\1\11"; private static int [] zzUnpackAttribute() { - int [] result = new int[129]; + int [] result = new int[130]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -648,170 +648,180 @@ public class _HtmlLexer implements FlexLexer { zzMarkedPos = zzMarkedPosL; switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 18: + case 19: { return XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN; } - case 42: break; - case 25: + case 43: break; + case 26: { yybegin(START_TAG_NAME); yypushback(yylength()); } - case 43: break; - case 22: + case 44: break; + case 23: { return XmlTokenType.XML_TAG_CHARACTERS; } - case 44: break; - case 14: + case 45: break; + case 15: { yybegin(ATTRIBUTE_VALUE_START); return XmlTokenType.XML_EQ; } - case 45: break; - case 33: + case 46: break; + case 34: { return elTokenType; } - case 46: break; - case 12: + case 47: break; + case 13: { return XmlTokenType.XML_NAME; } - case 47: break; - case 19: + case 48: break; + case 20: { yybegin(TAG_ATTRIBUTES); return XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER; } - case 48: break; - case 9: + case 49: break; + case 10: { yybegin(YYINITIAL); yypushback(1); break; } - case 49: break; - case 40: + case 50: break; + case 41: { return XmlTokenType.XML_DOCTYPE_PUBLIC; } - case 50: break; - case 38: + case 51: break; + case 8: + { int loc = getTokenStart(); + char prev = zzBuffer.charAt(loc - 1); + char prevPrev = zzBuffer.charAt(loc - 2); + if (prev == '-' && prevPrev == '-') { + yybegin(YYINITIAL); return XmlTokenType.XML_COMMENT_END; + } + return XmlTokenType.XML_COMMENT_CHARACTERS; + } + case 52: break; + case 39: { yybegin(COMMENT); return XmlTokenType.XML_COMMENT_START; } - case 51: break; + case 53: break; case 3: { return XmlTokenType.XML_REAL_WHITE_SPACE; } - case 52: break; - case 31: + case 54: break; + case 32: { yybegin(END_TAG_NAME); yypushback(yylength()); } - case 53: break; + case 55: break; case 1: { return XmlTokenType.XML_DATA_CHARACTERS; } - case 54: break; - case 24: + case 56: break; + case 25: { yybegin(COMMENT); return XmlTokenType.XML_CONDITIONAL_COMMENT_END; } - case 55: break; - case 32: + case 57: break; + case 33: { yybegin(END_TAG_NAME2); yypushback(yylength()); } - case 56: break; + case 58: break; case 4: { return XmlTokenType.XML_BAD_CHARACTER; } - case 57: break; - case 13: + case 59: break; + case 14: { yybegin(YYINITIAL); return XmlTokenType.XML_TAG_END; } - case 58: break; - case 30: + case 60: break; + case 31: { yybegin(COMMENT); return XmlTokenType.XML_CONDITIONAL_COMMENT_START_END; } - case 59: break; - case 28: + case 61: break; + case 29: { return XmlTokenType.XML_END_TAG_START; } - case 60: break; - case 35: + case 62: break; + case 36: { yybegin(YYINITIAL); return XmlTokenType.XML_COMMENT_END; } - case 61: break; - case 41: + case 63: break; + case 42: { yybegin(DOC_TYPE); return XmlTokenType.XML_DOCTYPE_START; } - case 62: break; + case 64: break; case 2: { return XmlTokenType.XML_PI_TARGET; } - case 63: break; - case 29: + case 65: break; + case 30: { yybegin(YYINITIAL); return XmlTokenType.XML_EMPTY_ELEMENT_END; } - case 64: break; - case 36: + case 66: break; + case 37: { yybegin(C_COMMENT_END); return XmlTokenType.XML_CONDITIONAL_COMMENT_END_START; } - case 65: break; - case 27: + case 67: break; + case 28: { yybegin(PROCESSING_INSTRUCTION); return XmlTokenType.XML_PI_START; } - case 66: break; - case 8: + case 68: break; + case 9: { yybegin(C_COMMENT_START); return XmlTokenType.XML_CONDITIONAL_COMMENT_START; } - case 67: break; - case 21: + case 69: break; + case 22: { yybegin(TAG_CHARACTERS); return XmlTokenType.XML_NAME; } - case 68: break; + case 70: break; case 6: { yybegin(YYINITIAL); return XmlTokenType.XML_DOCTYPE_END; } - case 69: break; - case 39: + case 71: break; + case 40: { return XmlTokenType.XML_CHAR_ENTITY_REF; } - case 70: break; - case 11: + case 72: break; + case 12: { return XmlTokenType.XML_START_TAG_START; } - case 71: break; + case 73: break; case 5: { return XmlTokenType.XML_WHITE_SPACE; } - case 72: break; - case 34: + case 74: break; + case 35: { return XmlTokenType.XML_ENTITY_REF_TOKEN; } - case 73: break; - case 23: + case 75: break; + case 24: { yybegin(COMMENT); return XmlTokenType.XML_COMMENT_CHARACTERS; } - case 74: break; - case 37: + case 76: break; + case 38: { return elTokenType2; } - case 75: break; - case 20: + case 77: break; + case 21: { yybegin(YYINITIAL); return XmlTokenType.XML_PI_END; } - case 76: break; - case 16: + case 78: break; + case 17: { yybegin(ATTRIBUTE_VALUE_DQ); return XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER; } - case 77: break; - case 17: + case 79: break; + case 18: { yybegin(ATTRIBUTE_VALUE_SQ); return XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER; } - case 78: break; - case 10: + case 80: break; + case 11: { yybegin(TAG_ATTRIBUTES); return XmlTokenType.XML_NAME; } - case 79: break; - case 26: + case 81: break; + case 27: { yybegin(START_TAG_NAME2); yypushback(yylength()); } - case 80: break; - case 15: + case 82: break; + case 16: { yybegin(TAG_ATTRIBUTES); return XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN; } - case 81: break; + case 83: break; case 7: { return XmlTokenType.XML_COMMENT_CHARACTERS; } - case 82: break; + case 84: break; default: if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { zzAtEOF = true; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/AttributeValueSelfReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/AttributeValueSelfReference.java new file mode 100644 index 000000000000..781c49f527f0 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/AttributeValueSelfReference.java @@ -0,0 +1,56 @@ +/* + * 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.psi.impl.source.resolve.reference.impl.providers; + +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; +import com.intellij.util.ArrayUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author peter +*/ +public class AttributeValueSelfReference extends BasicAttributeValueReference { + public AttributeValueSelfReference(final PsiElement element) { + super(element); + } + + public AttributeValueSelfReference(final PsiElement element, int offset) { + super(element, offset); + } + + public AttributeValueSelfReference(final PsiElement element, TextRange range) { + super(element, range); + } + + @Override + @Nullable + public PsiElement resolve() { + return myElement; + } + + @Override + @NotNull + public Object[] getVariants() { + return ArrayUtil.EMPTY_OBJECT_ARRAY; + } + + @Override + public boolean isSoft() { + return true; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileBasedUserDataCache.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileBasedUserDataCache.java new file mode 100644 index 000000000000..5f30df017190 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileBasedUserDataCache.java @@ -0,0 +1,56 @@ +/* + * 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.psi.impl.source.resolve.reference.impl.providers; + +import com.intellij.psi.util.CachedValue; +import com.intellij.psi.util.CachedValueProvider; +import com.intellij.psi.PsiFile; +import com.intellij.psi.FileViewProvider; +import com.intellij.openapi.util.UserDataCache; +import com.intellij.openapi.util.Key; +import com.intellij.psi.util.CachedValuesManager; + +/** + * @author Maxim.Mossienko +* Date: 30.12.2008 +* Time: 21:03:42 +*/ +public abstract class FileBasedUserDataCache<T> extends UserDataCache<CachedValue<T>, PsiFile, Object> { + @Override + protected CachedValue<T> compute(final PsiFile xmlFile, final Object o) { + return CachedValuesManager.getManager(xmlFile.getProject()).createCachedValue(new CachedValueProvider<T>() { + @Override + public Result<T> compute() { + + return new Result<T>(doCompute(xmlFile), getDependencies(xmlFile)); + } + }, false); + } + + protected Object[] getDependencies(PsiFile xmlFile) { + return new Object[] {xmlFile}; + } + + protected abstract T doCompute(PsiFile file); + protected abstract Key<CachedValue<T>> getKey(); + + public T compute(PsiFile file) { + final FileViewProvider fileViewProvider = file.getViewProvider(); + final PsiFile baseFile = fileViewProvider.getPsi(fileViewProvider.getBaseLanguage()); + baseFile.getFirstChild(); // expand chameleon out of lock + return get(getKey(), baseFile, null).getValue(); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/ImplicitIdRefProvider.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/ImplicitIdRefProvider.java new file mode 100644 index 000000000000..891f0c67e6e4 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/ImplicitIdRefProvider.java @@ -0,0 +1,30 @@ +/* + * 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.psi.impl.source.resolve.reference.impl.providers; + + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlTag; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface ImplicitIdRefProvider { + ExtensionPointName<ImplicitIdRefProvider> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.xml.implicitIdRefProvider"); + + @Nullable + XmlAttribute getIdRefAttribute(@NotNull XmlTag tag); +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java index b030815ad2a4..7cbc00cc4587 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java @@ -89,7 +89,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { private volatile long myDescriptorModCount = -1; private volatile long myExtResourcesModCount = -1; - private volatile boolean myHaveNamespaceDeclarations = false; + private volatile boolean myHasNamespaceDeclarations = false; private volatile BidirectionalMap<String, String> myNamespaceMap = null; @NonNls private static final String XML_NS_PREFIX = "xml"; @@ -135,7 +135,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { myDescriptorModCount = -1; myAttributes = null; myAttributeValueMap = null; - myHaveNamespaceDeclarations = false; + myHasNamespaceDeclarations = false; myValue = null; myNSDescriptorsMap = null; super.clearCaches(); @@ -584,7 +584,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { XmlAttribute attribute = (XmlAttribute)element; result.add(attribute); cacheOneAttributeValue(attribute.getName(), attribute.getValue(), attributesValueMap); - myHaveNamespaceDeclarations = myHaveNamespaceDeclarations || attribute.isNamespaceDeclaration(); + myHasNamespaceDeclarations = myHasNamespaceDeclarations || attribute.isNamespaceDeclaration(); } else if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_TAG_END) { return false; @@ -866,7 +866,8 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { @Nullable private BidirectionalMap<String, String> computeNamespaceMap(PsiElement parent) { BidirectionalMap<String, String> map = null; - if (hasNamespaceDeclarations()) { + boolean hasNamespaceDeclarations = hasNamespaceDeclarations(); + if (hasNamespaceDeclarations) { map = new BidirectionalMap<String, String>(); final XmlAttribute[] attributes = getAttributes(); @@ -891,12 +892,12 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { if (parent instanceof XmlDocument) { final XmlExtension extension = XmlExtension.getExtensionByElement(parent); if (extension != null) { - final String[][] defaultNamespace = extension.getNamespacesFromDocument((XmlDocument)parent, map != null); - if (defaultNamespace != null) { + final String[][] namespacesFromDocument = extension.getNamespacesFromDocument((XmlDocument)parent, hasNamespaceDeclarations); + if (namespacesFromDocument != null) { if (map == null) { map = new BidirectionalMap<String, String>(); } - for (final String[] prefix2ns : defaultNamespace) { + for (final String[] prefix2ns : namespacesFromDocument) { map.put(prefix2ns[0], getRealNs(prefix2ns[1])); } } @@ -930,7 +931,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { @Override public boolean hasNamespaceDeclarations() { getAttributes(); - return myHaveNamespaceDeclarations; + return myHasNamespaceDeclarations; } @Override diff --git a/xml/xml-psi-impl/src/com/intellij/xml/HtmlXmlExtension.java b/xml/xml-psi-impl/src/com/intellij/xml/HtmlXmlExtension.java new file mode 100644 index 000000000000..4ece939ffac0 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/HtmlXmlExtension.java @@ -0,0 +1,24 @@ +package com.intellij.xml; + +import com.intellij.ide.highlighter.HtmlFileType; +import com.intellij.psi.PsiFile; +import com.intellij.psi.xml.XmlDocument; +import org.jetbrains.annotations.Nullable; + +/** + * @author Dmitry Avdeev + * Date: 24.10.13 + */ +public class HtmlXmlExtension extends DefaultXmlExtension { + + @Override + public boolean isAvailable(PsiFile file) { + return file.getFileType() == HtmlFileType.INSTANCE; + } + + @Nullable + @Override + public String[][] getNamespacesFromDocument(XmlDocument parent, boolean declarationsExist) { + return super.getNamespacesFromDocument(parent, false); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java index 0a6792487b5a..1e549442011a 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -45,7 +45,7 @@ public abstract class XmlIndex<V> extends FileBasedIndexExtension<String, V> { protected static GlobalSearchScope createFilter(final Project project) { final GlobalSearchScope projectScope = GlobalSearchScope.allScope(project); return new GlobalSearchScope(project) { - public int compare(VirtualFile file1, VirtualFile file2) { + public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) { return projectScope.compare(file1, file2); } @@ -54,7 +54,7 @@ public abstract class XmlIndex<V> extends FileBasedIndexExtension<String, V> { } @Override - public boolean contains(VirtualFile file) { + public boolean contains(@NotNull VirtualFile file) { final VirtualFile parent = file.getParent(); return parent != null && (parent.getName().equals("standardSchemas") || projectScope.contains(file)); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlDoctypeProvider.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlDoctypeProvider.java new file mode 100644 index 000000000000..841523f2cbfa --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlDoctypeProvider.java @@ -0,0 +1,32 @@ +/* + * 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.util; + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.psi.xml.XmlDoctype; +import com.intellij.psi.xml.XmlFile; +import org.jetbrains.annotations.Nullable; + +/** + * @author traff + */ +public interface HtmlDoctypeProvider { + ExtensionPointName<HtmlDoctypeProvider> EP_NAME = ExtensionPointName.create("com.intellij.xml.util.htmlDoctypeProvider"); + + + @Nullable + XmlDoctype getDoctype(XmlFile file); +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlIdContributor.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlIdContributor.java new file mode 100644 index 000000000000..dafeb9ca409a --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlIdContributor.java @@ -0,0 +1,28 @@ +/* + * 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.util; + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.psi.xml.XmlFile; + +/** + * @author yole + */ +public interface XmlIdContributor { + ExtensionPointName<XmlIdContributor> EP_NAME = ExtensionPointName.create("com.intellij.xml.idContributor"); + + boolean suppressExistingIdValidation(XmlFile file); +} |