From cef9eee6b4408acaf46832d2e64f2d6782550963 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 27 Jan 2011 17:28:43 +0100 Subject: [PATCH] don't optimize groovy imports when the user is editing them manually --- .../codeInspection/local/GroovyUnusedImportPass.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyUnusedImportPass.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyUnusedImportPass.java index fcb10dcd99ac..b71f419f463b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyUnusedImportPass.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyUnusedImportPass.java @@ -70,6 +70,14 @@ public class GroovyUnusedImportPass extends TextEditorHighlightingPass { if (!myUnusedImports.isEmpty() && CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY) { final VirtualFile vfile = myFile.getVirtualFile(); if (vfile != null && ProjectRootManager.getInstance(myFile.getProject()).getFileIndex().isInSource(vfile)) { + final GrImportStatement[] imports = myFile.getImportStatements(); + if (imports.length > 0) { + final int offset = myEditor.getCaretModel().getOffset(); + if (imports[0].getTextRange().getStartOffset() <= offset && offset <= imports[imports.length - 1].getTextRange().getEndOffset()) { + return; + } + } + myOptimizeRunnable = new GroovyImportOptimizer().processFile(myFile); } }