mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 07:40:42 +07:00
Cleanup
This commit is contained in:
@@ -1,17 +1,32 @@
|
||||
/*
|
||||
* @author ven
|
||||
* Copyright 2000-2012 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.codeInsight.generation.ClassMember;
|
||||
import com.intellij.codeInsight.generation.GenerateConstructorHandler;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class GenerateConstructorTest extends LightCodeInsightTestCase {
|
||||
public void testAbstractClass() throws Exception { doTest(); }
|
||||
public void testPackageLocalClass() throws Exception { doTest(); }
|
||||
@@ -22,25 +37,22 @@ public class GenerateConstructorTest extends LightCodeInsightTestCase {
|
||||
public void testNoMoreConstructorsCanBeGenerated() throws Exception { doTest(); }
|
||||
|
||||
public void testImmediatelyAfterRBrace() throws Exception { // IDEADEV-28811
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
|
||||
final int old = settings.CLASS_BRACE_STYLE;
|
||||
settings.CLASS_BRACE_STYLE = CodeStyleSettings.NEXT_LINE;
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
settings.CLASS_BRACE_STYLE = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void testBoundCommentsKeepsBlankLine() throws Exception {
|
||||
CodeStyleSettingsManager styleSettingsManager = CodeStyleSettingsManager.getInstance(getProject());
|
||||
final CodeStyleSettings settings = styleSettingsManager.getCurrentSettings();
|
||||
settings.BLANK_LINES_AFTER_CLASS_HEADER = 1;
|
||||
CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFinalFieldPreselection() throws Exception {
|
||||
public void testBoundCommentsKeepsBlankLine() throws Exception {
|
||||
CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().BLANK_LINES_AFTER_CLASS_HEADER = 1;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFinalFieldPreselection() throws Exception { doTest(true); }
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(final boolean preSelect) throws Exception {
|
||||
String name = getTestName(false);
|
||||
configureByFile("/codeInsight/generateConstructor/before" + name + ".java");
|
||||
new GenerateConstructorHandler() {
|
||||
@@ -49,30 +61,15 @@ public class GenerateConstructorTest extends LightCodeInsightTestCase {
|
||||
boolean allowEmptySelection,
|
||||
boolean copyJavadocCheckbox,
|
||||
Project project) {
|
||||
final List<ClassMember> preselection = GenerateConstructorHandler.preselect(members);
|
||||
return preselection.toArray(new ClassMember[preselection.size()]);
|
||||
if (preSelect) {
|
||||
final List<ClassMember> preselection = GenerateConstructorHandler.preselect(members);
|
||||
return preselection.toArray(new ClassMember[preselection.size()]);
|
||||
}
|
||||
else {
|
||||
return members;
|
||||
}
|
||||
}
|
||||
}.invoke(getProject(), getEditor(), getFile());
|
||||
checkResultByFile("/codeInsight/generateConstructor/after" + name +".java");
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
String name = getTestName(false);
|
||||
configureByFile("/codeInsight/generateConstructor/before" +
|
||||
name +
|
||||
".java");
|
||||
new GenerateConstructorHandler(){
|
||||
@Override
|
||||
protected ClassMember[] chooseMembers(ClassMember[] members,
|
||||
boolean allowEmptySelection,
|
||||
boolean copyJavadocCheckbox,
|
||||
Project project) {
|
||||
return members;
|
||||
}
|
||||
}.invoke(getProject(), getEditor(), getFile());
|
||||
checkResultByFile("/codeInsight/generateConstructor/after" +
|
||||
name +
|
||||
".java");
|
||||
|
||||
checkResultByFile("/codeInsight/generateConstructor/after" + name + ".java");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user