2 * Copyright 2000-2011 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.codeInsight;
18 import com.intellij.JavaTestUtil;
19 import com.intellij.openapi.actionSystem.IdeActions;
20 import com.intellij.psi.codeStyle.CodeStyleSettings;
21 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
22 import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
23 import com.intellij.testFramework.EditorActionTestCase;
24 import com.intellij.testFramework.TestDataPath;
25 import org.jetbrains.annotations.NotNull;
30 @TestDataPath("$CONTENT_ROOT/testData")
31 public class CompleteStatementTest extends EditorActionTestCase {
32 public void testAddMissingSemicolon() throws Exception { doTest(); }
34 public void testAddMissingSemicolonToPackageStatement() { doTest(); }
36 public void testAddMissingParen() throws Exception { doTest(); }
38 public void testCompleteIf() throws Exception { doTest(); }
40 public void testCompleteIfKeyword() throws Exception { doTest(); }
42 public void testCompleteIfStatementGoesToThen() throws Exception { doTest(); }
44 public void testCompleteIfKeywordStatementGoesToThen() throws Exception { doTest(); }
46 public void testIndentation() throws Exception { doTest(); }
48 public void testErrorNavigation() throws Exception { doTest(); }
50 public void testStringLiteral() throws Exception { doTest(); }
52 public void testCompleteCatch() throws Exception { doTest(); }
54 public void testCompleteCatchLParen() throws Exception { doTest(); }
56 public void testAlreadyCompleteCatch() throws Exception {
57 CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
58 int old = settings.BRACE_STYLE;
59 settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
64 settings.BRACE_STYLE = old;
68 public void testCompleteCatchWithExpression() throws Exception { doTest(); }
70 public void testCompleteCatchBody() throws Exception { doTest(); }
72 public void testSCR11147() throws Exception { doTest(); }
74 public void testNoErrors() throws Exception { doTest(); }
76 public void testThrow() throws Exception { doTest(); }
78 public void testReturn() throws Exception { doTest(); }
80 public void testEmptyLine() throws Exception { doTest(); }
82 public void testBlock() throws Exception { doTest(); }
84 public void testTwoStatementsInLine() throws Exception { doTest(); }
86 public void testFor() throws Exception { doTest(); }
88 public void testForEach() throws Exception { doTest(); }
90 public void testForBlock() throws Exception { doTest(); }
92 public void testForIncrementExpressionAndBody() throws Exception { doTest(); }
94 public void testEmptyBeforeReturn() throws Exception { doTest(); }
96 public void testIf() throws Exception { doTest(); }
98 public void testBeforeStatement() throws Exception { doTest(); }
100 public void testTry1() throws Exception { doTest(); }
102 public void testBlock1() throws Exception { doTest(); }
104 public void testAfterFor() throws Exception { doTest(); }
106 public void testBeforeFor() throws Exception { doTest(); }
108 public void testAtBlockEnd() throws Exception { doTest(); }
110 public void testForceBlock() throws Exception { doTest(); }
112 public void testElseIf() throws Exception { doTest(); }
114 public void testIncompleteElseIf() throws Exception { doTest(); }
116 public void testField() throws Exception { doTest(); }
118 public void testMethod() throws Exception { doTest(); }
120 public void testClass() throws Exception { doTest(); }
122 public void testInnerEnumBeforeMethod() { doTest(); }
124 public void testInnerEnumBeforeMethodWithSpace() { doTest(); }
126 public void testCompleteElseIf() throws Exception { doTest(); }
128 public void testCompleteStringLiteral() throws Exception {
132 public void testNonAbstractMethodWithSemicolon() throws Exception { doTest(); }
134 public void testReturnFromNonVoid() throws Exception { doTest(); }
136 public void testReturnFromVoid() throws Exception { doTest(); }
138 public void testIncompleteCall() throws Exception { doTest(); }
140 public void testCompleteCall() throws Exception { doTest(); }
142 public void testStartNewBlock() throws Exception { doTest(); }
144 public void testInPreceedingBlanks() throws Exception { doTest(); }
146 public void testNoBlockReturn() throws Exception { doTest(); }
148 public void testInComment() throws Exception { doTest(); }
150 public void testInComment2() throws Exception { doTest(); }
151 public void testInComment3() throws Exception { doTest(); }
152 public void testInComment4() throws Exception { doTest(); }
154 public void testSCR22904() throws Exception { doTest(); }
155 public void testSCR30227() throws Exception { doTest(); }
157 public void testFieldWithInitializer() throws Exception { doTest(); }
159 public void testFieldBeforeAnnotation() throws Exception { doTest(); }
160 public void testMethodBeforeAnnotation() throws Exception { doTest(); }
161 public void testMethodBeforeCommentField() throws Exception { doTest(); }
162 public void testMethodBeforeCommentMethod() throws Exception { doTest(); }
164 public void testParenthesized() throws Exception { doTest(); }
166 public void testCompleteBreak() throws Exception {
170 public void testCompleteIfNextLineBraceStyle() throws Exception {
171 CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
172 settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
174 settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
177 public void testCompleteIfNextLineBraceStyle2() throws Exception {
178 CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
179 settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
181 settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
184 public void testSCR36110() throws Exception {
188 public void testSCR37331() throws Exception { doTest(); }
189 public void testIDEADEV434() throws Exception {
190 CodeStyleSettingsManager.getSettings(getProject()).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
192 CodeStyleSettingsManager.getSettings(getProject()).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false;
196 public void testIDEADEV1093() throws Exception { doTest(); }
198 public void testIDEADEV1710() throws Exception { doTest(); }
200 public void testInterfaceMethodSemicolon() throws Exception { doTest(); }
202 public void testSynchronized() throws Exception { doTest(); }
204 public void testCdrEndlessLoop() throws Exception { doTest(); }
206 public void testFollowedByComment() throws Exception { doTest(); }
208 public void testBraceFixeNewLine() throws Exception { doTest(); }
210 public void testSwitchKeyword() throws Exception { doTest(); }
212 public void testSwitchKeywordWithCondition() throws Exception { doTest(); }
213 public void testCaseColon() { doTest(); }
215 public void testNewInParentheses() throws Exception { doTest(); }
217 public void testIDEADEV20713() throws Exception { doTest(); }
219 public void testIDEA22125() throws Exception { doTest(); }
221 public void testIDEA22385() throws Exception { doTest(); }
223 public void testIDEADEV40479() throws Exception { doTest(); }
225 public void testMultilineReturn() throws Exception { doTest(); }
226 public void testMultilineCall() throws Exception { doTest(); }
228 public void testIDEADEV13019() throws Exception {
229 doTestBracesNextLineStyle();
232 public void testIDEA25139() throws Exception {
233 doTestBracesNextLineStyle();
236 public void testBeforeIfRBrace() throws Exception {
237 CodeStyleSettingsManager.getSettings(getProject()).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
241 public void testNoUnnecessaryEmptyLineAtCodeBlock() throws Exception { doTest(); }
243 public void testForStatementGeneration() throws Exception { doTest(); }
245 public void testSpaceAfterSemicolon() throws Exception {
246 CodeStyleSettingsManager.getSettings(getProject()).SPACE_AFTER_SEMICOLON = true;
250 public void testNoSpaceAfterSemicolon() throws Exception {
251 CodeStyleSettingsManager.getSettings(getProject()).SPACE_AFTER_SEMICOLON = false;
255 public void testForUpdateGeneration() throws Exception { doTest(); }
257 public void testValidCodeBlock() throws Exception { doTest(); }
259 public void testValidCodeBlockWithEmptyLineAfterIt() throws Exception { doTest(); }
261 public void testFromJavadocParameterDescriptionEndToNextParameter() throws Exception { doTest(); }
263 public void testFromJavadocParameterDescriptionMiddleToNextParameter() throws Exception { doTest(); }
265 public void testLastJavadocParameterDescription() throws Exception { doTest(); }
267 public void testLastJavadocParameterDescriptionToReturn() throws Exception { doTest(); }
269 public void testCompleteMethodCallAtReturn() throws Exception { doTest(); }
271 public void testGenericMethodBody() throws Exception { doTest(); }
273 public void testDefaultMethodBody() { doTest(); }
275 public void testArrayInitializerRBracket() throws Exception { doTest(); }
277 public void testReturnInLambda() { doTest(); }
279 private void doTestBracesNextLineStyle() throws Exception {
280 CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
281 settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
282 settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
283 settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
288 settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
289 settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
290 settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
294 private void doTest() {
298 private void doTest(String ext) {
299 String path = "/codeInsight/completeStatement/";
300 doFileTest(path + getTestName(false) + "." + ext, path + getTestName(false) + "_after." + ext, true);
304 protected String getActionId() {
305 return IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT;
310 protected String getTestDataPath() {
311 return JavaTestUtil.getJavaTestDataPath();