diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index 6c32c762ce30..aa4e2bc60ec8 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -647,7 +647,7 @@ public class CompileDriver { final String contentName = forceCompile ? CompilerBundle.message("compiler.content.name.compile") : CompilerBundle.message("compiler.content.name.make"); - final boolean compileInBackground = useServer? true : CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_IN_BACKGROUND; + final boolean compileInBackground = true; final CompilerTask compileTask = new CompilerTask(myProject, compileInBackground, contentName, ApplicationManager.getApplication().isUnitTestMode()); @@ -1301,6 +1301,8 @@ public class CompileDriver { final Function>, Pair>> dependencyFilter = new DependentClassesCumulativeFilter(); do { + generatedTypes.clear(); + snapshot = null; for (int currentCompiler = 0, translatorsLength = translators.length; currentCompiler < translatorsLength; currentCompiler++) { sink.setCurrentCompilerIndex(currentCompiler); final TranslatingCompiler compiler = translators[currentCompiler]; @@ -1310,18 +1312,16 @@ public class CompileDriver { dumbService.waitForSmartMode(); - if (round == 0) { - if (snapshot == null || ContainerUtil.intersects(generatedTypes, compilerManager.getRegisteredInputTypes(compiler))) { - // rescan snapshot if previously generated files may influence the input of this compiler - snapshot = ApplicationManager.getApplication().runReadAction(new Computable() { - public VirtualFile[] compute() { - return context.getCompileScope().getFiles(null, true); - } - }); - recalculateChunkToFilesMap(context, sortedChunks, snapshot, chunkMap); - chunkFiles = chunkMap.get(currentChunk); - total = snapshot.length * translatorsLength; - } + if (snapshot == null || ContainerUtil.intersects(generatedTypes, compilerManager.getRegisteredInputTypes(compiler))) { + // rescan snapshot if previously generated files may influence the input of this compiler + snapshot = ApplicationManager.getApplication().runReadAction(new Computable() { + public VirtualFile[] compute() { + return context.getCompileScope().getFiles(null, true); + } + }); + recalculateChunkToFilesMap(context, sortedChunks, snapshot, chunkMap); + chunkFiles = chunkMap.get(currentChunk); + total = snapshot.length * translatorsLength; } final CompileContextEx _context; @@ -2250,7 +2250,7 @@ public class CompileDriver { public void executeCompileTask(final CompileTask task, final CompileScope scope, final String contentName, final Runnable onTaskFinished) { final CompilerTask progressManagerTask = - new CompilerTask(myProject, CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_IN_BACKGROUND, contentName, false); + new CompilerTask(myProject, true, contentName, false); final CompileContextImpl compileContext = new CompileContextImpl(myProject, progressManagerTask, scope, null, false, false); FileDocumentManager.getInstance().saveAllDocuments(); diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form index fceb7255b549..64a4db5bc0ac 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form +++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form @@ -1,6 +1,6 @@
- + @@ -10,7 +10,7 @@ - + @@ -69,17 +69,9 @@ - - - - - - - - - + @@ -87,7 +79,7 @@ - + @@ -95,7 +87,7 @@ - + diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java index f713c9d94977..96d884fe0cc0 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java @@ -39,7 +39,6 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura private final Project myProject; private JTextField myResourcePatternsField; - private JCheckBox myCbCompileInBackground; private JCheckBox myCbClearOutputDirectory; private JCheckBox myCbAssertNotNull; private JLabel myPatternLegendLabel; @@ -71,7 +70,6 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura final CompilerConfigurationImpl configuration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject); final CompilerWorkspaceConfiguration workspaceConfiguration = CompilerWorkspaceConfiguration.getInstance(myProject); - myCbCompileInBackground.setSelected(workspaceConfiguration.COMPILE_IN_BACKGROUND); myCbAutoShowFirstError.setSelected(workspaceConfiguration.AUTO_SHOW_ERRORS_IN_EDITOR); myCbClearOutputDirectory.setSelected(workspaceConfiguration.CLEAR_OUTPUT_DIRECTORY); myCbAssertNotNull.setSelected(configuration.isAddNotNullAssertions()); @@ -99,7 +97,6 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura CompilerConfigurationImpl configuration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject); final CompilerWorkspaceConfiguration workspaceConfiguration = CompilerWorkspaceConfiguration.getInstance(myProject); - workspaceConfiguration.COMPILE_IN_BACKGROUND = myCbCompileInBackground.isSelected(); workspaceConfiguration.AUTO_SHOW_ERRORS_IN_EDITOR = myCbAutoShowFirstError.isSelected(); workspaceConfiguration.CLEAR_OUTPUT_DIRECTORY = myCbClearOutputDirectory.isSelected(); boolean wasUsing = workspaceConfiguration.USE_COMPILE_SERVER; @@ -165,7 +162,6 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura public boolean isModified() { boolean isModified = false; final CompilerWorkspaceConfiguration workspaceConfiguration = CompilerWorkspaceConfiguration.getInstance(myProject); - isModified |= ComparingUtils.isModified(myCbCompileInBackground, workspaceConfiguration.COMPILE_IN_BACKGROUND); isModified |= ComparingUtils.isModified(myCbAutoShowFirstError, workspaceConfiguration.AUTO_SHOW_ERRORS_IN_EDITOR); isModified |= ComparingUtils.isModified(myCbUseCompileServer, workspaceConfiguration.USE_COMPILE_SERVER); isModified |= ComparingUtils.isModified(myCbMakeProjectOnSave, workspaceConfiguration.MAKE_PROJECT_ON_SAVE); diff --git a/java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java b/java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java index 3ac9cd96bb25..e1753d19ee05 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java +++ b/java/compiler/openapi/src/com/intellij/compiler/CompilerWorkspaceConfiguration.java @@ -37,7 +37,6 @@ import com.intellij.util.xmlb.XmlSerializerUtil; ) public class CompilerWorkspaceConfiguration implements PersistentStateComponent { - public boolean COMPILE_IN_BACKGROUND = true; public boolean AUTO_SHOW_ERRORS_IN_EDITOR = true; @Deprecated public boolean CLOSE_MESSAGE_VIEW_IF_SUCCESS = true; public boolean CLEAR_OUTPUT_DIRECTORY = true; diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java index 32c1716645b4..44701a3ab0de 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java @@ -17,10 +17,13 @@ package com.intellij.codeInsight.completion; import com.intellij.codeInsight.ExpectedTypeInfo; import com.intellij.codeInsight.ExpectedTypeInfoImpl; -import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.codeInsight.lookup.LookupElementWeigher; -import com.intellij.codeInsight.lookup.PsiTypeLookupItem; +import com.intellij.codeInsight.completion.impl.CompletionSorterImpl; +import com.intellij.codeInsight.completion.impl.LiftShorterItemsClassifier; +import com.intellij.codeInsight.lookup.*; +import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.patterns.PsiJavaPatterns; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; @@ -31,6 +34,7 @@ import com.intellij.psi.util.PropertyUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.TypeConversionUtil; +import com.intellij.util.ProcessingContext; import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; @@ -75,6 +79,32 @@ public class JavaCompletionSorting { CompletionSorter sorter = CompletionSorter.defaultSorter(parameters, result.getPrefixMatcher()); if (!smart && afterNew) { sorter = sorter.weighBefore("liftShorter", new PreferExpected(true, expectedTypes)); + } else { + final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(position.getProject()).getFileIndex(); + sorter = ((CompletionSorterImpl)sorter).withClassifier("liftShorter", true, new ClassifierFactory("liftShorterClasses") { + @Override + public Classifier createClassifier(Classifier next) { + return new LiftShorterItemsClassifier(next, new LiftShorterItemsClassifier.LiftingCondition() { + @Override + public boolean shouldLift(LookupElement shorterElement, LookupElement longerElement, ProcessingContext context) { + if (super.shouldLift(shorterElement, longerElement, context)) { + return true; + } + Object object = shorterElement.getObject(); + if (object instanceof PsiClass) { + PsiFile file = ((PsiClass)object).getContainingFile(); + if (file != null) { + VirtualFile vFile = file.getOriginalFile().getVirtualFile(); + if (vFile != null && fileIndex.isInSource(vFile)) { + return true; + } + } + } + return false; + } + }); + } + }); } if (smart) { sorter = sorter.weighBefore("negativeStats", new PreferDefaultTypeWeigher(expectedTypes, parameters)); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy index 4148143c9fce..a3c6273a587a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy @@ -101,7 +101,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { public void testDispreferImpls() throws Throwable { myFixture.addClass("package foo; public class Xxx {}"); configureSecondCompletion(); - assertPreferredItems(1, "Xxx", "XxxEx", "XxxImpl", "Xxy"); + assertPreferredItems(0, "Xxx", "XxxEx", "XxxImpl", "Xxy"); } public void testPreferOwnInnerClasses() throws Throwable { @@ -128,7 +128,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { myFixture.addClass("package foo; public interface XaYa {}"); myFixture.addClass("package foo; public interface XyYa {}"); configureSecondCompletion(); - assertPreferredItems(1, "XaYa", "XaYaEx", "XaYaImpl", "XyYa", "XyYaXa"); + assertPreferredItems(0, "XaYa", "XaYaEx", "XaYaImpl", "XyYa", "XyYaXa"); } public void testPreferLessParameters() throws Throwable { @@ -219,7 +219,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { } public void testPreferClassStaticMembers() { - checkPreferredItems(1, "Zoo", "Zoo.A", "Zoo.B", "Zoo.C", "Zoo.D", "Zoo.E", "Zoo.F", "Zoo.G", "Zoo.H"); + checkPreferredItems(0, "Zoo", "Zoo.A", "Zoo.B", "Zoo.C", "Zoo.D", "Zoo.E", "Zoo.F", "Zoo.G", "Zoo.H"); } public void testPreferFinallyToFinal() { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy index e8002a8be6c4..cddb71d9e6bc 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy @@ -21,7 +21,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase { } public void testJComponentAdd() throws Throwable { - checkPreferredItems(0, "name", "b", "fooBean239", "this", "getName"); + checkPreferredItems(0, "name", "b", "foo", "fooBean239", "this", "getName"); } public void testJComponentAddNew() throws Throwable { diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java index e3b44f03f40b..dc3284c1bf9c 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java @@ -3,6 +3,7 @@ package org.jetbrains.jps.incremental; import com.intellij.openapi.Forceable; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.LowMemoryWatcher; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.io.MappingFailedException; @@ -39,7 +40,6 @@ import java.util.concurrent.TimeUnit; */ public class IncProjectBuilder { private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.IncProjectBuilder"); - private static final Logger LocalLOG = Logger.getInstance("#org.jetbrains.jps.incremental.Builder"); public static final String COMPILE_SERVER_NAME = "COMPILE SERVER"; private static final String CLASSPATH_INDEX_FINE_NAME = "classpath.index"; @@ -235,6 +235,23 @@ public class IncProjectBuilder { private void cleanOutputRoots(CompileContext context) throws ProjectBuildException { // whole project is affected + final boolean shouldClear = context.getProject().getCompilerConfiguration().isClearOutputDirectoryOnRebuild(); + try { + if (shouldClear) { + clearOutputs(context); + } + else { + for (Module module : context.getProject().getModules().values()) { + final String moduleName = module.getName(); + clearOutputFiles(context, moduleName, true); + clearOutputFiles(context, moduleName, false); + } + } + } + catch (IOException e) { + throw new ProjectBuildException("Error cleaning output files", e); + } + try { context.getTimestamps().clean(); } @@ -248,19 +265,33 @@ public class IncProjectBuilder { throw new ProjectBuildException("Error cleaning compiler storages", e); } myProjectDescriptor.fsState.clearAll(); + } + private static void clearOutputFiles(CompileContext context, final String moduleName, boolean forTests) throws IOException { + final SourceToOutputMapping map = context.getDataManager().getSourceToOutputMap(moduleName, forTests); + for (String srcPath : map.getKeys()) { + final Collection outs = map.getState(srcPath); + if (outs != null) { + for (String out : outs) { + new File(out).delete(); + } + } + } + } + + private static void clearOutputs(CompileContext context) throws ProjectBuildException, IOException { final Collection modulesToClean = context.getProject().getModules().values(); - final Set rootsToDelete = new HashSet(); + final Map>> rootsToDelete = new HashMap>>(); // map: outputRoot-> setOfPairs([module, isTest]) final Set allSourceRoots = new HashSet(); for (Module module : modulesToClean) { final File out = context.getProjectPaths().getModuleOutputDir(module, false); if (out != null) { - rootsToDelete.add(out); + appendRootInfo(rootsToDelete, out, module, false); } final File testOut = context.getProjectPaths().getModuleOutputDir(module, true); if (testOut != null) { - rootsToDelete.add(testOut); + appendRootInfo(rootsToDelete, testOut, module, true); } final List moduleRoots = context.getModuleRoots(module); for (RootDescriptor d : moduleRoots) { @@ -270,9 +301,10 @@ public class IncProjectBuilder { // check that output and source roots are not overlapping final List filesToDelete = new ArrayList(); - for (File outputRoot : rootsToDelete) { + for (Map.Entry>> entry : rootsToDelete.entrySet()) { context.checkCanceled(); boolean okToDelete = true; + final File outputRoot = entry.getKey(); if (PathUtil.isUnder(allSourceRoots, outputRoot)) { okToDelete = false; } @@ -294,6 +326,10 @@ public class IncProjectBuilder { } else { context.processMessage(new CompilerMessage(COMPILE_SERVER_NAME, BuildMessage.Kind.WARNING, "Output path " + outputRoot.getPath() + " intersects with a source root. The output cannot be cleaned.")); + // clean only those files we are aware of + for (Pair info : entry.getValue()) { + clearOutputFiles(context, info.first, info.second); + } } } @@ -301,6 +337,15 @@ public class IncProjectBuilder { FileUtil.asyncDelete(filesToDelete); } + private static void appendRootInfo(Map>> rootsToDelete, File out, Module module, boolean isTest) { + Set> infos = rootsToDelete.get(out); + if (infos == null) { + infos = new HashSet>(); + rootsToDelete.put(out, infos); + } + infos.add(Pair.create(module.getName(), isTest)); + } + private static void runTasks(CompileContext context, final List tasks) throws ProjectBuildException { for (BuildTask task : tasks) { task.build(context); diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSConstants.java b/platform/core-api/src/com/intellij/openapi/vfs/PersistentFSConstants.java similarity index 97% rename from platform/core-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSConstants.java rename to platform/core-api/src/com/intellij/openapi/vfs/PersistentFSConstants.java index 1f95ac54d3d7..40dc925bb3b1 100644 --- a/platform/core-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSConstants.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/PersistentFSConstants.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.openapi.vfs.newvfs.persistent; +package com.intellij.openapi.vfs; import com.intellij.openapi.application.ApplicationManager; import org.jetbrains.annotations.NonNls; diff --git a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java index af2a1cab97f5..c2fdc2a229f2 100644 --- a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java +++ b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java @@ -34,7 +34,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.openapi.vfs.NonPhysicalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSConstants; +import com.intellij.openapi.vfs.PersistentFSConstants; import com.intellij.psi.impl.PsiFileEx; import com.intellij.psi.impl.PsiManagerEx; import com.intellij.psi.impl.PsiManagerImpl; diff --git a/platform/icons/src/actions/restart.png b/platform/icons/src/actions/restart.png new file mode 100644 index 000000000000..beb592feb05d Binary files /dev/null and b/platform/icons/src/actions/restart.png differ diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java b/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java index 1e121ba7e1ff..1169bf53bc02 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java +++ b/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java @@ -107,6 +107,7 @@ public class InspectionEP extends LanguageExtensionPoint { public String level; public HighlightDisplayLevel getDefaultLevel() { + if (level == null) return HighlightDisplayLevel.WARNING; HighlightDisplayLevel displayLevel = HighlightDisplayLevel.find(level); if (displayLevel == null) { LOG.error("Can't find highlight display level: " + level); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java index aa3a9510ae46..4854888bfc60 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java @@ -292,7 +292,7 @@ public class CompletionServiceImpl extends CompletionService{ return sorter.withClassifier("priority", true, new ClassifierFactory("liftShorter") { @Override public Classifier createClassifier(final Classifier next) { - return new LiftShorterItemsClassifier(next); + return new LiftShorterItemsClassifier(next, new LiftShorterItemsClassifier.LiftingCondition()); } }); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java index 4a05b7758acf..65391ce8e046 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java @@ -30,14 +30,16 @@ import java.util.*; /** * @author peter */ -class LiftShorterItemsClassifier extends Classifier { +public class LiftShorterItemsClassifier extends Classifier { private final TreeSet mySortedStrings; private final MultiMap myElements; private final MultiMap myPrefixes; private final Classifier myNext; + private final LiftingCondition myCondition; - public LiftShorterItemsClassifier(Classifier next) { + public LiftShorterItemsClassifier(Classifier next, LiftingCondition condition) { myNext = next; + myCondition = condition; mySortedStrings = new TreeSet(); myElements = new MultiMap(); myPrefixes = new MultiMap(); @@ -76,9 +78,6 @@ class LiftShorterItemsClassifier extends Classifier { @Override public Iterable classify(Iterable source, ProcessingContext context) { - if (context.get(CompletionLookupArranger.PURE_RELEVANCE) == Boolean.TRUE) { - return myNext.classify(source, context); - } return liftShorterElements(source, new THashSet(TObjectHashingStrategy.IDENTITY), context); } @@ -99,7 +98,7 @@ class LiftShorterItemsClassifier extends Classifier { for (String prefix : prefixes) { List shorter = new SmartList(); for (LookupElement shorterElement : myElements.get(prefix)) { - if (srcSet.contains(shorterElement) && processed.add(shorterElement)) { + if (srcSet.contains(shorterElement) && myCondition.shouldLift(shorterElement, element, context) && processed.add(shorterElement)) { shorter.add(shorterElement); } } @@ -134,4 +133,10 @@ class LiftShorterItemsClassifier extends Classifier { } myNext.describeItems(map, context); } + + public static class LiftingCondition { + public boolean shouldLift(LookupElement shorterElement, LookupElement longerElement, ProcessingContext context) { + return context.get(CompletionLookupArranger.PURE_RELEVANCE) != Boolean.TRUE; + } + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java index 90df114554c5..3d14bdd93c61 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.intention.impl; import com.intellij.codeInsight.lookup.LookupManager; +import com.intellij.codeInsight.template.TemplateManager; import com.intellij.lang.Language; import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.Disposable; @@ -126,7 +127,9 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable { @Override public void update(AnActionEvent e) { Editor editor = PlatformDataKeys.EDITOR.getData(e.getDataContext()); - e.getPresentation().setEnabled(editor != null && LookupManager.getActiveLookup(editor) == null); + e.getPresentation().setEnabled( + editor != null && LookupManager.getActiveLookup(editor) == null && + TemplateManager.getInstance(myProject).getActiveTemplate(editor) == null); } @Override diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java index e995243dd5c5..9571d8ca97da 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java @@ -24,6 +24,7 @@ import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.IconLoader; import javax.swing.*; @@ -31,10 +32,13 @@ import javax.swing.*; * @author dyoma */ public class RestartAction extends AnAction implements DumbAware { + private static final Icon STOP_AND_START_ICON = IconLoader.getIcon("/actions/restart.png"); + private ProcessHandler myProcessHandler; private final ProgramRunner myRunner; private final RunContentDescriptor myDescriptor; private final Executor myExecutor; + private final Icon myIcon; private final ExecutionEnvironment myEnvironment; public RestartAction(final Executor executor, @@ -44,6 +48,7 @@ public class RestartAction extends AnAction implements DumbAware { final RunContentDescriptor descritor, final ExecutionEnvironment env) { super(null, null, icon); + myIcon = icon; myEnvironment = env; getTemplatePresentation().setEnabled(false); myProcessHandler = processHandler; @@ -55,6 +60,7 @@ public class RestartAction extends AnAction implements DumbAware { public void actionPerformed(final AnActionEvent e) { final DataContext dataContext = e.getDataContext(); + ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM).actionPerformed(e); doRestart(dataContext); } @@ -65,7 +71,7 @@ public class RestartAction extends AnAction implements DumbAware { private void doRestart(final DataContext dataContext) { final Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId())) { - return; + return; } try { final ExecutionEnvironment old = myEnvironment; @@ -86,8 +92,9 @@ public class RestartAction extends AnAction implements DumbAware { if (myProcessHandler != null && !isRunning) { myProcessHandler = null; // already terminated } + presentation.setIcon(isRunning ? STOP_AND_START_ICON : myIcon); - presentation.setEnabled(!isRunning /*&& myRunner.canRun(, myProfile)*/ && !ExecutorRegistry.getInstance().isStarting(myEnvironment.getProject(), myExecutor.getId(), myRunner.getRunnerId())); + presentation.setEnabled(true); } public void registerShortcut(final JComponent component) { diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java b/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java index c8bde1879bce..7db150821b82 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java +++ b/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java @@ -32,11 +32,9 @@ public class SmartTreeStructure extends AbstractTreeStructure { public SmartTreeStructure(@NotNull Project project, @NotNull TreeModel model) { myModel = model; myProject = project; - } public void commit() { - PsiDocumentManager.getInstance(myProject).commitAllDocuments(); } @NotNull @@ -54,7 +52,6 @@ public class SmartTreeStructure extends AbstractTreeStructure { public Object getRootElement() { if (myRootElementWrapper == null){ - PsiDocumentManager.getInstance(myProject).commitAllDocuments(); myRootElementWrapper = createTree(); } return myRootElementWrapper; diff --git a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java index 529d7be987b2..183183ed4bea 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueNameEditorTabTitleProvider.java @@ -1,3 +1,18 @@ +/* + * 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.openapi.fileEditor.impl; import com.intellij.ide.ui.UISettings; @@ -15,6 +30,7 @@ public class UniqueNameEditorTabTitleProvider implements EditorTabTitleProvider if (!UISettings.getInstance().SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES || DumbService.isDumb(project)) { return null; } - return UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(project, file); + final String uniqueName = UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(project, file); + return uniqueName.equals(file.getName()) ? null : uniqueName; } } diff --git a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueVFilePathBuilderImpl.java b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueVFilePathBuilderImpl.java index c79e68c04bd6..d9ee50ab9104 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueVFilePathBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/UniqueVFilePathBuilderImpl.java @@ -35,7 +35,7 @@ public class UniqueVFilePathBuilderImpl extends UniqueVFilePathBuilder { public String getUniqueVirtualFilePath(Project project, VirtualFile file) { final Collection filesWithSameName = FilenameIndex.getVirtualFilesByName(project, file.getName(), ProjectScope.getProjectScope(project)); - if (filesWithSameName.size() > 1) { + if (filesWithSameName.size() > 1 && filesWithSameName.contains(file)) { String path = project.getBasePath(); path = path == null ? "" : FileUtil.toSystemIndependentName(path); UniqueNameBuilder builder = new UniqueNameBuilder(path, File.separator, 25); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java index 12ebbbade27a..e05486982f86 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java @@ -39,19 +39,21 @@ public class FileReferenceSet { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet"); private static final FileType[] EMPTY_FILE_TYPES = {}; - private static final char SEPARATOR = '/'; - private static final String SEPARATOR_STRING = "/"; - public static final CustomizableReferenceProvider.CustomizationKey>> DEFAULT_PATH_EVALUATOR_OPTION = - new CustomizableReferenceProvider.CustomizationKey>>(PsiBundle.message("default.path.evaluator.option")); - public static final Function> ABSOLUTE_TOP_LEVEL = new Function>() { - @Override - @Nullable - public Collection fun(final PsiFile file) { - return getAbsoluteTopLevelDirLocations(file); - } - }; - public static final Condition FILE_FILTER = new Condition() { + public static final CustomizableReferenceProvider.CustomizationKey>> + DEFAULT_PATH_EVALUATOR_OPTION = + new CustomizableReferenceProvider.CustomizationKey>>( + PsiBundle.message("default.path.evaluator.option")); + public static final Function> ABSOLUTE_TOP_LEVEL = + new Function>() { + @Override + @Nullable + public Collection fun(final PsiFile file) { + return getAbsoluteTopLevelDirLocations(file); + } + }; + + public static final Condition FILE_FILTER = new Condition() { @Override public boolean value(final PsiFileSystemItem item) { return item instanceof PsiFile; @@ -114,7 +116,14 @@ public class FileReferenceSet { return absoluteUrlNeedsStartSlash() ? "/" + relativePath : relativePath; } - public static FileReferenceSet createSet(PsiElement element, final boolean soft, boolean endingSlashNotAllowed, final boolean urlEncoded) { + public String getSeparatorString() { + return "/"; + } + + public static FileReferenceSet createSet(PsiElement element, + final boolean soft, + boolean endingSlashNotAllowed, + final boolean urlEncoded) { String text; int offset; @@ -202,23 +211,34 @@ public class FileReferenceSet { String str = myPathStringNonTrimmed; final List referencesList = new ArrayList(); + + + String separatorString = getSeparatorString(); // separator's length can be more then 1 char + int sepLen = separatorString.length(); + int currentSlash = -sepLen; + // skip white space - int currentSlash = -1; - while (currentSlash + 1 < str.length() && Character.isWhitespace(str.charAt(currentSlash + 1))) currentSlash++; - if (currentSlash + 1 < str.length() && str.charAt(currentSlash + 1) == SEPARATOR) currentSlash++; + while (currentSlash + sepLen < str.length() && Character.isWhitespace(str.charAt(currentSlash + sepLen))) { + currentSlash++; + } + + if (currentSlash + sepLen + sepLen < str.length() && + str.substring(currentSlash + sepLen, currentSlash + sepLen + sepLen).equals(separatorString)) { + currentSlash+=sepLen; + } int index = 0; - if (str.equals(SEPARATOR_STRING)) { + if (str.equals(separatorString)) { final FileReference fileReference = - createFileReference(new TextRange(myStartInElement, myStartInElement + 1), index++, SEPARATOR_STRING); + createFileReference(new TextRange(myStartInElement, myStartInElement + 1), index++, separatorString); referencesList.add(fileReference); } while (true) { - final int nextSlash = str.indexOf(SEPARATOR, currentSlash + 1); - final String subreferenceText = nextSlash > 0 ? str.substring(currentSlash + 1, nextSlash) : str.substring(currentSlash + 1); + final int nextSlash = str.indexOf(separatorString, currentSlash + sepLen); + final String subreferenceText = nextSlash > 0 ? str.substring(currentSlash + sepLen, nextSlash) : str.substring(currentSlash + sepLen); final FileReference ref = createFileReference( - new TextRange(myStartInElement + currentSlash + 1, myStartInElement + (nextSlash > 0 ? nextSlash : str.length())), + new TextRange(myStartInElement + currentSlash + sepLen, myStartInElement + (nextSlash > 0 ? nextSlash : str.length())), index++, subreferenceText); referencesList.add(ref); @@ -259,7 +279,7 @@ public class FileReferenceSet { public Collection computeDefaultContexts() { final PsiFile file = getContainingFile(); if (file == null) return Collections.emptyList(); - + if (myOptions != null) { final Function> value = DEFAULT_PATH_EVALUATOR_OPTION.getValue(myOptions); @@ -294,7 +314,7 @@ public class FileReferenceSet { private Collection getContextByFile(@NotNull PsiFile file) { final PsiElement context = file.getContext(); if (context != null) file = context.getContainingFile(); - + if (useIncludingFileAsContext()) { final FileContextProvider contextProvider = FileContextProvider.getProvider(file); if (contextProvider != null) { @@ -317,7 +337,7 @@ public class FileReferenceSet { final Project project = file.getProject(); for (FileReferenceHelper helper : helpers) { if (helper.isMine(project, virtualFile)) { - list.addAll(helper.getContexts(project, virtualFile)); + list.addAll(helper.getContexts(project, virtualFile)); } } if (list.size() > 0) { @@ -339,7 +359,7 @@ public class FileReferenceSet { } public boolean isAbsolutePathReference() { - return myPathString.startsWith(SEPARATOR_STRING); + return myPathString.startsWith(getSeparatorString()); } protected boolean useIncludingFileAsContext() { diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexExtension.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexExtension.java index a1b7a8831724..51dc7cc449d0 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexExtension.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexExtension.java @@ -64,7 +64,7 @@ public abstract class FileBasedIndexExtension { * * Use carefully, because indexing large files may influence index update speed dramatically. * - * @see com.intellij.openapi.vfs.newvfs.persistent.PersistentFSConstants#MAX_INTELLISENSE_FILESIZE + * @see com.intellij.openapi.vfs.PersistentFSConstants#MAX_INTELLISENSE_FILESIZE */ @NotNull public Collection getFileTypesWithSizeLimitNotApplicable() { diff --git a/platform/platform-api/src/com/intellij/ide/actions/QuickSwitchSchemeAction.java b/platform/platform-api/src/com/intellij/ide/actions/QuickSwitchSchemeAction.java index c3143fbe55ca..a33a70b482cf 100644 --- a/platform/platform-api/src/com/intellij/ide/actions/QuickSwitchSchemeAction.java +++ b/platform/platform-api/src/com/intellij/ide/actions/QuickSwitchSchemeAction.java @@ -71,7 +71,7 @@ public abstract class QuickSwitchSchemeAction extends AnAction implements DumbAw } protected JBPopupFactory.ActionSelectionAid getAidMethod() { - return JBPopupFactory.ActionSelectionAid.NUMBERING; + return JBPopupFactory.ActionSelectionAid.ALPHA_NUMBERING; } protected String getPopupTitle(AnActionEvent e) { diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java index 9d4b1f4c4315..f22010baa31a 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java +++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java @@ -77,7 +77,7 @@ public interface FileEditor extends UserDataHolder, Disposable { void setState(@NotNull FileEditorState state); /** - * @return whether the editor's content is modified in comparision with its file. + * @return whether the editor's content is modified in comparison with its file. */ boolean isModified(); diff --git a/platform/platform-api/src/com/intellij/ui/AutoScrollToSourceHandler.java b/platform/platform-api/src/com/intellij/ui/AutoScrollToSourceHandler.java index 51e35d615f93..63b41d6aa027 100644 --- a/platform/platform-api/src/com/intellij/ui/AutoScrollToSourceHandler.java +++ b/platform/platform-api/src/com/intellij/ui/AutoScrollToSourceHandler.java @@ -26,6 +26,7 @@ import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.vfs.PersistentFSConstants; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindow; import com.intellij.pom.Navigatable; @@ -179,6 +180,9 @@ public abstract class AutoScrollToSourceHandler { // Attempt to navigate to the virtual file with unknown file type will show a modal dialog // asking to register some file type for this file. This behaviour is undesirable when autoscrolling. if (vFile.getFileType() == FileTypes.UNKNOWN) return; + + //IDEA-84881 Don't autoscroll to very large files + if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return; } Navigatable[] navigatables = PlatformDataKeys.NAVIGATABLE_ARRAY.getData(context); if (navigatables != null) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java index 416e46a6c719..8a75838fcdaf 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java @@ -2069,6 +2069,8 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements * tool window depending on decoration type. */ public void resized(final InternalDecorator source) { + if (!source.isShowing()) return; // do not recalculate the tool window size if it is not yet shown (and, therefore, has 0,0,0,0 bounds) + final WindowInfoImpl info = getInfo(source.getToolWindow().getId()); if (info.isFloating()) { final Window owner = SwingUtilities.getWindowAncestor(source); diff --git a/plugins/git4idea/src/git4idea/actions/GitQuickListContentProvider.java b/plugins/git4idea/src/git4idea/actions/GitQuickListContentProvider.java index a6017f959ddb..4c72d48e355b 100644 --- a/plugins/git4idea/src/git4idea/actions/GitQuickListContentProvider.java +++ b/plugins/git4idea/src/git4idea/actions/GitQuickListContentProvider.java @@ -45,28 +45,23 @@ public class GitQuickListContentProvider implements VcsQuickListContentProvider final ActionManager manager = ActionManager.getInstance(); final List actions = new ArrayList(); - // Basic actions.add(new Separator(activeVcs.getDisplayName())); - add("ChangesView.AddUnversioned", manager, actions); add("CheckinProject", manager, actions); - add("CheckinFiles", manager, actions); add("ChangesView.Rollback", manager, actions); - - // History, Diff - addSeparator(actions); add("Vcs.ShowTabbedFileHistory", manager, actions); add("Annotate", manager, actions); add("Compare.SameVersion", manager, actions); - // Pull/Push addSeparator(actions); add("Git.Branches", manager, actions); + add("Git.Fetch", manager, actions); add("Git.Push", manager, actions); - - // misc add("Git.Stash", manager, actions); add("Git.Unstash", manager, actions); + add("ChangesView.AddUnversioned", manager, actions); + add("Git.ResolveConflicts", manager, actions); + // Github addSeparator(actions); final AnAction githubRebase = manager.getAction("Github.Rebase"); @@ -90,11 +85,11 @@ public class GitQuickListContentProvider implements VcsQuickListContentProvider return true; } - private void addSeparator(@NotNull final List actions) { + private static void addSeparator(@NotNull final List actions) { actions.add(new Separator()); } - private void add(String actionName, ActionManager manager, List actions) { + private static void add(String actionName, ActionManager manager, List actions) { final AnAction action = manager.getAction(actionName); assert action != null; actions.add(action); diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java index 19c3319527da..1f3fc88dd2a2 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java +++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java @@ -608,9 +608,9 @@ public class GitCheckinEnvironment implements CheckinEnvironment { c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; final List usersList = getUsersList(project, roots); - final List authors = usersList == null ? new ArrayList() : new ArrayList(usersList); + final Set authors = usersList == null ? new HashSet() : new HashSet(usersList); ContainerUtil.addAll(authors, mySettings.getCommitAuthors()); - Collections.sort(authors); + Collections.sort(new ArrayList(authors)); myAuthor = new JComboBox(ArrayUtil.toObjectArray(authors)); myAuthor.insertItemAt("", 0); myAuthor.setSelectedItem(""); diff --git a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java index feabdb62c367..c748728f852e 100644 --- a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java +++ b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java @@ -39,7 +39,7 @@ import java.util.Set; /** *

* Stores files which are untracked by the Git repository. - * Should be updated by calling {@link #add(com.intellij.openapi.vfs.VirtualFile)} and {@link #remove(com.intellij.openapi.vfs.VirtualFile)} + * Should be updated by calling {@link #add(com.intellij.openapi.vfs.VirtualFile)} and {@link #remove(java.util.Collection)} * whenever the list of unversioned files changes. * Able to get the list of unversioned files from Git. *

@@ -68,10 +68,18 @@ import java.util.Set; * In some cases (file creation/deletion) the file is not silently added/removed from the list - instead the file is marked as * "possibly untracked" and Git is asked for the exact status of this file. * It is needed, since the file may be created and added to the index independently, and events may race. - *
+ *

+ *

* Also, if .git/index changes, then a full refresh is initiated. The reason is not only untracked files tracking, but also handling * committing outside IDEA, etc. *

+ *

+ * Synchronization policy used in this class:
+ * myDefinitelyUntrackedFiles is accessed under the myDefinitelyUntrackedFiles lock.
+ * myPossiblyUntrackedFiles and myReady is accessed under the LOCK lock.
+ * This is done so, because the latter two variables are accessed from the AWT in after() and we don't want to lock the AWT long, + * while myDefinitelyUntrackedFiles is modified along with native request to Git. + *

* * @author Kirill Likhodedov */ @@ -84,9 +92,8 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener { private final GitRepositoryFiles myRepositoryFiles; private final Git myGit; - private Set myDefinitelyUntrackedFiles = new HashSet(); - private Set myPossiblyUntrackedFiles = new HashSet(); - private Set myPossiblyTrackedFiles = new HashSet(); + private final Set myDefinitelyUntrackedFiles = new HashSet(); + private final Set myPossiblyUntrackedFiles = new HashSet(); private boolean myReady; // if false, total refresh is needed private final Object LOCK = new Object(); private final GitRepositoryManager myRepositoryManager; @@ -112,10 +119,11 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener { @Override public void dispose() { - synchronized (LOCK) { + synchronized (myDefinitelyUntrackedFiles) { myDefinitelyUntrackedFiles.clear(); + } + synchronized (LOCK) { myPossiblyUntrackedFiles.clear(); - myPossiblyTrackedFiles.clear(); } } @@ -123,32 +131,8 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener { * Adds the file to the list of untracked. */ public void add(@NotNull VirtualFile file) { - synchronized (LOCK) { - if (myReady) { - myDefinitelyUntrackedFiles.add(file); - } - } - } - - /** - * Adds several files to the list of untracked. - */ - public void add(@NotNull Collection files) { - synchronized (LOCK) { - if (myReady) { - myDefinitelyUntrackedFiles.addAll(files); - } - } - } - - /** - * Removes the file from untracked. - */ - public void remove(@NotNull VirtualFile file) { - synchronized (LOCK) { - if (myReady) { - myDefinitelyUntrackedFiles.remove(file); - } + synchronized (myDefinitelyUntrackedFiles) { + myDefinitelyUntrackedFiles.add(file); } } @@ -156,10 +140,8 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener { * Removes several files from untracked. */ public void remove(@NotNull Collection files) { - synchronized (LOCK) { - if (myReady) { - myDefinitelyUntrackedFiles.removeAll(files); - } + synchronized (myDefinitelyUntrackedFiles) { + myDefinitelyUntrackedFiles.removeAll(files); } } @@ -176,7 +158,7 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener { } else { rescanAll(); } - synchronized (LOCK) { + synchronized (myDefinitelyUntrackedFiles) { return myDefinitelyUntrackedFiles; } } @@ -192,10 +174,12 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener { */ public void rescanAll() throws VcsException { Set untrackedFiles = myGit.untrackedFiles(myProject, myRoot, null); + synchronized (myDefinitelyUntrackedFiles) { + myDefinitelyUntrackedFiles.clear(); + myDefinitelyUntrackedFiles.addAll(untrackedFiles); + } synchronized (LOCK) { - myDefinitelyUntrackedFiles = untrackedFiles; myPossiblyUntrackedFiles.clear(); - myPossiblyTrackedFiles.clear(); myReady = true; } } @@ -216,17 +200,15 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener { Set suspiciousFiles = new HashSet(); synchronized (LOCK) { suspiciousFiles.addAll(myPossiblyUntrackedFiles); - suspiciousFiles.addAll(myPossiblyTrackedFiles); + myPossiblyUntrackedFiles.clear(); } - Set untrackedFiles = myGit.untrackedFiles(myProject, myRoot, suspiciousFiles); - suspiciousFiles.removeAll(untrackedFiles); - // files that were suspicious (and thus passed to 'git ls-files'), but are not untracked, are definitely tracked. - Set trackedFiles = suspiciousFiles; + synchronized (myDefinitelyUntrackedFiles) { + Set untrackedFiles = myGit.untrackedFiles(myProject, myRoot, suspiciousFiles); + suspiciousFiles.removeAll(untrackedFiles); + // files that were suspicious (and thus passed to 'git ls-files'), but are not untracked, are definitely tracked. + Set trackedFiles = suspiciousFiles; - synchronized (LOCK) { - myPossiblyUntrackedFiles.clear(); - myPossiblyTrackedFiles.clear(); myDefinitelyUntrackedFiles.addAll(untrackedFiles); myDefinitelyUntrackedFiles.removeAll(trackedFiles); } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy index c1a99b1033aa..9dfb4d16ec60 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy @@ -615,6 +615,20 @@ public class Main { shouldFail { compileModule(myModule) } } + public void "test stubs generated while processing groovy class file dependencies"() { + def foo = myFixture.addFileToProject('Foo.groovy', 'class Foo { }') + def bar = myFixture.addFileToProject('Bar.groovy', 'class Bar extends Foo { }') + def client = myFixture.addFileToProject('Client.groovy', 'class Client { Bar bar = new Bar() }') + def java = myFixture.addFileToProject('Java.java', 'class Java extends Client { String getName(Bar bar) { return bar.toString(); } }') + + assertEmpty(make()) + + setFileText(bar, 'class Bar { }') + + assertEmpty(make()) + assert findClassFile("Client") + } + public static class IdeaModeTest extends GroovyCompilerTest { @Override protected boolean useJps() { false } } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java index 84cb5ac129bd..c150655db22c 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java @@ -15,7 +15,6 @@ */ package org.jetbrains.idea.maven; -import com.intellij.compiler.CompilerWorkspaceConfiguration; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; @@ -67,7 +66,6 @@ public abstract class MavenTestCase extends UsefulTestCase { protected VirtualFile myProjectPom; protected List myAllPoms = new ArrayList(); - private boolean myCompileInBackground; static { IdeaTestCase.initPlatformPrefix(); @@ -112,8 +110,6 @@ public abstract class MavenTestCase extends UsefulTestCase { } }); - myCompileInBackground = CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_IN_BACKGROUND; - CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_IN_BACKGROUND = false; } private static void ensureTempDirCreated() { @@ -137,8 +133,6 @@ public abstract class MavenTestCase extends UsefulTestCase { @Override protected void tearDown() throws Exception { - CompilerWorkspaceConfiguration.getInstance(myProject).COMPILE_IN_BACKGROUND = myCompileInBackground; - myProject = null; UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java index 78b8859f0af9..7ddb4d84ba25 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java @@ -300,7 +300,12 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit private final Alarm myUpdateEditorAlarm = new Alarm(); private void selectionChanged() { myBackSlashPressed.clear(); - updateEditorsFromProperties(); + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + updateEditorsFromProperties(); + } + }); } private void updateEditorsFromProperties() { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java index b19d46b823ac..e829de30dae4 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/designSurface/GuiEditor.java @@ -210,10 +210,9 @@ public final class GuiEditor extends JPanel implements DataProvider { * @param file file to be edited * @throws java.lang.IllegalArgumentException * if the file - * is null or file is not falid PsiFile + * is null or file is not valid PsiFile */ public GuiEditor(@NotNull final Module module, @NotNull final VirtualFile file) { - ApplicationManager.getApplication().assertIsDispatchThread(); LOG.assertTrue(file.isValid()); myModule = module; @@ -474,7 +473,9 @@ public final class GuiEditor extends JPanel implements DataProvider { } // Standard Swing cut/copy/paste actions should work if user is editing something inside property inspector - final UIDesignerToolWindowManager manager = UIDesignerToolWindowManager.getInstance(getProject()); + Project project = getProject(); + if (project.isDisposed()) return null; + final UIDesignerToolWindowManager manager = UIDesignerToolWindowManager.getInstance(project); final PropertyInspector inspector = manager.getPropertyInspector(); if (inspector != null && inspector.isEditing()) { return null;