summaryrefslogtreecommitdiff
path: root/java/java-tests/testSrc/com/intellij/codeInsight/CompleteStatementTest.java
blob: 3f199d44ea134d10281b1de7037782b365be58fd (plain)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
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
/*
 * Copyright 2000-2011 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.codeInsight;

import com.intellij.JavaTestUtil;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.testFramework.EditorActionTestCase;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.annotations.NotNull;

/**
 * @author max
 */
@TestDataPath("$CONTENT_ROOT/testData")
public class CompleteStatementTest extends EditorActionTestCase {
  public void testAddMissingSemicolon() throws Exception { doTest(); }

  public void testAddMissingParen() throws Exception { doTest(); }

  public void testCompleteIf() throws Exception { doTest(); }

  public void testCompleteIfKeyword() throws Exception { doTest(); }

  public void testCompleteIfStatementGoesToThen() throws Exception { doTest(); }

  public void testCompleteIfKeywordStatementGoesToThen() throws Exception { doTest(); }

  public void testIndentation() throws Exception { doTest(); }

  public void testErrorNavigation() throws Exception { doTest(); }

  public void testStringLiteral() throws Exception { doTest(); }

  public void testCompleteCatch() throws Exception { doTest(); }
  
  public void testCompleteCatchLParen() throws Exception { doTest(); }

  public void testAlreadyCompleteCatch() throws Exception {
    CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    int old = settings.BRACE_STYLE;
    settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    try {
      doTest();
    }
    finally {
      settings.BRACE_STYLE = old;
    }
  }

  public void testCompleteCatchWithExpression() throws Exception { doTest(); }

  public void testCompleteCatchBody() throws Exception { doTest(); }

  public void testSCR11147() throws Exception { doTest(); }

  public void testNoErrors() throws Exception { doTest(); }

  public void testThrow() throws Exception { doTest(); }

  public void testReturn() throws Exception { doTest(); }

  public void testEmptyLine() throws Exception { doTest(); }

  public void testBlock() throws Exception { doTest(); }

  public void testTwoStatementsInLine() throws Exception { doTest(); }

  public void testFor() throws Exception { doTest(); }

  public void testForEach() throws Exception { doTest(); }

  public void testForBlock() throws Exception { doTest(); }

  public void testForIncrementExpressionAndBody() throws Exception { doTest(); }

  public void testEmptyBeforeReturn() throws Exception { doTest(); }

  public void testIf() throws Exception { doTest(); }

  public void testBeforeStatement() throws Exception { doTest(); }

  public void testTry1() throws Exception { doTest(); }

  public void testBlock1() throws Exception { doTest(); }

  public void testAfterFor() throws Exception { doTest(); }

  public void testBeforeFor() throws Exception { doTest(); }

  public void testAtBlockEnd() throws Exception { doTest(); }

  public void testForceBlock() throws Exception { doTest(); }

  public void testElseIf() throws Exception { doTest(); }

  public void testIncompleteElseIf() throws Exception { doTest(); }

  public void testField() throws Exception { doTest(); }

  public void testMethod() throws Exception { doTest(); }

  public void testClass() throws Exception { doTest(); }
  
  public void testInnerEnumBeforeMethod() { doTest(); }
  
  public void testInnerEnumBeforeMethodWithSpace() { doTest(); }

  public void testCompleteElseIf() throws Exception { doTest(); }

  public void testCompleteStringLiteral() throws Exception {
    doTest();
  }

  public void testNonAbstractMethodWithSemicolon() throws Exception { doTest(); }

  public void testReturnFromNonVoid() throws Exception { doTest(); }

  public void testReturnFromVoid() throws Exception { doTest(); }

  public void testIncompleteCall() throws Exception { doTest(); }

  public void testCompleteCall() throws Exception { doTest(); }

  public void testStartNewBlock() throws Exception { doTest(); }

  public void testInPreceedingBlanks() throws Exception { doTest(); }

  public void testNoBlockReturn() throws Exception { doTest(); }

  public void testInComment() throws Exception { doTest(); }

  public void testInComment2() throws Exception { doTest(); }
  public void testInComment3() throws Exception { doTest(); }
  public void testInComment4() throws Exception { doTest(); }

  public void testSCR22904() throws Exception { doTest(); }
  public void testSCR30227() throws Exception { doTest(); }

  public void testFieldWithInitializer() throws Exception { doTest(); }

  public void testFieldBeforeAnnotation() throws Exception { doTest(); }
  public void testMethodBeforeAnnotation() throws Exception { doTest(); }
  public void testMethodBeforeCommentField() throws Exception { doTest(); }
  public void testMethodBeforeCommentMethod() throws Exception { doTest(); }

  public void testParenthesized() throws Exception { doTest(); }

  public void testCompleteBreak() throws Exception {
    doTest();
  }

  public void testCompleteIfNextLineBraceStyle() throws Exception {
    CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    doTest();
    settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
  }

  public void testCompleteIfNextLineBraceStyle2() throws Exception {
    CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    doTest();
    settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
  }

  public void testSCR36110() throws Exception {
    doTest();
  }

  public void testSCR37331() throws Exception { doTest(); }
  public void testIDEADEV434() throws Exception {
    CodeStyleSettingsManager.getSettings(getProject()).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
    doTest();
    CodeStyleSettingsManager.getSettings(getProject()).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false;
    doTest();
  }

  public void testIDEADEV1093() throws Exception { doTest(); }

  public void testIDEADEV1710() throws Exception { doTest(); }

  public void testInterfaceMethodSemicolon() throws Exception { doTest(); }

  public void testSynchronized() throws Exception { doTest(); }

  public void testCdrEndlessLoop() throws Exception { doTest(); }

  public void testFollowedByComment() throws Exception { doTest(); }

  public void testBraceFixeNewLine() throws Exception { doTest(); }

  public void testSwitchKeyword() throws Exception { doTest(); }

  public void testSwitchKeywordWithCondition() throws Exception { doTest(); }
  public void testCaseColon() { doTest(); }

  public void testNewInParentheses() throws Exception { doTest(); }
  
  public void testIDEADEV20713() throws Exception { doTest(); }

  public void testIDEA22125() throws Exception { doTest(); }
  
  public void testIDEA22385() throws Exception { doTest(); }

  public void testIDEADEV40479() throws Exception { doTest(); }

  public void testMultilineReturn() throws Exception { doTest(); }
  public void testMultilineCall() throws Exception { doTest(); }

  public void testIDEADEV13019() throws Exception {
    doTestBracesNextLineStyle();
  }

  public void testIDEA25139() throws Exception {
    doTestBracesNextLineStyle();
  }
  
  public void testBeforeIfRBrace() throws Exception {
    CodeStyleSettingsManager.getSettings(getProject()).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
    doTest();
  }

  public void testNoUnnecessaryEmptyLineAtCodeBlock() throws Exception { doTest(); }

  public void testForStatementGeneration() throws Exception { doTest(); }

  public void testSpaceAfterSemicolon() throws Exception {
    CodeStyleSettingsManager.getSettings(getProject()).SPACE_AFTER_SEMICOLON = true;
    doTest();
  }

  public void testNoSpaceAfterSemicolon() throws Exception {
    CodeStyleSettingsManager.getSettings(getProject()).SPACE_AFTER_SEMICOLON = false;
    doTest();
  }
  
  public void testForUpdateGeneration() throws Exception { doTest(); }

  public void testValidCodeBlock() throws Exception { doTest(); }

  public void testValidCodeBlockWithEmptyLineAfterIt() throws Exception { doTest(); }
  
  public void testFromJavadocParameterDescriptionEndToNextParameter() throws Exception { doTest(); }

  public void testFromJavadocParameterDescriptionMiddleToNextParameter() throws Exception { doTest(); }

  public void testLastJavadocParameterDescription() throws Exception { doTest(); }
  
  public void testLastJavadocParameterDescriptionToReturn() throws Exception { doTest(); }
  
  public void testCompleteMethodCallAtReturn() throws Exception { doTest(); }
  
  public void testGenericMethodBody() throws Exception { doTest(); }
  
  public void testArrayInitializerRBracket() throws Exception { doTest(); }
  
  private void doTestBracesNextLineStyle() throws Exception {
    CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    try {
      doTest();
    }
    finally {
      settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
      settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
      settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
    }
  }

  private void doTest() {
    doTest("java");
  }

  private void doTest(String ext) {
    String path = "/codeInsight/completeStatement/";
    doFileTest(path + getTestName(false) + "." + ext, path + getTestName(false) + "_after." + ext, true);
  }

  @Override
  protected String getActionId() {
    return IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT;
  }

  @NotNull
  @Override
  protected String getTestDataPath() {
    return JavaTestUtil.getJavaTestDataPath();
  }
}