";
75 | }
76 | }
77 | }
78 |
79 | @Override
80 | @Deprecated
81 | public String[] getTokenNames() {
82 | return tokenNames;
83 | }
84 |
85 | @Override
86 | public Vocabulary getVocabulary() {
87 | return VOCABULARY;
88 | }
89 |
90 | public EditorConfigLexer(CharStream input) {
91 | super(input);
92 | _interp = new LexerATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
93 | }
94 |
95 | @Override
96 | public String getGrammarFileName() {
97 | return "EditorConfigLexer.g4";
98 | }
99 |
100 | @Override
101 | public String[] getRuleNames() {
102 | return ruleNames;
103 | }
104 |
105 | @Override
106 | public String getSerializedATN() {
107 | return _serializedATN;
108 | }
109 |
110 | @Override
111 | public String[] getModeNames() {
112 | return modeNames;
113 | }
114 |
115 | @Override
116 | public ATN getATN() {
117 | return _ATN;
118 | }
119 |
120 | public static final String _serializedATN
121 | = "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2\24\u00e6\b\1\b\1"
122 | + "\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4"
123 | + "\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t"
124 | + "\21\4\22\t\22\4\23\t\23\4\24\t\24\4\25\t\25\3\2\3\2\3\2\3\2\3\2\3\3\3"
125 | + "\3\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4"
126 | + "\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3"
127 | + "\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7"
128 | + "\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3"
129 | + "\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t"
130 | + "\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3"
131 | + "\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\f\3"
132 | + "\r\3\r\3\16\3\16\3\16\3\16\3\17\6\17\u00b5\n\17\r\17\16\17\u00b6\3\17"
133 | + "\3\17\3\20\3\20\7\20\u00bd\n\20\f\20\16\20\u00c0\13\20\3\20\3\20\3\21"
134 | + "\6\21\u00c5\n\21\r\21\16\21\u00c6\3\22\3\22\3\22\7\22\u00cc\n\22\f\22"
135 | + "\16\22\u00cf\13\22\3\22\6\22\u00d2\n\22\r\22\16\22\u00d3\3\22\3\22\3\23"
136 | + "\3\23\3\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25"
137 | + "\3\u00cd\2\26\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33"
138 | + "\17\35\20\37\3!\21#\22%\23\'\2)\2+\24\5\2\3\4\7\5\2\13\f\17\17\"\"\4\2"
139 | + "%%==\4\2\f\f\17\17\n\2\13\f\17\17\"\"%%==??]]__\6\2\f\f\17\17%%]_\u00e9"
140 | + "\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2"
141 | + "\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2"
142 | + "\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\3%\3\2\2"
143 | + "\2\3\'\3\2\2\2\4)\3\2\2\2\4+\3\2\2\2\5-\3\2\2\2\7\62\3\2\2\2\t:\3\2\2"
144 | + "\2\13F\3\2\2\2\rR\3\2\2\2\17_\3\2\2\2\21t\3\2\2\2\23\u0084\3\2\2\2\25"
145 | + "\u008e\3\2\2\2\27\u00a7\3\2\2\2\31\u00a9\3\2\2\2\33\u00ad\3\2\2\2\35\u00af"
146 | + "\3\2\2\2\37\u00b4\3\2\2\2!\u00ba\3\2\2\2#\u00c4\3\2\2\2%\u00d1\3\2\2\2"
147 | + "\'\u00d7\3\2\2\2)\u00dd\3\2\2\2+\u00e2\3\2\2\2-.\7t\2\2./\7q\2\2/\60\7"
148 | + "q\2\2\60\61\7v\2\2\61\6\3\2\2\2\62\63\7e\2\2\63\64\7j\2\2\64\65\7c\2\2"
149 | + "\65\66\7t\2\2\66\67\7u\2\2\678\7g\2\289\7v\2\29\b\3\2\2\2:;\7g\2\2;<\7"
150 | + "p\2\2<=\7f\2\2=>\7a\2\2>?\7q\2\2?@\7h\2\2@A\7a\2\2AB\7n\2\2BC\7k\2\2C"
151 | + "D\7p\2\2DE\7g\2\2E\n\3\2\2\2FG\7k\2\2GH\7p\2\2HI\7f\2\2IJ\7g\2\2JK\7p"
152 | + "\2\2KL\7v\2\2LM\7a\2\2MN\7u\2\2NO\7k\2\2OP\7|\2\2PQ\7g\2\2Q\f\3\2\2\2"
153 | + "RS\7k\2\2ST\7p\2\2TU\7f\2\2UV\7g\2\2VW\7p\2\2WX\7v\2\2XY\7a\2\2YZ\7u\2"
154 | + "\2Z[\7v\2\2[\\\7{\2\2\\]\7n\2\2]^\7g\2\2^\16\3\2\2\2_`\7k\2\2`a\7p\2\2"
155 | + "ab\7u\2\2bc\7g\2\2cd\7t\2\2de\7v\2\2ef\7a\2\2fg\7h\2\2gh\7k\2\2hi\7p\2"
156 | + "\2ij\7c\2\2jk\7n\2\2kl\7a\2\2lm\7p\2\2mn\7g\2\2no\7y\2\2op\7n\2\2pq\7"
157 | + "k\2\2qr\7p\2\2rs\7g\2\2s\20\3\2\2\2tu\7o\2\2uv\7c\2\2vw\7z\2\2wx\7a\2"
158 | + "\2xy\7n\2\2yz\7k\2\2z{\7p\2\2{|\7g\2\2|}\7a\2\2}~\7n\2\2~\177\7g\2\2\177"
159 | + "\u0080\7p\2\2\u0080\u0081\7i\2\2\u0081\u0082\7v\2\2\u0082\u0083\7j\2\2"
160 | + "\u0083\22\3\2\2\2\u0084\u0085\7v\2\2\u0085\u0086\7c\2\2\u0086\u0087\7"
161 | + "d\2\2\u0087\u0088\7a\2\2\u0088\u0089\7y\2\2\u0089\u008a\7k\2\2\u008a\u008b"
162 | + "\7f\2\2\u008b\u008c\7v\2\2\u008c\u008d\7j\2\2\u008d\24\3\2\2\2\u008e\u008f"
163 | + "\7v\2\2\u008f\u0090\7t\2\2\u0090\u0091\7k\2\2\u0091\u0092\7o\2\2\u0092"
164 | + "\u0093\7a\2\2\u0093\u0094\7v\2\2\u0094\u0095\7t\2\2\u0095\u0096\7c\2\2"
165 | + "\u0096\u0097\7k\2\2\u0097\u0098\7n\2\2\u0098\u0099\7k\2\2\u0099\u009a"
166 | + "\7p\2\2\u009a\u009b\7i\2\2\u009b\u009c\7a\2\2\u009c\u009d\7y\2\2\u009d"
167 | + "\u009e\7j\2\2\u009e\u009f\7k\2\2\u009f\u00a0\7v\2\2\u00a0\u00a1\7g\2\2"
168 | + "\u00a1\u00a2\7u\2\2\u00a2\u00a3\7r\2\2\u00a3\u00a4\7c\2\2\u00a4\u00a5"
169 | + "\7e\2\2\u00a5\u00a6\7g\2\2\u00a6\26\3\2\2\2\u00a7\u00a8\5#\21\2\u00a8"
170 | + "\30\3\2\2\2\u00a9\u00aa\7]\2\2\u00aa\u00ab\3\2\2\2\u00ab\u00ac\b\f\2\2"
171 | + "\u00ac\32\3\2\2\2\u00ad\u00ae\7_\2\2\u00ae\34\3\2\2\2\u00af\u00b0\7?\2"
172 | + "\2\u00b0\u00b1\3\2\2\2\u00b1\u00b2\b\16\3\2\u00b2\36\3\2\2\2\u00b3\u00b5"
173 | + "\t\2\2\2\u00b4\u00b3\3\2\2\2\u00b5\u00b6\3\2\2\2\u00b6\u00b4\3\2\2\2\u00b6"
174 | + "\u00b7\3\2\2\2\u00b7\u00b8\3\2\2\2\u00b8\u00b9\b\17\4\2\u00b9 \3\2\2\2"
175 | + "\u00ba\u00be\t\3\2\2\u00bb\u00bd\n\4\2\2\u00bc\u00bb\3\2\2\2\u00bd\u00c0"
176 | + "\3\2\2\2\u00be\u00bc\3\2\2\2\u00be\u00bf\3\2\2\2\u00bf\u00c1\3\2\2\2\u00c0"
177 | + "\u00be\3\2\2\2\u00c1\u00c2\b\20\4\2\u00c2\"\3\2\2\2\u00c3\u00c5\n\5\2"
178 | + "\2\u00c4\u00c3\3\2\2\2\u00c5\u00c6\3\2\2\2\u00c6\u00c4\3\2\2\2\u00c6\u00c7"
179 | + "\3\2\2\2\u00c7$\3\2\2\2\u00c8\u00d2\n\6\2\2\u00c9\u00cd\7]\2\2\u00ca\u00cc"
180 | + "\13\2\2\2\u00cb\u00ca\3\2\2\2\u00cc\u00cf\3\2\2\2\u00cd\u00ce\3\2\2\2"
181 | + "\u00cd\u00cb\3\2\2\2\u00ce\u00d0\3\2\2\2\u00cf\u00cd\3\2\2\2\u00d0\u00d2"
182 | + "\7_\2\2\u00d1\u00c8\3\2\2\2\u00d1\u00c9\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3"
183 | + "\u00d1\3\2\2\2\u00d3\u00d4\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\u00d6\b\22"
184 | + "\5\2\u00d6&\3\2\2\2\u00d7\u00d8\t\4\2\2\u00d8\u00d9\3\2\2\2\u00d9\u00da"
185 | + "\b\23\6\2\u00da\u00db\b\23\4\2\u00db\u00dc\b\23\5\2\u00dc(\3\2\2\2\u00dd"
186 | + "\u00de\5\37\17\2\u00de\u00df\3\2\2\2\u00df\u00e0\b\24\6\2\u00e0\u00e1"
187 | + "\b\24\4\2\u00e1*\3\2\2\2\u00e2\u00e3\5#\21\2\u00e3\u00e4\3\2\2\2\u00e4"
188 | + "\u00e5\b\25\5\2\u00e5,\3\2\2\2\13\2\3\4\u00b6\u00be\u00c6\u00cd\u00d1"
189 | + "\u00d3\7\7\3\2\7\4\2\2\3\2\6\2\2\t\3\2";
190 | public static final ATN _ATN
191 | = new ATNDeserializer().deserialize(_serializedATN.toCharArray());
192 |
193 | static {
194 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
195 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
196 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
197 | }
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/src/main/java/org/antlr4/EditorConfigParserBaseListener.java:
--------------------------------------------------------------------------------
1 | // Generated from editorconfig/EditorConfigParser.g4 by ANTLR 4.5
2 | package org.antlr4;
3 |
4 | import org.antlr.v4.runtime.ParserRuleContext;
5 | import org.antlr.v4.runtime.tree.ErrorNode;
6 | import org.antlr.v4.runtime.tree.TerminalNode;
7 |
8 | /**
9 | * This class provides an empty implementation of
10 | * {@link EditorConfigParserListener}, which can be extended to create a
11 | * listener which only needs to handle a subset of the available methods.
12 | */
13 | public class EditorConfigParserBaseListener implements EditorConfigParserListener {
14 |
15 | /**
16 | * {@inheritDoc}
17 | *
18 | *
19 | * The default implementation does nothing.
20 | */
21 | @Override
22 | public void enterFile(EditorConfigParser.FileContext ctx) {
23 | }
24 |
25 | /**
26 | * {@inheritDoc}
27 | *
28 | *
29 | * The default implementation does nothing.
30 | */
31 | @Override
32 | public void exitFile(EditorConfigParser.FileContext ctx) {
33 | }
34 |
35 | /**
36 | * {@inheritDoc}
37 | *
38 | *
39 | * The default implementation does nothing.
40 | */
41 | @Override
42 | public void enterSection(EditorConfigParser.SectionContext ctx) {
43 | }
44 |
45 | /**
46 | * {@inheritDoc}
47 | *
48 | *
49 | * The default implementation does nothing.
50 | */
51 | @Override
52 | public void exitSection(EditorConfigParser.SectionContext ctx) {
53 | }
54 |
55 | /**
56 | * {@inheritDoc}
57 | *
58 | *
59 | * The default implementation does nothing.
60 | */
61 | @Override
62 | public void enterSectionHeader(EditorConfigParser.SectionHeaderContext ctx) {
63 | }
64 |
65 | /**
66 | * {@inheritDoc}
67 | *
68 | *
69 | * The default implementation does nothing.
70 | */
71 | @Override
72 | public void exitSectionHeader(EditorConfigParser.SectionHeaderContext ctx) {
73 | }
74 |
75 | /**
76 | * {@inheritDoc}
77 | *
78 | *
79 | * The default implementation does nothing.
80 | */
81 | @Override
82 | public void enterRootPropertyStatement(EditorConfigParser.RootPropertyStatementContext ctx) {
83 | }
84 |
85 | /**
86 | * {@inheritDoc}
87 | *
88 | *
89 | * The default implementation does nothing.
90 | */
91 | @Override
92 | public void exitRootPropertyStatement(EditorConfigParser.RootPropertyStatementContext ctx) {
93 | }
94 |
95 | /**
96 | * {@inheritDoc}
97 | *
98 | *
99 | * The default implementation does nothing.
100 | */
101 | @Override
102 | public void enterPropertyStatement(EditorConfigParser.PropertyStatementContext ctx) {
103 | }
104 |
105 | /**
106 | * {@inheritDoc}
107 | *
108 | *
109 | * The default implementation does nothing.
110 | */
111 | @Override
112 | public void exitPropertyStatement(EditorConfigParser.PropertyStatementContext ctx) {
113 | }
114 |
115 | /**
116 | * {@inheritDoc}
117 | *
118 | *
119 | * The default implementation does nothing.
120 | */
121 | @Override
122 | public void enterPropertyKey(EditorConfigParser.PropertyKeyContext ctx) {
123 | }
124 |
125 | /**
126 | * {@inheritDoc}
127 | *
128 | *
129 | * The default implementation does nothing.
130 | */
131 | @Override
132 | public void exitPropertyKey(EditorConfigParser.PropertyKeyContext ctx) {
133 | }
134 |
135 | /**
136 | * {@inheritDoc}
137 | *
138 | *
139 | * The default implementation does nothing.
140 | */
141 | @Override
142 | public void enterPropertyValue(EditorConfigParser.PropertyValueContext ctx) {
143 | }
144 |
145 | /**
146 | * {@inheritDoc}
147 | *
148 | *
149 | * The default implementation does nothing.
150 | */
151 | @Override
152 | public void exitPropertyValue(EditorConfigParser.PropertyValueContext ctx) {
153 | }
154 |
155 | /**
156 | * {@inheritDoc}
157 | *
158 | *
159 | * The default implementation does nothing.
160 | */
161 | @Override
162 | public void enterEveryRule(ParserRuleContext ctx) {
163 | }
164 |
165 | /**
166 | * {@inheritDoc}
167 | *
168 | *
169 | * The default implementation does nothing.
170 | */
171 | @Override
172 | public void exitEveryRule(ParserRuleContext ctx) {
173 | }
174 |
175 | /**
176 | * {@inheritDoc}
177 | *
178 | *
179 | * The default implementation does nothing.
180 | */
181 | @Override
182 | public void visitTerminal(TerminalNode node) {
183 | }
184 |
185 | /**
186 | * {@inheritDoc}
187 | *
188 | *
189 | * The default implementation does nothing.
190 | */
191 | @Override
192 | public void visitErrorNode(ErrorNode node) {
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/src/main/java/org/antlr4/EditorConfigParserBaseVisitor.java:
--------------------------------------------------------------------------------
1 | // Generated from editorconfig/EditorConfigParser.g4 by ANTLR 4.5
2 | package org.antlr4;
3 |
4 | import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
5 |
6 | /**
7 | * This class provides an empty implementation of
8 | * {@link EditorConfigParserVisitor}, which can be extended to create a visitor
9 | * which only needs to handle a subset of the available methods.
10 | *
11 | * @param The return type of the visit operation. Use {@link Void} for
12 | * operations with no return type.
13 | */
14 | public class EditorConfigParserBaseVisitor extends AbstractParseTreeVisitor implements EditorConfigParserVisitor {
15 |
16 | /**
17 | * {@inheritDoc}
18 | *
19 | *
20 | * The default implementation returns the result of calling
21 | * {@link #visitChildren} on {@code ctx}.
22 | */
23 | @Override
24 | public T visitFile(EditorConfigParser.FileContext ctx) {
25 | return visitChildren(ctx);
26 | }
27 |
28 | /**
29 | * {@inheritDoc}
30 | *
31 | *
32 | * The default implementation returns the result of calling
33 | * {@link #visitChildren} on {@code ctx}.
34 | */
35 | @Override
36 | public T visitSection(EditorConfigParser.SectionContext ctx) {
37 | return visitChildren(ctx);
38 | }
39 |
40 | /**
41 | * {@inheritDoc}
42 | *
43 | *
44 | * The default implementation returns the result of calling
45 | * {@link #visitChildren} on {@code ctx}.
46 | */
47 | @Override
48 | public T visitSectionHeader(EditorConfigParser.SectionHeaderContext ctx) {
49 | return visitChildren(ctx);
50 | }
51 |
52 | /**
53 | * {@inheritDoc}
54 | *
55 | *
56 | * The default implementation returns the result of calling
57 | * {@link #visitChildren} on {@code ctx}.
58 | */
59 | @Override
60 | public T visitRootPropertyStatement(EditorConfigParser.RootPropertyStatementContext ctx) {
61 | return visitChildren(ctx);
62 | }
63 |
64 | /**
65 | * {@inheritDoc}
66 | *
67 | *
68 | * The default implementation returns the result of calling
69 | * {@link #visitChildren} on {@code ctx}.
70 | */
71 | @Override
72 | public T visitPropertyStatement(EditorConfigParser.PropertyStatementContext ctx) {
73 | return visitChildren(ctx);
74 | }
75 |
76 | /**
77 | * {@inheritDoc}
78 | *
79 | *
80 | * The default implementation returns the result of calling
81 | * {@link #visitChildren} on {@code ctx}.
82 | */
83 | @Override
84 | public T visitPropertyKey(EditorConfigParser.PropertyKeyContext ctx) {
85 | return visitChildren(ctx);
86 | }
87 |
88 | /**
89 | * {@inheritDoc}
90 | *
91 | *
92 | * The default implementation returns the result of calling
93 | * {@link #visitChildren} on {@code ctx}.
94 | */
95 | @Override
96 | public T visitPropertyValue(EditorConfigParser.PropertyValueContext ctx) {
97 | return visitChildren(ctx);
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/org/antlr4/EditorConfigParserListener.java:
--------------------------------------------------------------------------------
1 | // Generated from editorconfig/EditorConfigParser.g4 by ANTLR 4.5
2 | package org.antlr4;
3 |
4 | import org.antlr.v4.runtime.tree.ParseTreeListener;
5 |
6 | /**
7 | * This interface defines a complete listener for a parse tree produced by
8 | * {@link EditorConfigParser}.
9 | */
10 | public interface EditorConfigParserListener extends ParseTreeListener {
11 |
12 | /**
13 | * Enter a parse tree produced by {@link EditorConfigParser#file}.
14 | *
15 | * @param ctx the parse tree
16 | */
17 | void enterFile(EditorConfigParser.FileContext ctx);
18 |
19 | /**
20 | * Exit a parse tree produced by {@link EditorConfigParser#file}.
21 | *
22 | * @param ctx the parse tree
23 | */
24 | void exitFile(EditorConfigParser.FileContext ctx);
25 |
26 | /**
27 | * Enter a parse tree produced by {@link EditorConfigParser#section}.
28 | *
29 | * @param ctx the parse tree
30 | */
31 | void enterSection(EditorConfigParser.SectionContext ctx);
32 |
33 | /**
34 | * Exit a parse tree produced by {@link EditorConfigParser#section}.
35 | *
36 | * @param ctx the parse tree
37 | */
38 | void exitSection(EditorConfigParser.SectionContext ctx);
39 |
40 | /**
41 | * Enter a parse tree produced by {@link EditorConfigParser#sectionHeader}.
42 | *
43 | * @param ctx the parse tree
44 | */
45 | void enterSectionHeader(EditorConfigParser.SectionHeaderContext ctx);
46 |
47 | /**
48 | * Exit a parse tree produced by {@link EditorConfigParser#sectionHeader}.
49 | *
50 | * @param ctx the parse tree
51 | */
52 | void exitSectionHeader(EditorConfigParser.SectionHeaderContext ctx);
53 |
54 | /**
55 | * Enter a parse tree produced by
56 | * {@link EditorConfigParser#rootPropertyStatement}.
57 | *
58 | * @param ctx the parse tree
59 | */
60 | void enterRootPropertyStatement(EditorConfigParser.RootPropertyStatementContext ctx);
61 |
62 | /**
63 | * Exit a parse tree produced by
64 | * {@link EditorConfigParser#rootPropertyStatement}.
65 | *
66 | * @param ctx the parse tree
67 | */
68 | void exitRootPropertyStatement(EditorConfigParser.RootPropertyStatementContext ctx);
69 |
70 | /**
71 | * Enter a parse tree produced by
72 | * {@link EditorConfigParser#propertyStatement}.
73 | *
74 | * @param ctx the parse tree
75 | */
76 | void enterPropertyStatement(EditorConfigParser.PropertyStatementContext ctx);
77 |
78 | /**
79 | * Exit a parse tree produced by {@link EditorConfigParser#propertyStatement}.
80 | *
81 | * @param ctx the parse tree
82 | */
83 | void exitPropertyStatement(EditorConfigParser.PropertyStatementContext ctx);
84 |
85 | /**
86 | * Enter a parse tree produced by {@link EditorConfigParser#propertyKey}.
87 | *
88 | * @param ctx the parse tree
89 | */
90 | void enterPropertyKey(EditorConfigParser.PropertyKeyContext ctx);
91 |
92 | /**
93 | * Exit a parse tree produced by {@link EditorConfigParser#propertyKey}.
94 | *
95 | * @param ctx the parse tree
96 | */
97 | void exitPropertyKey(EditorConfigParser.PropertyKeyContext ctx);
98 |
99 | /**
100 | * Enter a parse tree produced by {@link EditorConfigParser#propertyValue}.
101 | *
102 | * @param ctx the parse tree
103 | */
104 | void enterPropertyValue(EditorConfigParser.PropertyValueContext ctx);
105 |
106 | /**
107 | * Exit a parse tree produced by {@link EditorConfigParser#propertyValue}.
108 | *
109 | * @param ctx the parse tree
110 | */
111 | void exitPropertyValue(EditorConfigParser.PropertyValueContext ctx);
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/org/antlr4/EditorConfigParserVisitor.java:
--------------------------------------------------------------------------------
1 | // Generated from editorconfig/EditorConfigParser.g4 by ANTLR 4.5
2 | package org.antlr4;
3 |
4 | import org.antlr.v4.runtime.tree.ParseTreeVisitor;
5 |
6 | /**
7 | * This interface defines a complete generic visitor for a parse tree produced
8 | * by {@link EditorConfigParser}.
9 | *
10 | * @param The return type of the visit operation. Use {@link Void} for
11 | * operations with no return type.
12 | */
13 | public interface EditorConfigParserVisitor extends ParseTreeVisitor {
14 |
15 | /**
16 | * Visit a parse tree produced by {@link EditorConfigParser#file}.
17 | *
18 | * @param ctx the parse tree
19 | * @return the visitor result
20 | */
21 | T visitFile(EditorConfigParser.FileContext ctx);
22 |
23 | /**
24 | * Visit a parse tree produced by {@link EditorConfigParser#section}.
25 | *
26 | * @param ctx the parse tree
27 | * @return the visitor result
28 | */
29 | T visitSection(EditorConfigParser.SectionContext ctx);
30 |
31 | /**
32 | * Visit a parse tree produced by {@link EditorConfigParser#sectionHeader}.
33 | *
34 | * @param ctx the parse tree
35 | * @return the visitor result
36 | */
37 | T visitSectionHeader(EditorConfigParser.SectionHeaderContext ctx);
38 |
39 | /**
40 | * Visit a parse tree produced by
41 | * {@link EditorConfigParser#rootPropertyStatement}.
42 | *
43 | * @param ctx the parse tree
44 | * @return the visitor result
45 | */
46 | T visitRootPropertyStatement(EditorConfigParser.RootPropertyStatementContext ctx);
47 |
48 | /**
49 | * Visit a parse tree produced by
50 | * {@link EditorConfigParser#propertyStatement}.
51 | *
52 | * @param ctx the parse tree
53 | * @return the visitor result
54 | */
55 | T visitPropertyStatement(EditorConfigParser.PropertyStatementContext ctx);
56 |
57 | /**
58 | * Visit a parse tree produced by {@link EditorConfigParser#propertyKey}.
59 | *
60 | * @param ctx the parse tree
61 | * @return the visitor result
62 | */
63 | T visitPropertyKey(EditorConfigParser.PropertyKeyContext ctx);
64 |
65 | /**
66 | * Visit a parse tree produced by {@link EditorConfigParser#propertyValue}.
67 | *
68 | * @param ctx the parse tree
69 | * @return the visitor result
70 | */
71 | T visitPropertyValue(EditorConfigParser.PropertyValueContext ctx);
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/org/antlr4/SyntaxError.java:
--------------------------------------------------------------------------------
1 | package org.antlr4;
2 |
3 | import org.antlr.v4.runtime.RecognitionException;
4 |
5 | /**
6 | *
7 | * @author junichi11
8 | */
9 | public class SyntaxError {
10 |
11 | private final String message;
12 | private final int line;
13 | private final int charPositionInLine;
14 | private final RecognitionException recognitionException;
15 |
16 | public SyntaxError(String message, int line, int charPositionInLine, RecognitionException recognitionException) {
17 | this.message = message;
18 | this.line = line;
19 | this.charPositionInLine = charPositionInLine;
20 | this.recognitionException = recognitionException;
21 | }
22 |
23 | public String getMessage() {
24 | return message;
25 | }
26 |
27 | public int getLine() {
28 | return line;
29 | }
30 |
31 | public int getCharPositionInLine() {
32 | return charPositionInLine;
33 | }
34 |
35 | public RecognitionException getRecognitionException() {
36 | return recognitionException;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/editorconfig/core/EditorConfigException.java:
--------------------------------------------------------------------------------
1 | package org.editorconfig.core;
2 |
3 | import java.io.IOException;
4 |
5 | /**
6 | * The base class of all EditorConfig exceptions
7 | *
8 | * @author Dennis.Ushakov
9 | */
10 | public class EditorConfigException extends Exception {
11 | public EditorConfigException(String s, IOException e) {
12 | super(s, e);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/editorconfig/core/ParsingException.java:
--------------------------------------------------------------------------------
1 | package org.editorconfig.core;
2 |
3 | import java.io.IOException;
4 |
5 | /**
6 | * Exception which is thrown by {@link EditorConfig#getProperties(String)} if an EditorConfig file could not be parsed
7 | *
8 | * @author Dennis.Ushakov
9 | */
10 | public class ParsingException extends EditorConfigException {
11 | public ParsingException(String s, IOException e) {
12 | super(s, e);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/editorconfig/core/VersionException.java:
--------------------------------------------------------------------------------
1 | package org.editorconfig.core;
2 |
3 | /**
4 | * Exception which is thrown by {@link EditorConfig#getProperties(String)} if an invalid version number is specified
5 | *
6 | * @author Dennis.Ushakov
7 | */
8 | public class VersionException extends EditorConfigException {
9 | public VersionException(String s) {
10 | super(s, null);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/editorconfig/core/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides the Java API for accessing
3 | * EditorConfig Core
4 | * (For the purpose and usage of EditorConfig, see
5 | * EditorConfig homepage for details).
6 | */
7 |
8 | package org.editorconfig.core;
--------------------------------------------------------------------------------
/src/main/nbm/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | OpenIDE-Module-Install: com/welovecoding/nbeditorconfig/listener/Installer.class
3 | OpenIDE-Module-Layer: com/welovecoding/nbeditorconfig/layer.xml
4 | OpenIDE-Module-Localizing-Bundle: com/welovecoding/nbeditorconfig/Bundle.properties
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/Bundle.properties:
--------------------------------------------------------------------------------
1 | OpenIDE-Module-Name=EditorConfig Plugin
2 | OpenIDE-Module-Short-Description=EditorConfig Plugin for NetBeans IDE.
3 | OpenIDE-Module-Long-Description=\
4 | A NetBeans IDE plugin supporting the EditorConfig standard. For more Information check: http://editorconfig.org/ \u2014 After installation, simply restart your IDE to activate the plugin.\
5 | Plugin info: https://github.com/welovecoding/editorconfig-netbeans
\
6 | BETA DISCLAIMER
THIS SOFTWARE IS IN BETA AND IS BELIEVED TO CONTAIN DEFECTS. A PRIMARY PURPOSE OF THIS BETA VERSION IS TO OBTAIN FEEDBACK ON SOFTWARE PERFORMANCE AND THE IDENTIFICATION OF DEFECTS. WE DO NOT RECOMMEND TO USE THIS SOFTWARE WITH PRODUCTION CODE. PLEASE MAKE BACKUPS OF IMPORTANT FILES BEFORE USING THIS SOFTWARE; USE CAUTION AND DO NOT TO RELY IN ANY WAY ON THE CORRECT FUNCTIONING OR PERFORMANCE OF THE SOFTWARE AND/OR ACCOMPANYING PARTS.
7 | OpenIDE-Module-Display-Category=Editing
8 |
9 | text/x-editorconfig=EditorConfig
10 |
11 | wlc-nbeditorconfig-comment=Comment
12 | wlc-nbeditorconfig-equals=Equals
13 | wlc-nbeditorconfig-keyword=Keyword
14 | wlc-nbeditorconfig-section=Section
15 | wlc-nbeditorconfig-section-delimiter=Section Delimiter
16 | wlc-nbeditorconfig-string=String
17 | wlc-nbeditorconfig-whitespace=Whitespace
18 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/EditorConfigExample.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | end_of_line=lf
9 | insert_final_newline = true
10 |
11 | # Matches multiple files with brace expansion notation
12 | # Set default charset
13 | [*.{js,py}]
14 | charset = utf-8
15 |
16 | # 4 space indentation
17 | [*.py]
18 | indent_style = space
19 | indent_size = 4
20 |
21 | # Tab indentation (no size specified)
22 | [*.js]
23 | indent_style = tab
24 |
25 | ; Indentation override for all JS under lib directory
26 | [lib/**.js]
27 | indent_style = space
28 | indent_size = 2
29 |
30 | # Matches the exact files either package.json or .travis.yml
31 | [{package.json,.travis.yml}]
32 | indent_style = space
33 | indent_size = 2
34 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/FontAndColors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/editorconfig-code-templates.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | root
7 |
8 |
9 |
10 | indent_style
11 |
12 |
13 |
14 | indent_size
15 |
16 |
17 |
18 | tab_width
19 |
20 |
21 |
22 | end_of_line
23 |
24 |
25 |
26 | charset
27 |
28 |
29 |
30 | trim_trailing_whitespace
31 |
32 |
33 |
34 | insert_final_newline
35 |
36 |
37 |
38 | max_line_length
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/filetype/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | EditorConfig
4 |
5 |
6 | EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs.
7 | The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors
8 | to read the file format and adhere to defined styles.
9 | EditorConfig files are easily readable and they work nicely with version control systems.
10 |
11 | Visit the EditorConfig website
12 |
13 | Visit the website of the EditorConfig Plugin creators
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/filetype/ec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/welovecoding/editorconfig-netbeans/2796df7e1756b7212c89b20f39b3b0f489d6c38f/src/main/resources/com/welovecoding/nbeditorconfig/filetype/ec.png
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/layer.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 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/listener/Bundle.properties:
--------------------------------------------------------------------------------
1 | wlc-nbeditorconfig-version-error-title=Invalid Java Version - EditorConfig Plugin
2 | wlc-nbeditorconfig-version-error-message=The EditorConfig Plugin needs Java 1.7 or greater to work. Please consider updating to a compatible Java version.
3 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/options/Bundle.properties:
--------------------------------------------------------------------------------
1 | EditorConfigOptionsPanel.lineCommnetPrefixLabel.text=Line comment prefix:
2 |
--------------------------------------------------------------------------------
/src/main/resources/com/welovecoding/nbeditorconfig/section16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/welovecoding/editorconfig-netbeans/2796df7e1756b7212c89b20f39b3b0f489d6c38f/src/main/resources/com/welovecoding/nbeditorconfig/section16.png
--------------------------------------------------------------------------------
/src/test/java/com/welovecoding/nbeditorconfig/processor/EditorConfigProcessorTest.java:
--------------------------------------------------------------------------------
1 | package com.welovecoding.nbeditorconfig.processor;
2 |
3 | import com.welovecoding.nbeditorconfig.processor.FileInfo;
4 | import com.welovecoding.nbeditorconfig.processor.EditorConfigProcessor;
5 | import com.welovecoding.nbeditorconfig.io.model.MappedCharset;
6 | import com.welovecoding.nbeditorconfig.model.MappedEditorConfig;
7 | import java.io.File;
8 | import java.io.IOException;
9 | import java.nio.charset.StandardCharsets;
10 | import java.nio.file.Files;
11 | import java.nio.file.Path;
12 | import java.nio.file.Paths;
13 | import java.nio.file.StandardOpenOption;
14 | import org.junit.Test;
15 | import static org.junit.Assert.*;
16 | import org.openide.filesystems.FileUtil;
17 | import org.openide.loaders.DataObject;
18 | import org.openide.util.Exceptions;
19 | import org.openide.util.Utilities;
20 |
21 | public class EditorConfigProcessorTest {
22 |
23 | public EditorConfigProcessorTest() {
24 | }
25 |
26 | @Test
27 | public void itDoesNotLoopOnFinalNewLineOperation() throws Exception {
28 | // Setup test file
29 | DataObject dataObject = null;
30 | File file = null;
31 |
32 | String content = "alert('Hello World! or Καλημέρα κόσμε! or こんにちは 世界!');";
33 |
34 | try {
35 | file = File.createTempFile(this.getClass().getSimpleName(), ".js");
36 | Path path = Paths.get(Utilities.toURI(file));
37 | Files.write(path, content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
38 | dataObject = DataObject.find(FileUtil.toFileObject(file));
39 | } catch (IOException ex) {
40 | Exceptions.printStackTrace(ex);
41 | }
42 |
43 | // Setup EditorConfig
44 | MappedCharset charset = new MappedCharset(StandardCharsets.UTF_8.name());
45 | MappedEditorConfig config = new MappedEditorConfig();
46 | config.setCharset(charset);
47 | config.setEndOfLine(System.lineSeparator());
48 | config.setInsertFinalNewLine(true);
49 |
50 | // Run processor
51 | EditorConfigProcessor proc = new EditorConfigProcessor();
52 | FileInfo info = proc.excuteOperations(dataObject, config);
53 | assertEquals(true, info.isFileChangeNeeded());
54 |
55 | /*
56 | Run the processor a second time and test that a file change is NOT
57 | needed (because it has been already performed during the first run).
58 | */
59 | proc.flushFile(info);
60 | info = proc.excuteOperations(dataObject, config);
61 | assertEquals(false, info.isFileChangeNeeded());
62 |
63 | // Delete test file
64 | assertEquals(true, file.delete());
65 | }
66 |
67 | @Test
68 | public void itDoesNotLoopOnTrimTrailingWhiteSpaceOperation() throws Exception {
69 | // Setup test file
70 | DataObject dataObject = null;
71 | File file = null;
72 |
73 | String content = "alert('Hello World!'); ";
74 |
75 | try {
76 | file = File.createTempFile(this.getClass().getSimpleName(), ".js");
77 | Path path = Paths.get(Utilities.toURI(file));
78 | Files.write(path, content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
79 | dataObject = DataObject.find(FileUtil.toFileObject(file));
80 | } catch (IOException ex) {
81 | Exceptions.printStackTrace(ex);
82 | }
83 |
84 | // Setup EditorConfig
85 | MappedEditorConfig config = new MappedEditorConfig();
86 | config.setEndOfLine(System.lineSeparator());
87 | config.setTrimTrailingWhiteSpace(true);
88 |
89 | // Run processor
90 | EditorConfigProcessor proc = new EditorConfigProcessor();
91 | FileInfo info = proc.excuteOperations(dataObject, config);
92 | assertEquals(true, info.isFileChangeNeeded());
93 |
94 | /*
95 | Run the processor a second time and test that a file change is NOT
96 | needed (because it has been already performed during the first run).
97 | */
98 | proc.flushFile(info);
99 | info = proc.excuteOperations(dataObject, config);
100 | assertEquals(false, info.isFileChangeNeeded());
101 |
102 | // Delete test file
103 | assertEquals(true, file.delete());
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/test/java/com/welovecoding/nbeditorconfig/processor/operation/FinalNewLineOperationTest.java:
--------------------------------------------------------------------------------
1 | package com.welovecoding.nbeditorconfig.processor.operation;
2 |
3 | import com.welovecoding.nbeditorconfig.processor.operation.FinalNewLineOperation;
4 | import com.welovecoding.nbeditorconfig.processor.FileInfo;
5 | import java.io.File;
6 | import java.io.IOException;
7 | import java.net.URISyntaxException;
8 | import java.nio.charset.StandardCharsets;
9 | import java.nio.file.Files;
10 | import java.nio.file.Path;
11 | import java.nio.file.Paths;
12 | import java.nio.file.StandardOpenOption;
13 | import org.junit.After;
14 | import org.junit.Before;
15 | import org.junit.Test;
16 | import static org.junit.Assert.*;
17 | import org.openide.filesystems.FileUtil;
18 | import org.openide.loaders.DataObject;
19 | import org.openide.loaders.DataObjectNotFoundException;
20 | import org.openide.util.Exceptions;
21 | import org.openide.util.Utilities;
22 |
23 | public class FinalNewLineOperationTest {
24 |
25 | private DataObject dataObject = null;
26 | private File file;
27 |
28 | @Before
29 | public void setUp() throws DataObjectNotFoundException, URISyntaxException {
30 | String content = "alert('no final new line.');";
31 |
32 | try {
33 | file = File.createTempFile(this.getClass().getSimpleName(), ".js");
34 | Path path = Paths.get(Utilities.toURI(file));
35 | Files.write(path, content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
36 | dataObject = DataObject.find(FileUtil.toFileObject(file));
37 | } catch (IOException ex) {
38 | Exceptions.printStackTrace(ex);
39 | }
40 | }
41 |
42 | @After
43 | public void tearDown() {
44 | file.delete();
45 | }
46 |
47 | public FinalNewLineOperationTest() {
48 | }
49 |
50 | @Test
51 | public void itAddsAFinalNewLine() throws IOException {
52 | StringBuilder content = new StringBuilder(dataObject.getPrimaryFile().asText());
53 |
54 | String expectedContent = content.toString();
55 | expectedContent += System.lineSeparator();
56 |
57 | FileInfo info = new FileInfo();
58 | info.setContent(content);
59 | info.setEndOfLine(System.lineSeparator());
60 |
61 | boolean wasPerformed = new FinalNewLineOperation().operate(info);
62 |
63 | assertEquals(true, wasPerformed);
64 | assertEquals(expectedContent, content.toString());
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/test/java/com/welovecoding/nbeditorconfig/processor/operation/IndentSizeOperationTest.java:
--------------------------------------------------------------------------------
1 | package com.welovecoding.nbeditorconfig.processor.operation;
2 |
3 | import com.welovecoding.nbeditorconfig.processor.operation.IndentSizeOperation;
4 | import java.io.File;
5 | import java.io.IOException;
6 | import java.nio.charset.StandardCharsets;
7 | import java.nio.file.Files;
8 | import java.nio.file.Path;
9 | import java.nio.file.Paths;
10 | import java.nio.file.StandardOpenOption;
11 | import java.util.prefs.BackingStoreException;
12 | import java.util.prefs.Preferences;
13 | import javax.swing.text.BadLocationException;
14 | import javax.swing.text.StyledDocument;
15 | import org.junit.After;
16 | import static org.junit.Assert.assertEquals;
17 | import org.junit.Before;
18 | import org.junit.Test;
19 | import org.netbeans.api.editor.settings.SimpleValueNames;
20 | import org.netbeans.modules.editor.indent.api.Reformat;
21 | import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
22 | import org.openide.cookies.EditorCookie;
23 | import org.openide.filesystems.FileUtil;
24 | import org.openide.loaders.DataObject;
25 | import org.openide.text.NbDocument;
26 | import org.openide.util.Exceptions;
27 | import org.openide.util.Utilities;
28 |
29 | public class IndentSizeOperationTest {
30 |
31 | private DataObject dataObject;
32 | private File file;
33 |
34 | @Before
35 | public void setUp() {
36 | String codeWith4SpacesIndent = "(function(){" + System.lineSeparator();
37 | codeWith4SpacesIndent += " alert('Hello World!');" + System.lineSeparator();
38 | codeWith4SpacesIndent += "})();";
39 |
40 | try {
41 | file = File.createTempFile(this.getClass().getSimpleName(), ".js");
42 | Path path = Paths.get(Utilities.toURI(file));
43 | Files.write(path, codeWith4SpacesIndent.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
44 | dataObject = DataObject.find(FileUtil.toFileObject(file));
45 | } catch (IOException ex) {
46 | Exceptions.printStackTrace(ex);
47 | }
48 | }
49 |
50 | @After
51 | public void tearDown() {
52 | file.delete();
53 | }
54 |
55 | public IndentSizeOperationTest() {
56 | }
57 |
58 | @Test
59 | public void itDetectsIfChangesAreNeeded() throws
60 | IOException, BadLocationException, BackingStoreException {
61 | int indentWidth = 2;
62 |
63 | String codeWith2SpacesIndent = "(function(){" + System.lineSeparator();
64 | codeWith2SpacesIndent += " alert('Hello World!');" + System.lineSeparator();
65 | codeWith2SpacesIndent += "})();";
66 |
67 | Preferences codeStyle = CodeStylePreferences.get(
68 | dataObject.getPrimaryFile(),
69 | dataObject.getPrimaryFile().getMIMEType()
70 | ).getPreferences();
71 |
72 | // Check indent size before change
73 | // Note: "org-netbeans-modules-csl-api" sets default value to 4
74 | int indentSizeBefore = codeStyle.getInt(SimpleValueNames.INDENT_SHIFT_WIDTH, 4);
75 | assertEquals(4, indentSizeBefore);
76 |
77 | // Change indent size within an operation
78 | boolean changeNeeded = new IndentSizeOperation(dataObject.getPrimaryFile()).changeIndentSize(indentWidth);
79 | assertEquals(true, changeNeeded);
80 |
81 | // Update code style reference
82 | codeStyle = CodeStylePreferences.get(
83 | dataObject.getPrimaryFile(),
84 | dataObject.getPrimaryFile().getMIMEType()
85 | ).getPreferences();
86 |
87 | // Save the new style
88 | codeStyle.flush();
89 |
90 | // Check that new style has been applied
91 | int indentSizeAfter = codeStyle.getInt(SimpleValueNames.INDENT_SHIFT_WIDTH, -1);
92 | assertEquals(indentWidth, indentSizeAfter);
93 |
94 | // Save indent size
95 | final EditorCookie cookie = dataObject.getLookup().lookup(EditorCookie.class);
96 | cookie.open();
97 |
98 | final StyledDocument document = cookie.openDocument();
99 |
100 | NbDocument.runAtomicAsUser(document, new Runnable() {
101 | @Override
102 | public void run() {
103 | try {
104 | // Save test file
105 | cookie.saveDocument();
106 |
107 | // Reformat test file
108 | Reformat reformat = Reformat.get(document);
109 | reformat.lock();
110 |
111 | try {
112 | reformat.reformat(0, document.getLength());
113 | } catch (BadLocationException ex) {
114 | Exceptions.printStackTrace(ex);
115 | } finally {
116 | reformat.unlock();
117 | try {
118 | // Save formatted document
119 | cookie.saveDocument();
120 | System.out.println("Content saved:");
121 | System.out.println(document.getText(0, document.getLength()));
122 | } catch (IOException | BadLocationException ex) {
123 | Exceptions.printStackTrace(ex);
124 | }
125 | }
126 | } catch (IOException ex) {
127 | Exceptions.printStackTrace(ex);
128 | }
129 | }
130 | });
131 |
132 | // TODO: This check fails
133 | // assertEquals(codeWith2SpacesIndent, dataObject.getPrimaryFile().asText());
134 | }
135 |
136 | }
137 |
--------------------------------------------------------------------------------
/src/test/java/com/welovecoding/nbeditorconfig/processor/operation/LineEndingOperationTest.java:
--------------------------------------------------------------------------------
1 | package com.welovecoding.nbeditorconfig.processor.operation;
2 |
3 | import com.welovecoding.nbeditorconfig.processor.operation.LineEndingOperation;
4 | import com.welovecoding.nbeditorconfig.processor.FileInfo;
5 | import java.io.File;
6 | import java.io.IOException;
7 | import java.net.URISyntaxException;
8 | import java.nio.charset.StandardCharsets;
9 | import java.nio.file.Files;
10 | import java.nio.file.Path;
11 | import java.nio.file.Paths;
12 | import java.nio.file.StandardOpenOption;
13 | import org.junit.After;
14 | import static org.junit.Assert.assertEquals;
15 | import org.junit.Before;
16 | import org.junit.Test;
17 | import org.openide.filesystems.FileUtil;
18 | import org.openide.loaders.DataObject;
19 | import org.openide.loaders.DataObjectNotFoundException;
20 | import org.openide.util.Exceptions;
21 | import org.openide.util.Utilities;
22 |
23 | public class LineEndingOperationTest {
24 |
25 | private DataObject dataObject = null;
26 | private File file;
27 |
28 | @Before
29 | public void setUp() throws DataObjectNotFoundException, URISyntaxException {
30 | String content = "alert('no final new line.');\n";
31 |
32 | try {
33 | file = File.createTempFile(this.getClass().getSimpleName(), ".js");
34 | Path path = Paths.get(Utilities.toURI(file));
35 | Files.write(path, content.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE);
36 | dataObject = DataObject.find(FileUtil.toFileObject(file));
37 | } catch (IOException ex) {
38 | Exceptions.printStackTrace(ex);
39 | }
40 | }
41 |
42 | @After
43 | public void tearDown() {
44 | file.delete();
45 | }
46 |
47 | public LineEndingOperationTest() {
48 | }
49 |
50 | /**
51 | * Test of operate method, of class LineEndingOperation.
52 | */
53 | @Test
54 | public void itChangesEndOfLine() throws IOException {
55 | StringBuilder content = new StringBuilder(dataObject.getPrimaryFile().asText());
56 |
57 | String expectedContent = content.toString() + "\r";
58 |
59 | FileInfo info = new FileInfo();
60 | info.setContent(content);
61 | info.setEndOfLine("\n\r");
62 |
63 | boolean wasPerformed = new LineEndingOperation().operate(info);
64 |
65 | assertEquals(true, wasPerformed);
66 | assertEquals(expectedContent, content.toString());
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/test/java/com/welovecoding/nbeditorconfig/processor/operation/TrimTrailingWhiteSpaceOperationTest.java:
--------------------------------------------------------------------------------
1 | package com.welovecoding.nbeditorconfig.processor.operation;
2 |
3 | import com.welovecoding.nbeditorconfig.processor.operation.TrimTrailingWhiteSpaceOperation;
4 | import com.welovecoding.nbeditorconfig.processor.FileInfo;
5 | import org.junit.Test;
6 | import static org.junit.Assert.*;
7 |
8 | public class TrimTrailingWhiteSpaceOperationTest {
9 |
10 | public TrimTrailingWhiteSpaceOperationTest() {
11 | }
12 |
13 | @Test
14 | public void itRemovesSpacesFromEndOfLine() {
15 | StringBuilder content = new StringBuilder();
16 | content.append("(function(){ ").append(System.lineSeparator());
17 | content.append(" alert('Hello World!'); ").append(System.lineSeparator());
18 | content.append("})(); ").append(System.lineSeparator());
19 |
20 | StringBuilder expectedContent = new StringBuilder();
21 | expectedContent.append("(function(){").append(System.lineSeparator());
22 | expectedContent.append(" alert('Hello World!');").append(System.lineSeparator());
23 | expectedContent.append("})();").append(System.lineSeparator());
24 |
25 | FileInfo info = new FileInfo();
26 | info.setContent(content);
27 | info.setEndOfLine(System.lineSeparator());
28 |
29 | boolean removedWhiteSpaces = new TrimTrailingWhiteSpaceOperation().operate(info);
30 |
31 | assertEquals(true, removedWhiteSpaces);
32 | assertEquals(expectedContent.toString(), content.toString());
33 | }
34 |
35 | @Test
36 | public void itRemovesMultipleSpacesFromEndOfLine() {
37 | StringBuilder content = new StringBuilder();
38 | content.append("(function(){ ").append(System.lineSeparator());
39 | content.append(" alert('Hello World!'); ").append(System.lineSeparator());
40 | content.append("})(); ").append(System.lineSeparator());
41 |
42 | StringBuilder expectedContent = new StringBuilder();
43 | expectedContent.append("(function(){").append(System.lineSeparator());
44 | expectedContent.append(" alert('Hello World!');").append(System.lineSeparator());
45 | expectedContent.append("})();").append(System.lineSeparator());
46 |
47 | FileInfo info = new FileInfo();
48 | info.setContent(content);
49 | info.setEndOfLine(System.lineSeparator());
50 |
51 | boolean removedWhiteSpaces = new TrimTrailingWhiteSpaceOperation().operate(info);
52 |
53 | assertEquals(true, removedWhiteSpaces);
54 | assertEquals(expectedContent.toString(), content.toString());
55 | }
56 |
57 | @Test
58 | public void itRemovesTabsFromEndOfLine() {
59 | StringBuilder content = new StringBuilder();
60 | content.append("(function(){\t").append(System.lineSeparator());
61 | content.append(" alert('Hello World!');\t").append(System.lineSeparator());
62 | content.append("})();\t").append(System.lineSeparator());
63 |
64 | StringBuilder expectedContent = new StringBuilder();
65 | expectedContent.append("(function(){").append(System.lineSeparator());
66 | expectedContent.append(" alert('Hello World!');").append(System.lineSeparator());
67 | expectedContent.append("})();").append(System.lineSeparator());
68 |
69 | FileInfo info = new FileInfo();
70 | info.setContent(content);
71 | info.setEndOfLine(System.lineSeparator());
72 |
73 | boolean removedWhiteSpaces = new TrimTrailingWhiteSpaceOperation().operate(info);
74 |
75 | assertEquals(true, removedWhiteSpaces);
76 | assertEquals(expectedContent.toString(), content.toString());
77 | }
78 |
79 | @Test
80 | public void itRemovesMultipleTabsFromEndOfLine() {
81 | StringBuilder content = new StringBuilder();
82 | content.append("(function(){\t\t").append(System.lineSeparator());
83 | content.append(" alert('Hello World!');\t\t").append(System.lineSeparator());
84 | content.append("})();\t\t").append(System.lineSeparator());
85 |
86 | StringBuilder expectedContent = new StringBuilder();
87 | expectedContent.append("(function(){").append(System.lineSeparator());
88 | expectedContent.append(" alert('Hello World!');").append(System.lineSeparator());
89 | expectedContent.append("})();").append(System.lineSeparator());
90 |
91 | FileInfo info = new FileInfo();
92 | info.setContent(content);
93 | info.setEndOfLine(System.lineSeparator());
94 |
95 | boolean removedWhiteSpaces = new TrimTrailingWhiteSpaceOperation().operate(info);
96 |
97 | assertEquals(true, removedWhiteSpaces);
98 | assertEquals(expectedContent.toString(), content.toString());
99 | }
100 |
101 | @Test
102 | public void itRemovesMixedTabsAndSpacesFromEndOfLine() {
103 | StringBuilder content = new StringBuilder();
104 | content.append("(function(){ ").append(System.lineSeparator());
105 | content.append(" alert('Hello World!');\t \t").append(System.lineSeparator());
106 | content.append("})(); \t\t").append(System.lineSeparator());
107 |
108 | StringBuilder expectedContent = new StringBuilder();
109 | expectedContent.append("(function(){").append(System.lineSeparator());
110 | expectedContent.append(" alert('Hello World!');").append(System.lineSeparator());
111 | expectedContent.append("})();").append(System.lineSeparator());
112 |
113 | FileInfo info = new FileInfo();
114 | info.setContent(content);
115 | info.setEndOfLine(System.lineSeparator());
116 |
117 | boolean removedWhiteSpaces = new TrimTrailingWhiteSpaceOperation().operate(info);
118 |
119 | assertEquals(true, removedWhiteSpaces);
120 | assertEquals(expectedContent.toString(), content.toString());
121 | }
122 |
123 | }
124 |
--------------------------------------------------------------------------------
/src/test/resources/files/IndentSize.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/test/resources/files/charsets/latin1.txt:
--------------------------------------------------------------------------------
1 | EditorConfig: latin1
2 | Java: ISO-8859-1
3 | Notepad++: ANSI / US-ASCII
--------------------------------------------------------------------------------
/src/test/resources/files/charsets/utf-16-be.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/welovecoding/editorconfig-netbeans/2796df7e1756b7212c89b20f39b3b0f489d6c38f/src/test/resources/files/charsets/utf-16-be.txt
--------------------------------------------------------------------------------
/src/test/resources/files/charsets/utf-16-le.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/welovecoding/editorconfig-netbeans/2796df7e1756b7212c89b20f39b3b0f489d6c38f/src/test/resources/files/charsets/utf-16-le.txt
--------------------------------------------------------------------------------
/src/test/resources/files/charsets/utf-8-bom.txt:
--------------------------------------------------------------------------------
1 | EditorConfig: utf-8
2 | Java: UTF-8
3 | Notepad++: UTF-8
4 |
5 | Buchstabe y
6 | Buchstabe ä
7 | Eurozeichen €
8 | Violinschlüssel 𝄞
9 | CJK-Ideogramm 𤽜
10 |
--------------------------------------------------------------------------------
/src/test/resources/files/charsets/utf-8.txt:
--------------------------------------------------------------------------------
1 | EditorConfig: utf-8
2 | Java: UTF-8
3 | Notepad++: UTF-8 without BOM
4 |
5 | Buchstabe y
6 | Buchstabe ä
7 | Eurozeichen €
8 | Violinschlüssel 𝄞
9 | CJK-Ideogramm 𤽜
10 |
--------------------------------------------------------------------------------
/src/test/resources/files/configs/editorconfig-test.ini:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | charset = utf-8
9 | end_of_line = lf
10 | insert_final_newline = true
11 | trim_trailing_whitespace = true
12 |
13 | # 4 space indentation
14 | [*.py]
15 | indent_size = 4
16 | indent_style = space
17 |
18 | # Tab indentation (no size specified)
19 | [*.js]
20 | indent_style = tab
21 | tab_width = 4
22 |
23 | # Indentation override for all JS under lib directory
24 | [lib/**.js]
25 | indent_size = 2
26 | indent_style = space
27 |
28 | # Matches the exact files either package.json or .travis.yml
29 | [{package.json,.travis.yml}]
30 | indent_size = 4
31 | indent_style = space
32 |
--------------------------------------------------------------------------------
/src/test/resources/files/line-endings/utf8_final_newline_1_character.txt:
--------------------------------------------------------------------------------
1 | A
2 |
--------------------------------------------------------------------------------
/src/test/resources/files/line-endings/utf8_final_newline_n.txt:
--------------------------------------------------------------------------------
1 | # Final new line in UNIX style (\n)
2 |
--------------------------------------------------------------------------------
/src/test/resources/files/line-endings/utf8_final_newline_rn.txt:
--------------------------------------------------------------------------------
1 | # Last line in Windows format
2 |
--------------------------------------------------------------------------------
/src/test/resources/files/line-endings/utf8_no_final_newline.txt:
--------------------------------------------------------------------------------
1 | # No final new line
--------------------------------------------------------------------------------
/src/test/resources/files/line-endings/utf8_no_final_newline_1_character.txt:
--------------------------------------------------------------------------------
1 | A
--------------------------------------------------------------------------------