diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java index eeab8ea28473..dbf1ae9d7258 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java @@ -29,6 +29,8 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; @@ -42,6 +44,7 @@ import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.File; import java.lang.reflect.Array; import java.util.*; import java.util.concurrent.Semaphore; @@ -60,6 +63,7 @@ public class CompilerManagerImpl extends CompilerManager { private final Map> myCompilerToInputTypes = new HashMap>(); private final Map> myCompilerToOutputTypes = new HashMap>(); private final Set myValidationDisabledModuleTypes = new HashSet(); + private final Set myWatchRoots; public CompilerManagerImpl(final Project project, CompilerConfigurationImpl compilerConfiguration, MessageBus messageBus) { myProject = project; @@ -82,6 +86,17 @@ public class CompilerManagerImpl extends CompilerManager { } addCompilableFileType(StdFileTypes.JAVA); + + final File projectGeneratedSrcRoot = CompilerPaths.getGeneratedDataDirectory(project); + FileUtil.createIfDoesntExist(projectGeneratedSrcRoot); + final LocalFileSystem lfs = LocalFileSystem.getInstance(); + myWatchRoots = lfs.addRootsToWatch(Collections.singletonList(FileUtil.toCanonicalPath(projectGeneratedSrcRoot.getPath())), true); + Disposer.register(project, new Disposable() { + public void dispose() { + lfs.removeWatchedRoots(myWatchRoots); + } + }); + // //addCompiler(new DummyTransformingCompiler()); // this one is for testing purposes only //addCompiler(new DummySourceGeneratingCompiler(myProject)); // this one is for testing purposes only diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java index 42e9c4cb9ca2..c5cf7931a274 100644 --- a/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java +++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java @@ -70,7 +70,7 @@ public class JavaCoreEnvironment extends CoreEnvironment { myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper()); - myFileManager = new CoreJavaFileManager(myPsiManager, getLocalFileSystem(), myJarFileSystem); + myFileManager = createCoreFileManager(); myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager)); myProject.registerService(JavaPsiImplementationHelper.class, new CoreJavaPsiImplementationHelper()); myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager)); @@ -92,6 +92,10 @@ public class JavaCoreEnvironment extends CoreEnvironment { myApplication.registerService(JavaVersionService.class, new JavaVersionService()); } + protected CoreJavaFileManager createCoreFileManager() { + return new CoreJavaFileManager(myPsiManager, getLocalFileSystem(), myJarFileSystem); + } + public void addToClasspath(File path) { final VirtualFile root = path.isFile() ? myJarFileSystem.findFileByPath(path + "!/") diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java index 10fa441dedc4..e145a713225b 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java +++ b/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java @@ -278,6 +278,14 @@ public abstract class InspectionProfileEntry { return true; } + /** + * @return short name of tool whose results will be used + */ + @Nullable + public String getMainToolId() { + return null; + } + @Nullable public String loadDescription() { final String description = getStaticDescription(); diff --git a/platform/lang-api/src/com/intellij/ui/FileColorManager.java b/platform/lang-api/src/com/intellij/ui/FileColorManager.java index 4f60564760ab..a51549060430 100644 --- a/platform/lang-api/src/com/intellij/ui/FileColorManager.java +++ b/platform/lang-api/src/com/intellij/ui/FileColorManager.java @@ -42,6 +42,8 @@ public abstract class FileColorManager { public abstract boolean isEnabledForProjectView(); + public abstract Project getProject(); + @SuppressWarnings({"MethodMayBeStatic"}) @Nullable public abstract Color getColor(@NotNull String name); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index a81c867b3e40..7a7c661e3dcd 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -63,6 +63,7 @@ import com.intellij.util.containers.HashMap; import com.intellij.util.ui.UIUtil; import gnu.trove.THashMap; import gnu.trove.THashSet; +import gnu.trove.TObjectHashingStrategy; import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -78,6 +79,17 @@ import java.util.Set; public class GlobalInspectionContextImpl extends UserDataHolderBase implements GlobalInspectionContext { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.GlobalInspectionContextImpl"); + private static final TObjectHashingStrategy TOOLS_HASHING_STRATEGY = new TObjectHashingStrategy() { + @Override + public int computeHashCode(ToolsImpl object) { + return object.getShortName().hashCode(); + } + + @Override + public boolean equals(ToolsImpl o1, ToolsImpl o2) { + return o1.getShortName().equals(o2.getShortName()); + } + }; private RefManager myRefManager; private final NotNullLazyValue myContentManager; @@ -142,12 +154,12 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G profile = InspectionProfileManager.getInstance().getProfile(managerEx.getCurrentProfile()); if (profile != null) return (InspectionProfile)profile; - final String[] avaliableProfileNames = inspectionProfileManager.getAvailableProfileNames(); - if (avaliableProfileNames == null || avaliableProfileNames.length == 0) { + final String[] availableProfileNames = inspectionProfileManager.getAvailableProfileNames(); + if (availableProfileNames == null || availableProfileNames.length == 0) { //can't be return null; } - profile = inspectionProfileManager.getProfile(avaliableProfileNames[0]); + profile = inspectionProfileManager.getProfile(availableProfileNames[0]); } return (InspectionProfile)profile; } @@ -702,7 +714,21 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G } protected List getUsedTools() { - return ((InspectionProfileImpl)getCurrentProfile()).getAllEnabledInspectionTools(myProject); + InspectionProfileImpl profile = (InspectionProfileImpl)getCurrentProfile(); + List tools = profile.getAllEnabledInspectionTools(myProject); + THashSet set = null; + for (ToolsImpl tool : tools) { + String id = tool.getTool().getMainToolId(); + if (id != null) { + InspectionProfileEntry mainTool = profile.getInspectionTool(id); + LOG.assertTrue(mainTool != null, "Can't find main tool: " + id); + if (set == null) { + set = new THashSet(tools, TOOLS_HASHING_STRATEGY); + } + set.add(new ToolsImpl(mainTool, mainTool.getDefaultLevel(), true)); + } + } + return set == null ? tools : new ArrayList(set); } private void classifyTool(List outGlobalTools, diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index c3c45db3336f..37a1d1b304d5 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -204,7 +204,7 @@ public class FileStructurePopup implements Disposable { }; //myAbstractTreeBuilder.getUi().setPassthroughMode(true); - myAbstractTreeBuilder.getUi().getUpdater().setDelay(1); + myAbstractTreeBuilder.getUi().getUpdater().setDelay(0); myInitialPsiElement = getCurrentElement(getPsiFile(myProject)); //myAbstractTreeBuilder.setCanYieldUpdate(true); Disposer.register(this, myAbstractTreeBuilder); diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorConfigurationEditDialog.java b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorConfigurationEditDialog.java index 79dd21586975..112b70c17b3b 100644 --- a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorConfigurationEditDialog.java +++ b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorConfigurationEditDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -20,12 +20,14 @@ import com.intellij.notification.impl.ui.StickyButton; import com.intellij.notification.impl.ui.StickyButtonUI; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.search.scope.packageSet.CustomScopesProviderEx; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.search.scope.packageSet.NamedScopeManager; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import com.intellij.ui.ColorChooser; import com.intellij.ui.ColorUtil; +import com.intellij.ui.FileColorManager; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NotNull; @@ -46,12 +48,12 @@ import java.util.List; public class FileColorConfigurationEditDialog extends DialogWrapper { private FileColorConfiguration myConfiguration; private JComboBox myScopeComboBox; - private final FileColorManagerImpl myManager; + private final FileColorManager myManager; private HashMap myColorToButtonMap; private static final String CUSTOM_COLOR_NAME = "Custom"; private final Map myScopeNames = new HashMap(); - public FileColorConfigurationEditDialog(@NotNull final FileColorManagerImpl manager, @Nullable final FileColorConfiguration configuration) { + public FileColorConfigurationEditDialog(@NotNull final FileColorManager manager, @Nullable final FileColorConfiguration configuration) { super(true); setTitle(configuration == null ? "Add color label" : "Edit color label"); @@ -62,9 +64,16 @@ public class FileColorConfigurationEditDialog extends DialogWrapper { init(); updateCustomButton(); + if (myConfiguration != null && !StringUtil.isEmpty(myConfiguration.getScopeName())) { + myScopeComboBox.setSelectedItem(myConfiguration.getScopeName()); + } updateOKButton(); } + public JComboBox getScopeComboBox() { + return myScopeComboBox; + } + @Override protected JComponent createNorthPanel() { final JPanel result = new JPanel(); diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorSettingsTable.java b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorSettingsTable.java index 98e2083d496b..f984c4d09ccd 100644 --- a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorSettingsTable.java +++ b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorSettingsTable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * 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. @@ -31,6 +31,7 @@ import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import java.awt.*; import java.util.ArrayList; +import java.util.EventObject; import java.util.List; /** @@ -42,9 +43,11 @@ public abstract class FileColorSettingsTable extends JBTable { private static final int COLOR_COLUMN = 1; private final List myOriginal; + @NotNull private final FileColorManager myManager; public FileColorSettingsTable(@NotNull final FileColorManager manager, @NotNull final List configurations) { super(new ModelAdapter(manager, copy(configurations))); + myManager = manager; setStriped(true); myOriginal = configurations; @@ -78,6 +81,20 @@ public abstract class FileColorSettingsTable extends JBTable { return (ModelAdapter) super.getModel(); } + @Override + public boolean editCellAt(int row, int column, EventObject e) { + final Object at = getModel().getValueAt(row, column); + final FileColorConfigurationEditDialog dialog = new FileColorConfigurationEditDialog(myManager, ((FileColorConfiguration)at)); + dialog.getScopeComboBox().setEnabled(false); + dialog.show(); + return false; + } + + @Override + public boolean isCellEditable(int row, int column) { + return column == 1; + } + public boolean isModified() { final List current = getModel().getConfigurations(); diff --git a/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java b/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java index f3b2adfe6007..51f67a6d04ca 100644 --- a/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java +++ b/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * 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. @@ -39,7 +39,7 @@ public abstract class CopyPasteManager { public abstract void removeContentChangedListener(ContentChangedListener listener); - public abstract boolean isDataFlavorAvailable(@NotNull DataFlavor flavor); + public abstract boolean isDataFlavorAvailable(@Nullable DataFlavor flavor); @Nullable public abstract Transferable getContents(); diff --git a/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java b/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java index 3657a4a4cf31..d6f998d492be 100644 --- a/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java +++ b/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * 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. @@ -67,8 +67,8 @@ public class CopyPasteManagerEx extends CopyPasteManager implements ClipboardOwn } @Override - public boolean isDataFlavorAvailable(@NotNull DataFlavor flavor) { - return myClipboardSynchronizer.isDataFlavorAvailable(flavor); + public boolean isDataFlavorAvailable(@Nullable DataFlavor flavor) { + return flavor != null && myClipboardSynchronizer.isDataFlavorAvailable(flavor); } public void setContents(@NotNull final Transferable content) { diff --git a/platform/projectModel-impl/src/com/intellij/core/ProjectModelEnvironment.java b/platform/projectModel-impl/src/com/intellij/core/ProjectModelEnvironment.java index 9295351ef723..5fd165a41f17 100644 --- a/platform/projectModel-impl/src/com/intellij/core/ProjectModelEnvironment.java +++ b/platform/projectModel-impl/src/com/intellij/core/ProjectModelEnvironment.java @@ -23,9 +23,11 @@ import com.intellij.openapi.components.ExtensionAreas; import com.intellij.openapi.components.PathMacroManager; import com.intellij.openapi.components.impl.ProjectPathMacroManager; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.fileTypes.FileTypeRegistry; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.roots.impl.*; import com.intellij.openapi.roots.impl.libraries.ApplicationLibraryTable; @@ -56,5 +58,6 @@ public class ProjectModelEnvironment { env.registerProjectComponent(DirectoryIndex.class, index); env.registerProjectComponent(ProjectRootManager.class, new ProjectRootManagerImpl(project, index)); project.registerService(ProjectLibraryTable.class, new ProjectLibraryTable()); + project.registerService(ProjectFileIndex.class, new ProjectFileIndexImpl(project, index, FileTypeRegistry.getInstance())); } }