boolean (@NotNull PsiFile file, boolean isInContent, @NotNull ThreeState extensionsAllowToChangeFileSilently) { ThreadingAssertions.assertEventDispatchThread(); if (!CodeInsightWorkspaceSettings.getInstance(file.getProject()).isOptimizeImportsOnTheFly()) { return false; } DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(file.getProject()); // don't optimize out imports in JSP since it can be included in other JSP if (!codeAnalyzer.isHighlightingAvailable(file) || !(file instanceof PsiJavaFile) || file instanceof ServerPageFile) return false; if (!codeAnalyzer.isErrorAnalyzingFinished(file)) return false; boolean errors = containsErrorsPreventingOptimize(file); return !errors && DaemonListeners.canChangeFileSilently(file, isInContent, extensionsAllowToChangeFileSilently); }