├── .gitignore
├── .idea
├── .name
├── artifacts
│ └── tree_plugin_jar.xml
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── misc.xml
├── modules.xml
├── runConfigurations
│ └── Plugin.xml
├── scopes
│ └── scope_settings.xml
├── uiDesigner.xml
├── vcs.xml
└── workspace.xml
├── JFlex.jar
├── META-INF
├── MANIFEST.MF
└── plugin.xml
├── README.md
├── gen
└── ru
│ └── hyoo
│ └── jin
│ └── tree
│ ├── parser.java
│ └── psi
│ ├── Visitor.java
│ └── types.java
├── idea-flex.skeleton
├── src
└── ru
│ └── hyoo
│ └── jin
│ └── tree
│ ├── fileFactory.java
│ ├── fileType.java
│ ├── hlighter.java
│ ├── hlighterFactory.java
│ ├── icon.java
│ ├── icon.png
│ ├── lang.java
│ ├── lexer.java
│ ├── lexerAdapter.java
│ ├── parserDefinition.java
│ ├── psi
│ └── impl
│ │ ├── element.java
│ │ ├── file.java
│ │ └── token.java
│ ├── sample.tree
│ ├── tree.bnf
│ └── tree.flex
└── tree-plugin.iml
/.gitignore:
--------------------------------------------------------------------------------
1 | /out
2 |
3 | *.java~
4 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | tree-plugin
--------------------------------------------------------------------------------
/.idea/artifacts/tree_plugin_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/out/artifacts/tree_plugin_jar
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/Plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
158 |
159 |
160 |
161 |
162 | true
163 | DEFINITION_ORDER
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 | Android
180 |
181 |
182 | Android Lint
183 |
184 |
185 | General
186 |
187 |
188 | Java language level migration aids
189 |
190 |
191 | Maven
192 |
193 |
194 | Numeric issues
195 |
196 |
197 | Plugin DevKit
198 |
199 |
200 | XPath
201 |
202 |
203 |
204 |
205 | Abstraction issues
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 | localhost
489 | 5050
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 | 1399646232385
502 |
503 |
504 | 1399646232385
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 | tree-plugin:jar
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 | Detection
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 | JFlex & idea-flex.skeleton
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 | 1.8
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 | tree-plugin
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 | 1.8
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 |
1037 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
--------------------------------------------------------------------------------
/JFlex.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nin-jin/tree-plugin/e3dd29f3441497885fe503e9e681b5485fe8a2c6/JFlex.jar
--------------------------------------------------------------------------------
/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 |
3 |
--------------------------------------------------------------------------------
/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | ru.hyoo.jin.tree
3 | Tree syntax highlighter
4 | 2.0
5 | Jin
6 |
7 | Tree - very simple, readable, compact structural format. Better than xml, json, yaml and other.
9 | Plugin souces
10 | ]]>
11 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Tree highliting for IDEA
2 |
3 | Read more about tree format: https://github.com/nin-jin/tree.d
4 |
--------------------------------------------------------------------------------
/gen/ru/hyoo/jin/tree/parser.java:
--------------------------------------------------------------------------------
1 | // This is a generated file. Not intended for manual editing.
2 | package ru.hyoo.jin.tree;
3 |
4 | import com.intellij.lang.PsiBuilder;
5 | import com.intellij.lang.PsiBuilder.Marker;
6 | import static ru.hyoo.jin.tree.psi.types.*;
7 | import static com.intellij.lang.parser.GeneratedParserUtilBase.*;
8 | import com.intellij.psi.tree.IElementType;
9 | import com.intellij.lang.ASTNode;
10 | import com.intellij.psi.tree.TokenSet;
11 | import com.intellij.lang.PsiParser;
12 | import com.intellij.lang.LightPsiParser;
13 |
14 | @SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"})
15 | public class parser implements PsiParser, LightPsiParser {
16 |
17 | public ASTNode parse(IElementType t, PsiBuilder b) {
18 | parseLight(t, b);
19 | return b.getTreeBuilt();
20 | }
21 |
22 | public void parseLight(IElementType t, PsiBuilder b) {
23 | boolean r;
24 | b = adapt_builder_(t, b, this, null);
25 | Marker m = enter_section_(b, 0, _COLLAPSE_, null);
26 | r = parse_root_(t, b, 0);
27 | exit_section_(b, 0, m, t, r, true, TRUE_CONDITION);
28 | }
29 |
30 | protected boolean parse_root_(IElementType t, PsiBuilder b, int l) {
31 | return FILE(b, l + 1);
32 | }
33 |
34 | /* ********************************************************** */
35 | // ( NODES LF )* NODES?
36 | static boolean FILE(PsiBuilder b, int l) {
37 | if (!recursion_guard_(b, l, "FILE")) return false;
38 | boolean r;
39 | Marker m = enter_section_(b);
40 | r = FILE_0(b, l + 1);
41 | r = r && FILE_1(b, l + 1);
42 | exit_section_(b, m, null, r);
43 | return r;
44 | }
45 |
46 | // ( NODES LF )*
47 | private static boolean FILE_0(PsiBuilder b, int l) {
48 | if (!recursion_guard_(b, l, "FILE_0")) return false;
49 | int c = current_position_(b);
50 | while (true) {
51 | if (!FILE_0_0(b, l + 1)) break;
52 | if (!empty_element_parsed_guard_(b, "FILE_0", c)) break;
53 | c = current_position_(b);
54 | }
55 | return true;
56 | }
57 |
58 | // NODES LF
59 | private static boolean FILE_0_0(PsiBuilder b, int l) {
60 | if (!recursion_guard_(b, l, "FILE_0_0")) return false;
61 | boolean r;
62 | Marker m = enter_section_(b);
63 | r = NODES(b, l + 1);
64 | r = r && consumeToken(b, LF);
65 | exit_section_(b, m, null, r);
66 | return r;
67 | }
68 |
69 | // NODES?
70 | private static boolean FILE_1(PsiBuilder b, int l) {
71 | if (!recursion_guard_(b, l, "FILE_1")) return false;
72 | NODES(b, l + 1);
73 | return true;
74 | }
75 |
76 | /* ********************************************************** */
77 | // INDENT* ( NAME SPACE* )* ( VALUE_PREFIX VALUE? )?
78 | static boolean NODES(PsiBuilder b, int l) {
79 | if (!recursion_guard_(b, l, "NODES")) return false;
80 | boolean r;
81 | Marker m = enter_section_(b);
82 | r = NODES_0(b, l + 1);
83 | r = r && NODES_1(b, l + 1);
84 | r = r && NODES_2(b, l + 1);
85 | exit_section_(b, m, null, r);
86 | return r;
87 | }
88 |
89 | // INDENT*
90 | private static boolean NODES_0(PsiBuilder b, int l) {
91 | if (!recursion_guard_(b, l, "NODES_0")) return false;
92 | int c = current_position_(b);
93 | while (true) {
94 | if (!consumeToken(b, INDENT)) break;
95 | if (!empty_element_parsed_guard_(b, "NODES_0", c)) break;
96 | c = current_position_(b);
97 | }
98 | return true;
99 | }
100 |
101 | // ( NAME SPACE* )*
102 | private static boolean NODES_1(PsiBuilder b, int l) {
103 | if (!recursion_guard_(b, l, "NODES_1")) return false;
104 | int c = current_position_(b);
105 | while (true) {
106 | if (!NODES_1_0(b, l + 1)) break;
107 | if (!empty_element_parsed_guard_(b, "NODES_1", c)) break;
108 | c = current_position_(b);
109 | }
110 | return true;
111 | }
112 |
113 | // NAME SPACE*
114 | private static boolean NODES_1_0(PsiBuilder b, int l) {
115 | if (!recursion_guard_(b, l, "NODES_1_0")) return false;
116 | boolean r;
117 | Marker m = enter_section_(b);
118 | r = consumeToken(b, NAME);
119 | r = r && NODES_1_0_1(b, l + 1);
120 | exit_section_(b, m, null, r);
121 | return r;
122 | }
123 |
124 | // SPACE*
125 | private static boolean NODES_1_0_1(PsiBuilder b, int l) {
126 | if (!recursion_guard_(b, l, "NODES_1_0_1")) return false;
127 | int c = current_position_(b);
128 | while (true) {
129 | if (!consumeToken(b, SPACE)) break;
130 | if (!empty_element_parsed_guard_(b, "NODES_1_0_1", c)) break;
131 | c = current_position_(b);
132 | }
133 | return true;
134 | }
135 |
136 | // ( VALUE_PREFIX VALUE? )?
137 | private static boolean NODES_2(PsiBuilder b, int l) {
138 | if (!recursion_guard_(b, l, "NODES_2")) return false;
139 | NODES_2_0(b, l + 1);
140 | return true;
141 | }
142 |
143 | // VALUE_PREFIX VALUE?
144 | private static boolean NODES_2_0(PsiBuilder b, int l) {
145 | if (!recursion_guard_(b, l, "NODES_2_0")) return false;
146 | boolean r;
147 | Marker m = enter_section_(b);
148 | r = consumeToken(b, VALUE_PREFIX);
149 | r = r && NODES_2_0_1(b, l + 1);
150 | exit_section_(b, m, null, r);
151 | return r;
152 | }
153 |
154 | // VALUE?
155 | private static boolean NODES_2_0_1(PsiBuilder b, int l) {
156 | if (!recursion_guard_(b, l, "NODES_2_0_1")) return false;
157 | consumeToken(b, VALUE);
158 | return true;
159 | }
160 |
161 | }
162 |
--------------------------------------------------------------------------------
/gen/ru/hyoo/jin/tree/psi/Visitor.java:
--------------------------------------------------------------------------------
1 | // This is a generated file. Not intended for manual editing.
2 | package ru.hyoo.jin.tree.psi;
3 |
4 | import org.jetbrains.annotations.*;
5 | import com.intellij.psi.PsiElementVisitor;
6 | import com.intellij.psi.PsiElement;
7 |
8 | public class Visitor extends PsiElementVisitor {
9 |
10 | public void visitPsiElement(@NotNull PsiElement o) {
11 | visitElement(o);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/gen/ru/hyoo/jin/tree/psi/types.java:
--------------------------------------------------------------------------------
1 | // This is a generated file. Not intended for manual editing.
2 | package ru.hyoo.jin.tree.psi;
3 |
4 | import com.intellij.psi.tree.IElementType;
5 | import com.intellij.psi.PsiElement;
6 | import com.intellij.lang.ASTNode;
7 | import ru.hyoo.jin.tree.psi.impl.*;
8 |
9 | public interface types {
10 |
11 |
12 | IElementType INDENT = new token("INDENT");
13 | IElementType LF = new token("LF");
14 | IElementType NAME = new token("NAME");
15 | IElementType SPACE = new token("SPACE");
16 | IElementType VALUE = new token("VALUE");
17 | IElementType VALUE_PREFIX = new token("VALUE_PREFIX");
18 |
19 | class Factory {
20 | public static PsiElement createElement(ASTNode node) {
21 | IElementType type = node.getElementType();
22 | throw new AssertionError("Unknown element type: " + type);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/idea-flex.skeleton:
--------------------------------------------------------------------------------
1 | /** initial size of the lookahead buffer */
2 | --- private static final int ZZ_BUFFERSIZE = ...;
3 |
4 | /** lexical states */
5 | --- lexical states, charmap
6 |
7 | /* error codes */
8 | private static final int ZZ_UNKNOWN_ERROR = 0;
9 | private static final int ZZ_NO_MATCH = 1;
10 | private static final int ZZ_PUSHBACK_2BIG = 2;
11 | private static final char[] EMPTY_BUFFER = new char[0];
12 | private static final int YYEOF = -1;
13 | private static java.io.Reader zzReader = null; // Fake
14 |
15 | /* error messages for the codes above */
16 | private static final String ZZ_ERROR_MSG[] = {
17 | "Unkown internal scanner error",
18 | "Error: could not match input",
19 | "Error: pushback value was too large"
20 | };
21 |
22 | --- isFinal list
23 | /** the current state of the DFA */
24 | private int zzState;
25 |
26 | /** the current lexical state */
27 | private int zzLexicalState = YYINITIAL;
28 |
29 | /** this buffer contains the current text to be matched and is
30 | the source of the yytext() string */
31 | private CharSequence zzBuffer = "";
32 |
33 | /** this buffer may contains the current text array to be matched when it is cheap to acquire it */
34 | private char[] zzBufferArray;
35 |
36 | /** the textposition at the last accepting state */
37 | private int zzMarkedPos;
38 |
39 | /** the textposition at the last state to be included in yytext */
40 | private int zzPushbackPos;
41 |
42 | /** the current text position in the buffer */
43 | private int zzCurrentPos;
44 |
45 | /** startRead marks the beginning of the yytext() string in the buffer */
46 | private int zzStartRead;
47 |
48 | /** endRead marks the last character in the buffer, that has been read
49 | from input */
50 | private int zzEndRead;
51 |
52 | /**
53 | * zzAtBOL == true <=> the scanner is currently at the beginning of a line
54 | */
55 | private boolean zzAtBOL = true;
56 |
57 | /** zzAtEOF == true <=> the scanner is at the EOF */
58 | private boolean zzAtEOF;
59 |
60 | --- user class code
61 |
62 | --- constructor declaration
63 |
64 | public final int getTokenStart(){
65 | return zzStartRead;
66 | }
67 |
68 | public final int getTokenEnd(){
69 | return getTokenStart() + yylength();
70 | }
71 |
72 | public void reset(CharSequence buffer, int start, int end,int initialState){
73 | zzBuffer = buffer;
74 | zzBufferArray = com.intellij.util.text.CharArrayUtil.fromSequenceWithoutCopying(buffer);
75 | zzCurrentPos = zzMarkedPos = zzStartRead = start;
76 | zzPushbackPos = 0;
77 | zzAtEOF = false;
78 | zzAtBOL = true;
79 | zzEndRead = end;
80 | yybegin(initialState);
81 | }
82 |
83 | /**
84 | * Refills the input buffer.
85 | *
86 | * @return false
, iff there was new input.
87 | *
88 | * @exception java.io.IOException if any I/O-Error occurs
89 | */
90 | private boolean zzRefill() throws java.io.IOException {
91 | return true;
92 | }
93 |
94 |
95 | /**
96 | * Returns the current lexical state.
97 | */
98 | public final int yystate() {
99 | return zzLexicalState;
100 | }
101 |
102 |
103 | /**
104 | * Enters a new lexical state
105 | *
106 | * @param newState the new lexical state
107 | */
108 | public final void yybegin(int newState) {
109 | zzLexicalState = newState;
110 | }
111 |
112 |
113 | /**
114 | * Returns the text matched by the current regular expression.
115 | */
116 | public final CharSequence yytext() {
117 | return zzBuffer.subSequence(zzStartRead, zzMarkedPos);
118 | }
119 |
120 |
121 | /**
122 | * Returns the character at position pos from the
123 | * matched text.
124 | *
125 | * It is equivalent to yytext().charAt(pos), but faster
126 | *
127 | * @param pos the position of the character to fetch.
128 | * A value from 0 to yylength()-1.
129 | *
130 | * @return the character at position pos
131 | */
132 | public final char yycharat(int pos) {
133 | return zzBufferArray != null ? zzBufferArray[zzStartRead+pos]:zzBuffer.charAt(zzStartRead+pos);
134 | }
135 |
136 |
137 | /**
138 | * Returns the length of the matched text region.
139 | */
140 | public final int yylength() {
141 | return zzMarkedPos-zzStartRead;
142 | }
143 |
144 |
145 | /**
146 | * Reports an error that occured while scanning.
147 | *
148 | * In a wellformed scanner (no or only correct usage of
149 | * yypushback(int) and a match-all fallback rule) this method
150 | * will only be called with things that "Can't Possibly Happen".
151 | * If this method is called, something is seriously wrong
152 | * (e.g. a JFlex bug producing a faulty scanner etc.).
153 | *
154 | * Usual syntax/scanner level error handling should be done
155 | * in error fallback rules.
156 | *
157 | * @param errorCode the code of the errormessage to display
158 | */
159 | --- zzScanError declaration
160 | String message;
161 | try {
162 | message = ZZ_ERROR_MSG[errorCode];
163 | }
164 | catch (ArrayIndexOutOfBoundsException e) {
165 | message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
166 | }
167 |
168 | --- throws clause
169 | }
170 |
171 |
172 | /**
173 | * Pushes the specified amount of characters back into the input stream.
174 | *
175 | * They will be read again by then next call of the scanning method
176 | *
177 | * @param number the number of characters to be read again.
178 | * This number must not be greater than yylength()!
179 | */
180 | --- yypushback decl (contains zzScanError exception)
181 | if ( number > yylength() )
182 | zzScanError(ZZ_PUSHBACK_2BIG);
183 |
184 | zzMarkedPos -= number;
185 | }
186 |
187 |
188 | --- zzDoEOF
189 | /**
190 | * Resumes scanning until the next regular expression is matched,
191 | * the end of input is encountered or an I/O-Error occurs.
192 | *
193 | * @return the next token
194 | * @exception java.io.IOException if any I/O-Error occurs
195 | */
196 | --- yylex declaration
197 | int zzInput;
198 | int zzAction;
199 |
200 | // cached fields:
201 | int zzCurrentPosL;
202 | int zzMarkedPosL;
203 | int zzEndReadL = zzEndRead;
204 | CharSequence zzBufferL = zzBuffer;
205 | char[] zzBufferArrayL = zzBufferArray;
206 | char [] zzCMapL = ZZ_CMAP;
207 |
208 | --- local declarations
209 |
210 | while (true) {
211 | zzMarkedPosL = zzMarkedPos;
212 |
213 | --- start admin (line, char, col count)
214 | zzAction = -1;
215 |
216 | zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
217 |
218 | --- start admin (lexstate etc)
219 |
220 | zzForAction: {
221 | while (true) {
222 |
223 | --- next input, line, col, char count, next transition, isFinal action
224 | zzAction = zzState;
225 | zzMarkedPosL = zzCurrentPosL;
226 | --- line count update
227 | }
228 |
229 | }
230 | }
231 |
232 | // store back cached position
233 | zzMarkedPos = zzMarkedPosL;
234 | --- char count update
235 |
236 | --- actions
237 | default:
238 | if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
239 | zzAtEOF = true;
240 | --- eofvalue
241 | }
242 | else {
243 | --- no match
244 | }
245 | }
246 | }
247 | }
248 |
249 | --- main
250 |
251 | }
252 |
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/fileFactory.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.openapi.fileTypes.FileTypeConsumer;
4 | import com.intellij.openapi.fileTypes.FileTypeFactory;
5 | import org.jetbrains.annotations.NotNull;
6 |
7 | public class fileFactory extends FileTypeFactory {
8 | @Override
9 | public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
10 | fileTypeConsumer.consume(fileType.INSTANCE, "tree");
11 | }
12 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/fileType.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.openapi.fileTypes.LanguageFileType;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.jetbrains.annotations.Nullable;
6 | import javax.swing.*;
7 |
8 | public class fileType extends LanguageFileType {
9 | public static final fileType INSTANCE = new fileType();
10 |
11 | private fileType() {
12 | super(lang.INSTANCE);
13 | }
14 |
15 | @NotNull
16 | @Override
17 | public String getName() {
18 | return "Tree file";
19 | }
20 |
21 | @NotNull
22 | @Override
23 | public String getDescription() {
24 | return "Simple structural language";
25 | }
26 |
27 | @NotNull
28 | @Override
29 | public String getDefaultExtension() {
30 | return "tree";
31 | }
32 |
33 | @Nullable
34 | @Override
35 | public Icon getIcon() {
36 | return icon.FILE;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/hlighter.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.lexer.FlexAdapter;
4 | import com.intellij.lexer.Lexer;
5 | import com.intellij.openapi.editor.SyntaxHighlighterColors;
6 | import com.intellij.openapi.editor.colors.TextAttributesKey;
7 | import com.intellij.openapi.editor.markup.TextAttributes;
8 | import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
9 | import com.intellij.psi.TokenType;
10 | import com.intellij.psi.tree.IElementType;
11 | import ru.hyoo.jin.tree.psi.types;
12 | import org.jetbrains.annotations.NotNull;
13 | import java.awt.*;
14 | import java.io.Reader;
15 |
16 | import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
17 |
18 | public class hlighter extends SyntaxHighlighterBase {
19 | public static final TextAttributesKey VALUE_PREFIX = createTextAttributesKey("VALUE_PREFIX", SyntaxHighlighterColors.OPERATION_SIGN);
20 | private static final TextAttributesKey[] VALUE_PREFIXES = new TextAttributesKey[]{VALUE_PREFIX};
21 |
22 | public static final TextAttributesKey NAME = createTextAttributesKey("NAME", SyntaxHighlighterColors.KEYWORD);
23 | private static final TextAttributesKey[] NAMES = new TextAttributesKey[]{NAME};
24 |
25 | public static final TextAttributesKey VALUE = createTextAttributesKey("VALUE", SyntaxHighlighterColors.STRING);
26 | private static final TextAttributesKey[] VALUES = new TextAttributesKey[]{VALUE};
27 |
28 | static final TextAttributesKey BAD_CHARACTER = createTextAttributesKey("BAD_CHARACTER", new TextAttributes(Color.RED, null, null, null, Font.BOLD));
29 | private static final TextAttributesKey[] BAD_CHARARACTERS = new TextAttributesKey[]{BAD_CHARACTER};
30 |
31 | private static final TextAttributesKey[] EMPTIES = new TextAttributesKey[0];
32 |
33 | @NotNull
34 | @Override
35 | public Lexer getHighlightingLexer() {
36 | return new FlexAdapter(new lexer((Reader) null));
37 | }
38 |
39 | @NotNull
40 | @Override
41 | public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
42 | if (tokenType.equals(types.VALUE_PREFIX)) {
43 | return VALUE_PREFIXES;
44 | } else if (tokenType.equals(types.NAME)) {
45 | return NAMES;
46 | } else if (tokenType.equals(types.VALUE)) {
47 | return VALUES;
48 | } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
49 | return BAD_CHARARACTERS;
50 | } else {
51 | return EMPTIES;
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/hlighterFactory.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.openapi.fileTypes.SyntaxHighlighter;
4 | import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
5 | import com.intellij.openapi.project.Project;
6 | import com.intellij.openapi.vfs.VirtualFile;
7 | import org.jetbrains.annotations.NotNull;
8 |
9 | public class hlighterFactory extends SyntaxHighlighterFactory {
10 | @NotNull
11 | @Override
12 | public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) {
13 | return new hlighter();
14 | }
15 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/icon.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.openapi.util.IconLoader;
4 | import javax.swing.*;
5 |
6 | public class icon {
7 | public static final Icon FILE = IconLoader.getIcon("/ru/hyoo/jin/tree/icon.png");
8 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nin-jin/tree-plugin/e3dd29f3441497885fe503e9e681b5485fe8a2c6/src/ru/hyoo/jin/tree/icon.png
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/lang.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.lang.Language;
4 |
5 | public class lang extends Language {
6 | public static final lang INSTANCE = new lang();
7 |
8 | private lang() {
9 | super("Tree");
10 | }
11 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/lexer.java:
--------------------------------------------------------------------------------
1 | /* The following code was generated by JFlex 1.7.0-SNAPSHOT tweaked for IntelliJ platform */
2 |
3 | package ru.hyoo.jin.tree;
4 |
5 | import com.intellij.lexer.FlexLexer;
6 | import com.intellij.psi.tree.IElementType;
7 | import ru.hyoo.jin.tree.psi.types;
8 | import com.intellij.psi.TokenType;
9 |
10 |
11 | /**
12 | * This class is a scanner generated by
13 | * JFlex 1.7.0-SNAPSHOT
14 | * from the specification file tree.flex
15 | */
16 | class lexer implements FlexLexer {
17 |
18 | /** This character denotes the end of file */
19 | public static final int YYEOF = -1;
20 |
21 | /** initial size of the lookahead buffer */
22 | private static final int ZZ_BUFFERSIZE = 16384;
23 |
24 | /** lexical states */
25 | public static final int YYINITIAL = 0;
26 | public static final int STREAMING = 2;
27 |
28 | /**
29 | * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
30 | * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
31 | * at the beginning of a line
32 | * l is of the form l = 2*k, k a non negative integer
33 | */
34 | private static final int ZZ_LEXSTATE[] = {
35 | 0, 0, 1, 1
36 | };
37 |
38 | /**
39 | * Translates characters to character classes
40 | * Chosen bits are [8, 6, 7]
41 | * Total runtime size is 1040 bytes
42 | */
43 | public static int ZZ_CMAP(int ch) {
44 | return ZZ_CMAP_A[ZZ_CMAP_Y[ZZ_CMAP_Z[ch>>13]|((ch>>7)&0x3f)]|(ch&0x7f)];
45 | }
46 |
47 | /* The ZZ_CMAP_Z table has 136 entries */
48 | static final char ZZ_CMAP_Z[] = zzUnpackCMap(
49 | "\1\0\207\100");
50 |
51 | /* The ZZ_CMAP_Y table has 128 entries */
52 | static final char ZZ_CMAP_Y[] = zzUnpackCMap(
53 | "\1\0\177\200");
54 |
55 | /* The ZZ_CMAP_A table has 256 entries */
56 | static final char ZZ_CMAP_A[] = zzUnpackCMap(
57 | "\11\0\1\2\1\1\2\0\1\5\22\0\1\4\73\0\1\3\243\0");
58 |
59 | /**
60 | * Translates DFA states to action switch labels.
61 | */
62 | private static final int [] ZZ_ACTION = zzUnpackAction();
63 |
64 | private static final String ZZ_ACTION_PACKED_0 =
65 | "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\1";
66 |
67 | private static int [] zzUnpackAction() {
68 | int [] result = new int[8];
69 | int offset = 0;
70 | offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
71 | return result;
72 | }
73 |
74 | private static int zzUnpackAction(String packed, int offset, int [] result) {
75 | int i = 0; /* index in packed string */
76 | int j = offset; /* index in unpacked array */
77 | int l = packed.length();
78 | while (i < l) {
79 | int count = packed.charAt(i++);
80 | int value = packed.charAt(i++);
81 | do result[j++] = value; while (--count > 0);
82 | }
83 | return j;
84 | }
85 |
86 |
87 | /**
88 | * Translates a state to a row index in the transition table
89 | */
90 | private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
91 |
92 | private static final String ZZ_ROWMAP_PACKED_0 =
93 | "\0\0\0\6\0\14\0\22\0\22\0\22\0\30\0\36";
94 |
95 | private static int [] zzUnpackRowMap() {
96 | int [] result = new int[8];
97 | int offset = 0;
98 | offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
99 | return result;
100 | }
101 |
102 | private static int zzUnpackRowMap(String packed, int offset, int [] result) {
103 | int i = 0; /* index in packed string */
104 | int j = offset; /* index in unpacked array */
105 | int l = packed.length();
106 | while (i < l) {
107 | int high = packed.charAt(i++) << 16;
108 | result[j++] = high | packed.charAt(i++);
109 | }
110 | return j;
111 | }
112 |
113 | /**
114 | * The transition table of the DFA
115 | */
116 | private static final int [] ZZ_TRANS = zzUnpackTrans();
117 |
118 | private static final String ZZ_TRANS_PACKED_0 =
119 | "\1\3\1\4\1\5\1\6\1\7\1\0\1\10\1\4"+
120 | "\4\10\1\3\17\0\1\7\1\0\1\10\1\0\4\10";
121 |
122 | private static int [] zzUnpackTrans() {
123 | int [] result = new int[36];
124 | int offset = 0;
125 | offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
126 | return result;
127 | }
128 |
129 | private static int zzUnpackTrans(String packed, int offset, int [] result) {
130 | int i = 0; /* index in packed string */
131 | int j = offset; /* index in unpacked array */
132 | int l = packed.length();
133 | while (i < l) {
134 | int count = packed.charAt(i++);
135 | int value = packed.charAt(i++);
136 | value--;
137 | do result[j++] = value; while (--count > 0);
138 | }
139 | return j;
140 | }
141 |
142 |
143 | /* error codes */
144 | private static final int ZZ_UNKNOWN_ERROR = 0;
145 | private static final int ZZ_NO_MATCH = 1;
146 | private static final int ZZ_PUSHBACK_2BIG = 2;
147 |
148 | /* error messages for the codes above */
149 | private static final String[] ZZ_ERROR_MSG = {
150 | "Unknown internal scanner error",
151 | "Error: could not match input",
152 | "Error: pushback value was too large"
153 | };
154 |
155 | /**
156 | * ZZ_ATTRIBUTE[aState] contains the attributes of state aState
157 | */
158 | private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
159 |
160 | private static final String ZZ_ATTRIBUTE_PACKED_0 =
161 | "\1\0\2\1\3\11\2\1";
162 |
163 | private static int [] zzUnpackAttribute() {
164 | int [] result = new int[8];
165 | int offset = 0;
166 | offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
167 | return result;
168 | }
169 |
170 | private static int zzUnpackAttribute(String packed, int offset, int [] result) {
171 | int i = 0; /* index in packed string */
172 | int j = offset; /* index in unpacked array */
173 | int l = packed.length();
174 | while (i < l) {
175 | int count = packed.charAt(i++);
176 | int value = packed.charAt(i++);
177 | do result[j++] = value; while (--count > 0);
178 | }
179 | return j;
180 | }
181 |
182 | /** the input device */
183 | private java.io.Reader zzReader;
184 |
185 | /** the current state of the DFA */
186 | private int zzState;
187 |
188 | /** the current lexical state */
189 | private int zzLexicalState = YYINITIAL;
190 |
191 | /** this buffer contains the current text to be matched and is
192 | the source of the yytext() string */
193 | private CharSequence zzBuffer = "";
194 |
195 | /** the textposition at the last accepting state */
196 | private int zzMarkedPos;
197 |
198 | /** the current text position in the buffer */
199 | private int zzCurrentPos;
200 |
201 | /** startRead marks the beginning of the yytext() string in the buffer */
202 | private int zzStartRead;
203 |
204 | /** endRead marks the last character in the buffer, that has been read
205 | from input */
206 | private int zzEndRead;
207 |
208 | /**
209 | * zzAtBOL == true <=> the scanner is currently at the beginning of a line
210 | */
211 | private boolean zzAtBOL = true;
212 |
213 | /** zzAtEOF == true <=> the scanner is at the EOF */
214 | private boolean zzAtEOF;
215 |
216 | /** denotes if the user-EOF-code has already been executed */
217 | private boolean zzEOFDone;
218 |
219 |
220 | /**
221 | * Creates a new scanner
222 | *
223 | * @param in the java.io.Reader to read input from.
224 | */
225 | lexer(java.io.Reader in) {
226 | this.zzReader = in;
227 | }
228 |
229 |
230 | /**
231 | * Unpacks the compressed character translation table.
232 | *
233 | * @param packed the packed character translation table
234 | * @return the unpacked character translation table
235 | */
236 | private static char [] zzUnpackCMap(String packed) {
237 | int size = 0;
238 | for (int i = 0, length = packed.length(); i < length; i += 2) {
239 | size += packed.charAt(i);
240 | }
241 | char[] map = new char[size];
242 | int i = 0; /* index in packed string */
243 | int j = 0; /* index in unpacked array */
244 | while (i < packed.length()) {
245 | int count = packed.charAt(i++);
246 | char value = packed.charAt(i++);
247 | do map[j++] = value; while (--count > 0);
248 | }
249 | return map;
250 | }
251 |
252 | public final int getTokenStart() {
253 | return zzStartRead;
254 | }
255 |
256 | public final int getTokenEnd() {
257 | return getTokenStart() + yylength();
258 | }
259 |
260 | public void reset(CharSequence buffer, int start, int end, int initialState) {
261 | zzBuffer = buffer;
262 | zzCurrentPos = zzMarkedPos = zzStartRead = start;
263 | zzAtEOF = false;
264 | zzAtBOL = true;
265 | zzEndRead = end;
266 | yybegin(initialState);
267 | }
268 |
269 | /**
270 | * Refills the input buffer.
271 | *
272 | * @return false
, iff there was new input.
273 | *
274 | * @exception java.io.IOException if any I/O-Error occurs
275 | */
276 | private boolean zzRefill() throws java.io.IOException {
277 | return true;
278 | }
279 |
280 |
281 | /**
282 | * Returns the current lexical state.
283 | */
284 | public final int yystate() {
285 | return zzLexicalState;
286 | }
287 |
288 |
289 | /**
290 | * Enters a new lexical state
291 | *
292 | * @param newState the new lexical state
293 | */
294 | public final void yybegin(int newState) {
295 | zzLexicalState = newState;
296 | }
297 |
298 |
299 | /**
300 | * Returns the text matched by the current regular expression.
301 | */
302 | public final CharSequence yytext() {
303 | return zzBuffer.subSequence(zzStartRead, zzMarkedPos);
304 | }
305 |
306 |
307 | /**
308 | * Returns the character at position pos from the
309 | * matched text.
310 | *
311 | * It is equivalent to yytext().charAt(pos), but faster
312 | *
313 | * @param pos the position of the character to fetch.
314 | * A value from 0 to yylength()-1.
315 | *
316 | * @return the character at position pos
317 | */
318 | public final char yycharat(int pos) {
319 | return zzBuffer.charAt(zzStartRead+pos);
320 | }
321 |
322 |
323 | /**
324 | * Returns the length of the matched text region.
325 | */
326 | public final int yylength() {
327 | return zzMarkedPos-zzStartRead;
328 | }
329 |
330 |
331 | /**
332 | * Reports an error that occured while scanning.
333 | *
334 | * In a wellformed scanner (no or only correct usage of
335 | * yypushback(int) and a match-all fallback rule) this method
336 | * will only be called with things that "Can't Possibly Happen".
337 | * If this method is called, something is seriously wrong
338 | * (e.g. a JFlex bug producing a faulty scanner etc.).
339 | *
340 | * Usual syntax/scanner level error handling should be done
341 | * in error fallback rules.
342 | *
343 | * @param errorCode the code of the errormessage to display
344 | */
345 | private void zzScanError(int errorCode) {
346 | String message;
347 | try {
348 | message = ZZ_ERROR_MSG[errorCode];
349 | }
350 | catch (ArrayIndexOutOfBoundsException e) {
351 | message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
352 | }
353 |
354 | throw new Error(message);
355 | }
356 |
357 |
358 | /**
359 | * Pushes the specified amount of characters back into the input stream.
360 | *
361 | * They will be read again by then next call of the scanning method
362 | *
363 | * @param number the number of characters to be read again.
364 | * This number must not be greater than yylength()!
365 | */
366 | public void yypushback(int number) {
367 | if ( number > yylength() )
368 | zzScanError(ZZ_PUSHBACK_2BIG);
369 |
370 | zzMarkedPos -= number;
371 | }
372 |
373 |
374 | /**
375 | * Contains user EOF-code, which will be executed exactly once,
376 | * when the end of file is reached
377 | */
378 | private void zzDoEOF() {
379 | if (!zzEOFDone) {
380 | zzEOFDone = true;
381 | return;
382 |
383 | }
384 | }
385 |
386 |
387 | /**
388 | * Resumes scanning until the next regular expression is matched,
389 | * the end of input is encountered or an I/O-Error occurs.
390 | *
391 | * @return the next token
392 | * @exception java.io.IOException if any I/O-Error occurs
393 | */
394 | public IElementType advance() throws java.io.IOException {
395 | int zzInput;
396 | int zzAction;
397 |
398 | // cached fields:
399 | int zzCurrentPosL;
400 | int zzMarkedPosL;
401 | int zzEndReadL = zzEndRead;
402 | CharSequence zzBufferL = zzBuffer;
403 |
404 | int [] zzTransL = ZZ_TRANS;
405 | int [] zzRowMapL = ZZ_ROWMAP;
406 | int [] zzAttrL = ZZ_ATTRIBUTE;
407 |
408 | while (true) {
409 | zzMarkedPosL = zzMarkedPos;
410 |
411 | zzAction = -1;
412 |
413 | zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
414 |
415 | zzState = ZZ_LEXSTATE[zzLexicalState];
416 |
417 | // set up zzAction for empty match case:
418 | int zzAttributes = zzAttrL[zzState];
419 | if ( (zzAttributes & 1) == 1 ) {
420 | zzAction = zzState;
421 | }
422 |
423 |
424 | zzForAction: {
425 | while (true) {
426 |
427 | if (zzCurrentPosL < zzEndReadL) {
428 | zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/);
429 | zzCurrentPosL += Character.charCount(zzInput);
430 | }
431 | else if (zzAtEOF) {
432 | zzInput = YYEOF;
433 | break zzForAction;
434 | }
435 | else {
436 | // store back cached positions
437 | zzCurrentPos = zzCurrentPosL;
438 | zzMarkedPos = zzMarkedPosL;
439 | boolean eof = zzRefill();
440 | // get translated positions and possibly new buffer
441 | zzCurrentPosL = zzCurrentPos;
442 | zzMarkedPosL = zzMarkedPos;
443 | zzBufferL = zzBuffer;
444 | zzEndReadL = zzEndRead;
445 | if (eof) {
446 | zzInput = YYEOF;
447 | break zzForAction;
448 | }
449 | else {
450 | zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/);
451 | zzCurrentPosL += Character.charCount(zzInput);
452 | }
453 | }
454 | int zzNext = zzTransL[ zzRowMapL[zzState] + ZZ_CMAP(zzInput) ];
455 | if (zzNext == -1) break zzForAction;
456 | zzState = zzNext;
457 |
458 | zzAttributes = zzAttrL[zzState];
459 | if ( (zzAttributes & 1) == 1 ) {
460 | zzAction = zzState;
461 | zzMarkedPosL = zzCurrentPosL;
462 | if ( (zzAttributes & 8) == 8 ) break zzForAction;
463 | }
464 |
465 | }
466 | }
467 |
468 | // store back cached position
469 | zzMarkedPos = zzMarkedPosL;
470 |
471 | if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
472 | zzAtEOF = true;
473 | zzDoEOF();
474 | return null;
475 | }
476 | else {
477 | switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
478 | case 1:
479 | { yybegin(YYINITIAL); return types.VALUE;
480 | }
481 | case 7: break;
482 | case 2:
483 | { yybegin(YYINITIAL); return types.NAME;
484 | }
485 | case 8: break;
486 | case 3:
487 | { yybegin(YYINITIAL); return types.LF;
488 | }
489 | case 9: break;
490 | case 4:
491 | { return TokenType.BAD_CHARACTER;
492 | }
493 | case 10: break;
494 | case 5:
495 | { yybegin(STREAMING); return types.VALUE_PREFIX;
496 | }
497 | case 11: break;
498 | case 6:
499 | { yybegin(YYINITIAL); return TokenType.WHITE_SPACE;
500 | }
501 | case 12: break;
502 | default:
503 | zzScanError(ZZ_NO_MATCH);
504 | }
505 | }
506 | }
507 | }
508 |
509 |
510 | }
511 |
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/lexerAdapter.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.lexer.FlexAdapter;
4 | import java.io.Reader;
5 |
6 | public class lexerAdapter extends FlexAdapter {
7 | public lexerAdapter() {
8 | super(new lexer((Reader) null));
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/parserDefinition.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.lang.ASTNode;
4 | import com.intellij.lang.Language;
5 | import com.intellij.lang.ParserDefinition;
6 | import com.intellij.lang.PsiParser;
7 | import com.intellij.lexer.FlexAdapter;
8 | import com.intellij.lexer.Lexer;
9 | import com.intellij.openapi.project.Project;
10 | import com.intellij.psi.FileViewProvider;
11 | import com.intellij.psi.PsiElement;
12 | import com.intellij.psi.PsiFile;
13 | import com.intellij.psi.TokenType;
14 | import com.intellij.psi.tree.IFileElementType;
15 | import com.intellij.psi.tree.TokenSet;
16 | import ru.hyoo.jin.tree.psi.impl.file;
17 | import ru.hyoo.jin.tree.psi.types;
18 | import org.jetbrains.annotations.NotNull;
19 |
20 | import java.io.Reader;
21 |
22 | public class parserDefinition implements ParserDefinition{
23 | public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
24 | public static final TokenSet COMMENTS = TokenSet.create(TokenType.DUMMY_HOLDER);
25 |
26 | public static final IFileElementType FILE = new IFileElementType(Language.findInstance(lang.class));
27 |
28 | @NotNull
29 | @Override
30 | public Lexer createLexer(Project project) {
31 | return new FlexAdapter(new lexer((Reader) null));
32 | }
33 |
34 | @NotNull
35 | public TokenSet getWhitespaceTokens() {
36 | return WHITE_SPACES;
37 | }
38 |
39 | @NotNull
40 | public TokenSet getCommentTokens() {
41 | return COMMENTS;
42 | }
43 |
44 | @NotNull
45 | public TokenSet getStringLiteralElements() {
46 | return TokenSet.EMPTY;
47 | }
48 |
49 | @NotNull
50 | public PsiParser createParser(final Project project) {
51 | return new parser();
52 | }
53 |
54 | @Override
55 | public IFileElementType getFileNodeType() {
56 | return FILE;
57 | }
58 |
59 | public PsiFile createFile(FileViewProvider viewProvider) {
60 | return new file(viewProvider);
61 | }
62 |
63 | public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
64 | return SpaceRequirements.MAY;
65 | }
66 |
67 | @NotNull
68 | public PsiElement createElement(ASTNode node) {
69 | return types.Factory.createElement(node);
70 | }
71 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/psi/impl/element.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree.psi.impl;
2 |
3 | import com.intellij.psi.tree.IElementType;
4 | import ru.hyoo.jin.tree.lang;
5 | import org.jetbrains.annotations.NonNls;
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | public class element extends IElementType {
9 | public element(@NotNull @NonNls String debugName) {
10 | super(debugName, lang.INSTANCE);
11 | }
12 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/psi/impl/file.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree.psi.impl;
2 |
3 | import com.intellij.extapi.psi.PsiFileBase;
4 | import com.intellij.openapi.fileTypes.FileType;
5 | import com.intellij.psi.FileViewProvider;
6 | import ru.hyoo.jin.tree.fileType;
7 | import ru.hyoo.jin.tree.lang;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import javax.swing.*;
11 |
12 | public class file extends PsiFileBase {
13 | public file(@NotNull FileViewProvider viewProvider) {
14 | super(viewProvider, lang.INSTANCE);
15 | }
16 |
17 | @NotNull
18 | @Override
19 | public FileType getFileType() {
20 | return fileType.INSTANCE;
21 | }
22 |
23 | @Override
24 | public String toString() {
25 | return "Tree File";
26 | }
27 |
28 | @Override
29 | public Icon getIcon(int flags) {
30 | return super.getIcon(flags);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/psi/impl/token.java:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree.psi.impl;
2 |
3 | import com.intellij.psi.tree.IElementType;
4 | import ru.hyoo.jin.tree.lang;
5 | import org.jetbrains.annotations.NonNls;
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | public class token extends IElementType {
9 | public token(@NotNull @NonNls String debugName) {
10 | super(debugName, lang.INSTANCE);
11 | }
12 |
13 | @Override
14 | public String toString() {
15 | return "token." + super.toString();
16 | }
17 | }
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/sample.tree:
--------------------------------------------------------------------------------
1 | html
2 | @ xml:lang \ru
3 | head
4 | title \Рога & Копыта
5 | body
6 | h1 \Привет!
7 | p \Хочешь, я расскажу тебе сказку?
8 |
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/tree.bnf:
--------------------------------------------------------------------------------
1 | {
2 | parserClass="ru.hyoo.jin.tree.parser"
3 |
4 | extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
5 |
6 | psiClassPrefix=""
7 | psiImplClassSuffix=""
8 | psiPackage="ru.hyoo.jin.tree.psi"
9 | psiImplPackage="ru.hyoo.jin.tree.psi.impl"
10 |
11 | elementTypeHolderClass="ru.hyoo.jin.tree.psi.types"
12 | elementTypeClass="ru.hyoo.jin.tree.psi.element"
13 | tokenTypeClass="ru.hyoo.jin.tree.psi.impl.token"
14 | }
15 |
16 | FILE ::= ( NODES LF )* NODES?
17 | private NODES ::= INDENT* ( NAME SPACE* )* ( VALUE_PREFIX VALUE? )?
--------------------------------------------------------------------------------
/src/ru/hyoo/jin/tree/tree.flex:
--------------------------------------------------------------------------------
1 | package ru.hyoo.jin.tree;
2 |
3 | import com.intellij.lexer.FlexLexer;
4 | import com.intellij.psi.tree.IElementType;
5 | import ru.hyoo.jin.tree.psi.types;
6 | import com.intellij.psi.TokenType;
7 |
8 | %%
9 |
10 | %class lexer
11 | %implements FlexLexer
12 | %unicode
13 | %function advance
14 | %type IElementType
15 | %eof{
16 | return;
17 | %eof}
18 |
19 | LF= [\n]
20 | INDENT= [\t]
21 | VALUE_PREFIX= [\\]
22 | SPACE= [ ]
23 | NAME= [^\\ \n\r\t]
24 | VALUE= [^\n]
25 |
26 | %state STREAMING
27 |
28 | %%
29 |
30 | {NAME}+ { yybegin(YYINITIAL); return types.NAME; }
31 |
32 | {VALUE_PREFIX} { yybegin(STREAMING); return types.VALUE_PREFIX; }
33 |
34 | {LF} { yybegin(YYINITIAL); return types.LF; }
35 |
36 | {VALUE}* { yybegin(YYINITIAL); return types.VALUE; }
37 |
38 | {LF} { yybegin(YYINITIAL); return types.LF; }
39 |
40 | {SPACE}+ { yybegin(YYINITIAL); return TokenType.WHITE_SPACE; }
41 |
42 | . { return TokenType.BAD_CHARACTER; }
--------------------------------------------------------------------------------
/tree-plugin.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------