1 package org.vaadin.aceeditor;
2
3 import java.util.HashMap;
4
5
6
7
8
9 public enum AceMode {
10 abap,
11 actionscript,
12 ada,
13 apache_conf,
14 asciidoc,
15 assembly_x86,
16 autohotkey,
17 batchfile,
18 c9search,
19 clojure,
20 cobol,
21 coffee,
22 coldfusion,
23 csharp,
24 css,
25 curly,
26 c_cpp,
27 d,
28 dart,
29 diff,
30 django,
31 dot,
32 ejs,
33 erlang,
34 forth,
35 ftl,
36 glsl,
37 golang,
38 groovy,
39 haml,
40 handlebars,
41 haskell,
42 haxe,
43 html,
44 html_completions,
45 html_ruby,
46 ini,
47 jack,
48 jade,
49 java,
50 javascript,
51 json,
52 jsoniq,
53 jsp,
54 jsx,
55 julia,
56 latex,
57 less,
58 liquid,
59 lisp,
60 livescript,
61 logiql,
62 lsl,
63 lua,
64 luapage,
65 lucene,
66 makefile,
67 markdown,
68 matlab,
69 mel,
70 mushcode,
71 mushcode_high_rules,
72 mysql,
73 nix,
74 objectivec,
75 ocaml,
76 pascal,
77 perl,
78 pgsql,
79 php,
80 plain_text,
81 powershell,
82 prolog,
83 properties,
84 protobuf,
85 python,
86 r,
87 rdoc,
88 rhtml,
89 ruby,
90 rust,
91 sass,
92 scad,
93 scala,
94 scheme,
95 scss,
96 sh,
97 sjs,
98 snippets,
99 soy_template,
100 space,
101 sql,
102 stylus,
103 svg,
104 tcl,
105 tex,
106 text,
107 textile,
108 toml,
109 twig,
110 typescript,
111 vbscript,
112 velocity,
113 verilog,
114 vhdl,
115 xml,
116 xquery,
117 yaml;
118
119 public static AceMode forFile(String filename) {
120 int lastDot = filename.lastIndexOf(".");
121 if (lastDot == -1) {
122 return text;
123 }
124 return forFileEnding(filename.substring(lastDot + 1).toLowerCase());
125 }
126
127 private static HashMap<String, AceMode> endingModeMap = new HashMap<String, AceMode>();
128 static {
129 endingModeMap.put("js", javascript);
130 endingModeMap.put("json", json);
131 endingModeMap.put("c", c_cpp);
132 endingModeMap.put("cpp", c_cpp);
133 endingModeMap.put("cc", c_cpp);
134 endingModeMap.put("h", c_cpp);
135 endingModeMap.put("hpp", c_cpp);
136 endingModeMap.put("hh", c_cpp);
137 endingModeMap.put("java", java);
138 endingModeMap.put("py", python);
139 endingModeMap.put("tex", latex);
140 endingModeMap.put("css", css);
141
142 }
143
144
145
146
147
148 public static AceMode forFileEnding(String ending) {
149 AceMode mode = endingModeMap.get(ending);
150 return mode!=null ? mode : text;
151 }
152
153 }