@WrapInCommand public void testReimportConflictingClasses() throws Exception { configureByFile(BASE_PATH + "/x/Usage.java", BASE_PATH); assertEmpty(highlightErrors()); CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).clone(); settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = 2; CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(settings); try { new WriteCommandAction.Simple(getProject()) { @Override protected void run() throws Throwable { JavaCodeStyleManager.getInstance(getProject()).optimizeImports(getFile()); } }.execute().throwException(); } finally { CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings(); } @NonNls String fullPath = getTestDataPath() + BASE_PATH + "/x/Usage_afterOptimize.txt"; final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(fullPath.replace(File.separatorChar, '/')); String text = LoadTextUtil.loadText(vFile).toString(); assertEquals(text, getFile().getText()); }
@Override protected void setUp() throws Exception { super.setUp(); CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).clone(); settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = 100; CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(settings); DaemonCodeAnalyzer.getInstance(getProject()).setUpdateByTimerEnabled(false); }
@Override protected void tearDown() throws Exception { CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings(); super.tearDown(); }