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 08920390286f..e11132f6bfd1 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -186,6 +186,9 @@ public class CompileDriver { if (validateCompilerConfiguration(scope, false)) { startup(scope, false, false, callback, null, true, false); } + else { + callback.finished(true, 0, 0, DummyCompileContext.getInstance()); + } } public boolean isUpToDate(CompileScope scope) { @@ -247,6 +250,9 @@ public class CompileDriver { if (validateCompilerConfiguration(scope, false)) { startup(scope, false, true, callback, null, true, trackDependencies); } + else { + callback.finished(true, 0, 0, DummyCompileContext.getInstance()); + } } private static class CompileStatus { @@ -327,6 +333,9 @@ public class CompileDriver { if (validateCompilerConfiguration(compileScope, true)) { startup(compileScope, true, false, callback, message, checkCachesVersion, false); } + else { + callback.finished(true, 0, 0, DummyCompileContext.getInstance()); + } } private CompileScope addAdditionalRoots(CompileScope originalScope, final CompilerFilter filter) { diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java index 431e1488d998..444498fcfcbb 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java @@ -520,29 +520,25 @@ public class BackendCompilerWrapper { final List toRefresh = new ArrayList(); final Map> results = new HashMap>(); try { - ApplicationManager.getApplication().runReadAction(new Runnable() { - public void run() { - final FileTypeManager typeManager = FileTypeManager.getInstance(); - final String outputDirPath = outputDir.replace(File.separatorChar, '/'); - try { - for (final Module module : chunk.getModules()) { - for (final VirtualFile root : chunk.getSourceRoots(module)) { - final String packagePrefix = myProjectFileIndex.getPackageNameByDirectory(root); - if (LOG.isDebugEnabled()) { - LOG.debug("Building output items for " + root.getPresentableUrl() + "; output dir = " + outputDirPath + "; packagePrefix = \"" + packagePrefix + "\""); - } - buildOutputItemsList(outputDirPath, module, root, typeManager, root, packagePrefix, toRefresh, results); - } - } - } - catch (CacheCorruptedException e) { - myCompileContext.requestRebuildNextTime(CompilerBundle.message("error.compiler.caches.corrupted")); + final FileTypeManager typeManager = FileTypeManager.getInstance(); + final String outputDirPath = outputDir.replace(File.separatorChar, '/'); + try { + for (final Module module : chunk.getModules()) { + for (final VirtualFile root : chunk.getSourceRoots(module)) { + final String packagePrefix = myProjectFileIndex.getPackageNameByDirectory(root); if (LOG.isDebugEnabled()) { - LOG.debug(e); + LOG.debug("Building output items for " + root.getPresentableUrl() + "; output dir = " + outputDirPath + "; packagePrefix = \"" + packagePrefix + "\""); } + buildOutputItemsList(outputDirPath, module, root, typeManager, root, packagePrefix, toRefresh, results); } } - }); + } + catch (CacheCorruptedException e) { + myCompileContext.requestRebuildNextTime(CompilerBundle.message("error.compiler.caches.corrupted")); + if (LOG.isDebugEnabled()) { + LOG.debug(e); + } + } } finally { CompilerUtil.refreshIOFiles(toRefresh); @@ -617,11 +613,11 @@ public class BackendCompilerWrapper { paths.add(new CompiledClass(classQName, relativePathToSource, pathToClass)); } - private void updateOutputItemsList(final String outputDir, VirtualFile srcFile, + private void updateOutputItemsList(final String outputDir, final VirtualFile srcFile, VirtualFile sourceRoot, final String packagePrefix, final List filesToRefresh, Map> results, - GlobalSearchScope srcRootScope) throws CacheCorruptedException { + final GlobalSearchScope srcRootScope) throws CacheCorruptedException { final Cache newCache = myCompileContext.getDependencyCache().getNewClassesCache(); final Set paths = myFileNameToSourceMap.get(srcFile.getName()); if (paths == null || paths.isEmpty()) { @@ -638,19 +634,24 @@ public class BackendCompilerWrapper { if (!pathsEquals) { final String qName = myCompileContext.getDependencyCache().resolve(cc.qName); if (qName != null) { - final JavaPsiFacade facade = JavaPsiFacade.getInstance(myProject); - PsiClass psiClass = facade.findClass(qName, srcRootScope); - if (psiClass == null) { - final int dollarIndex = qName.indexOf("$"); - if (dollarIndex >= 0) { - final String topLevelClassName = qName.substring(0, dollarIndex); - psiClass = facade.findClass(topLevelClassName, srcRootScope); + pathsEquals = ApplicationManager.getApplication().runReadAction(new Computable() { + public Boolean compute() { + final JavaPsiFacade facade = JavaPsiFacade.getInstance(myProject); + PsiClass psiClass = facade.findClass(qName, srcRootScope); + if (psiClass == null) { + final int dollarIndex = qName.indexOf("$"); + if (dollarIndex >= 0) { + final String topLevelClassName = qName.substring(0, dollarIndex); + psiClass = facade.findClass(topLevelClassName, srcRootScope); + } + } + if (psiClass != null) { + final VirtualFile vFile = psiClass.getContainingFile().getVirtualFile(); + return vFile != null && vFile.equals(srcFile); + } + return false; } - } - if (psiClass != null) { - final VirtualFile vFile = psiClass.getContainingFile().getVirtualFile(); - pathsEquals = vFile != null && vFile.equals(srcFile); - } + }); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java index 7677d5097b5e..1aeb2a43bba8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java @@ -589,7 +589,7 @@ public class BreakpointManager implements JDOMExternalizable { } } - catch (InvalidDataException e) { + catch (InvalidDataException ignored) { } final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME); @@ -827,7 +827,7 @@ public class BreakpointManager implements JDOMExternalizable { //interaction with RequestManagerImpl public void disableBreakpoints(final DebugProcessImpl debugProcess) { final List breakpoints = getBreakpoints(); - if (breakpoints.size() > 0) { + if (!breakpoints.isEmpty()) { final RequestManagerImpl requestManager = debugProcess.getRequestsManager(); for (Breakpoint breakpoint : breakpoints) { breakpoint.markVerified(requestManager.isVerified(breakpoint)); @@ -843,7 +843,7 @@ public class BreakpointManager implements JDOMExternalizable { public void enableBreakpoints(final DebugProcessImpl debugProcess) { final List breakpoints = getBreakpoints(); - if (breakpoints.size() > 0) { + if (!breakpoints.isEmpty()) { for (Breakpoint breakpoint : breakpoints) { breakpoint.markVerified(false); // clean cached state breakpoint.createRequest(debugProcess); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTree.java index 59d027524862..14603acd135e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTree.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTree.java @@ -615,7 +615,7 @@ public class BreakpointTree extends CheckboxTree { // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } if (value instanceof CheckedTreeNode) { final CheckedTreeNode node = (CheckedTreeNode)value; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java index 7ddf469f971b..e7344f03245d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java @@ -415,7 +415,8 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { } private void setupGutterRenderer() { - getHighlighter().setGutterIconRenderer(new MyGutterIconRenderer()); + MyGutterIconRenderer renderer = new MyGutterIconRenderer(getIcon(), getDescription()); + getHighlighter().setGutterIconRenderer(renderer); } public abstract Key getCategory(); @@ -623,13 +624,21 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { } private class MyGutterIconRenderer extends GutterIconRenderer { + private final Icon myIcon; + private final String myDescription; + + public MyGutterIconRenderer(Icon icon, String description) { + myIcon = icon; + myDescription = description; + } + @NotNull public Icon getIcon() { - return BreakpointWithHighlighter.this.getIcon(); + return myIcon; } public String getTooltipText() { - return getDescription(); + return myDescription; } public AnAction getClickAction() { diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java index ac0179ca204d..adf1175a9ad0 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/DownloadingOptionsDialog.java @@ -21,6 +21,7 @@ import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.roots.ui.configuration.libraries.LibraryDownloadDescription; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.ui.CheckBoxList; import com.intellij.ui.CollectionListModel; import com.intellij.util.Function; @@ -68,7 +69,7 @@ public class DownloadingOptionsDialog extends DialogWrapper { FileChooserDescriptorFactory.createSingleFolderDescriptor()); myCopyDownloadedFilesToLabel.setLabelFor(myDirectoryField); - myDirectoryField.setText(settings.getDirectoryForDownloadedLibrariesPath()); + myDirectoryField.setText(FileUtil.toSystemDependentName(settings.getDirectoryForDownloadedLibrariesPath())); myDownloadSourcesCheckBox.setSelected(settings.isDownloadSources()); myDownloadJavadocsCheckBox.setSelected(settings.isDownloadJavadocs()); @@ -92,7 +93,7 @@ public class DownloadingOptionsDialog extends DialogWrapper { protected void doOKAction() { mySettings.setLibraryName(myNameAndLevelPanel.getLibraryName()); mySettings.setLibraryLevel(myNameAndLevelPanel.getLibraryLevel()); - mySettings.setDirectoryForDownloadedLibrariesPath(myDirectoryField.getText()); + mySettings.setDirectoryForDownloadedLibrariesPath(FileUtil.toSystemIndependentName(myDirectoryField.getText())); List selected = new ArrayList(); List downloads = myDownloadDescription.getDownloads(); diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java index f8c16e806d0e..1c950688d919 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryCompositionSettings.java @@ -108,9 +108,8 @@ public class LibraryCompositionSettings implements Disposable { @Nullable private Library createLibrary(final ModifiableRootModel rootModel, @Nullable LibrariesContainer additionalContainer) { if (myNewLibraryEditor != null) { - VirtualFile[] roots = myNewLibraryEditor.getFiles(OrderRootType.CLASSES); return LibrariesContainerFactory.createLibrary(additionalContainer, LibrariesContainerFactory.createContainer(rootModel), - myNewLibraryEditor.getName(), getLibraryLevel(), roots, VirtualFile.EMPTY_ARRAY); + myNewLibraryEditor, getLibraryLevel()); } return null; } diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloadSettings.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloadSettings.java index 791c948c1f30..f7a556a7f51f 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloadSettings.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryDownloadSettings.java @@ -21,7 +21,6 @@ import com.intellij.openapi.roots.ui.configuration.libraries.LibraryDownloadDesc import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor; import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer; import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -31,7 +30,6 @@ import java.util.List; * @author nik */ public class LibraryDownloadSettings { - @NonNls private static final String DEFAULT_LIB_FOLDER = "lib"; private final LibraryDownloadDescription myDescription; private String myDirectoryForDownloadedLibrariesPath; private String myLibraryName; @@ -42,7 +40,7 @@ public class LibraryDownloadSettings { public LibraryDownloadSettings(LibraryDownloadDescription description, String baseDirectoryForDownloadedFiles) { myDescription = description; - myDirectoryForDownloadedLibrariesPath = baseDirectoryForDownloadedFiles + "/" + DEFAULT_LIB_FOLDER; + myDirectoryForDownloadedLibrariesPath = baseDirectoryForDownloadedFiles + "/lib"; myLibraryName = description.getDefaultLibraryName(); mySelectedDownloads = description.getDownloads(); } diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java index b32bccae6445..9c95ff739ef4 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java @@ -45,7 +45,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.io.File; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; @@ -260,7 +259,7 @@ public class LibraryOptionsPanel { final String basePath = mySettings.getBaseDirectoryPath(); String path; if (!StringUtil.isEmpty(basePath) && FileUtil.startsWith(downloadPath, basePath)) { - path = FileUtil.getRelativePath(basePath, downloadPath, File.separatorChar); + path = FileUtil.getRelativePath(basePath, downloadPath, '/'); } else { path = PathUtil.getFileName(downloadPath); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java index 046e26fdc72e..293cde8ab466 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java @@ -235,9 +235,9 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel { final JButton addButton = new JButton(ProjectBundle.message("button.add")); final JButton removeButton = new JButton(ProjectBundle.message("button.remove")); - myEditButton = new JButton(ProjectBundle.message("button.edit")); - final JButton upButton = new JButton(ProjectBundle.message("button.move.up")); - final JButton downButton = new JButton(ProjectBundle.message("button.move.down")); + myEditButton = new JButton(ProjectBundle.message("module.classpath.button.edit")); + final JButton upButton = new JButton(ProjectBundle.message("module.classpath.button.move.up")); + final JButton downButton = new JButton(ProjectBundle.message("module.classpath.button.move.down")); final JButton analyzeButton = isAnalyzeShown ? new JButton(ProjectBundle.message("classpath.panel.analyze")) : null; final JPanel panel = new JPanel(new GridBagLayout()); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java index 1e00ecdfd78d..1f4c51957948 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryPresentationManagerImpl.java @@ -17,6 +17,7 @@ package com.intellij.openapi.roots.ui.configuration.libraries.impl; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.libraries.*; import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager; import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext; @@ -124,6 +125,9 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager { @NotNull private static VirtualFile[] getLibraryFiles(@NotNull Library library, @Nullable StructureConfigurableContext context) { + if (((LibraryEx)library).isDisposed()) { + return VirtualFile.EMPTY_ARRAY; + } return context != null ? context.getLibraryFiles(library, OrderRootType.CLASSES) : library.getFiles(OrderRootType.CLASSES); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java index 6f448fc6506d..d4a48d5b0ff0 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java @@ -126,6 +126,10 @@ public class NewLibraryEditor implements LibraryEditor { public void apply(@NotNull Library.ModifiableModel model) { model.setName(myLibraryName); + applyRoots(model); + } + + public void applyRoots(Library.ModifiableModel model) { for (OrderRootType type : myRoots.keySet()) { for (LightFilePointer pointer : myRoots.get(type)) { model.addRoot(pointer.getUrl(), type); @@ -135,4 +139,15 @@ public class NewLibraryEditor implements LibraryEditor { model.addJarDirectory(entry.getKey(), entry.getValue()); } } + + public void copyRoots(ExistingLibraryEditor editor) { + for (OrderRootType type : myRoots.keySet()) { + for (LightFilePointer pointer : myRoots.get(type)) { + editor.addRoot(pointer.getUrl(), type); + } + } + for (Map.Entry entry : myJarDirectories.entrySet()) { + editor.addJarDirectory(entry.getKey(), entry.getValue()); + } + } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainer.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainer.java index 39a98803bef9..3b0b23719f61 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainer.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainer.java @@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor; +import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; @@ -54,6 +55,8 @@ public interface LibrariesContainer { Library createLibrary(@NotNull @NonNls String name, @NotNull LibraryLevel level, @NotNull VirtualFile[] classRoots, @NotNull VirtualFile[] sourceRoots); + Library createLibrary(@NotNull NewLibraryEditor libraryEditor, @NotNull LibraryLevel level); + @NotNull String suggestUniqueLibraryName(@NotNull String baseName); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java index a14670142748..f8444ad44229 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/LibrariesContainerFactory.java @@ -25,6 +25,7 @@ import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; import com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider; import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor; import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor; +import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor; import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; @@ -72,27 +73,21 @@ public class LibrariesContainerFactory { } public static Library createLibrary(@Nullable LibrariesContainer container1, @NotNull LibrariesContainer container2, - @NotNull @NonNls final String name, @NotNull final LibrariesContainer.LibraryLevel level, - @NotNull final VirtualFile[] classRoots, @NotNull final VirtualFile[] sourceRoots) { + @NotNull @NonNls final NewLibraryEditor editor, @NotNull final LibrariesContainer.LibraryLevel level) { if (container1 != null && container1.canCreateLibrary(level)) { - return container1.createLibrary(name, level, classRoots, sourceRoots); + return container1.createLibrary(editor, level); } else { - return container2.createLibrary(name, level, classRoots, sourceRoots); + return container2.createLibrary(editor, level); } } @NotNull - public static Library createLibraryInTable(final @NonNls String name, final VirtualFile[] roots, final VirtualFile[] sources, final LibraryTable table) { + private static Library createLibraryInTable(final @NotNull NewLibraryEditor editor, final LibraryTable table) { LibraryTable.ModifiableModel modifiableModel = table.getModifiableModel(); - Library library = modifiableModel.createLibrary(getUniqueLibraryName(name, modifiableModel)); + Library library = modifiableModel.createLibrary(getUniqueLibraryName(editor.getName(), modifiableModel)); final Library.ModifiableModel model = library.getModifiableModel(); - for (VirtualFile root : roots) { - model.addRoot(root, OrderRootType.CLASSES); - } - for (VirtualFile root : sources) { - model.addRoot(root, OrderRootType.SOURCES); - } + editor.applyRoots(model); model.commit(); modifiableModel.commit(); return library; @@ -111,6 +106,22 @@ public class LibrariesContainerFactory { private abstract static class LibrariesContainerBase implements LibrariesContainer { private UniqueNameGenerator myNameGenerator; + @Override + public Library createLibrary(@NotNull @NonNls String name, + @NotNull LibraryLevel level, + @NotNull VirtualFile[] classRoots, + @NotNull VirtualFile[] sourceRoots) { + NewLibraryEditor editor = new NewLibraryEditor(); + editor.setName(name); + for (VirtualFile classRoot : classRoots) { + editor.addRoot(classRoot, OrderRootType.CLASSES); + } + for (VirtualFile sourceRoot : sourceRoots) { + editor.addRoot(sourceRoot, OrderRootType.SOURCES); + } + return createLibrary(editor, level); + } + @NotNull public Library[] getAllLibraries() { Library[] libraries = getLibraries(LibraryLevel.GLOBAL); @@ -204,10 +215,11 @@ public class LibrariesContainerFactory { return level == LibraryLevel.GLOBAL || myProject != null; } - public Library createLibrary(@NotNull @NonNls final String name, @NotNull final LibraryLevel level, - @NotNull final VirtualFile[] classRoots, @NotNull final VirtualFile[] sourceRoots) { + @Override + public Library createLibrary(@NotNull NewLibraryEditor libraryEditor, + @NotNull LibraryLevel level) { if (level == LibraryLevel.MODULE && myRootModel != null) { - return createLibraryInTable(name, classRoots, sourceRoots, myRootModel.getModuleLibraryTable()); + return createLibraryInTable(libraryEditor, myRootModel.getModuleLibraryTable()); } LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance(); @@ -221,7 +233,7 @@ public class LibrariesContainerFactory { else { return null; } - return createLibraryInTable(name, classRoots, sourceRoots, table); + return createLibraryInTable(libraryEditor, table); } @Override @@ -239,22 +251,18 @@ public class LibrariesContainerFactory { myContext = context; } - public Library createLibrary(@NotNull @NonNls final String name, @NotNull final LibraryLevel level, - @NotNull final VirtualFile[] classRoots, @NotNull final VirtualFile[] sourceRoots) { + @Override + public Library createLibrary(@NotNull NewLibraryEditor libraryEditor, + @NotNull LibraryLevel level) { LibraryTableModifiableModelProvider provider = getProvider(level); if (provider == null) { LOG.error("cannot create module library in this context"); } LibraryTable.ModifiableModel model = provider.getModifiableModel(); - Library library = model.createLibrary(getUniqueLibraryName(name, model)); - LibraryEditor libraryEditor = ((LibrariesModifiableModel)model).getLibraryEditor(library); - for (VirtualFile root : classRoots) { - libraryEditor.addRoot(root, OrderRootType.CLASSES); - } - for (VirtualFile source : sourceRoots) { - libraryEditor.addRoot(source, OrderRootType.SOURCES); - } + Library library = model.createLibrary(getUniqueLibraryName(libraryEditor.getName(), model)); + ExistingLibraryEditor createdLibraryEditor = ((LibrariesModifiableModel)model).getLibraryEditor(library); + libraryEditor.copyRoots(createdLibraryEditor); return library; } diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml index 54da7ac1d6cc..72169b16647d 100644 --- a/java/java-impl/java-impl.iml +++ b/java/java-impl/java-impl.iml @@ -26,6 +26,7 @@ + diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java index 7c31781da094..60a1d906305c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java @@ -31,6 +31,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.highlighter.HighlighterIterator; +import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Computable; @@ -177,7 +178,16 @@ public class JavaCompletionContributor extends CompletionContributor { final PsiElement lastElement = file.findElementAt(offset - 1); final JavaAwareCompletionData completionData = ApplicationManager.getApplication().runReadAction(new Computable() { public JavaAwareCompletionData compute() { - return getCompletionDataByElementInner(lastElement); + if (lastElement != null) { + if (!lastElement.isValid()) { + throw new ProcessCanceledException(); + } + if (PsiUtil.isLanguageLevel5OrHigher(lastElement)) { + return ourJava15CompletionData; + } + } + + return ourJavaCompletionData; } }); @@ -351,10 +361,6 @@ public class JavaCompletionContributor extends CompletionContributor { } } - private static JavaAwareCompletionData getCompletionDataByElementInner(PsiElement element) { - return element != null && PsiUtil.isLanguageLevel5OrHigher(element) ? ourJava15CompletionData : ourJavaCompletionData; - } - public String advertise(@NotNull final CompletionParameters parameters) { if (!(parameters.getOriginalFile() instanceof PsiJavaFile)) return null; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/GroovyScriptMacro.java b/java/java-impl/src/com/intellij/codeInsight/template/macro/GroovyScriptMacro.java similarity index 100% rename from platform/lang-impl/src/com/intellij/codeInsight/template/macro/GroovyScriptMacro.java rename to java/java-impl/src/com/intellij/codeInsight/template/macro/GroovyScriptMacro.java diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java index da2f66971478..8a13f5ff8398 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java @@ -20,6 +20,7 @@ import com.intellij.codeInspection.*; import com.intellij.ide.fileTemplates.FileTemplate; import com.intellij.ide.fileTemplates.FileTemplateManager; import com.intellij.ide.fileTemplates.JavaTemplateUtil; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; @@ -113,26 +114,35 @@ class CatchBodyVisitor extends JavaRecursiveElementWalkingVisitor { private static LocalQuickFix[] createQuickFix(final PsiCatchSection section) { FileTemplate template = FileTemplateManager.getInstance().getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY); + final Runnable runnable = new Runnable() { + public void run() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + final PsiParameter parameter = section.getParameter(); + if (parameter == null) return; + PsiCodeBlock catchBlock = section.getCatchBlock(); + if (catchBlock == null) return; + PsiType type = parameter.getType(); + if (!(type instanceof PsiClassType)) return; + final PsiJavaParserFacade elementFactory = JavaPsiFacade.getInstance(section.getProject()).getParserFacade(); + try { + PsiCatchSection sectionTemplate = elementFactory.createCatchSection((PsiClassType)type, parameter.getName(), parameter); + section.replace(sectionTemplate); + } + catch (IncorrectOperationException e) { + LOG.error(e); + } + } + }); + } + }; + ReplaceWithFileTemplateFix replaceWithFileTemplateFix = new ReplaceWithFileTemplateFix() { public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - final PsiParameter parameter = section.getParameter(); - if (parameter == null) return; - PsiCodeBlock catchBlock = section.getCatchBlock(); - if (catchBlock == null) return; - PsiType type = parameter.getType(); - if (!(type instanceof PsiClassType)) return; - final PsiJavaParserFacade elementFactory = JavaPsiFacade.getInstance(section.getProject()).getParserFacade(); - try { - PsiCatchSection sectionTemplate = elementFactory.createCatchSection((PsiClassType)type, parameter.getName(), parameter); - section.replace(sectionTemplate); - } - catch (IncorrectOperationException e) { - LOG.error(e); - } + runnable.run(); } - }; - LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, replaceWithFileTemplateFix); + LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, runnable); if (template.isDefault()) { return new LocalQuickFix[]{editFileTemplateFix}; } diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java index d1156a131a07..256265b2e5ea 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java @@ -15,14 +15,17 @@ */ package com.intellij.codeInspection.defaultFileTemplateUsage; +import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.*; import com.intellij.ide.fileTemplates.FileTemplate; import com.intellij.ide.fileTemplates.FileTemplateManager; import com.intellij.ide.fileTemplates.impl.FileTemplateConfigurable; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.options.ShowSettingsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; +import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -119,31 +122,62 @@ public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionT return new InspectionOptions(this).getComponent(); } - public static LocalQuickFix createEditFileTemplateFix(final FileTemplate templateToEdit, final LocalQuickFix replaceTemplateFix) { - return new LocalQuickFix() { - @NotNull - public String getName() { - return InspectionsBundle.message("default.file.template.edit.template"); - } + public static LocalQuickFix createEditFileTemplateFix(final FileTemplate templateToEdit, final Runnable replaceTemplateFix) { + return new MyLocalQuickFix(templateToEdit, replaceTemplateFix); + } - @NotNull - public String getFamilyName() { - return getName(); - } + private static class MyLocalQuickFix implements LocalQuickFix, IntentionAction { + private final FileTemplate myTemplateToEdit; + private final Runnable myReplaceTemplateFix; - public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - final FileTemplateConfigurable configurable = new FileTemplateConfigurable(); - SwingUtilities.invokeLater(new Runnable(){ - public void run() { - configurable.setTemplate(templateToEdit, null); - } - }); - boolean ok = ShowSettingsUtil.getInstance().editConfigurable(project, configurable); - if (ok) { - replaceTemplateFix.applyFix(project, descriptor); - FileTemplateManager.getInstance().saveAll(); + public MyLocalQuickFix(FileTemplate templateToEdit, Runnable replaceTemplateFix) { + myTemplateToEdit = templateToEdit; + myReplaceTemplateFix = replaceTemplateFix; + } + + @NotNull + public String getName() { + return InspectionsBundle.message("default.file.template.edit.template"); + } + + @NotNull + public String getFamilyName() { + return getName(); + } + + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { + invoke(project, null, null); + } + + @NotNull + @Override + public String getText() { + return getName(); + } + + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + return true; + } + + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + final FileTemplateConfigurable configurable = new FileTemplateConfigurable(); + SwingUtilities.invokeLater(new Runnable(){ + public void run() { + configurable.setTemplate(myTemplateToEdit, null); } + }); + boolean ok = ShowSettingsUtil.getInstance().editConfigurable(project, configurable); + if (ok) { + myReplaceTemplateFix.run(); + FileTemplateManager.getInstance().saveAll(); } - }; + } + + @Override + public boolean startInWriteAction() { + return false; + } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java index 56c9251fa0c4..9096ae84e829 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.CodeInsightUtil; import com.intellij.codeInspection.*; import com.intellij.ide.fileTemplates.FileTemplate; import com.intellij.ide.fileTemplates.FileTemplateManager; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; @@ -82,61 +83,70 @@ public class FileHeaderChecker { return null; } + private static Properties computeProperties(final Matcher matcher, final TIntObjectHashMap offsetToProperty) { + Properties properties = new Properties(FileTemplateManager.getInstance().getDefaultProperties()); + int[] offsets = offsetToProperty.keys(); + Arrays.sort(offsets); + + for (int i = 0; i < offsets.length; i++) { + final int offset = offsets[i]; + String propName = offsetToProperty.get(offset); + int groupNum = i + 2; // first group is whole doc comment + String propValue = matcher.group(groupNum); + properties.put(propName, propValue); + } + return properties; + } + private static LocalQuickFix[] createQuickFix(final PsiDocComment element, final Matcher matcher, final TIntObjectHashMap offsetToProperty) { final FileTemplate template = FileTemplateManager.getInstance().getPattern(FileTemplateManager.FILE_HEADER_TEMPLATE_NAME); - final ReplaceWithFileTemplateFix replaceTemplateFix = new ReplaceWithFileTemplateFix() { - public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - if (!element.isValid()) return; - if (!CodeInsightUtil.preparePsiElementsForWrite(element)) return; - String newText; - try { - newText = template.getText(computeProperties(matcher, offsetToProperty)); - } - catch (IOException e) { - LOG.error(e); - return; - } - try { - int offset = element.getTextRange().getStartOffset(); - PsiFile psiFile = element.getContainingFile(); - if (psiFile == null) return; - PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); - Document document = documentManager.getDocument(psiFile); - if (document == null) return; + final Runnable runnable = new Runnable() { + public void run() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + if (!element.isValid()) return; + if (!CodeInsightUtil.preparePsiElementsForWrite(element)) return; + String newText; + try { + newText = template.getText(computeProperties(matcher, offsetToProperty)); + } + catch (IOException e) { + LOG.error(e); + return; + } + try { + int offset = element.getTextRange().getStartOffset(); + PsiFile psiFile = element.getContainingFile(); + if (psiFile == null) return; + PsiDocumentManager documentManager = PsiDocumentManager.getInstance(psiFile.getProject()); + Document document = documentManager.getDocument(psiFile); + if (document == null) return; - element.delete(); - documentManager.doPostponedOperationsAndUnblockDocument(document); - documentManager.commitDocument(document); + element.delete(); + documentManager.doPostponedOperationsAndUnblockDocument(document); + documentManager.commitDocument(document); - document.insertString(offset, newText); - } - catch (IncorrectOperationException e) { - LOG.error(e); - } - catch (IllegalStateException e) { - LOG.error("Cannot create doc comment from text: '"+newText+"'",e); - } - } - - private Properties computeProperties(final Matcher matcher, final TIntObjectHashMap offsetToProperty) { - Properties properties = new Properties(FileTemplateManager.getInstance().getDefaultProperties()); - int[] offsets = offsetToProperty.keys(); - Arrays.sort(offsets); - - for (int i = 0; i < offsets.length; i++) { - final int offset = offsets[i]; - String propName = offsetToProperty.get(offset); - int groupNum = i + 2; // first group is whole doc comment - String propValue = matcher.group(groupNum); - properties.put(propName, propValue); - } - - return properties; + document.insertString(offset, newText); + } + catch (IncorrectOperationException e) { + LOG.error(e); + } + catch (IllegalStateException e) { + LOG.error("Cannot create doc comment from text: '" + newText + "'", e); + } + } + }); } }; - final LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, replaceTemplateFix); + + final ReplaceWithFileTemplateFix replaceTemplateFix = new ReplaceWithFileTemplateFix() { + public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) { + runnable.run(); + } + }; + final LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, runnable); if (template.isDefault()) { return new LocalQuickFix[]{editFileTemplateFix}; } diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java index 2a99d957e10f..3d060bf487a2 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java @@ -23,6 +23,7 @@ import com.intellij.codeInspection.*; import com.intellij.ide.fileTemplates.FileTemplate; import com.intellij.ide.fileTemplates.FileTemplateManager; import com.intellij.ide.fileTemplates.JavaTemplateUtil; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; @@ -168,31 +169,40 @@ public class MethodBodyChecker { return null; } - final ReplaceWithFileTemplateFix replaceWithFileTemplateFix = new ReplaceWithFileTemplateFix() { - public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - PsiType returnType = method.getReturnType(); - if (method.isConstructor() || returnType == null) return; - PsiCodeBlock body = method.getBody(); - if (body == null) return; - if (!CodeInsightUtil.preparePsiElementsForWrite(body)) return; - PsiClass aClass = method.getContainingClass(); - if (aClass == null) return; - List superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures(); - try { - PsiMethod templateMethod = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createMethod("x", returnType); - setupMethodBody(superSignatures, templateMethod, aClass, false); - final PsiCodeBlock templateBody = templateMethod.getBody(); - if (templateBody == null) return; + final Runnable runnable = new Runnable() { + public void run() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + PsiType returnType = method.getReturnType(); + if (method.isConstructor() || returnType == null) return; + PsiCodeBlock body = method.getBody(); + if (body == null) return; + if (!CodeInsightUtil.preparePsiElementsForWrite(body)) return; + PsiClass aClass = method.getContainingClass(); + if (aClass == null) return; + List superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures(); + try { + PsiMethod templateMethod = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createMethod("x", returnType); + setupMethodBody(superSignatures, templateMethod, aClass, false); + final PsiCodeBlock templateBody = templateMethod.getBody(); + if (templateBody == null) return; - PsiElement newBody = body.replace(templateBody); - CodeStyleManager.getInstance(project).reformat(newBody); - } - catch (IncorrectOperationException e) { - LOG.error(e); - } + PsiElement newBody = body.replace(templateBody); + CodeStyleManager.getInstance(aClass.getManager()).reformat(newBody); + } + catch (IncorrectOperationException e) { + LOG.error(e); + } + } + }); } }; - LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, replaceWithFileTemplateFix); + final ReplaceWithFileTemplateFix replaceWithFileTemplateFix = new ReplaceWithFileTemplateFix() { + public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) { + runnable.run(); + } + }; + LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, runnable); if (template != null && template.isDefault()) { return new LocalQuickFix[]{editFileTemplateFix}; } diff --git a/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspection.java index 513fd7296133..f85f171eb3bf 100644 --- a/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/unusedSymbol/UnusedSymbolLocalInspection.java @@ -26,12 +26,19 @@ import com.intellij.codeInspection.BaseJavaLocalInspectionTool; import com.intellij.codeInspection.ex.UnfairLocalInspectionTool; import com.intellij.codeInspection.reference.EntryPoint; import com.intellij.codeInspection.util.SpecialAnnotationsUtil; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.extensions.ExtensionPoint; +import com.intellij.openapi.extensions.ExtensionPointListener; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.extensions.PluginDescriptor; import com.intellij.openapi.util.JDOMExternalizableStringList; +import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiModifierListOwner; import com.intellij.psi.util.PropertyUtil; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.ui.UIUtil; +import gnu.trove.THashSet; import org.intellij.lang.annotations.Pattern; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -49,7 +56,7 @@ import java.util.List; * Date: 17-Feb-2006 */ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool implements UnfairLocalInspectionTool { - private static final Collection STANDARD_INJECTION_ANNOS = Collections.unmodifiableCollection(new HashSet(Arrays.asList( + private static final Collection STANDARD_INJECTION_ANNOS = Collections.unmodifiableCollection(new THashSet(Arrays.asList( "javax.annotation.Resource", "javax.ejb.EJB", "javax.xml.ws.WebServiceRef", @@ -70,6 +77,28 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp public boolean REPORT_PARAMETER_FOR_PUBLIC_METHODS = true; public JDOMExternalizableStringList INJECTION_ANNOS = new JDOMExternalizableStringList(); + static { + final ExtensionPoint point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.DEAD_CODE_TOOL); + point.addExtensionPointListener(new ExtensionPointListener() { + @Override + public void extensionAdded(@NotNull EntryPoint extension, @Nullable PluginDescriptor pluginDescriptor) { + extensionRemoved(extension, pluginDescriptor); + } + + @Override + public void extensionRemoved(@NotNull EntryPoint extension, @Nullable PluginDescriptor pluginDescriptor) { + ANNOTATIONS = null; + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + if (ApplicationManager.getApplication().isDisposed()) return; + InspectionProfileManager.getInstance().fireProfileChanged(null); + } + }); + } + }); + } + @NotNull public String getGroupDisplayName() { return GroupNames.DECLARATION_REDUNDANCY; @@ -113,7 +142,6 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp private JPanel myPanel; public OptionsPanel() { - myCheckLocalVariablesCheckBox.setSelected(LOCAL_VARIABLE); myCheckClassesCheckBox.setSelected(CLASS); myCheckFieldsCheckBox.setSelected(FIELD); @@ -169,8 +197,9 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp List annotations = ANNOTATIONS; if (annotations == null) { annotations = new ArrayList(); - for (Object extension : Extensions.getExtensions(ExtensionPoints.DEAD_CODE_TOOL)) { - final String[] ignoredAnnotations = ((EntryPoint)extension).getIgnoreAnnotations(); + EntryPoint[] extensions = Extensions.getExtensions(ExtensionPoints.DEAD_CODE_TOOL, null); + for (EntryPoint extension : extensions) { + final String[] ignoredAnnotations = extension.getIgnoreAnnotations(); if (ignoredAnnotations != null) { ContainerUtil.addAll(annotations, ignoredAnnotations); } diff --git a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java index e01309644010..ea368ffc712b 100644 --- a/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java +++ b/java/java-impl/src/com/intellij/find/findUsages/JavaFindUsagesHandler.java @@ -602,7 +602,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{ final PsiClass parentClass = method.getContainingClass(); if (parentClass != null) { - MethodReferencesSearch.search(new MethodReferencesSearch.SearchParameters(method, searchScope, !((JavaMethodFindUsagesOptions)options).isIncludeOverloadUsages, options.fastTrack)).forEach(new ReadActionProcessor() { + MethodReferencesSearch.search(new MethodReferencesSearch.SearchParameters(method, searchScope, options instanceof JavaMethodFindUsagesOptions ? !((JavaMethodFindUsagesOptions)options).isIncludeOverloadUsages : true, options.fastTrack)).forEach(new ReadActionProcessor() { public boolean processInReadAction(final PsiReference ref) { return addResult(result, ref, options); } diff --git a/java/java-impl/src/com/intellij/ide/JavaFilePasteProvider.java b/java/java-impl/src/com/intellij/ide/JavaFilePasteProvider.java index 599dd6aa4fe6..79416038cddf 100644 --- a/java/java-impl/src/com/intellij/ide/JavaFilePasteProvider.java +++ b/java/java-impl/src/com/intellij/ide/JavaFilePasteProvider.java @@ -18,8 +18,9 @@ package com.intellij.ide; import com.intellij.lang.StdLanguages; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataKeys; -import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.Result; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.ide.CopyPasteManager; @@ -47,8 +48,10 @@ public class JavaFilePasteProvider implements PasteProvider { if (classes.length != 1) return; final PsiDirectory targetDir = ideView.getOrChooseDirectory(); if (targetDir == null) return; - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { + + new WriteCommandAction(project, "Paste class '" + classes[0].getName() + "'") { + @Override + protected void run(Result result) throws Throwable { PsiFile file; try { file = targetDir.createFile(classes[0].getName() + ".java"); @@ -64,7 +67,7 @@ public class JavaFilePasteProvider implements PasteProvider { } new OpenFileDescriptor(project, file.getVirtualFile()).navigate(true); } - }); + }.execute(); } private static void updatePackageStatement(final PsiJavaFile javaFile, final PsiDirectory targetDir) { diff --git a/java/java-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java b/java/java-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java index 726c59ad1fa4..478cabdfdaa4 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java @@ -51,10 +51,12 @@ public class JavaFileElementType extends IStubFileElementType { super("java.FILE", StdLanguages.JAVA); } + @Override public StubBuilder getBuilder() { return new JavaFileStubBuilder(); } + @Override public int getStubVersion() { return STUB_VERSION; } @@ -65,6 +67,7 @@ public class JavaFileElementType extends IStubFileElementType { return dir == null || dir.getUserData(LanguageLevel.KEY) != null; } + @Override public ASTNode parseContents(final ASTNode chameleon) { if (JavaParserDefinition.USE_NEW_PARSER) { final PsiBuilder builder = JavaParserUtil.createBuilder(chameleon); @@ -84,22 +87,26 @@ public class JavaFileElementType extends IStubFileElementType { return FileTextParsing.parseFileText(manager, lexer, seq, 0, seq.length(), node.getCharTable()); } + @Override public String getExternalId() { return "java.FILE"; } + @Override public void serialize(final PsiJavaFileStub stub, final StubOutputStream dataStream) throws IOException { dataStream.writeBoolean(stub.isCompiled()); dataStream.writeName(stub.getPackageName()); } + @Override public PsiJavaFileStub deserialize(final StubInputStream dataStream, final StubElement parentStub) throws IOException { boolean compiled = dataStream.readBoolean(); StringRef packName = dataStream.readName(); return new PsiJavaFileStubImpl(packName, compiled); } + @Override public void indexStub(final PsiJavaFileStub stub, final IndexSink sink) { } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java index 2d2128e9a14e..6ad5422fc2cf 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java @@ -47,11 +47,11 @@ public class JavaConcatenationInjectorManager implements ModificationTracker { public JavaConcatenationInjectorManager(Project project, PsiManagerEx psiManagerEx) { final ExtensionPoint concatPoint = Extensions.getArea(project).getExtensionPoint(CONCATENATION_INJECTOR_EP_NAME); concatPoint.addExtensionPointListener(new ExtensionPointListener() { - public void extensionAdded(ConcatenationAwareInjector injector, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull ConcatenationAwareInjector injector, @Nullable PluginDescriptor pluginDescriptor) { registerConcatenationInjector(injector); } - public void extensionRemoved(ConcatenationAwareInjector injector, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull ConcatenationAwareInjector injector, @Nullable PluginDescriptor pluginDescriptor) { unregisterConcatenationInjector(injector); } }); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java index 6f4ba36062d3..a53c00a942bc 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java @@ -366,7 +366,9 @@ public class PsiReferenceExpressionImpl extends ExpressionPsiElement implements public void processVariants(PsiScopeProcessor processor) { OrFilter filter = new OrFilter(); filter.addFilter(ElementClassFilter.CLASS); - filter.addFilter(ElementClassFilter.PACKAGE_FILTER); + if (isQualified()) { + filter.addFilter(ElementClassFilter.PACKAGE_FILTER); + } filter.addFilter(new AndFilter(ElementClassFilter.METHOD, new NotFilter(new ConstructorFilter()))); filter.addFilter(ElementClassFilter.VARIABLE); diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java index e588508992e9..493fc203c876 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java @@ -15,6 +15,7 @@ */ package com.intellij.refactoring.changeSignature; +import com.intellij.codeInsight.CodeInsightUtilBase; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; @@ -23,11 +24,14 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.vfs.ReadonlyStatusHandler; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.PsiSearchHelper; import com.intellij.psi.search.SearchScope; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.PsiUtil; import com.intellij.refactoring.util.CanonicalTypes; import com.intellij.usageView.UsageInfo; import com.intellij.util.IncorrectOperationException; @@ -65,7 +69,11 @@ public class JavaChangeSignatureDetector implements LanguageChangeSignatureDetec } final MyJavaChangeInfo fromMethod = new MyJavaChangeInfo(newVisibility, method, newReturnType, parameterInfos, null, method.getName()); if (changeInfo == null) { //before replacement - fromMethod.setSuperMethod(method.findDeepestSuperMethod()); + final PsiMethod deepestSuperMethod = method.findDeepestSuperMethod(); + if (deepestSuperMethod != null) { + if (!deepestSuperMethod.getManager().isInProject(deepestSuperMethod)) return null; + } + fromMethod.setSuperMethod(deepestSuperMethod); return fromMethod; } else { final MyJavaChangeInfo info = (MyJavaChangeInfo)changeInfo; diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesHandlerBase.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesHandlerBase.java index bec9ae48471c..7b835208ce3d 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesHandlerBase.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesHandlerBase.java @@ -24,6 +24,7 @@ import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import com.intellij.psi.impl.PsiCachedValue; import com.intellij.psi.impl.file.JavaDirectoryServiceImpl; import com.intellij.psi.impl.source.jsp.jspJava.JspClass; import com.intellij.refactoring.JavaRefactoringSettings; @@ -307,6 +308,10 @@ public class MoveClassesOrPackagesHandlerBase extends MoveHandlerDelegate { return true; } } + if (target instanceof PsiDirectory && source instanceof PsiDirectory) { + final PsiPackage aPackage = JavaDirectoryServiceImpl.getInstance().getPackage((PsiDirectory)source); + if (aPackage != null && !MoveClassesOrPackagesImpl.checkNesting(target.getProject(), aPackage, target, false)) return true; + } return super.isMoveRedundant(source, target); } } diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java index 9ab24ce8ab3f..7191c36ea1e6 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java @@ -98,13 +98,13 @@ public class MoveClassesOrPackagesImpl { CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("move.title"), message, HelpID.getMoveHelpID(element), project); return null; } - if (!checkNesting(project, aPackage, targetElement)) return null; + if (!checkNesting(project, aPackage, targetElement, true)) return null; if (!checkMovePackage(project, aPackage)) return null; element = aPackage; } else if (element instanceof PsiPackage) { final PsiPackage psiPackage = (PsiPackage)element; - if (!checkNesting(project, psiPackage, targetElement)) return null; + if (!checkNesting(project, psiPackage, targetElement, true)) return null; if (!checkMovePackage(project, psiPackage)) return null; } else if (element instanceof PsiClass) { @@ -166,16 +166,18 @@ public class MoveClassesOrPackagesImpl { return true; } - private static boolean checkNesting(final Project project, final PsiPackage srcPackage, final PsiElement targetElement) { + static boolean checkNesting(final Project project, final PsiPackage srcPackage, final PsiElement targetElement, boolean showError) { final PsiPackage targetPackage = targetElement instanceof PsiPackage ? (PsiPackage)targetElement : targetElement instanceof PsiDirectory ? JavaDirectoryService.getInstance() .getPackage((PsiDirectory)targetElement) : null; for (PsiPackage curPackage = targetPackage; curPackage != null; curPackage = curPackage.getParentPackage()) { if (curPackage.equals(srcPackage)) { - CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("move.title"), - RefactoringBundle.message("cannot.move.package.into.itself"), - HelpID.getMoveHelpID(srcPackage), project); + if (showError) { + CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("move.title"), + RefactoringBundle.message("cannot.move.package.into.itself"), + HelpID.getMoveHelpID(srcPackage), project); + } return false; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DynamicallyAddIgnoredAnnotations.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DynamicallyAddIgnoredAnnotations.java new file mode 100644 index 000000000000..97d405de4af1 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DynamicallyAddIgnoredAnnotations.java @@ -0,0 +1,9 @@ + +public class WithMain { + @MyAnno + public void myTestMethod(){} +} + +@interface MyAnno { + +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index c998b72a2f79..de005bbdba59 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -33,6 +33,23 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase { assertEmpty(myItems); } + public void testNoPackagesInExpressionCodeFragment() throws Throwable { + final String text = "jav"; + PsiFile file = getJavaFacade().getElementFactory().createExpressionCodeFragment(text, null, null, true); + myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); + complete(); + myFixture.checkResult(text); + assertEmpty(myItems); + } + + public void testSubPackagesInExpressionCodeFragment() throws Throwable { + PsiFile file = getJavaFacade().getElementFactory().createExpressionCodeFragment("java.la", null, null, true); + myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); + complete(); + myFixture.checkResult("java.lang."); + assertNull(myItems); + } + private JavaPsiFacade getJavaFacade() { return JavaPsiFacade.getInstance(getProject()); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java index 33ef19861114..a9f368178485 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -1,6 +1,21 @@ package com.intellij.codeInsight.daemon; +import com.intellij.ExtensionPoints; +import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; +import com.intellij.codeInspection.reference.EntryPoint; +import com.intellij.codeInspection.reference.RefElement; +import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.lang.annotation.HighlightSeverity; +import com.intellij.openapi.extensions.ExtensionPoint; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.psi.PsiElement; +import org.jdom.Element; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import java.util.List; /** * This class is for "lightweight" tests only, i.e. those which can run inside default light project set up @@ -13,12 +28,17 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos); } + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{new UnusedSymbolLocalInspection()}; + } + public void testDuplicateAnnotations() throws Exception { doTest(false, false); } public void testSwitchByString() throws Exception { - doTest(true, false); + doTest(false, false); } public void testDiamondPos1() throws Exception { @@ -56,4 +76,69 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testDiamondNeg5() throws Exception { doTest(false, false); } + + public void testDynamicallyAddIgnoredAnnotations() throws Exception { + ExtensionPoint point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.DEAD_CODE_TOOL); + EntryPoint extension = new EntryPoint() { + @NotNull + @Override + public String getDisplayName() { + return "duh"; + } + + @Override + public boolean isEntryPoint(RefElement refElement, PsiElement psiElement) { + return false; + } + + @Override + public boolean isEntryPoint(PsiElement psiElement) { + return false; + } + + @Override + public boolean isSelected() { + return false; + } + + @Override + public void setSelected(boolean selected) { + + } + + @Override + public void readExternal(Element element) { + + } + + @Override + public void writeExternal(Element element) { + + } + + @Override + public String[] getIgnoreAnnotations() { + return new String[]{"MyAnno"}; + } + }; + + UnusedDeclarationInspection deadCodeInspection = new UnusedDeclarationInspection(); + enableInspectionTool(deadCodeInspection); + + doTest(true, false); + List infos = DaemonAnalyzerTestCase.filter(doHighlighting(), HighlightSeverity.WARNING); + assertEquals(2, infos.size()); // unused class and unused method + + try { + point.registerExtension(extension); + + infos = DaemonAnalyzerTestCase.filter(doHighlighting(), HighlightSeverity.WARNING); + HighlightInfo info = assertOneElement(infos); + assertEquals("Class 'WithMain' is never used", info.description); + } + finally { + point.unregisterExtension(extension); + } + } + } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java index 5a7f69e89bee..33621dc9e0ef 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java @@ -3,10 +3,10 @@ package com.intellij.codeInsight.daemon; import com.intellij.ExtensionPoints; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance; -import com.intellij.codeInspection.reference.EntryPoint; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.deprecation.DeprecationInspection; import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection; +import com.intellij.codeInspection.reference.EntryPoint; import com.intellij.codeInspection.reference.RefElement; import com.intellij.codeInspection.sillyAssignment.SillyAssignmentInspection; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; @@ -56,7 +56,6 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase { setLanguageLevel(LanguageLevel.JDK_1_4); } - @Override protected LocalInspectionTool[] configureLocalInspectionTools() { myUnusedSymbolLocalInspection = new UnusedSymbolLocalInspection(); diff --git a/platform/extensions/src/com/intellij/openapi/extensions/ExtensionPointListener.java b/platform/extensions/src/com/intellij/openapi/extensions/ExtensionPointListener.java index 995b467e2e69..3dbebcf7bee6 100644 --- a/platform/extensions/src/com/intellij/openapi/extensions/ExtensionPointListener.java +++ b/platform/extensions/src/com/intellij/openapi/extensions/ExtensionPointListener.java @@ -15,9 +15,10 @@ */ package com.intellij.openapi.extensions; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public interface ExtensionPointListener { - void extensionAdded(T extension, @Nullable final PluginDescriptor pluginDescriptor); - void extensionRemoved(T extension, @Nullable final PluginDescriptor pluginDescriptor); + void extensionAdded(@NotNull T extension, @Nullable final PluginDescriptor pluginDescriptor); + void extensionRemoved(@NotNull T extension, @Nullable final PluginDescriptor pluginDescriptor); } diff --git a/platform/extensions/src/com/intellij/openapi/extensions/SmartExtensionPoint.java b/platform/extensions/src/com/intellij/openapi/extensions/SmartExtensionPoint.java index 8270be57bd34..a147038a214d 100644 --- a/platform/extensions/src/com/intellij/openapi/extensions/SmartExtensionPoint.java +++ b/platform/extensions/src/com/intellij/openapi/extensions/SmartExtensionPoint.java @@ -74,7 +74,7 @@ public abstract class SmartExtensionPoint implements ExtensionPoint } } - public final void extensionAdded(final Extension extension, @Nullable final PluginDescriptor pluginDescriptor) { + public final void extensionAdded(@NotNull final Extension extension, @Nullable final PluginDescriptor pluginDescriptor) { dropCache(); } @@ -88,7 +88,7 @@ public abstract class SmartExtensionPoint implements ExtensionPoint } } - public final void extensionRemoved(final Extension extension, @Nullable final PluginDescriptor pluginDescriptor) { + public final void extensionRemoved(@NotNull final Extension extension, @Nullable final PluginDescriptor pluginDescriptor) { dropCache(); } diff --git a/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionsAreaImpl.java b/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionsAreaImpl.java index 7cde8f3213f5..5ac0528cc7e5 100644 --- a/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionsAreaImpl.java +++ b/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionsAreaImpl.java @@ -250,7 +250,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea { getExtensionPoint(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME).addExtensionPointListener(new ExtensionPointListener() { @SuppressWarnings({"unchecked"}) - public void extensionRemoved(Object extension, final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) { EPAvailabilityListenerExtension epListenerExtension = (EPAvailabilityListenerExtension) extension; Collection listeners = myAvailabilityListeners.get(epListenerExtension.getExtensionPointName()); for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { @@ -263,7 +263,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea { myLogger.warn("Failed to find EP availability listener: " + epListenerExtension.getListenerClass()); } - public void extensionAdded(Object extension, final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) { EPAvailabilityListenerExtension epListenerExtension = (EPAvailabilityListenerExtension) extension; try { String epName = epListenerExtension.getExtensionPointName(); diff --git a/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionPointImplTest.java b/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionPointImplTest.java index d33369ff23f0..a225479abc90 100644 --- a/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionPointImplTest.java +++ b/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionPointImplTest.java @@ -17,6 +17,7 @@ package com.intellij.openapi.extensions.impl; import com.intellij.openapi.extensions.*; import junit.framework.TestCase; +import org.jetbrains.annotations.NotNull; import org.picocontainer.defaults.DefaultPicoContainer; /** @@ -101,12 +102,12 @@ public class ExtensionPointImplTest extends TestCase { final boolean removed[] = new boolean[1]; extensionPoint.addExtensionPointListener(new ExtensionPointListener() { @Override - public void extensionAdded(Object extension, final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) { added[0] = true; } @Override - public void extensionRemoved(Object extension, final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) { removed[0] = true; } }); @@ -128,12 +129,12 @@ public class ExtensionPointImplTest extends TestCase { assertFalse(added[0]); extensionPoint.addExtensionPointListener(new ExtensionPointListener() { @Override - public void extensionAdded(Object extension, final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) { added[0] = true; } @Override - public void extensionRemoved(Object extension, final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) { } }); assertTrue(added[0]); diff --git a/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionsImplTest.java b/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionsImplTest.java index 2aa4bb7ae225..12653098c084 100644 --- a/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionsImplTest.java +++ b/platform/extensions/testSrc/com/intellij/openapi/extensions/impl/ExtensionsImplTest.java @@ -17,6 +17,7 @@ package com.intellij.openapi.extensions.impl; import com.intellij.openapi.extensions.*; import junit.framework.TestCase; +import org.jetbrains.annotations.NotNull; import org.picocontainer.MutablePicoContainer; import org.picocontainer.defaults.DefaultPicoContainer; @@ -56,11 +57,11 @@ public class ExtensionsImplTest extends TestCase { removed[0] = false; extensionsArea.getExtensionPoint(EXTENSION_POINT_NAME_1).addExtensionPointListener(new ExtensionPointListener() { @Override - public void extensionAdded(Object extension, final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) { } @Override - public void extensionRemoved(Object extension, final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) { removed[0] = true; } }); diff --git a/platform/lang-api/src/com/intellij/codeInspection/reference/EntryPoint.java b/platform/lang-api/src/com/intellij/codeInspection/reference/EntryPoint.java index 5ce8267f9a80..6ee0c0ddd26b 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/reference/EntryPoint.java +++ b/platform/lang-api/src/com/intellij/codeInspection/reference/EntryPoint.java @@ -38,7 +38,7 @@ public abstract class EntryPoint implements JDOMExternalizable , Cloneable { } @Nullable - public String [] getIgnoreAnnotations() { + public String[] getIgnoreAnnotations() { return null; } diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/ListTable.java b/platform/lang-api/src/com/intellij/codeInspection/ui/ListTable.java index 5bc4366817a5..365aed6ffa8f 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/ui/ListTable.java +++ b/platform/lang-api/src/com/intellij/codeInspection/ui/ListTable.java @@ -1,5 +1,5 @@ /* - * Copyright 2007 Bas Leijdekkers + * Copyright 2007-2010 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. @@ -15,10 +15,10 @@ */ package com.intellij.codeInspection.ui; -import com.intellij.codeInspection.ui.ListWrappingTableModel; import com.intellij.ui.table.JBTable; import javax.swing.*; +import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableModel; import java.awt.*; @@ -30,7 +30,20 @@ public class ListTable extends JBTable { setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS); setRowSelectionAllowed(true); setDragEnabled(false); - getTableHeader().setReorderingAllowed(false); + final JTableHeader header = getTableHeader(); + header.setReorderingAllowed(false); + final TableCellRenderer delegate = header.getDefaultRenderer(); + final TableCellRenderer newRenderer = new TableCellRenderer() { + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + final Component component = delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + // to display the table header in disabled state when the table is disabled. + component.setEnabled(table.isEnabled()); + return component; + } + }; + header.setDefaultRenderer(newRenderer); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } diff --git a/platform/lang-api/src/com/intellij/lang/LighterASTTokenNode.java b/platform/lang-api/src/com/intellij/lang/LighterASTTokenNode.java new file mode 100644 index 000000000000..9db0c5176016 --- /dev/null +++ b/platform/lang-api/src/com/intellij/lang/LighterASTTokenNode.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2010 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.lang; + + +public interface LighterASTTokenNode extends LighterASTNode { + /** + * Note: a text returned may be linked back to file content text and therefore should be internalized + * through {@linkplain com.intellij.util.CharTable} if referenced as is. + * @return text of a token + */ + CharSequence getText(); +} diff --git a/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java b/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java index ad4bdc75aa0d..930d9e7af5da 100644 --- a/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java +++ b/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java @@ -49,7 +49,7 @@ public class SerializationManagerImpl extends SerializationManager implements Ap private final Map, Integer> mySerializerToId = new HashMap, Integer>(); private final List> myAllSerializers = new ArrayList>(); private final AtomicBoolean myNameStorageCrashed = new AtomicBoolean(false); - private final File myFile = new File(PathManager.getSystemPath() + "/index/rep.names"); + private final File myFile = new File(PathManager.getIndexRoot(), "rep.names"); private boolean mySerializersLoaded = false; public SerializationManagerImpl() { diff --git a/platform/lang-impl/lang-impl.iml b/platform/lang-impl/lang-impl.iml index 8826fbdf2382..4d0dc179b794 100644 --- a/platform/lang-impl/lang-impl.iml +++ b/platform/lang-impl/lang-impl.iml @@ -18,7 +18,6 @@ - diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java index 89c5aa902d32..f88ac48e7699 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontDescriptionPanel.java @@ -67,6 +67,15 @@ public class ColorAndFontDescriptionPanel extends JPanel { add(settingsPanel, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(4, 0, 4, 4)); + + myEffectsCombo.setRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + if (value == null) value = "Invalid"; + return super.getListCellRendererComponent(list, value, index, isSelected, + cellHasFocus); + } + }); } private JPanel createSettingsPanel() { @@ -366,7 +375,7 @@ public class ColorAndFontDescriptionPanel extends JPanel { myEffectsCombo.setSelectedItem(BOLD_DOTTED_LINE_EFFECT); } else { - LOG.assertTrue(false); + myEffectsCombo.setSelectedItem(null); } updatingEffects = false; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java index 8a5275fc0ec7..ebc362d60dde 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java @@ -109,6 +109,8 @@ public class CodeInsightSettings implements PersistentStateComponent, C public static final int INDENT_EACH_LINE = 3; public static final int REFORMAT_BLOCK = 4; + public boolean INDENT_TO_CARET_ON_PASTE = false; + public int ADD_IMPORTS_ON_PASTE = ASK; // YES, NO or ASK public static final int YES = 1; public static final int NO = 2; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java index 7ad8e6bd0b9f..c3d13ac3a5ab 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java @@ -48,6 +48,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; @@ -90,7 +91,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { public final void invoke(final Project project, final Editor editor) { invoke(project, editor, PsiUtilBase.getPsiFileInEditor(editor, project)); } - + public final void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile psiFile) { if (!ApplicationManager.getApplication().isUnitTestMode()) { assert !ApplicationManager.getApplication().isWriteAccessAllowed() : "Please don't invoke completion inside write action"; @@ -115,7 +116,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { } psiFile.putUserData(PsiFileEx.BATCH_REFERENCE_PROCESSING, Boolean.TRUE); - + final CompletionProgressIndicator indicator = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); if (indicator != null) { if (indicator.isRepeatedInvocation(myCompletionType, editor)) { @@ -143,62 +144,76 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { } } - final CompletionInitializationContext initializationContext = new WriteCommandAction(project) { - protected void run(Result result) throws Throwable { - CommandProcessor.getInstance().setCurrentCommandGroupId(null); + final CompletionInitializationContext[] initializationContext = {null}; - final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); - EditorUtil.fillVirtualSpaceUntilCaret(editor); - documentManager.commitAllDocuments(); - final CompletionInitializationContext initializationContext = new CompletionInitializationContext(editor, psiFile, myCompletionType); - result.setResult(initializationContext); + Runnable initCmd = new Runnable() { + @Override + public void run() { - for (final CompletionContributor contributor : CompletionContributor.forLanguage(PsiUtilBase.getLanguageInEditor(editor, project))) { - if (DumbService.getInstance(project).isDumb() && !DumbService.isDumbAware(contributor)) { - continue; + Runnable runnable = new Runnable() { + public void run() { + final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); + + EditorUtil.fillVirtualSpaceUntilCaret(editor); + documentManager.commitAllDocuments(); + initializationContext[0] = new CompletionInitializationContext(editor, psiFile, myCompletionType); + for (final CompletionContributor contributor : CompletionContributor.forLanguage(PsiUtilBase.getLanguageInEditor(editor, project))) { + if (DumbService.getInstance(project).isDumb() && !DumbService.isDumbAware(contributor)) { + continue; + } + + contributor.beforeCompletion(initializationContext[0]); + assert !documentManager.isUncommited(document) : "Contributor " + contributor + " left the document uncommitted"; + } } - - contributor.beforeCompletion(initializationContext); - assert !documentManager.isUncommited(document) : "Contributor " + contributor + " left the document uncommitted"; - } + }; + ApplicationManager.getApplication().runWriteAction(runnable); } - }.execute().getResultObject(); + }; + if (!focusLookup) { + CommandProcessor.getInstance().runUndoTransparentAction(initCmd); + } else { + CommandProcessor.getInstance().executeCommand(project, initCmd, null, null); + } + final int offset1 = initializationContext[0].getStartOffset(); + final int offset2 = initializationContext[0].getSelectionEndOffset(); + final CompletionContext context = new CompletionContext(project, editor, psiFile, initializationContext[0].getOffsetMap()); - final int offset1 = initializationContext.getStartOffset(); - final int offset2 = initializationContext.getSelectionEndOffset(); - final CompletionContext context = new CompletionContext(project, editor, psiFile, initializationContext.getOffsetMap()); - - doComplete(offset1, offset2, context, initializationContext.getFileCopyPatcher(), editor, time); + doComplete(offset1, offset2, context, initializationContext[0].getFileCopyPatcher(), editor, time); } protected void doComplete(final int offset1, final int offset2, final CompletionContext context, final FileCopyPatcher patcher, final Editor editor, final int invocationCount) { - final Pair insertedInfo = new WriteCommandAction>(context.project) { - protected void run(Result> result) throws Throwable { - result.setResult(insertDummyIdentifier(context, patcher)); - } - }.execute().getResultObject(); - - final PsiElement insertedElement = insertedInfo.getSecond(); - final CompletionContext newContext = insertedInfo.getFirst(); - insertedElement.putUserData(CompletionContext.COMPLETION_CONTEXT_KEY, newContext); - - PsiFile originalFile = newContext.file; - final PsiFile rightLanguagedOriginal = originalFile.getViewProvider().getPsi(insertedElement.getContainingFile().getLanguage()); - if (rightLanguagedOriginal != null) { - originalFile = rightLanguagedOriginal; - } - - final CompletionParameters parameters = new CompletionParameters(insertedElement, originalFile, myCompletionType, newContext.getStartOffset(), invocationCount); + final CompletionParameters parameters = createCompletionParameters(context, patcher, invocationCount); final Semaphore freezeSemaphore = new Semaphore(); freezeSemaphore.down(); - final CompletionProgressIndicator indicator = new CompletionProgressIndicator(editor, parameters, this, context, freezeSemaphore); + final CompletionProgressIndicator indicator = new CompletionProgressIndicator(editor, parameters, this, freezeSemaphore, context.getOffsetMap()); + final AtomicReference data = startCompletionThread(parameters, indicator); + + if (!invokedExplicitly) { + indicator.notifyBackgrounded(); + return; + } + + if (freezeSemaphore.waitFor(2000)) { + final LookupElement[] allItems = data.get(); + if (allItems != null) { // the completion is really finished, now we may auto-insert or show lookup + completionFinished(offset1, offset2, indicator, allItems); + return; + } + } + + indicator.notifyBackgrounded(); + indicator.showLookup(); + } + + private AtomicReference startCompletionThread(final CompletionParameters parameters, final CompletionProgressIndicator indicator) { final AtomicReference data = new AtomicReference(null); final Semaphore startSemaphore = new Semaphore(); startSemaphore.down(); @@ -231,27 +246,33 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { } startSemaphore.waitFor(); - - if (!invokedExplicitly) { - indicator.notifyBackgrounded(); - return; - } - - if (freezeSemaphore.waitFor(2000)) { - final LookupElement[] allItems = data.get(); - if (allItems != null) { // the completion is really finished, now we may auto-insert or show lookup - completionFinished(offset1, offset2, context, indicator, allItems); - return; - } - } - - indicator.notifyBackgrounded(); - indicator.showLookup(); + return data; } - private AutoCompletionDecision shouldAutoComplete(final CompletionContext context, - final CompletionProgressIndicator indicator, - final LookupElement[] items) { + private CompletionParameters createCompletionParameters(final CompletionContext context, final FileCopyPatcher patcher, int invocationCount) { + final Ref> ref = Ref.create(null); + CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() { + @Override + public void run() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + ref.set(insertDummyIdentifier(context, patcher, context.file, context.editor)); + } + }); + } + }); + + final PsiElement insertedElement = ref.get().getSecond(); + final CompletionContext newContext = ref.get().getFirst(); + insertedElement.putUserData(CompletionContext.COMPLETION_CONTEXT_KEY, newContext); + + return new CompletionParameters(insertedElement, newContext.file, myCompletionType, newContext.getStartOffset(), invocationCount); + } + + private AutoCompletionDecision shouldAutoComplete( + final CompletionProgressIndicator indicator, + final LookupElement[] items) { if (!invokedExplicitly) { return AutoCompletionDecision.SHOW_LOOKUP; } @@ -265,7 +286,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { if (!isAutocompleteOnInvocation(parameters.getCompletionType())) { return AutoCompletionDecision.SHOW_LOOKUP; } - if (isInsideIdentifier(context.getOffsetMap())) { + if (isInsideIdentifier(indicator.getOffsetMap())) { return AutoCompletionDecision.SHOW_LOOKUP; } if (items.length == 1 && getAutocompletionPolicy(item) == AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE) { @@ -273,7 +294,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { } for (final CompletionContributor contributor : CompletionContributor.forParameters(parameters)) { - final AutoCompletionDecision decision = contributor.handleAutoCompletionPossibility(new AutoCompletionContext(parameters, items, context.getOffsetMap())); + final AutoCompletionDecision decision = contributor.handleAutoCompletionPossibility(new AutoCompletionContext(parameters, items, indicator.getOffsetMap())); if (decision != null) { return decision; } @@ -302,15 +323,17 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { } - protected void completionFinished(final int offset1, final int offset2, final CompletionContext context, final CompletionProgressIndicator indicator, + protected void completionFinished(final int offset1, + final int offset2, + final CompletionProgressIndicator indicator, final LookupElement[] items) { if (items.length == 0) { - LookupManager.getInstance(context.project).hideActiveLookup(); - handleEmptyLookup(context.project, context.editor, indicator.getParameters(), indicator); + LookupManager.getInstance(indicator.getProject()).hideActiveLookup(); + handleEmptyLookup(indicator.getProject(), indicator.getEditor(), indicator.getParameters(), indicator); return; } - final AutoCompletionDecision decision = shouldAutoComplete(context, indicator, items); + final AutoCompletionDecision decision = shouldAutoComplete(indicator, items); if (decision == AutoCompletionDecision.SHOW_LOOKUP) { indicator.showLookup(); if (isAutocompleteCommonPrefixOnInvocation() && items.length > 1) { @@ -320,8 +343,8 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { final LookupElement item = ((AutoCompletionDecision.InsertItem)decision).getElement(); indicator.closeAndFinish(); indicator.rememberDocumentState(); - context.setStartOffset(offset1 - item.getPrefixMatcher().getPrefix().length()); - handleSingleItem(offset2, context, items, item.getLookupString(), item); + indicator.getOffsetMap().addOffset(CompletionInitializationContext.START_OFFSET, (offset1 - item.getPrefixMatcher().getPrefix().length())); + handleSingleItem(offset2, indicator, items, item.getLookupString(), item); // the insert handler may have started a live template with completion if (CompletionService.getCompletionService() == null) { @@ -330,14 +353,13 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { } } - protected static void handleSingleItem(final int offset2, final CompletionContext context, final LookupElement[] items, final String _uniqueText, final LookupElement item) { - - new WriteCommandAction(context.project) { + protected static void handleSingleItem(final int offset2, final CompletionProgressIndicator context, final LookupElement[] items, final String _uniqueText, final LookupElement item) { + new WriteCommandAction(context.getProject()) { protected void run(Result result) throws Throwable { String uniqueText = _uniqueText; if (item.getObject() instanceof DeferredUserLookupValue && item.as(LookupItem.class) != null) { - if (!((DeferredUserLookupValue)item.getObject()).handleUserSelection(item.as(LookupItem.class), context.project)) { + if (!((DeferredUserLookupValue)item.getObject()).handleUserSelection(item.as(LookupItem.class), context.getProject())) { return; } @@ -348,36 +370,37 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_CAMEL_HUMPS); } - insertLookupString(context, offset2, uniqueText); - context.editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); + insertLookupString(offset2, uniqueText, context.getEditor(), context.getOffsetMap()); + context.getEditor().getScrollingModel().scrollToCaret(ScrollType.RELATIVE); lookupItemSelected(context, item, Lookup.AUTO_INSERT_SELECT_CHAR, Arrays.asList(items)); } }.execute(); } - private static void insertLookupString(final CompletionContext context, final int currentOffset, final String newText) { - Editor editor = context.editor; - editor.getDocument().replaceString(context.getStartOffset(), currentOffset, newText); - editor.getCaretModel().moveToOffset(context.getStartOffset() + newText.length()); + private static void insertLookupString(final int currentOffset, final String newText, final Editor editor, final OffsetMap offsetMap) { + editor.getDocument().replaceString(offsetMap.getOffset(CompletionInitializationContext.START_OFFSET), currentOffset, newText); + editor.getCaretModel().moveToOffset(offsetMap.getOffset(CompletionInitializationContext.START_OFFSET) + newText.length()); editor.getSelectionModel().removeSelection(); } - protected static void selectLookupItem(final LookupElement item, final char completionChar, final CompletionContext context, final List items) { - final int caretOffset = context.editor.getCaretModel().getOffset(); + protected static void selectLookupItem(final LookupElement item, final char completionChar, final CompletionProgressIndicator context, final List items) { + final int caretOffset = context.getEditor().getCaretModel().getOffset(); - context.setSelectionEndOffset(caretOffset); - final int idEnd = context.getOffsetMap().getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET); + context.getOffsetMap().addOffset(CompletionInitializationContext.SELECTION_END_OFFSET, caretOffset); + final int idEnd = context.getIdentifierEndOffset(); final int identifierEndOffset = - CompletionUtil.isOverwrite(item, completionChar) && context.getSelectionEndOffset() == idEnd ? - caretOffset : - Math.max(caretOffset, idEnd); + CompletionUtil.isOverwrite(item, completionChar) && context.getSelectionEndOffset() == idEnd ? + caretOffset : + Math.max(caretOffset, idEnd); context.getOffsetMap().addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, identifierEndOffset); lookupItemSelected(context, item, completionChar, items); } - private Pair insertDummyIdentifier(final CompletionContext context, final FileCopyPatcher patcher) { - PsiFile oldFileCopy = createFileCopy(context.file); + private Pair insertDummyIdentifier(final CompletionContext context, + final FileCopyPatcher patcher, + final PsiFile file, final Editor originalEditor) { + PsiFile oldFileCopy = createFileCopy(file); PsiFile hostFile = InjectedLanguageUtil.getTopLevelFile(oldFileCopy); boolean wasInjected = hostFile != oldFileCopy; Project project = hostFile.getProject(); @@ -402,7 +425,6 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { if (oldFileCopy != fileCopy && !wasInjected) { // newly inserted identifier can well end up in the injected language region - Editor oldEditor = context.editor; Editor editor = EditorFactory.getInstance().createEditor(document, project); Editor newEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, hostFile, context.getStartOffset()); if (newEditor instanceof EditorWindow) { @@ -411,9 +433,9 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { final OffsetMap map = new OffsetMap(newEditor.getDocument()); final OffsetMap oldMap = context.getOffsetMap(); for (final OffsetKey key : oldMap.keySet()) { - map.addOffset(key, injectedEditor.logicalPositionToOffset(injectedEditor.hostToInjected(oldEditor.offsetToLogicalPosition(oldMap.getOffset(key))))); + map.addOffset(key, injectedEditor.logicalPositionToOffset(injectedEditor.hostToInjected(originalEditor.offsetToLogicalPosition(oldMap.getOffset(key))))); } - CompletionContext newContext = new CompletionContext(context.project, injectedEditor, injectedFile, map); + CompletionContext newContext = new CompletionContext(file.getProject(), injectedEditor, injectedFile, map); int injectedOffset = newContext.getStartOffset(); PsiElement element = findElementAt(injectedFile, injectedOffset); @@ -480,21 +502,21 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { } } - private static void lookupItemSelected(final CompletionContext context, @NotNull final LookupElement item, final char completionChar, + private static void lookupItemSelected(final CompletionProgressIndicator context, @NotNull final LookupElement item, final char completionChar, final List items) { - final Editor editor = context.editor; - final PsiFile file = context.file; + final Editor editor = context.getEditor(); + final PsiFile file = context.getParameters().getOriginalFile(); final InsertionContext context1 = new InsertionContext(context.getOffsetMap(), completionChar, items.toArray(new LookupElement[items.size()]), file, editor); ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { - final int idEndOffset = context.getOffsetMap().getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET); + final int idEndOffset = context.getIdentifierEndOffset(); if (idEndOffset != context.getSelectionEndOffset() && CompletionUtil.isOverwrite(item, completionChar)) { editor.getDocument().deleteString(context.getSelectionEndOffset(), idEndOffset); } - PsiDocumentManager.getInstance(context.project).commitAllDocuments(); + PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments(); item.handleInsert(context1); - PostprocessReformattingAspect.getInstance(context.project).doPostponedFormatting(); + PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting(); if (context1.shouldAddCompletionChar() && completionChar != Lookup.AUTO_INSERT_SELECT_CHAR && completionChar != Lookup.REPLACE_SELECT_CHAR && @@ -592,7 +614,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { case SMART: return settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION; case BASIC: - default: + default: return settings.AUTOCOMPLETE_ON_CODE_COMPLETION; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionContext.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionContext.java index 0c9f1b99e36c..801f6e747e7e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionContext.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionContext.java @@ -44,16 +44,12 @@ public class CompletionContext { getOffsetMap().addOffset(CompletionInitializationContext.START_OFFSET, newStartOffset); } - public int getSelectionEndOffset() { - return getOffsetMap().getOffset(CompletionInitializationContext.SELECTION_END_OFFSET); - } - - public void setSelectionEndOffset(final int selectionEndOffset) { - getOffsetMap().addOffset(CompletionInitializationContext.SELECTION_END_OFFSET, selectionEndOffset); - } - public OffsetMap getOffsetMap() { return myOffsetMap; } + + public Project getProject() { + return project; + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index ff48b86419dd..d9a94cb91340 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -35,6 +35,7 @@ import com.intellij.openapi.editor.SelectionModel; import com.intellij.openapi.editor.event.*; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.util.ProgressIndicatorBase; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.text.StringUtil; @@ -76,7 +77,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } }; private LightweightHint myHint; - private final CompletionContext myContextOriginal; private final Semaphore myFreezeSemaphore; private boolean myModifiersReleased; @@ -86,14 +86,15 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement private int myOldStart; private int myOldEnd; private boolean myBackgrounded = true; + private OffsetMap myOffsetMap; - public CompletionProgressIndicator(final Editor editor, CompletionParameters parameters, CodeCompletionHandlerBase handler, - final CompletionContext contextOriginal, Semaphore freezeSemaphore) { + public CompletionProgressIndicator(final Editor editor, CompletionParameters parameters, CodeCompletionHandlerBase handler, Semaphore freezeSemaphore, + final OffsetMap offsetMap) { myEditor = editor; myParameters = parameters; myHandler = handler; - myContextOriginal = contextOriginal; myFreezeSemaphore = freezeSemaphore; + myOffsetMap = offsetMap; myLookup = (LookupImpl)LookupManager.getInstance(editor.getProject()).createLookup(editor, LookupElement.EMPTY_ARRAY, "", new CompletionLookupArranger(parameters)); if (editor.isOneLineMode()) { @@ -114,8 +115,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement setMergeCommand(); - contextOriginal.setStartOffset(myEditor.getCaretModel().getOffset() - item.getLookupString().length()); - CodeCompletionHandlerBase.selectLookupItem(item, event.getCompletionChar(), contextOriginal, myLookup.getItems()); + myOffsetMap.addOffset(CompletionInitializationContext.START_OFFSET, myEditor.getCaretModel().getOffset() - item.getLookupString().length()); + CodeCompletionHandlerBase.selectLookupItem(item, event.getCompletionChar(), CompletionProgressIndicator.this, myLookup.getItems()); } @@ -137,6 +138,14 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement trackModifiers(); } + public OffsetMap getOffsetMap() { + return myOffsetMap; + } + + public int getSelectionEndOffset() { + return getOffsetMap().getOffset(CompletionInitializationContext.SELECTION_END_OFFSET); + } + void notifyBackgrounded() { ApplicationManager.getApplication().assertIsDispatchThread(); myBackgrounded = true; @@ -315,8 +324,12 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement return myCount; } - private boolean isInsideIdentifier() { - return myContextOriginal.getOffsetMap().getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET) != myContextOriginal.getSelectionEndOffset(); + final boolean isInsideIdentifier() { + return getIdentifierEndOffset() != getSelectionEndOffset(); + } + + public int getIdentifierEndOffset() { + return myOffsetMap.getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET); } @@ -353,7 +366,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement if (myHint != null) { myHint.hide(); } - LookupManager.getInstance(myEditor.getProject()).hideActiveLookup(); + LookupManager.getInstance(getProject()).hideActiveLookup(); } private void lookupClosed() { @@ -413,11 +426,11 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } if (myCount == 0) { - LookupManager.getInstance(myContextOriginal.project).hideActiveLookup(); + LookupManager.getInstance(getProject()).hideActiveLookup(); assert CompletionServiceImpl.getCompletionService().getCurrentCompletion() == null; if (!isAutopopupCompletion() ) { - myHandler.handleEmptyLookup(myContextOriginal.project, myEditor, myParameters, CompletionProgressIndicator.this); + myHandler.handleEmptyLookup(getProject(), myEditor, myParameters, CompletionProgressIndicator.this); } } else { updateLookup(); @@ -433,7 +446,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement lookup.refreshUi(); final List items = lookup.getItems(); if (items.size() == 0 || items.size() == 1 && (items.get(0).getPrefixMatcher().getPrefix() + lookup.getAdditionalPrefix()).equals(items.get(0).getLookupString())) { - lookup.hide(); + lookup.hideLookup(false); assert CompletionServiceImpl.getCompletionService().getCurrentCompletion() == null; return true; } @@ -489,7 +502,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement return false; } - final Boolean aBoolean = new WriteCommandAction(myEditor.getProject()) { + final Boolean aBoolean = new WriteCommandAction(getProject()) { protected void run(Result result) throws Throwable { if (!explicit) { setMergeCommand(); @@ -546,4 +559,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement public boolean isAutopopupCompletion() { return !myLookup.isFocused(); } + + public Project getProject() { + return myEditor.getProject(); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java index a323b4124a8a..aad941cf421e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java @@ -188,7 +188,6 @@ class DaemonListeners implements Disposable { }); connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() { - public void enteredDumbMode() { stopDaemon(true); } @@ -312,7 +311,7 @@ class DaemonListeners implements Disposable { if (vcsIsThinking) return Result.UNCHANGED; // do not modify file which is in the process of updating FileStatus status = FileStatusManager.getInstance(project).getStatus(virtualFile); - + if (status == FileStatus.UNKNOWN) return Result.NOT_SURE; return status == FileStatus.MODIFIED || status == FileStatus.ADDED ? Result.CHANGED : Result.UNCHANGED; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java index 09fb830abf38..694c0006cf2d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonTooltipRendererProvider.java @@ -111,8 +111,8 @@ public class DaemonTooltipRendererProvider implements ErrorStripTooltipRendererP } @Override - public TrafficTooltipRenderer createTrafficTooltipRenderer(Runnable onHide) { - return new TrafficTooltipRendererImpl(onHide); + public TrafficTooltipRenderer createTrafficTooltipRenderer(Runnable onHide, Editor editor) { + return new TrafficTooltipRendererImpl(onHide, editor); } private static class MyRenderer extends LineTooltipRenderer { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java index 4e62cca8dfae..13930912b194 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficProgressPanel.java @@ -21,17 +21,20 @@ import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.ui.HintHint; -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.ui.components.panels.NonOpaquePanel; +import com.intellij.ui.components.panels.VerticalBox; +import com.intellij.util.containers.HashMap; import com.intellij.util.containers.hash.LinkedHashMap; +import com.intellij.util.ui.AwtVisitor; import javax.swing.*; +import javax.swing.border.LineBorder; +import java.awt.*; import java.util.ArrayList; import java.util.Map; @@ -39,18 +42,34 @@ import java.util.Map; * User: cdr */ public class TrafficProgressPanel extends JPanel { + + private static final int MAX = 100; + private static final String MAX_TEXT = "100%"; + private static final String MIN_TEXT = "0%"; + private final JLabel statistics = new JLabel(); private final Map> passes = new LinkedHashMap>(); + private Map myProgressToText = new HashMap(); + private final JLabel statusLabel = new JLabel(); private final TrafficLightRenderer myTrafficLightRenderer; private final JPanel passStatuses = new JPanel(); + private HintHint myHintHint; public TrafficProgressPanel(TrafficLightRenderer trafficLightRenderer, Editor editor, HintHint hintHint) { - super(new VerticalFlowLayout()); + myHintHint = hintHint; myTrafficLightRenderer = trafficLightRenderer; - add(statusLabel); + setLayout(new BorderLayout()); + + VerticalBox center = new VerticalBox(); + add(center, BorderLayout.NORTH); + + center.add(statusLabel); + center.add(new Separator()); + center.add(Box.createVerticalStrut(6)); + TrafficLightRenderer.DaemonCodeAnalyzerStatus fakeStatusLargeEnough = new TrafficLightRenderer.DaemonCodeAnalyzerStatus(); fakeStatusLargeEnough.errorCount = new int[]{1,1,1,1}; Project project = trafficLightRenderer.getProject(); @@ -70,63 +89,103 @@ public class TrafficProgressPanel extends JPanel { rebuildPassesPanel(fakeStatusLargeEnough); for (Pair pair : passes.values()) { JProgressBar bar = pair.first; - bar.setMaximum(100); + bar.setMaximum(MAX); JLabel label = pair.second; - label.setText("100%"); + label.setText(MAX_TEXT); } - add(passStatuses); + center.add(passStatuses); - add(statistics); + add(statistics, BorderLayout.SOUTH); updatePanel(fakeStatusLargeEnough); hintHint.initStyle(this, true); } + private class Separator extends NonOpaquePanel { + @Override + protected void paintComponent(Graphics g) { + Insets insets = getInsets(); + if (insets == null) { + insets = new Insets(0, 0, 0, 0); + } + g.setColor(myHintHint.getTextForeground()); + g.drawLine(insets.left, insets.top, getWidth() - insets.left - insets.right, insets.top); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(1, 1); + } + + @Override + public Dimension getMinimumSize() { + return new Dimension(1, 1); + } + } + private void rebuildPassesPanel(TrafficLightRenderer.DaemonCodeAnalyzerStatus status) { passStatuses.removeAll(); - passStatuses.setLayout(new GridLayoutManager(Math.max(status.passStati.size(),1), 3)); + passStatuses.setLayout(new GridBagLayout()); passes.clear(); - GridConstraints constraints = new GridConstraints(); + GridBagConstraints c = new GridBagConstraints(); + c.gridy = 0; + c.fill = GridBagConstraints.HORIZONTAL; for (ProgressableTextEditorHighlightingPass pass : status.passStati) { - JLabel label = new JLabel(pass.getPresentableName() + ":"); - JProgressBar progressBar = new JProgressBar(0,100); + JLabel label = new JLabel(pass.getPresentableName() + ": "); + label.setHorizontalTextPosition(JLabel.RIGHT); + + JProgressBar progressBar = new JProgressBar(0, MAX); + progressBar.putClientProperty("JComponent.sizeVariant", "mini"); JLabel percLabel = new JLabel(); passes.put(pass, Pair.create(progressBar, percLabel)); - constraints.setColumn(0); passStatuses.add(label, constraints); - constraints.setColumn(1); passStatuses.add(progressBar, constraints); - constraints.setColumn(2); passStatuses.add(percLabel, constraints); - constraints.setRow(constraints.getRow()+1); + myProgressToText.put(progressBar, percLabel); + c.gridx = 0; + passStatuses.add(label, c); + c.gridx = 1; + passStatuses.add(progressBar, c); + c.gridx = 2; + c.weightx = 1; + passStatuses.add(percLabel, c); + + c.gridy++; } + + myHintHint.initStyle(passStatuses, true); + statusLabel.setFont(statusLabel.getFont().deriveFont(Font.BOLD)); } public void updatePanel(TrafficLightRenderer.DaemonCodeAnalyzerStatus status) { if (status == null) return; if (PowerSaveMode.isEnabled()) { - statusLabel.setText("Code analysis is disabled in power save mode."); + statusLabel.setText("Code analysis is disabled in power save mode"); passStatuses.setVisible(false); statistics.setText(""); return; } if (!status.enabled) { - statusLabel.setText("Code analysis has been suspended."); - passStatuses.setVisible(false); + statusLabel.setText("Code analysis has been suspended"); + passStatuses.setVisible(true); + setPassesEnabled(false, Boolean.FALSE); statistics.setText(""); return; } if (status.noHighlightingRoots != null && status.noHighlightingRoots.length == status.rootsNumber) { statusLabel.setText(DaemonBundle.message("analysis.hasnot.been.run")); - passStatuses.setVisible(false); + passStatuses.setVisible(true); + setPassesEnabled(false, Boolean.FALSE); statistics.setText(""); return; } if (status.errorAnalyzingFinished) { statusLabel.setText(DaemonBundle.message("analysis.completed")); - passStatuses.setVisible(false); + passStatuses.setVisible(true); + setPassesEnabled(false, Boolean.TRUE); } else { statusLabel.setText(DaemonBundle.message("performing.code.analysis")); passStatuses.setVisible(true); + setPassesEnabled(true, null); if (!status.passStati.equals(new ArrayList(passes.keySet()))) { // passes set has changed @@ -137,7 +196,7 @@ public class TrafficProgressPanel extends JPanel { double progress = pass.getProgress(); Pair pair = passes.get(pass); JProgressBar progressBar = pair.first; - int percent = (int)Math.round(progress * 100); + int percent = (int)Math.round(progress * MAX); progressBar.setValue(percent); JLabel percentage = pair.second; percentage.setText(percent + "%"); @@ -164,4 +223,26 @@ public class TrafficProgressPanel extends JPanel { } statistics.setText(text); } + + private void setPassesEnabled(final boolean enabled, final Boolean completed) { + new AwtVisitor(passStatuses) { + @Override + public boolean visit(Component component) { + if (component instanceof JProgressBar) { + JProgressBar progress = (JProgressBar)component; + progress.setEnabled(enabled); + if (completed != null) { + if (completed) { + progress.setValue(MAX); + myProgressToText.get(progress).setText(MAX_TEXT); + } else { + progress.setValue(0); + myProgressToText.get(progress).setText(MIN_TEXT); + } + } + } + return false; + } + }; + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficTooltipRendererImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficTooltipRendererImpl.java index 255fec49dda0..432fca6692e2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficTooltipRendererImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficTooltipRendererImpl.java @@ -24,18 +24,20 @@ import com.intellij.openapi.editor.impl.EditorMarkupModelImpl; import com.intellij.openapi.editor.impl.TrafficTooltipRenderer; import com.intellij.ui.HintHint; import com.intellij.ui.LightweightHint; +import com.intellij.util.ui.update.ComparableObject; import java.awt.*; /** * User: cdr */ -public class TrafficTooltipRendererImpl implements TrafficTooltipRenderer { +public class TrafficTooltipRendererImpl extends ComparableObject.Impl implements TrafficTooltipRenderer { private TrafficProgressPanel myPanel; private final Runnable onHide; private TrafficLightRenderer myTrafficLightRenderer; - public TrafficTooltipRendererImpl(Runnable onHide) { + public TrafficTooltipRendererImpl(Runnable onHide, Editor editor) { + super(editor); this.onHide = onHide; } @@ -69,9 +71,4 @@ public class TrafficTooltipRendererImpl implements TrafficTooltipRenderer { repaintTooltipWindow(); return hint; } - - @Override - public boolean equals(Object obj) { - return obj.getClass() == getClass() && myTrafficLightRenderer == ((TrafficTooltipRendererImpl)obj).myTrafficLightRenderer; - } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/DefaultHighlightVisitor.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/DefaultHighlightVisitor.java index 483ab63d0477..5d29686f7e04 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/DefaultHighlightVisitor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/DefaultHighlightVisitor.java @@ -111,11 +111,11 @@ public class DefaultHighlightVisitor implements HighlightVisitor, DumbAware { static { LanguageAnnotators.INSTANCE.addListener(new ExtensionPointListener() { - public void extensionAdded(Annotator extension, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) { cachedAnnotators.clear(); } - public void extensionRemoved(Annotator extension, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) { cachedAnnotators.clear(); } }); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java index e71ffedc4128..4a0dab2fccc0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java @@ -25,6 +25,7 @@ import com.intellij.codeInsight.lookup.Lookup; import com.intellij.codeInsight.lookup.LookupAdapter; import com.intellij.codeInsight.lookup.LookupEvent; import com.intellij.codeInsight.lookup.LookupManager; +import com.intellij.openapi.Disposable; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.event.DocumentAdapter; import com.intellij.openapi.editor.event.DocumentEvent; @@ -35,6 +36,8 @@ import com.intellij.openapi.fileEditor.FileEditorManagerAdapter; import com.intellij.openapi.fileEditor.FileEditorManagerEvent; import com.intellij.openapi.fileEditor.FileEditorManagerListener; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiFile; import com.intellij.util.messages.MessageBusConnection; @@ -44,7 +47,11 @@ import com.intellij.util.messages.MessageBusConnection; */ public class CompletionAutoPopupHandler extends TypedHandlerDelegate { private Editor myEditor; - private int myLastOffset; + + //todo store this in some less nasty place + public static int ourLastOffset; + + private static final Key COMPLETION_AUTO_POPUP_HANDLER = Key.create("CompletionAutoPopupHandler"); @Override public Result checkAutoPopup(char charTyped, final Project project, final Editor editor, final PsiFile file) { @@ -56,10 +63,13 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate { } if (myEditor != null) { - if (editor != myEditor || editor.getCaretModel().getOffset() != myLastOffset + 1) { + if (editor != myEditor || editor.getCaretModel().getOffset() != ourLastOffset + 1) { finishAutopopupCompletion(); - return Result.CONTINUE; + } else { + //noinspection AssignmentToStaticFieldFromInstanceMethod + ourLastOffset = editor.getCaretModel().getOffset(); } + return Result.CONTINUE; } else { if (LookupManager.getActiveLookup(editor) != null) { return Result.CONTINUE; @@ -67,8 +77,43 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate { } myEditor = editor; - myLastOffset = editor.getCaretModel().getOffset(); + //noinspection AssignmentToStaticFieldFromInstanceMethod + ourLastOffset = editor.getCaretModel().getOffset(); + trackProjectClosing(project); + trackUserActivity(project, editor); + + final boolean isMainEditor = FileEditorManager.getInstance(project).getSelectedTextEditor() == editor; + + AutoPopupController.getInstance(project).invokeAutoPopupRunnable(new Runnable() { + @Override + public void run() { + if (project.isDisposed() || !file.isValid()) return; + if (editor.isDisposed() || isMainEditor && FileEditorManager.getInstance(project).getSelectedTextEditor() != editor) return; + + new CodeCompletionHandlerBase(CompletionType.BASIC, false, false).invoke(project, editor); + final Lookup lookup = LookupManager.getActiveLookup(editor); + if (lookup != null) { + lookup.addLookupListener(new LookupAdapter() { + @Override + public void itemSelected(LookupEvent event) { + myEditor = null; + } + + @Override + public void lookupCanceled(LookupEvent event) { + if (event.isCanceledExplicitly()) { + myEditor = null; + } + } + }); + } + } + }, CodeInsightSettings.getInstance().AUTO_LOOKUP_DELAY); + return Result.STOP; + } + + private void trackUserActivity(Project project, final Editor editor) { final MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() { @Override @@ -95,33 +140,18 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate { } } }); + } - final boolean isMainEditor = FileEditorManager.getInstance(project).getSelectedTextEditor() == editor; - - AutoPopupController.getInstance(project).invokeAutoPopupRunnable(new Runnable() { - @Override - public void run() { - if (project.isDisposed() || !file.isValid()) return; - if (editor.isDisposed() || isMainEditor && FileEditorManager.getInstance(project).getSelectedTextEditor() != editor) return; - - new CodeCompletionHandlerBase(CompletionType.BASIC, false, false).invoke(project, editor); - final Lookup lookup = LookupManager.getActiveLookup(editor); - if (lookup != null) { - lookup.addLookupListener(new LookupAdapter() { - @Override - public void itemSelected(LookupEvent event) { - myEditor = null; - } - - @Override - public void lookupCanceled(LookupEvent event) { - myEditor = null; - } - }); + private void trackProjectClosing(Project project) { + if (project.getUserData(COMPLETION_AUTO_POPUP_HANDLER) == null) { + project.putUserData(COMPLETION_AUTO_POPUP_HANDLER, new Object()); + Disposer.register(project, new Disposable() { + @Override + public void dispose() { + myEditor = null; } - } - }, CodeInsightSettings.getInstance().AUTO_LOOKUP_DELAY); - return Result.STOP; + }); + } } private void finishAutopopupCompletion() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteIndentProcessor.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteIndentProcessor.java index 235e5b2b6180..cba12a20d4d9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteIndentProcessor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteIndentProcessor.java @@ -1,5 +1,6 @@ package com.intellij.codeInsight.editorActions; +import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeStyle.CodeStyleFacade; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; @@ -115,6 +116,9 @@ public class CopyPasteIndentProcessor implements CopyPastePostProcessor indented, final IndentTransferableData value) { + if (!CodeInsightSettings.getInstance().INDENT_TO_CARET_ON_PASTE) { + return; + } final Document document = editor.getDocument(); final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document); if (psiFile == null || !acceptFileType(psiFile.getFileType())) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java index bfdeeb249598..89400d7a5776 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java @@ -64,11 +64,11 @@ public class IntentionManagerImpl extends IntentionManager { final ExtensionPoint point = Extensions.getArea(null).getExtensionPoint(EP_INTENTION_ACTIONS); point.addExtensionPointListener(new ExtensionPointListener() { - public void extensionAdded(final IntentionActionBean extension, @Nullable final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull final IntentionActionBean extension, @Nullable final PluginDescriptor pluginDescriptor) { registerIntentionFromBean(extension); } - public void extensionRemoved(final IntentionActionBean extension, @Nullable final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull final IntentionActionBean extension, @Nullable final PluginDescriptor pluginDescriptor) { } }); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsTree.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsTree.java index 5adbeff09838..33c42af31fa1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsTree.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsTree.java @@ -71,7 +71,7 @@ public abstract class IntentionSettingsTree { SimpleTextAttributes attributes = node.getUserObject() instanceof IntentionActionMetaData ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES; final String text = getNodeText(node); final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); if (text != null) { SearchUtil.appendFragments(myFilter != null ? myFilter.getFilter() : null, text, diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupEvent.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupEvent.java index 035cf0c7eb77..6306421ebdc4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupEvent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/LookupEvent.java @@ -25,16 +25,22 @@ public class LookupEvent extends EventObject { private final Lookup myLookup; private final LookupElement myItem; private final char myCompletionChar; + private final boolean myCanceledExplicitly; - public LookupEvent(Lookup lookup, LookupElement item){ - this(lookup, item, (char)0); + public LookupEvent(Lookup lookup, boolean canceledExplicitly){ + super(lookup); + myLookup = lookup; + myItem = null; + myCompletionChar = 0; + myCanceledExplicitly = canceledExplicitly; } - public LookupEvent(Lookup lookup, LookupElement item, char completionChar){ + public LookupEvent(Lookup lookup, LookupElement item, char completionChar) { super(lookup); myLookup = lookup; myItem = item; myCompletionChar = completionChar; + myCanceledExplicitly = false; } public Lookup getLookup(){ @@ -49,4 +55,8 @@ public class LookupEvent extends EventObject { public char getCompletionChar(){ return myCompletionChar; } + + public boolean isCanceledExplicitly() { + return myCanceledExplicitly; + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index e3553d0d19f7..87c5c0c3f936 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -33,7 +33,6 @@ import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.event.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; @@ -497,7 +496,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { } final LookupElement item = (LookupElement)myList.getSelectedValue(); - doHide(false); + doHide(false, true); if (item == null || item instanceof EmptyLookupItem || item.getObject() instanceof DeferredUserLookupValue && @@ -736,9 +735,9 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { } } - private void fireLookupCanceled(){ + private void fireLookupCanceled(final boolean explicitly) { if (!myListeners.isEmpty()){ - LookupEvent event = new LookupEvent(this, null); + LookupEvent event = new LookupEvent(this, explicitly); LookupListener[] listeners = myListeners.toArray(new LookupListener[myListeners.size()]); for (LookupListener listener : listeners) { try { @@ -753,7 +752,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { private void fireCurrentItemChanged(LookupElement item){ if (!myListeners.isEmpty()){ - LookupEvent event = new LookupEvent(this, item); + LookupEvent event = new LookupEvent(this, item, (char)0); LookupListener[] listeners = myListeners.toArray(new LookupListener[myListeners.size()]); for (LookupListener listener : listeners) { listener.currentItemChanged(event); @@ -895,16 +894,18 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { } public void hide(){ - ApplicationManager.getApplication().assertIsDispatchThread(); + hideLookup(true); + } - //if (IdeEventQueue.getInstance().getPopupManager().closeAllPopups()) return; + public void hideLookup(boolean explicitly) { + ApplicationManager.getApplication().assertIsDispatchThread(); if (myDisposed) return; - doHide(true); + doHide(true, explicitly); } - private void doHide(final boolean fireCanceled) { + private void doHide(final boolean fireCanceled, final boolean explicitly) { assert !myDisposed; myHidden = true; @@ -913,7 +914,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { Disposer.dispose(this); if (fireCanceled) { - fireLookupCanceled(); + fireLookupCanceled(explicitly); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/TypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/TypedHandler.java index 43ee0bd0cfd8..b0f9a506ba5b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/TypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/TypedHandler.java @@ -20,6 +20,7 @@ import com.intellij.codeInsight.completion.CodeCompletionFeatures; import com.intellij.codeInsight.completion.CompletionProgressIndicator; import com.intellij.codeInsight.completion.PrefixMatcher; import com.intellij.codeInsight.editorActions.AutoHardWrapHandler; +import com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler; import com.intellij.codeInsight.lookup.CharFilter; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupManager; @@ -67,6 +68,8 @@ public class TypedHandler implements TypedActionHandler { }, "", editor.getDocument()); if (result == CharFilter.Result.ADD_TO_PREFIX){ + //noinspection AssignmentToStaticFieldFromInstanceMethod + CompletionAutoPopupHandler.ourLastOffset = editor.getCaretModel().getOffset() - 1; CompletionProgressIndicator.hideAutopopupIfMeaningless(lookup); return; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java index 697c00a27035..2b6cca6ae37f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java @@ -15,7 +15,6 @@ */ package com.intellij.codeInsight.template; -import com.intellij.codeInsight.template.impl.TemplateContext; import com.intellij.codeInsight.template.impl.TemplateImpl; import com.intellij.codeInsight.template.impl.TemplateManagerImpl; import com.intellij.codeInsight.template.impl.TemplateSettings; @@ -76,31 +75,31 @@ public class CustomTemplateCallback { } @Nullable - public TemplateImpl findApplicableTemplate(@NotNull String key, TemplateContextType... contextTypes) { - List templates = findApplicableTemplates(key, contextTypes); + public TemplateImpl findApplicableTemplate(@NotNull String key) { + List templates = findApplicableTemplates(key); return templates.size() > 0 ? templates.get(0) : null; } @NotNull - public List findApplicableTemplates(String key, TemplateContextType... contextTypes) { + public List findApplicableTemplates(String key) { List templates = getMatchingTemplates(key); - templates = filterApplicableCandidates(templates, contextTypes); + templates = filterApplicableCandidates(templates); return templates; } - private List filterApplicableCandidates(Collection candidates, TemplateContextType... contextTypes) { + private List filterApplicableCandidates(Collection candidates) { List result = new ArrayList(); for (TemplateImpl candidate : candidates) { if (TemplateManagerImpl.isApplicable(myFile, myOffset > 0 ? myOffset - 1 : myOffset, candidate)) { result.add(candidate); } - TemplateContext context = candidate.getTemplateContext(); + /*TemplateContext context = candidate.getTemplateContext(); for (TemplateContextType contextType : contextTypes) { if (context.isEnabled(contextType)) { result.add(candidate); break; } - } + }*/ } return result; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index 5d10102b71a5..21138a092ccf 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -631,7 +631,7 @@ class TemplateListPanel extends JPanel { // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } if (value instanceof TemplateImpl) { diff --git a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java index 0bd51de4f52d..d9d3114b14b9 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java @@ -18,6 +18,7 @@ package com.intellij.execution.actions; import com.intellij.execution.*; import com.intellij.execution.configurations.ConfigurationType; +import com.intellij.execution.configurations.UnknownConfigurationType; import com.intellij.execution.executors.DefaultRunExecutor; import com.intellij.execution.impl.EditConfigurationsDialog; import com.intellij.execution.impl.RunDialog; @@ -452,14 +453,16 @@ public class ChooseRunConfigurationAction extends AnAction { final Map wrappedExisting = new LinkedHashMap(); final ConfigurationType[] factories = manager.getConfigurationFactories(); for (final ConfigurationType factory : factories) { - final RunnerAndConfigurationSettings[] configurations = manager.getConfigurationSettings(factory); - for (final RunnerAndConfigurationSettings configuration : configurations) { - final ItemWrapper wrapped = ItemWrapper.wrap(project, configuration); - if (configuration == selectedConfiguration) { - wrapped.setMnemonic(1); - } + if (!(factory instanceof UnknownConfigurationType)) { + final RunnerAndConfigurationSettings[] configurations = manager.getConfigurationSettings(factory); + for (final RunnerAndConfigurationSettings configuration : configurations) { + final ItemWrapper wrapped = ItemWrapper.wrap(project, configuration); + if (configuration == selectedConfiguration) { + wrapped.setMnemonic(1); + } - wrappedExisting.put(configuration, wrapped); + wrappedExisting.put(configuration, wrapped); + } } } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/BaseExecuteBeforeRunDialog.java b/platform/lang-impl/src/com/intellij/execution/impl/BaseExecuteBeforeRunDialog.java index 9274a6a5dfb0..638759607a8a 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/BaseExecuteBeforeRunDialog.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/BaseExecuteBeforeRunDialog.java @@ -314,7 +314,7 @@ public abstract class BaseExecuteBeforeRunDialog extend myCheckbox.setBackground(UIUtil.getTreeTextBackground()); setBackground(selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground()); - Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground(); + final Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground(); setForeground(foreground); myCheckbox.setForeground(foreground); myLabel.setForeground(foreground); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index c518f5c98b7a..c91457623c83 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -1385,6 +1385,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo return next(1, true); } + @Nullable private OccurenceInfo next(final int delta, boolean doMove) { List ranges = new ArrayList(myHyperlinks.getRanges().keySet()); for (Iterator iterator = ranges.iterator(); iterator.hasNext();) { @@ -1412,7 +1413,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo scrollTo(next.getStartOffset()); } final HyperlinkInfo hyperlinkInfo = myHyperlinks.getRanges().get(next); - return new OccurenceInfo(new Navigatable.Adapter() { + return hyperlinkInfo == null ? null : new OccurenceInfo(new Navigatable.Adapter() { public void navigate(final boolean requestFocus) { hyperlinkInfo.navigate(myProject); linkFollowed(hyperlinkInfo); diff --git a/platform/lang-impl/src/com/intellij/facet/impl/FacetTypeRegistryImpl.java b/platform/lang-impl/src/com/intellij/facet/impl/FacetTypeRegistryImpl.java index 38302a48fc3c..b4a1c7ad25ba 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/FacetTypeRegistryImpl.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/FacetTypeRegistryImpl.java @@ -22,6 +22,7 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.ExtensionPointListener; import com.intellij.openapi.extensions.PluginDescriptor; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -87,11 +88,11 @@ public class FacetTypeRegistryImpl extends FacetTypeRegistry { myExtensionsLoaded = true; final ExtensionPoint extensionPoint = Extensions.getArea(null).getExtensionPoint(FacetType.EP_NAME); extensionPoint.addExtensionPointListener(new ExtensionPointListener() { - public void extensionAdded(final FacetType extension, @Nullable final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull final FacetType extension, @Nullable final PluginDescriptor pluginDescriptor) { registerFacetType(extension); } - public void extensionRemoved(final FacetType extension, @Nullable final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull final FacetType extension, @Nullable final PluginDescriptor pluginDescriptor) { unregisterFacetType(extension); } }); diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java b/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java index 20de75dc2040..efdad42f26d1 100644 --- a/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java +++ b/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java @@ -301,7 +301,8 @@ public class FormatterImpl extends FormatterEx final int defaultOffset = offset - whiteSpace.getLength() + newWS.length(); if (wsContainsCaret) { - final int ws = whiteSpace.getStartOffset() + CharArrayUtil.shiftForward(newWS, lineStartOffset - whiteSpace.getStartOffset(), " \t"); + final int ws = whiteSpace.getStartOffset() + + CharArrayUtil.shiftForward(newWS, Math.max(0, lineStartOffset - whiteSpace.getStartOffset()), " \t"); return Math.max(defaultOffset, ws); } else { return defaultOffset; diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java index 43e53c76dd06..bb5baa771a28 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyBrowserBaseEx.java @@ -19,6 +19,7 @@ package com.intellij.ide.hierarchy; import com.intellij.ide.IdeBundle; import com.intellij.ide.OccurenceNavigator; import com.intellij.ide.OccurenceNavigatorSupport; +import com.intellij.ide.PsiCopyPasteManager; import com.intellij.ide.dnd.DnDAction; import com.intellij.ide.dnd.DnDDragStartBean; import com.intellij.ide.dnd.DnDManager; @@ -54,6 +55,7 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; import java.awt.*; +import java.io.File; import java.text.MessageFormat; import java.util.*; import java.util.List; @@ -216,6 +218,11 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem public PsiElement[] getPsiElements() { return getSelectedElements(); } + + @Override + public List asFileList() { + return PsiCopyPasteManager.asFileList(getPsiElements()); + } }); } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java index 7664a3c70c38..8bd4660eed16 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java @@ -22,8 +22,8 @@ package com.intellij.ide.projectView.impl; import com.intellij.ide.DataManager; import com.intellij.ide.PsiCopyPasteManager; import com.intellij.ide.SelectInTarget; +import com.intellij.ide.dnd.*; import com.intellij.ide.dnd.aware.DnDAwareTree; -import com.intellij.ide.favoritesTreeView.FavoritesTreeViewPanel; import com.intellij.ide.projectView.BaseProjectTreeBuilder; import com.intellij.ide.projectView.ProjectView; import com.intellij.ide.projectView.impl.nodes.AbstractModuleNode; @@ -61,9 +61,11 @@ import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.datatransfer.DataFlavor; +import java.awt.*; import java.awt.datatransfer.Transferable; -import java.awt.dnd.*; +import java.awt.dnd.DnDConstants; +import java.awt.image.BufferedImage; +import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -84,6 +86,10 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl @NonNls private static final String ELEMENT_SUBPANE = "subPane"; @NonNls private static final String ATTRIBUTE_SUBID = "subId"; + private DnDTarget myDropTarget; + private DnDSource myDragSource; + private DnDManager myDndManager; + protected AbstractProjectViewPane(Project project) { myProject = project; } @@ -148,6 +154,17 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl } public void dispose() { + if (myDndManager != null) { + if (myDropTarget != null) { + myDndManager.unregisterTarget(myDropTarget, myTree); + myDropTarget = null; + } + if (myDragSource != null) { + myDndManager.unregisterSource(myDragSource, myTree); + myDragSource = null; + } + myDndManager = null; + } setTreeBuilder(null); myTree = null; myTreeStructure = null; @@ -465,36 +482,50 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl // Drag'n'Drop stuff - public static final DataFlavor[] FLAVORS; private static final Logger LOG = Logger.getInstance("com.intellij.ide.projectView.ProjectViewImpl"); - private final MyDragSourceListener myDragSourceListener = new MyDragSourceListener(); - static { - DataFlavor[] flavors; + + + @Nullable + public static PsiElement[] getTransferedPsiElements(Transferable transferable) { try { - final Class aClass = MyTransferable.class; - flavors = new DataFlavor[]{new DataFlavor( - DataFlavor.javaJVMLocalObjectMimeType + ";class=" + aClass.getName(), - FavoritesTreeViewPanel.ABSTRACT_TREE_NODE_TRANSFERABLE, - aClass.getClassLoader() - )}; + final Object transferData = transferable.getTransferData(DnDEventImpl.ourDataFlavor); + if (transferData instanceof TransferableWrapper) { + return ((TransferableWrapper)transferData).getPsiElements(); + } + return null; } - catch (ClassNotFoundException e) { - LOG.error(e); // should not happen - flavors = new DataFlavor[0]; + catch (Exception e) { + return null; + } + } + + @Nullable + public static TreeNode[] getTransferedTreeNodes(Transferable transferable) { + try { + final Object transferData = transferable.getTransferData(DnDEventImpl.ourDataFlavor); + if (transferData instanceof TransferableWrapper) { + return ((TransferableWrapper)transferData).getTreeNodes(); + } + return null; + } + catch (Exception e) { + return null; } - FLAVORS = flavors; } protected void enableDnD() { if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { - DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(myTree, DnDConstants.ACTION_COPY_OR_MOVE, new MyDragGestureListener()); - new DropTarget(myTree, new MoveDropTargetListener(new PsiRetriever() { - @Nullable - public PsiElement getPsiElement(@Nullable final TreeNode node) { + myDropTarget = new ProjectViewDropTarget(myTree, new PsiRetriever(){ + @Override + public PsiElement getPsiElement(@Nullable TreeNode node) { return getPSIElement(getElement(node)); } - }, myTree, myProject, FLAVORS[0])); + }, myProject); + myDragSource = new MyDragSource(); + myDndManager = DnDManager.getInstance(); + myDndManager.registerSource(myDragSource, myTree); + myDndManager.registerTarget(myDropTarget, myTree); } } @@ -507,99 +538,85 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl myTreeBuilder = treeBuilder; } - private static class MyTransferable implements Transferable { - private final Object myTransferable; - - public MyTransferable(Object transferable) { - myTransferable = transferable; - } - - public DataFlavor[] getTransferDataFlavors() { - DataFlavor[] flavors = new DataFlavor[2]; - flavors [0] = FLAVORS [0]; - flavors [1] = DataFlavor.javaFileListFlavor; - return flavors; - } - - public boolean isDataFlavorSupported(DataFlavor flavor) { - DataFlavor[] flavors = getTransferDataFlavors(); - return ArrayUtil.find(flavors, flavor) != -1; - } - - public Object getTransferData(DataFlavor flavor) { - if (flavor == DataFlavor.javaFileListFlavor) { - TransferableWrapper wrapper = (TransferableWrapper) myTransferable; - return PsiCopyPasteManager.asFileList(wrapper.getPsiElements()); - } - return myTransferable; - } - } - - public interface TransferableWrapper { + public interface TransferableWrapper extends DnDEventImpl.FileFlavorProvider{ TreeNode[] getTreeNodes(); @Nullable PsiElement[] getPsiElements(); } - private class MyDragGestureListener implements DragGestureListener { - public void dragGestureRecognized(DragGestureEvent dge) { - if ((dge.getDragAction() & DnDConstants.ACTION_COPY_OR_MOVE) == 0) return; - DataContext dataContext = DataManager.getInstance().getDataContext(); - ProjectView projectView = ProjectViewImpl.DATA_KEY.getData(dataContext); - if (projectView == null) return; - - final AbstractProjectViewPane currentPane = projectView.getCurrentProjectViewPane(); - final TreeNode[] nodes = currentPane.getSelectedTreeNodes(); - if (nodes != null) { - final Object[] elements = currentPane.getSelectedElements(); - final PsiElement[] psiElements = currentPane.getSelectedPSIElements(); - try { - Object transferableWrapper = new TransferableWrapper() { - public TreeNode[] getTreeNodes() { - return nodes; - } - public PsiElement[] getPsiElements() { - return psiElements; - } - }; - - //FavoritesManager.getInstance(myProject).getCurrentTreeViewPanel().setDraggableObject(draggableObject.getClass(), draggableObject.getValue()); - if ((psiElements != null && psiElements.length > 0) || canDragElements(elements, dataContext, dge.getDragAction())) { - dge.startDrag(DragSource.DefaultMoveNoDrop, new MyTransferable(transferableWrapper), myDragSourceListener); - } - } - catch (InvalidDnDOperationException idoe) { - // ignore - } - } + private class MyDragSource implements DnDSource { + @Override + public boolean canStartDragging(DnDAction action, Point dragOrigin) { + if ((action.getActionId() & DnDConstants.ACTION_COPY_OR_MOVE) == 0) return false; + final Object[] elements = getSelectedElements(); + final PsiElement[] psiElements = getSelectedPSIElements(); + DataContext dataContext = DataManager.getInstance().getDataContext(myTree); + return (psiElements.length > 0) || canDragElements(elements, dataContext, action.getActionId()); } - private boolean canDragElements(Object[] elements, DataContext dataContext, int dragAction) { - for (Object element : elements) { - if (element instanceof Module) { - return true; + @Override + public DnDDragStartBean startDragging(DnDAction action, Point dragOrigin) { + final PsiElement[] psiElements = getSelectedPSIElements(); + final TreeNode[] nodes = getSelectedTreeNodes(); + return new DnDDragStartBean(new TransferableWrapper(){ + + @Override + public List asFileList() { + return PsiCopyPasteManager.asFileList(psiElements); } - } - if (dragAction == DnDConstants.ACTION_MOVE) { - return MoveHandler.canMove(dataContext); - } - return false; + + @Override + public TreeNode[] getTreeNodes() { + return nodes; + } + + @Override + public PsiElement[] getPsiElements() { + return psiElements; + } + }); + } + + @Override + public Pair createDraggedImage(DnDAction action, Point dragOrigin) { + final TreePath[] paths = getSelectionPaths(); + if (paths == null) return null; + + final int count = paths.length; + + final JLabel label = new JLabel(String.format("%s item%s", count, count == 1 ? "" : "s")); + label.setOpaque(true); + label.setForeground(myTree.getForeground()); + label.setBackground(myTree.getBackground()); + label.setFont(myTree.getFont()); + label.setSize(label.getPreferredSize()); + final BufferedImage image = new BufferedImage(label.getWidth(), label.getHeight(), BufferedImage.TYPE_INT_ARGB); + + Graphics2D g2 = (Graphics2D)image.getGraphics(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f)); + label.paint(g2); + g2.dispose(); + + return new Pair(image, new Point(-image.getWidth(null), -image.getHeight(null))); + } + + @Override + public void dragDropEnd() { + } + + @Override + public void dropActionChanged(int gestureModifiers) { } } - private static class MyDragSourceListener implements DragSourceListener { - - public void dragEnter(DragSourceDragEvent dsde) { - dsde.getDragSourceContext().setCursor(null); + private static boolean canDragElements(Object[] elements, DataContext dataContext, int dragAction) { + for (Object element : elements) { + if (element instanceof Module) { + return true; + } } - - public void dragOver(DragSourceDragEvent dsde) {} - - public void dropActionChanged(DragSourceDragEvent dsde) { - dsde.getDragSourceContext().setCursor(null); + if (dragAction == DnDConstants.ACTION_MOVE) { + return MoveHandler.canMove(dataContext); } - - public void dragDropEnd(DragSourceDropEvent dsde) { } - - public void dragExit(DragSourceEvent dse) { } + return false; } } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/MoveDropTargetListener.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewDropTarget.java similarity index 73% rename from platform/lang-impl/src/com/intellij/ide/projectView/impl/MoveDropTargetListener.java rename to platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewDropTarget.java index 4fb424ff8a3b..df1878fba764 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/MoveDropTargetListener.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewDropTarget.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2010 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. @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.ide.projectView.impl; import com.intellij.ide.DataManager; +import com.intellij.ide.dnd.DnDEvent; +import com.intellij.ide.dnd.DnDNativeTarget; import com.intellij.ide.projectView.impl.nodes.DropTargetNode; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.LangDataKeys; @@ -29,6 +30,7 @@ import com.intellij.refactoring.RefactoringActionHandlerFactory; import com.intellij.refactoring.actions.BaseRefactoringAction; import com.intellij.refactoring.copy.CopyHandler; import com.intellij.refactoring.move.MoveHandler; +import com.intellij.ui.awt.RelativeRectangle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,116 +41,92 @@ import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.awt.dnd.*; +import java.awt.dnd.DnDConstants; import java.io.File; -import java.io.IOException; -import java.util.ArrayList; +import java.util.*; import java.util.List; /** - * @author vladk - */ -class MoveDropTargetListener implements DropTargetListener { - final private DataFlavor dataFlavor; - final private Project myProject; - final private JTree myTree; - final private PsiRetriever myPsiRetriever; +* User: anna +* Date: 10/7/10 +*/ +class ProjectViewDropTarget implements DnDNativeTarget { - public interface ModifierSource { - int getModifiers(); - } + private JTree myTree; + private final PsiRetriever myPsiRetriever; + private final Project myProject; - public MoveDropTargetListener(final PsiRetriever psiRetriever, final JTree tree, final Project project, final DataFlavor flavor) { + ProjectViewDropTarget(JTree tree, PsiRetriever psiRetriever, Project project) { + myTree = tree; myPsiRetriever = psiRetriever; myProject = project; - myTree = tree; - dataFlavor = flavor; } - public void dragEnter(DropTargetDragEvent dtde) { - final DropHandler dropHandler = getDropHandler(dtde.getDropAction()); - final TreeNode[] sourceNodes = getSourceNodes(dtde.getTransferable()); - if (sourceNodes != null && dropHandler.isValidSource(sourceNodes)) { - dtde.acceptDrag(dtde.getDropAction()); + @Override + public boolean update(DnDEvent aEvent) { + final Object attached = aEvent.getAttachedObject(); + aEvent.setDropPossible(false, ""); + final int dropAction = aEvent.getAction().getActionId(); + final DropHandler dropHandler = getDropHandler(dropAction); + final TreeNode[] sourceNodes = getSourceNodes(attached); + final Point point = aEvent.getPoint(); + final TreeNode targetNode = getTargetNode(point); + + if (targetNode == null || (dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0 ) { + return false; } - else if (dtde.getTransferable().isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { - dtde.acceptDrag(dtde.getDropAction()); + else if (sourceNodes == null && !aEvent.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { + return false; } - else { - dtde.rejectDrag(); + else if (sourceNodes != null && !dropHandler.isValidSource(sourceNodes, targetNode)) { + return false; } + final Rectangle pathBounds = myTree.getPathBounds(myTree.getPathForLocation(point.x, point.y)); + aEvent.setHighlighting(new RelativeRectangle(myTree, pathBounds), DnDEvent.DropTargetHighlightingType.RECTANGLE ); + aEvent.setDropPossible(true, null); + return false; } - public void dragOver(DropTargetDragEvent dtde) { - final TreeNode[] sourceNodes = getSourceNodes(dtde.getTransferable()); - final TreeNode targetNode = getTargetNode(dtde.getLocation()); - final int dropAction = dtde.getDropAction(); - if (sourceNodes != null && targetNode != null && canDrop(sourceNodes, targetNode, dropAction)) { - dtde.acceptDrag(dropAction); - } - else if (targetNode != null && dtde.getTransferable().isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { - dtde.acceptDrag(dropAction); - } - else { - dtde.rejectDrag(); - } - } - - public void dropActionChanged(DropTargetDragEvent dtde) { - } - - public void dragExit(DropTargetEvent dte) { - } - - public void drop(DropTargetDropEvent dtde) { - final TreeNode[] sourceNodes = getSourceNodes(dtde.getTransferable()); - final TreeNode targetNode = getTargetNode(dtde.getLocation()); - final int dropAction = dtde.getDropAction(); - if (targetNode == null || (dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0) { - dtde.rejectDrop(); - } - else if (sourceNodes == null) { - if (dtde.getTransferable().isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { - dtde.acceptDrop(dropAction); - List fileList; + @Override + public void drop(DnDEvent aEvent) { + Object attached = aEvent.getAttachedObject(); + final TreeNode[] sourceNodes = getSourceNodes(attached); + final TreeNode targetNode = getTargetNode(aEvent.getPoint()); + assert targetNode != null; + final int dropAction = aEvent.getAction().getActionId(); + if (sourceNodes == null) { + if (aEvent.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { + Object fileList; try { - fileList = (List)dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor); + fileList = ((EventInfo)attached).getTransferable().getTransferData(DataFlavor.javaFileListFlavor); } catch (Exception e) { - dtde.rejectDrop(); return; } - getDropHandler(dropAction).doDropFiles(fileList, targetNode); - } - else { - dtde.rejectDrop(); + if (fileList instanceof List) { + getDropHandler(dropAction).doDropFiles((List)fileList, targetNode); + } } } - else if (!doDrop(sourceNodes, targetNode, dropAction, dtde)) { - dtde.rejectDrop(); + else { + doDrop(sourceNodes, targetNode, dropAction); } } + @Override + public void cleanUpOnLeave() { + } + + @Override + public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) { + } + @Nullable - private TreeNode[] getSourceNodes(final Transferable transferable) { - if (!transferable.isDataFlavorSupported(dataFlavor)) { - return null; - } - try { - Object transferData = transferable.getTransferData(dataFlavor); - if (transferData instanceof AbstractProjectViewPSIPane.TransferableWrapper) { - return ((AbstractProjectViewPSIPane.TransferableWrapper)transferData).getTreeNodes(); - } - return null; - } - catch (UnsupportedFlavorException e) { - return null; - } - catch (IOException e) { - return null; + private static TreeNode[] getSourceNodes(final Object transferData) { + if (transferData instanceof AbstractProjectViewPSIPane.TransferableWrapper) { + return ((AbstractProjectViewPSIPane.TransferableWrapper)transferData).getTreeNodes(); } + return null; } @Nullable @@ -157,22 +135,14 @@ class MoveDropTargetListener implements DropTargetListener { return path == null ? null : (TreeNode)path.getLastPathComponent(); } - private boolean canDrop(@NotNull final TreeNode[] sourceNodes, @NotNull final TreeNode targetNode, final int dropAction) { - return doDrop(sourceNodes, targetNode, dropAction, null); - } - private boolean doDrop(@NotNull final TreeNode[] sourceNodes, @NotNull final TreeNode targetNode, - final int dropAction, - @Nullable final DropTargetDropEvent dtde) { + final int dropAction) { TreeNode validTargetNode = getValidTargetNode(sourceNodes, targetNode, dropAction); if (validTargetNode != null) { final TreeNode[] filteredSourceNodes = removeRedundantSourceNodes(sourceNodes, validTargetNode, dropAction); if (filteredSourceNodes.length != 0) { - if (dtde != null) { - dtde.dropComplete(true); - getDropHandler(dropAction).doDrop(filteredSourceNodes, validTargetNode); - } + getDropHandler(dropAction).doDrop(filteredSourceNodes, validTargetNode); return true; } } @@ -209,7 +179,7 @@ class MoveDropTargetListener implements DropTargetListener { } private interface DropHandler { - boolean isValidSource(@NotNull TreeNode[] sourceNodes); + boolean isValidSource(@NotNull TreeNode[] sourceNodes, TreeNode targetNode); boolean isValidTarget(@NotNull TreeNode[] sourceNodes, @NotNull TreeNode targetNode); @@ -224,8 +194,8 @@ class MoveDropTargetListener implements DropTargetListener { public abstract class MoveCopyDropHandler implements DropHandler { - public boolean isValidSource(@NotNull final TreeNode[] sourceNodes) { - return canDrop(sourceNodes, null); + public boolean isValidSource(@NotNull final TreeNode[] sourceNodes, TreeNode targetNode) { + return canDrop(sourceNodes, targetNode); } public boolean isValidTarget(@NotNull final TreeNode[] sourceNodes, final @NotNull TreeNode targetNode) { @@ -234,11 +204,11 @@ class MoveDropTargetListener implements DropTargetListener { protected abstract boolean canDrop(@NotNull TreeNode[] sourceNodes, @Nullable TreeNode targetNode); - @Nullable protected PsiElement getPsiElement(@Nullable final TreeNode treeNode) { return myPsiRetriever.getPsiElement(treeNode); } + @NotNull protected PsiElement[] getPsiElements(@NotNull TreeNode[] nodes) { List psiElements = new ArrayList(nodes.length); for (TreeNode node : nodes) { @@ -307,7 +277,7 @@ class MoveDropTargetListener implements DropTargetListener { final PsiElement targetElement = getPsiElement(targetNode); if (targetElement == null) return; final DataContext dataContext = DataManager.getInstance().getDataContext(myTree); - getActionHandler(dataContext).invoke(myProject, sourceElements, new DataContext() { + getActionHandler().invoke(myProject, sourceElements, new DataContext() { @Nullable public Object getData(@NonNls String dataId) { if (LangDataKeys.TARGET_PSI_ELEMENT.is(dataId)) { @@ -320,7 +290,7 @@ class MoveDropTargetListener implements DropTargetListener { }); } - private RefactoringActionHandler getActionHandler(final DataContext dataContext) { + private RefactoringActionHandler getActionHandler() { return RefactoringActionHandlerFactory.getInstance().createMoveHandler(); } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java index d6d08f5f0ca1..89458c21f188 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java @@ -21,6 +21,8 @@ import com.intellij.history.LocalHistory; import com.intellij.history.LocalHistoryAction; import com.intellij.ide.*; import com.intellij.ide.FileEditorProvider; +import com.intellij.ide.dnd.DnDManager; +import com.intellij.ide.dnd.DnDTarget; import com.intellij.ide.impl.ProjectViewSelectInTarget; import com.intellij.ide.projectView.HelpID; import com.intellij.ide.projectView.ProjectView; diff --git a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index cc59482522af..a5007d61353f 100644 --- a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -402,7 +402,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { return pre; } - private static class Token extends Node { + private static abstract class Token extends Node { public PsiBuilderImpl myBuilder; public IElementType myTokenType; public int myTokenStart; @@ -461,6 +461,9 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } } + private static class TokenNode extends Token implements LighterASTTokenNode { + } + private static class LazyParseableToken extends Token implements LighterLazyParseableNode { private MyTreeStructure myParent; private FlyweightCapableTreeStructure myParsed; @@ -1169,7 +1172,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } public Token create() { - return new Token(); + return new TokenNode(); } }); myLazyPool = new LimitedPool(200, new LimitedPool.ObjectFactory() { @@ -1229,7 +1232,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { ProductionMarker prevChild = null; int lexIndex = marker.myLexemeIndex; while (child != null) { - lexIndex = insertLeafs(lexIndex, child.myLexemeIndex, into, marker.myBuilder); + lexIndex = insertLeaves(lexIndex, child.myLexemeIndex, into, marker.myBuilder); if (child instanceof StartMarker && ((StartMarker)child).myDoneMarker.myCollapse) { final int start = marker.myBuilder.myLexStarts[child.myLexemeIndex]; @@ -1251,7 +1254,8 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } child = child.next; } - insertLeafs(lexIndex, marker.myDoneMarker.myLexemeIndex, into, marker.myBuilder); + + insertLeaves(lexIndex, marker.myDoneMarker.myLexemeIndex, into, marker.myBuilder); return count; } @@ -1269,7 +1273,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } } - private int insertLeafs(int curToken, int lastIdx, Ref into, PsiBuilderImpl builder) { + private int insertLeaves(int curToken, int lastIdx, Ref into, PsiBuilderImpl builder) { lastIdx = Math.min(lastIdx, builder.myLexemeCount); while (curToken < lastIdx) { final int start = builder.myLexStarts[curToken]; @@ -1284,7 +1288,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } private void insertLeaf(Ref into, int start, int end, IElementType type, PsiBuilderImpl builder) { - Token lexeme; + final Token lexeme; if (type instanceof ILightLazyParseableElementType) { lexeme = myLazyPool.alloc(); ((LazyParseableToken)lexeme).myParent = this; diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerImpl.java index 4c07c0d5efea..091e451f5dd1 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ProjectRootManagerImpl.java @@ -628,7 +628,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj } private void addRootsToWatch() { - final Set rootPaths = getAllRoots(); + final Set rootPaths = getAllRoots(false); if (rootPaths == null) return; final Set newRootsToWatch = LocalFileSystem.getInstance().addRootsToWatch(rootPaths, true); @@ -639,7 +639,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj } @Nullable - private Set getAllRoots() { + private Set getAllRoots(boolean includeSourceRoots) { if (myProject.isDefault()) return null; final Set rootPaths = new HashSet(); @@ -648,6 +648,10 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); final String[] contentRootUrls = moduleRootManager.getContentRootUrls(); rootPaths.addAll(getRootsToTrack(contentRootUrls)); + if (includeSourceRoots) { + final String[] sourceRootUrls = moduleRootManager.getSourceRootUrls(); + rootPaths.addAll(getRootsToTrack(sourceRootUrls)); + } rootPaths.add(module.getModuleFilePath()); } @@ -775,7 +779,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj } private boolean affectsRoots(VirtualFilePointer[] pointers) { - Set roots = getAllRoots(); + Set roots = getAllRoots(true); if (roots == null) return false; for (VirtualFilePointer pointer : pointers) { diff --git a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.form b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.form index 09ddcc8e4285..fc6ca43d8312 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.form +++ b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.form @@ -8,7 +8,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.java b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.java index 28ff88985d5d..2ec67154b7c5 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.java +++ b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.java @@ -21,7 +21,11 @@ import com.intellij.ide.IdeBundle; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.openapi.options.*; +import com.intellij.openapi.application.ApplicationNamesInfo; +import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.options.NonDefaultProjectConfigurable; +import com.intellij.openapi.options.OptionalConfigurable; +import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.IconLoader; @@ -51,10 +55,12 @@ public class FileEncodingConfigurable implements SearchableConfigurable, NonDefa private JPanel myPropertiesFilesEncodingCombo; private Charset mySelectedCharsetForPropertiesFiles; private JComboBox myIdeEncodingsCombo; + private JLabel myTitleLabel; private ChooseFileEncodingAction myAction; public FileEncodingConfigurable(Project project) { myProject = project; + myTitleLabel.setText(myTitleLabel.getText().replace("$productName", ApplicationNamesInfo.getInstance().getFullProductName())); } @Nls diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java index b414c83073c5..a41e807bbba8 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java @@ -60,7 +60,6 @@ import java.util.Set; public class InspectionProjectProfileManager extends DefaultProjectProfileManager implements SeverityProvider, ProjectComponent, PersistentStateComponent { private final Map myName2Profile = new HashMap(); private final SeverityRegistrar mySeverityRegistrar; - private StatusBarEx myStatusBar; private TogglePopupHintsPanel myTogglePopupHintsPanel; public InspectionProjectProfileManager(final Project project, InspectionProfileManager inspectionProfileManager, DependencyValidationManager holder) { @@ -147,9 +146,9 @@ public class InspectionProjectProfileManager extends DefaultProjectProfileManage } public void projectOpened() { - myStatusBar = (StatusBarEx)WindowManager.getInstance().getStatusBar(myProject); + StatusBarEx statusBar = (StatusBarEx)WindowManager.getInstance().getStatusBar(myProject); myTogglePopupHintsPanel = new TogglePopupHintsPanel(myProject); - myStatusBar.addWidget(myTogglePopupHintsPanel, myProject); + statusBar.addWidget(myTogglePopupHintsPanel, myProject); StartupManager.getInstance(myProject).registerPostStartupActivity(new Runnable() { public void run() { final Set profiles = new HashSet(); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java index 84bf2ab96d2c..f80f845ad3a5 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java @@ -49,7 +49,7 @@ abstract class InspectionsConfigTreeRenderer extends CheckboxTree.CheckboxTreeCe Object object = node.getUserObject(); final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); Color foreground = selected ? UIUtil.getTreeSelectionForeground() : node.isProperSetting ? Color.BLUE : UIUtil.getTreeTextForeground(); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/DebugUtil.java b/platform/lang-impl/src/com/intellij/psi/impl/DebugUtil.java index 321a592dff98..093f36a80258 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/DebugUtil.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/DebugUtil.java @@ -18,7 +18,7 @@ package com.intellij.psi.impl; import com.intellij.lang.ASTNode; import com.intellij.lang.LighterASTNode; -import com.intellij.lang.LighterLazyParseableNode; +import com.intellij.lang.LighterASTTokenNode; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Ref; @@ -136,26 +136,18 @@ public class DebugUtil { } public static String lightTreeToString(@NotNull final FlyweightCapableTreeStructure tree, - @NotNull final String source, final boolean skipWhitespaces) { final StringBuilder buffer = new StringBuilder(); - lightTreeToBuffer(tree, source, buffer, tree.getRoot(), 0, skipWhitespaces, 0); + lightTreeToBuffer(tree, tree.getRoot(), buffer, 0, skipWhitespaces); return buffer.toString(); } - public static void lightTreeToBuffer(@NotNull final FlyweightCapableTreeStructure tree, - @NotNull final String source, - @NotNull final StringBuilder buffer, - @NotNull final LighterASTNode root, - final int indent, - final boolean skipWhiteSpaces, - final int chameleonShift) { - final IElementType tokenType = root.getTokenType(); + public static void lightTreeToBuffer(@NotNull final FlyweightCapableTreeStructure tree, @NotNull final LighterASTNode node, + @NotNull final StringBuilder buffer, final int indent, final boolean skipWhiteSpaces) { + final IElementType tokenType = node.getTokenType(); if (skipWhiteSpaces && tokenType == TokenType.WHITE_SPACE) return; - final Ref kids = new Ref(); - final int numKids = tree.getChildren(tree.prepareForGetChildren(root), kids); - final boolean composite = numKids > 0 || root.getStartOffset() == root.getEndOffset(); + final boolean isLeaf = (node instanceof LighterASTTokenNode); StringUtil.repeatSymbol(buffer, ' ', indent); if (tokenType == TokenType.ERROR_ELEMENT) { @@ -165,24 +157,25 @@ public class DebugUtil { buffer.append("PsiWhiteSpace"); } else { - buffer.append(composite ? "Element" : "PsiElement").append('(').append(tokenType).append(')'); + buffer.append(isLeaf ? "PsiElement" : "Element").append('(').append(tokenType).append(')'); } - if (!composite) { - final String text = source.substring(chameleonShift + root.getStartOffset(), chameleonShift + root.getEndOffset()); + if (isLeaf) { + final String text = ((LighterASTTokenNode)node).getText().toString(); buffer.append("('").append(fixWhiteSpaces(text)).append("')"); } buffer.append('\n'); - if (composite) { + if (!isLeaf) { + final Ref kids = new Ref(); + final int numKids = tree.getChildren(tree.prepareForGetChildren(node), kids); if (numKids == 0) { StringUtil.repeatSymbol(buffer, ' ', indent + 2); buffer.append("\n"); } else { - final int shift = root instanceof LighterLazyParseableNode ? root.getStartOffset() : 0; for (int i = 0; i < numKids; i++) { - lightTreeToBuffer(tree, source, buffer, kids.get()[i], indent + 2, skipWhiteSpaces, chameleonShift + shift); + lightTreeToBuffer(tree, kids.get()[i], buffer, indent + 2, skipWhiteSpaces); } } } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java index 81c525c9df0c..e22b3f8a5fd1 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java @@ -66,20 +66,20 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager { final ExtensionPoint multiPoint = Extensions.getArea(project).getExtensionPoint(MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME); multiPoint.addExtensionPointListener(new ExtensionPointListener() { - public void extensionAdded(MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) { registerMultiHostInjector(injector); } - public void extensionRemoved(MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) { unregisterMultiHostInjector(injector); } }); final ExtensionPointListener myListener = new ExtensionPointListener() { - public void extensionAdded(LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) { psiManagerInjectorsChanged(); } - public void extensionRemoved(LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) { psiManagerInjectorsChanged(); } }; diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/SerializedStubTree.java b/platform/lang-impl/src/com/intellij/psi/stubs/SerializedStubTree.java index 89d999989cf3..ff98fd7edd2b 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/SerializedStubTree.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/SerializedStubTree.java @@ -19,19 +19,22 @@ */ package com.intellij.psi.stubs; +import org.jetbrains.annotations.Nullable; + import java.io.ByteArrayInputStream; -import java.io.DataInputStream; import java.util.Arrays; public class SerializedStubTree { private final byte[] myBytes; + private final StubElement myStub; - public SerializedStubTree(final byte[] bytes) { + public SerializedStubTree(final byte[] bytes, @Nullable StubElement stub) { myBytes = bytes; + myStub = stub; } public StubElement getStub() { - return SerializationManager.getInstance().deserialize(new ByteArrayInputStream(myBytes)); + return myStub == null ? SerializationManager.getInstance().deserialize(new ByteArrayInputStream(myBytes)) : myStub; } public boolean equals(final Object that) { diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java index e403b2cb302d..83c475c3a805 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java @@ -63,7 +63,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi int len = in.readInt(); byte[] result = new byte[len]; in.readFully(result); - return new SerializedStubTree(result); + return new SerializedStubTree(result, null); } }; @@ -118,7 +118,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi SerializationManager.getInstance().serialize(rootStub, bytes); final int key = Math.abs(FileBasedIndex.getFileId(inputData.getFile())); - result.put(key, new SerializedStubTree(bytes.toByteArray())); + result.put(key, new SerializedStubTree(bytes.toByteArray(), rootStub)); } }); diff --git a/platform/lang-impl/src/com/intellij/refactoring/actions/BasePlatformRefactoringAction.java b/platform/lang-impl/src/com/intellij/refactoring/actions/BasePlatformRefactoringAction.java index f5dab5ab830a..2efa4455d885 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/actions/BasePlatformRefactoringAction.java +++ b/platform/lang-impl/src/com/intellij/refactoring/actions/BasePlatformRefactoringAction.java @@ -48,11 +48,11 @@ public abstract class BasePlatformRefactoringAction extends BaseRefactoringActio public BasePlatformRefactoringAction() { LanguageRefactoringSupport.INSTANCE.addListener(new ExtensionPointListener() { - public void extensionAdded(RefactoringSupportProvider extension, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull RefactoringSupportProvider extension, @Nullable PluginDescriptor pluginDescriptor) { myHidden = null; } - public void extensionRemoved(RefactoringSupportProvider extension, @Nullable PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull RefactoringSupportProvider extension, @Nullable PluginDescriptor pluginDescriptor) { myHidden = null; } }); diff --git a/platform/lang-impl/src/com/intellij/testIntegration/GotoTestOrCodeAction.java b/platform/lang-impl/src/com/intellij/testIntegration/GotoTestOrCodeAction.java index 342daabc8699..f71f6664507f 100644 --- a/platform/lang-impl/src/com/intellij/testIntegration/GotoTestOrCodeAction.java +++ b/platform/lang-impl/src/com/intellij/testIntegration/GotoTestOrCodeAction.java @@ -41,6 +41,10 @@ public class GotoTestOrCodeAction extends BaseCodeInsightAction { @Override public void update(AnActionEvent event) { Presentation p = event.getPresentation(); + if (TestFinderHelper.getFinders().length == 0) { + p.setVisible(false); + return; + } p.setEnabled(false); Project project = event.getData(PlatformDataKeys.PROJECT); Editor editor = event.getData(PlatformDataKeys.EDITOR); diff --git a/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java b/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java index bbe2631576e1..b7e0ebc9b624 100644 --- a/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java +++ b/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java @@ -55,7 +55,7 @@ public class TestFinderHelper { return false; } - private static TestFinder[] getFinders() { + public static TestFinder[] getFinders() { return Extensions.getExtensions(TestFinder.EP_NAME); } } diff --git a/platform/lang-impl/src/com/intellij/tools/ToolsPanel.java b/platform/lang-impl/src/com/intellij/tools/ToolsPanel.java index 1027380ca1cf..c8074bd5912c 100644 --- a/platform/lang-impl/src/com/intellij/tools/ToolsPanel.java +++ b/platform/lang-impl/src/com/intellij/tools/ToolsPanel.java @@ -88,7 +88,7 @@ class ToolsPanel extends JPanel { // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } if (object instanceof ToolsGroup) { diff --git a/platform/lang-impl/testSrc/com/intellij/lang/PsiBuilderQuickTest.java b/platform/lang-impl/testSrc/com/intellij/lang/PsiBuilderQuickTest.java index 21bf084484a2..96a5fb4e6d35 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/PsiBuilderQuickTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/PsiBuilderQuickTest.java @@ -523,10 +523,10 @@ public class PsiBuilderQuickTest { // check light tree composition final FlyweightCapableTreeStructure lightTree = builder.getLightTree(); final String lightExpected = expected.replaceAll("PsiErrorElement:.*\n", "PsiErrorElement\n"); - assertEquals(lightExpected, DebugUtil.lightTreeToString(lightTree, text, false)); + assertEquals(lightExpected, DebugUtil.lightTreeToString(lightTree, false)); // verify that light tree can be taken multiple times final FlyweightCapableTreeStructure lightTree2 = builder.getLightTree(); - assertEquals(lightExpected, DebugUtil.lightTreeToString(lightTree2, text, false)); + assertEquals(lightExpected, DebugUtil.lightTreeToString(lightTree2, false)); // check heavy tree composition final ASTNode root = builder.getTreeBuilt(); diff --git a/platform/lvcs-impl/src/com/intellij/openapi/command/impl/FileUndoProvider.java b/platform/lvcs-impl/src/com/intellij/openapi/command/impl/FileUndoProvider.java index ae3b5026bd5a..4c8bc8d2b11c 100644 --- a/platform/lvcs-impl/src/com/intellij/openapi/command/impl/FileUndoProvider.java +++ b/platform/lvcs-impl/src/com/intellij/openapi/command/impl/FileUndoProvider.java @@ -23,7 +23,6 @@ import com.intellij.history.core.changes.ContentChange; import com.intellij.history.core.changes.StructuralChange; import com.intellij.history.integration.IdeaGateway; import com.intellij.history.integration.LocalHistoryImpl; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.undo.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -111,7 +110,10 @@ public class FileUndoProvider extends VirtualFileAdapter implements UndoProvider } public void beforeFileDeletion(VirtualFileEvent e) { - if (shouldNotProcess(e)) return; + if (shouldNotProcess(e)) { + invalidateActionsFor(e); + return; + } if (isUndoable(e)) { VirtualFile file = e.getFile(); file.putUserData(DELETION_WAS_UNDOABLE, createDocumentReference(e)); @@ -155,6 +157,10 @@ public class FileUndoProvider extends VirtualFileAdapter implements UndoProvider getUndoManager().nonundoableActionPerformed(createDocumentReference(e), true); } + private void invalidateActionsFor(VirtualFileEvent e) { + getUndoManager().invalidateActionsFor(createDocumentReference(e)); + } + private DocumentReference createDocumentReference(VirtualFileEvent e) { return DocumentReferenceManager.getInstance().create(e.getFile()); } diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java index 048bc1aeab55..91500c2713b2 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java +++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java @@ -15,10 +15,13 @@ */ package com.intellij.openapi.fileChooser; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.UIBundle; public class FileChooserDescriptorFactory { - private FileChooserDescriptorFactory() {} + private FileChooserDescriptorFactory() { + } public static FileChooserDescriptor createAllButJarContentsDescriptor() { return new FileChooserDescriptor(true, true, true, true, false, true); @@ -59,4 +62,18 @@ public class FileChooserDescriptorFactory { fileChooserDescriptor.setTitle(UIBundle.message("file.chooser.select.object.title", aSearchedObjectName)); return fileChooserDescriptor; } + + public static FileChooserDescriptor createSingleFileDescriptor(final FileType fileType) { + return new FileChooserDescriptor(true, false, false, false, false, false) { + @Override + public boolean isFileVisible(final VirtualFile file, final boolean showHiddenFiles) { + return file.isDirectory() || file.getFileType() == fileType; + } + + @Override + public boolean isFileSelectable(final VirtualFile file) { + return super.isFileSelectable(file) && file.getFileType() == fileType; + } + }; + } } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/JBPopup.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/JBPopup.java index db88d602c59a..0ea51772bae2 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/popup/JBPopup.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/JBPopup.java @@ -180,4 +180,6 @@ public interface JBPopup extends Disposable, LightweightWindow { void setFinalRunnable(@Nullable Runnable runnable); void moveToFitScreen(); + + Point getLocationOnScreen(); } diff --git a/platform/platform-api/src/com/intellij/openapi/util/KeyedExtensionCollector.java b/platform/platform-api/src/com/intellij/openapi/util/KeyedExtensionCollector.java index d17505cbb238..34044aef8e29 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/KeyedExtensionCollector.java +++ b/platform/platform-api/src/com/intellij/openapi/util/KeyedExtensionCollector.java @@ -178,7 +178,7 @@ public abstract class KeyedExtensionCollector { ExtensionPointName> typesafe = ExtensionPointName.create(myEpName); myPoint = Extensions.getRootArea().getExtensionPoint(typesafe); myListener = new ExtensionPointAndAreaListener>() { - public void extensionAdded(final KeyedLazyInstance bean, @Nullable final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull final KeyedLazyInstance bean, @Nullable final PluginDescriptor pluginDescriptor) { w.lock(); try { myCache.remove(bean.getKey()); @@ -191,7 +191,7 @@ public abstract class KeyedExtensionCollector { } } - public void extensionRemoved(final KeyedLazyInstance bean, @Nullable final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull final KeyedLazyInstance bean, @Nullable final PluginDescriptor pluginDescriptor) { w.lock(); try { myCache.remove(bean.getKey()); diff --git a/platform/platform-api/src/com/intellij/ui/table/JBTable.java b/platform/platform-api/src/com/intellij/ui/table/JBTable.java index 90b2c6b3d1db..5c87d5c6f4cb 100644 --- a/platform/platform-api/src/com/intellij/ui/table/JBTable.java +++ b/platform/platform-api/src/com/intellij/ui/table/JBTable.java @@ -232,7 +232,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } if (!selected) return result; diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java index 0328885ae07f..b5b57879085b 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java @@ -210,51 +210,25 @@ public class HintManagerImpl extends HintManager implements Disposable { ((ScrollAwareHint)hint.getComponent()).editorScrolled(); } - if (!hint.isVisible()) { - return; - } + if (!hint.isVisible()) return; Editor editor = e.getEditor(); if (!editor.getComponent().isShowing() || editor.isOneLineMode()) return; Rectangle newRectangle = e.getOldRectangle(); Rectangle oldRectangle = e.getNewRectangle(); - Rectangle bounds = hint.getBounds(); - Point location; - - final Window window = SwingUtilities.getWindowAncestor(hint.getComponent()); - final boolean realPopup = window != null && window != SwingUtilities.getWindowAncestor(editor.getComponent()); - if (realPopup) { - location = window.getLocationOnScreen(); - SwingUtilities.convertPointFromScreen(location, editor.getContentComponent()); - } else { - location = SwingUtilities.convertPoint( - editor.getComponent().getRootPane().getLayeredPane(), - bounds.getLocation(), - editor.getContentComponent() - ); - } + Point location = hint.getLocationOn(editor.getContentComponent()); + Dimension size = hint.getSize(); int xOffset = location.x - oldRectangle.x; int yOffset = location.y - oldRectangle.y; location = new Point(newRectangle.x + xOffset, newRectangle.y + yOffset); - Rectangle newBounds = new Rectangle(location.x, location.y, bounds.width, bounds.height); - - final boolean valid = hideIfOutOfEditor ? oldRectangle.contains(newBounds) : oldRectangle.intersects(newBounds); - if (valid) { - if (!realPopup) { - location = SwingUtilities.convertPoint( - editor.getContentComponent(), - location, - editor.getComponent().getRootPane().getLayeredPane() - ); - hint.updateBounds(location.x, location.y); - } else { - SwingUtilities.convertPointToScreen(location, editor.getContentComponent()); - window.setLocation(location); - } + Rectangle newBounds = new Rectangle(location.x, location.y, size.width, size.height); + final boolean okToUpdateBounds = hideIfOutOfEditor ? oldRectangle.contains(newBounds) : oldRectangle.intersects(newBounds); + if (okToUpdateBounds) { + hint.setLocation(new RelativePoint(editor.getContentComponent(), location)); } else { hint.hide(); diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/TooltipController.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/TooltipController.java index 68ce15a0570b..48d49751d2de 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/TooltipController.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/TooltipController.java @@ -26,7 +26,6 @@ import com.intellij.ui.LightweightHint; import com.intellij.ui.awt.RelativePoint; import org.jetbrains.annotations.NotNull; -import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; @@ -57,7 +56,13 @@ public class TooltipController { final boolean alignToRight, @NotNull final TooltipGroup group, final HintHint hintHint) { if (myCurrentTooltip == null || !myCurrentTooltip.isVisible()) { - myCurrentTooltipObject = null; + if (myCurrentTooltip != null) { + if (!IdeTooltipManager.getInstance().isQueuedToShow(myCurrentTooltip.getCurrentIdeTooltip())) { + myCurrentTooltipObject = null; + } + } else { + myCurrentTooltipObject = null; + } } if (Comparing.equal(tooltipObject, myCurrentTooltipObject)) { diff --git a/platform/platform-impl/src/com/intellij/featureStatistics/ui/ProgressTipPanel.java b/platform/platform-impl/src/com/intellij/featureStatistics/ui/ProgressTipPanel.java index bf45c7694562..629ed08dae88 100644 --- a/platform/platform-impl/src/com/intellij/featureStatistics/ui/ProgressTipPanel.java +++ b/platform/platform-impl/src/com/intellij/featureStatistics/ui/ProgressTipPanel.java @@ -67,8 +67,7 @@ public class ProgressTipPanel { final HTMLEditorKit editorKit = new HTMLEditorKit(); myBrowser.setEditorKit(editorKit); myBrowser.setContentType(UIUtil.HTML_MIME); - myBrowser.setBackground(UIUtil.getTextFieldBackground()); - + myBrowser.setBackground(Color.white); myScrollPane.setPreferredSize(new Dimension(600, 200)); myBrowser.setEditable(false); myPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java index d525f5752494..79a9a3a04fe9 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java @@ -17,11 +17,12 @@ package com.intellij.ide; import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.util.registry.Registry; +import com.intellij.util.ui.update.ComparableObject; import javax.swing.*; import java.awt.*; -public class IdeTooltip { +public class IdeTooltip extends ComparableObject.Impl { private Component myComponent; private Point myPoint; @@ -34,7 +35,8 @@ public class IdeTooltip { private boolean myToCenterIfSmall = true; private boolean myHighlighter; - public IdeTooltip(Component component, Point point, JComponent tipComponent) { + public IdeTooltip(Component component, Point point, JComponent tipComponent, Object... identity) { + super(identity); myComponent = component; myPoint = point; myTipComponent = tipComponent; diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java index c61301e90869..0414db008536 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java @@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.ui.popup.BalloonBuilder; import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.registry.Registry; @@ -31,7 +32,9 @@ import com.intellij.ui.HintHint; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.Alarm; import com.intellij.util.IJSwingUtilities; +import com.intellij.util.containers.ComparatorUtil; import com.intellij.util.ui.UIUtil; +import com.intellij.util.ui.update.ComparableObjectCheck; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -72,7 +75,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener private IdeTooltip myCurrentTooltip; private Runnable myShowRequest; - + private IdeTooltip myQueuedTooltip; public IdeTooltipManager(JBPopupFactory popupFactory) { @@ -151,7 +154,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener } private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter) { - final IdeTooltip tooltip = new IdeTooltip(c, me.getPoint(), null) { + final IdeTooltip tooltip = new IdeTooltip(c, me.getPoint(), null, new Object()) { @Override protected boolean beforeShow() { myCurrentEvent = me; @@ -179,6 +182,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener hideCurrent(null); myQueuedComponent = tooltip.getComponent(); + myQueuedTooltip = tooltip; myShowRequest = new Runnable() { @Override @@ -265,6 +269,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener myCurrentTooltip = tooltip; myShowRequest = null; myQueuedComponent = null; + myQueuedTooltip = null; myCurrentTipUi.show(new RelativePoint(tooltip.getComponent(), effectivePoint), tooltip.getPreferredPosition()); myAlarm.addRequest(new Runnable() { @@ -328,6 +333,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener private boolean hideCurrent(@Nullable MouseEvent me) { myShowRequest = null; myQueuedComponent = null; + myQueuedTooltip = null; if (myCurrentTooltip == null) return true; @@ -378,6 +384,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener myCurrentTipUi = null; myCurrentComponent = null; myQueuedComponent = null; + myQueuedTooltip = null; myCurrentEvent = null; myCurrentTipIsCentered = false; myX = -1; @@ -538,4 +545,8 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener public String getComponentName() { return "IDE Tooltip Manager"; } + + public boolean isQueuedToShow(IdeTooltip tooltip) { + return Comparing.equal(myQueuedTooltip, tooltip); + } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/OtherGroup.java b/platform/platform-impl/src/com/intellij/ide/actions/NonEmptyActionGroup.java similarity index 89% rename from platform/platform-impl/src/com/intellij/ide/actions/OtherGroup.java rename to platform/platform-impl/src/com/intellij/ide/actions/NonEmptyActionGroup.java index 79307c73fadd..57871d556d71 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/OtherGroup.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/NonEmptyActionGroup.java @@ -20,8 +20,8 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.project.DumbAware; -public class OtherGroup extends DefaultActionGroup implements DumbAware { - public OtherGroup() { +public class NonEmptyActionGroup extends DefaultActionGroup implements DumbAware { + public NonEmptyActionGroup() { super(); } diff --git a/platform/platform-impl/src/com/intellij/ide/dnd/DnDEventImpl.java b/platform/platform-impl/src/com/intellij/ide/dnd/DnDEventImpl.java index 69d63a7671ee..ba83c79a8f53 100644 --- a/platform/platform-impl/src/com/intellij/ide/dnd/DnDEventImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/dnd/DnDEventImpl.java @@ -17,20 +17,24 @@ package com.intellij.ide.dnd; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.UserDataHolderBase; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.awt.RelativeRectangle; +import com.intellij.util.ArrayUtil; import javax.swing.*; import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.File; import java.io.IOException; +import java.util.*; public class DnDEventImpl extends UserDataHolderBase implements Transferable, DnDEvent { private static final Logger LOG = Logger.getInstance("com.intellij.ide.dnd.DnDEventImpl"); - private static DataFlavor ourDataFlavor; + public static DataFlavor ourDataFlavor; private DnDTarget myDelegatedTarget; static { @@ -93,17 +97,24 @@ public class DnDEventImpl extends UserDataHolderBase implements Transferable, Dn } public DataFlavor[] getTransferDataFlavors() { - return new DataFlavor[]{ourDataFlavor}; - } - - public boolean isDataFlavorSupported(DataFlavor flavor) { - return flavor.equals(ourDataFlavor); + return new DataFlavor[]{ourDataFlavor, DataFlavor.javaFileListFlavor}; } public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { + if (flavor == DataFlavor.javaFileListFlavor) { + if (myAttachedObject instanceof FileFlavorProvider) { + return ((FileFlavorProvider)myAttachedObject).asFileList(); + } + } return getAttachedObject(); } + + public boolean isDataFlavorSupported(DataFlavor flavor) { + DataFlavor[] flavors = getTransferDataFlavors(); + return ArrayUtil.find(flavors, flavor) != -1; + } + public boolean isDropPossible() { return myDropPossible; } @@ -285,4 +296,8 @@ public class DnDEventImpl extends UserDataHolderBase implements Transferable, Dn myHandlerComponent = null; myManager = null; } + + public interface FileFlavorProvider { + java.util.List asFileList(); + } } diff --git a/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java b/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java index f63177a3813f..04a88241f66b 100644 --- a/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java @@ -61,7 +61,8 @@ public class TipUIUtil { StringBuffer text = new StringBuffer(ResourceUtil.loadText(url)); updateShortcuts(text); - browser.read(new StringReader(text.toString()), null); + String replaced = text.toString().replace("&productName;", ApplicationNamesInfo.getInstance().getFullProductName()); + browser.read(new StringReader(replaced), null); final Document document = browser.getDocument(); if (document instanceof HTMLDocument) { ((HTMLDocument)document).setBase(url); diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandMerger.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandMerger.java index b83a19a8daa9..dbac41645685 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandMerger.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandMerger.java @@ -35,6 +35,7 @@ public class CommandMerger { private boolean myForcedGlobal = false; private boolean myTransparent = false; private String myCommandName = null; + private boolean myValid = true; private List myCurrentActions = new ArrayList(); private Set myAffectedDocuments = new THashSet(); private EditorAndState myStateBefore; @@ -102,6 +103,7 @@ public class CommandMerger { myTransparent = nextCommandToMerge.myTransparent; } } + myValid &= nextCommandToMerge.myValid; myForcedGlobal |= nextCommandToMerge.myForcedGlobal; myCurrentActions.addAll(nextCommandToMerge.myCurrentActions); myAffectedDocuments.addAll(nextCommandToMerge.myAffectedDocuments); @@ -129,7 +131,8 @@ public class CommandMerger { myCurrentActions, myManager.nextCommandTimestamp(), myUndoConfirmationPolicy, - isTransparent())); + isTransparent(), + myValid)); } reset(); @@ -142,6 +145,7 @@ public class CommandMerger { myForcedGlobal = false; myTransparent = false; myCommandName = null; + myValid = true; myStateAfter = null; myStateBefore = null; myUndoConfirmationPolicy = UndoConfirmationPolicy.DEFAULT; @@ -244,4 +248,10 @@ public class CommandMerger { public void setAfterState(EditorAndState state) { myStateAfter = state; } + + public void invalidateActionsFor(DocumentReference ref) { + if (myAffectedDocuments.contains(ref)) { + myValid = false; + } + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/EditorChangeAction.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/EditorChangeAction.java index ccd4acd00315..af77f67c54cd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/EditorChangeAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/EditorChangeAction.java @@ -32,7 +32,8 @@ class EditorChangeAction implements UndoableAction { private final int myOffset; private final CharSequence myOldString; private final CharSequence myNewString; - private final long myTimeStamp; + private final long myOldTimeStamp; + private final long myNewTimeStamp; private final boolean myBulkUpdate; public EditorChangeAction(DocumentEx document, @@ -45,18 +46,21 @@ class EditorChangeAction implements UndoableAction { myOffset = offset; myOldString = oldString == null ? "" : oldString; myNewString = newString == null ? "" : newString; - myTimeStamp = oldTimeStamp; + myOldTimeStamp = oldTimeStamp; + myNewTimeStamp = document.getModificationStamp(); + myBulkUpdate = document.isInBulkUpdate(); } public void undo() { exchangeStrings(myNewString, myOldString); - getDocument().setModificationStamp(myTimeStamp); + getDocument().setModificationStamp(myOldTimeStamp); refreshFileStatus(); } public void redo() { exchangeStrings(myOldString, myNewString); + getDocument().setModificationStamp(myNewTimeStamp); refreshFileStatus(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java index c47336e39a24..1bc2839b9d56 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java @@ -284,6 +284,14 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap myCurrentMerger.addAction(action); } + public void invalidateActionsFor(DocumentReference ref) { + ApplicationManager.getApplication().assertIsDispatchThread(); + myMerger.invalidateActionsFor(ref); + if (myCurrentMerger != null) myCurrentMerger.invalidateActionsFor(ref); + myUndoStacksHolder.invalidateActionsFor(ref); + myRedoStacksHolder.invalidateActionsFor(ref); + } + public void undo(@Nullable FileEditor editor) { ApplicationManager.getApplication().assertIsDispatchThread(); LOG.assertTrue(isUndoAvailable(editor)); @@ -352,7 +360,7 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap private boolean isUndoOrRedoAvailable(Collection refs, boolean isUndo) { if (isUndo && myMerger.isUndoAvailable(refs)) return true; UndoRedoStacksHolder stackHolder = getStackHolder(isUndo); - return stackHolder.hasActions(refs); + return stackHolder.canBeUndoneOrRedone(refs); } private static Collection getDocRefs(FileEditor editor) { diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java index b063d2d85706..9bd62c41f57a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedo.java @@ -66,7 +66,7 @@ abstract class UndoRedo { } boolean hasMoreActions() { - return getStackHolder().hasActions(getDecRefs()); + return getStackHolder().canBeUndoneOrRedone(getDecRefs()); } private Set getDecRefs() { diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java index 4e5a58b244bc..7649349885b0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoRedoStacksHolder.java @@ -68,10 +68,10 @@ class UndoRedoStacksHolder { return result; } - public boolean hasActions(Collection refs) { - if (refs.isEmpty()) return !myGlobalStack.isEmpty(); + public boolean canBeUndoneOrRedone(Collection refs) { + if (refs.isEmpty()) return !myGlobalStack.isEmpty() && myGlobalStack.getLast().isValid(); for (DocumentReference each : refs) { - if (!getStack(each).isEmpty()) return true; + if (!getStack(each).isEmpty() && getStack(each).getLast().isValid()) return true; } return false; } @@ -224,4 +224,12 @@ class UndoRedoStacksHolder { if (stack.isEmpty()) return 0; return Math.max(stack.getFirst().getCommandTimestamp(), stack.getLast().getCommandTimestamp()); } + + public void invalidateActionsFor(DocumentReference ref) { + for (LinkedList eachStack : getAffectedStacks(true, Collections.singleton(ref))) { + for (UndoableGroup eachGroup : eachStack) { + eachGroup.invalidateActionsFor(ref); + } + } + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoableGroup.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoableGroup.java index 01272a9a30c1..ffcab6183080 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoableGroup.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoableGroup.java @@ -51,6 +51,8 @@ class UndoableGroup { private final Project myProject; private final UndoConfirmationPolicy myConfirmationPolicy; + private boolean myValid; + public UndoableGroup(String commandName, boolean isGlobal, Project project, @@ -59,7 +61,8 @@ class UndoableGroup { List actions, int commandTimestamp, UndoConfirmationPolicy confirmationPolicy, - boolean transparent) { + boolean transparent, + boolean valid) { myCommandName = commandName; myGlobal = isGlobal; myCommandTimestamp = commandTimestamp; @@ -69,6 +72,7 @@ class UndoableGroup { myStateAfter = stateAfter; myConfirmationPolicy = confirmationPolicy; myTransparent = transparent; + myValid = valid; } public boolean isGlobal() { @@ -208,6 +212,16 @@ class UndoableGroup { return myGlobal; } + public void invalidateActionsFor(DocumentReference ref) { + if (getAffectedDocuments().contains(ref)) { + myValid = false; + } + } + + public boolean isValid() { + return myValid; + } + public String toString() { StringBuilder result = new StringBuilder("UndoableGroup["); final boolean multiline = myActions.size() > 1; diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/ServiceManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/ServiceManagerImpl.java index ee198f9f2c4e..656a7b4d4d1a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/ServiceManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/ServiceManagerImpl.java @@ -56,7 +56,7 @@ public class ServiceManagerImpl implements BaseComponent { final MutablePicoContainer picoContainer = (MutablePicoContainer)componentManager.getPicoContainer(); myExtensionPointListener = new ExtensionPointListener() { - public void extensionAdded(final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor) { if (descriptor.overrides) { ComponentAdapter oldAdapter = picoContainer.unregisterComponent(descriptor.getInterface());// Allow to re-define service implementations in plugins. @@ -68,7 +68,7 @@ public class ServiceManagerImpl implements BaseComponent { picoContainer.registerComponent(new MyComponentAdapter(descriptor, pluginDescriptor, (ComponentManagerEx)componentManager)); } - public void extensionRemoved(final ServiceDescriptor extension, final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull final ServiceDescriptor extension, final PluginDescriptor pluginDescriptor) { picoContainer.unregisterComponent(extension.getInterface()); } }; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/ErrorStripTooltipRendererProvider.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/ErrorStripTooltipRendererProvider.java index 97a8b1086c33..195fe6ffcd35 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/ErrorStripTooltipRendererProvider.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/ErrorStripTooltipRendererProvider.java @@ -20,6 +20,7 @@ package com.intellij.openapi.editor.ex; import com.intellij.codeInsight.hint.TooltipRenderer; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.impl.TrafficTooltipRenderer; import com.intellij.openapi.editor.markup.RangeHighlighter; import org.jetbrains.annotations.NotNull; @@ -33,5 +34,5 @@ public interface ErrorStripTooltipRendererProvider { TooltipRenderer calcTooltipRenderer(@NotNull String text); TooltipRenderer calcTooltipRenderer(@NotNull String text, int width); - TrafficTooltipRenderer createTrafficTooltipRenderer(Runnable onHide); + TrafficTooltipRenderer createTrafficTooltipRenderer(Runnable onHide, Editor editor); } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java index 6a6c9ec4fdfb..bc5b87810c7a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java @@ -131,6 +131,12 @@ public class EditorUtil { return resVisEnd.column; } + public static int getVisualLineEndOffset(@NotNull Editor editor, int line) { + VisualPosition endLineVisualPosition = new VisualPosition(line, getLastVisualLineColumnNumber(editor, line)); + LogicalPosition endLineLogicalPosition = editor.visualToLogicalPosition(endLineVisualPosition); + return editor.logicalPositionToOffset(endLineLogicalPosition); + } + public static float calcVerticalScrollProportion(Editor editor) { Rectangle viewArea = editor.getScrollingModel().getVisibleAreaOnScrollingFinished(); if (viewArea.height == 0) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index 5c5c5ffbbe09..b1e5f2cd43c9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -77,6 +77,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { private final PropertyChangeSupport myPropertyChangeSupport = new PropertyChangeSupport(this); private volatile MarkupModelEx myMarkupModel; + private DocumentListener[] myCachedDocumentListeners; private final List myReadOnlyListeners = new ArrayList(1); private int myCheckGuardedBlocks = 0; @@ -468,12 +469,11 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { return null; // suppress events in shutdown hook } DocumentEvent event = new DocumentEventImpl(this, offset, oldString, newString, myModificationStamp, wholeTextReplaced); - //System.out.printf("%nbefore change: offset=%d, old text='%s', new text='%s', document modification stamp=%d%nDocument:'%s'%n", - // event.getOffset(), event.getOldFragment(), event.getNewFragment(), event.getDocument().getModificationStamp(), - // event.getDocument().getText()); - for (int i = myDocumentListeners.size() - 1; i >= 0; i--) { + + DocumentListener[] listeners = getCachedListeners(); + for (int i = listeners.length - 1; i >= 0; i--) { try { - myDocumentListeners.get(i).beforeDocumentChange(event); + listeners[i].beforeDocumentChange(event); } catch (Throwable e) { LOG.error(e); @@ -484,10 +484,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { return event; } - @SuppressWarnings({"ForLoopReplaceableByForEach"}) private void changedUpdate(DocumentEvent event, long newModificationStamp) { - //System.out.printf("after change: new modification stamp=%d%ndocument='%s'%n", event.getDocument().getModificationStamp(), - // event.getDocument().getText()); if (ShutDownTracker.isShutdownHookRunning()) { return; // suppress events in shutdown hook } @@ -497,10 +494,10 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { myLineSet.changedUpdate(event); setModificationStamp(newModificationStamp); - // Don't use for-each in order to avoid unnecessary iterator construction during frequent document updates. - for (int i = 0; i < myDocumentListeners.size(); i++) { + DocumentListener[] listeners = getCachedListeners(); + for (DocumentListener listener : listeners) { try { - myDocumentListeners.get(i).documentChanged(event); + listener.documentChanged(event); } catch (Throwable e) { LOG.error(e); @@ -557,21 +554,9 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { public void addDocumentListener(@NotNull DocumentListener listener) { + myCachedDocumentListeners = null; LOG.assertTrue(!myDocumentListeners.contains(listener), listener); - if (!(listener instanceof PrioritizedDocumentListener)) { - myDocumentListeners.add(listener); - return; - } - int i = Collections.binarySearch(myDocumentListeners, listener, PrioritizedDocumentListener.COMPARATOR); - if (i < 0) { - i = -i - 1; - } - if (i >= myDocumentListeners.size()) { - myDocumentListeners.add(listener); - } - else { - myDocumentListeners.add(i, listener); - } + myDocumentListeners.add(listener); } public void addDocumentListener(@NotNull final DocumentListener listener, @NotNull Disposable parentDisposable) { @@ -584,6 +569,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { } public void removeDocumentListener(@NotNull DocumentListener listener) { + myCachedDocumentListeners = null; boolean success = myDocumentListeners.remove(listener); LOG.assertTrue(success); } @@ -631,6 +617,15 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { return lineCount; } + private DocumentListener[] getCachedListeners() { + if (myCachedDocumentListeners == null) { + Collections.sort(myDocumentListeners, PrioritizedDocumentListener.COMPARATOR); + myCachedDocumentListeners = myDocumentListeners.toArray(new DocumentListener[myDocumentListeners.size()]); + } + + return myCachedDocumentListeners; + } + public void fireReadOnlyModificationAttempt() { ApplicationManagerEx.getApplicationEx().assertReadAccessToDocumentsAllowed(); EditReadOnlyListener[] listeners = myReadOnlyListeners.toArray( diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java index e81a3a7849c6..5f33b7b257a4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java @@ -539,7 +539,8 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse private void paintIconRow(int line, ArrayList row, final Graphics g) { processIconsRow(line, row, new LineGutterIconRendererProcessor() { public void process(int x, int y, GutterIconRenderer renderer) { - renderer.getIcon().paintIcon(EditorGutterComponentImpl.this, g, x, y); + Icon icon = renderer.getIcon(); + icon.paintIcon(EditorGutterComponentImpl.this, g, x, y); } }); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 0a12bd5e6d5e..95138bd0afae 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -1036,13 +1036,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } public int offsetToVisualLine(int offset) { - int line = calcLogicalLineNumber(offset); - return logicalToVisualLine(line); - } - - private int logicalToVisualLine(int line) { - assertReadAccess(); - return logicalToVisualPosition(new LogicalPosition(line, 0)).line; + return logicalToVisualPosition(offsetToLogicalPosition(offset)).line; } @NotNull @@ -2737,9 +2731,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi @NotNull public VisualPosition logicalToVisualPosition(@NotNull LogicalPosition logicalPos, boolean softWrapAware) { assertReadAccess(); - if (logicalPos.visualPositionAware) { - return logicalPos.toVisualPosition(); - } if (!myFoldingModel.isFoldingEnabled() && !mySoftWrapModel.isSoftWrappingEnabled()) { return new VisualPosition(logicalPos.line, logicalPos.column); } @@ -4222,6 +4213,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } private class MyMouseAdapter extends MouseAdapter { + + private boolean mySelectionTweaked; + public void mousePressed(MouseEvent e) { requestFocus(); runMousePressedCommand(e); @@ -4251,6 +4245,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi TooltipController.getInstance().cancelTooltip(FOLDING_TOOLTIP_GROUP, e, true); } private void runMousePressedCommand(final MouseEvent e) { + mySelectionTweaked = false; myMousePressedEvent = e; EditorMouseEvent event = new EditorMouseEvent(EditorImpl.this, e, getMouseEventArea(e)); @@ -4290,6 +4285,13 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } private void runMouseReleasedCommand(final MouseEvent e) { + if (!mySelectionTweaked) { + tweakSelectionIfNecessary(e); + } + if (e.isConsumed()) { + return; + } + myScrollingTimer.stop(); EditorMouseEvent event = new EditorMouseEvent(EditorImpl.this, e, getMouseEventArea(e)); for (EditorMouseListener listener : myMouseListeners) { @@ -4370,7 +4372,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi if (e.getSource() == myGutterComponent) { if (eventArea == EditorMouseEventArea.LINE_MARKERS_AREA || eventArea == EditorMouseEventArea.ANNOTATIONS_AREA || eventArea == EditorMouseEventArea.LINE_NUMBERS_AREA) { - myGutterComponent.mousePressed(e); + if (tweakSelectionIfNecessary(e)) { + mySelectionTweaked = true; + } + else { + myGutterComponent.mousePressed(e); + } if (e.isConsumed()) return; } x = 0; @@ -4450,6 +4457,79 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } } + /** + * Allows to answer if given event should tweak editor selection. + * + * @param e event for occurred mouse action + * @return true if action that produces given event will trigger editor selection change; false otherwise + */ + private boolean tweakSelectionEvent(@NotNull MouseEvent e) { + return getSelectionModel().hasSelection() && e.getButton() == MouseEvent.BUTTON1 && e.isShiftDown(); + } + + /** + * Checks if editor selection should be changed because of click at the given point at gutter and proceeds if necessary. + *

+ * The main idea is that selection can be changed during left mouse clicks with hold Shift button and we want + * to distinguish that situation from 'close line numbers gutter' action (activated by 'Shift+click' + * on gutter area). + * + * @param e event for mouse click on gutter area + * @return true if editor's selection is changed because of the click; false otherwise + */ + private boolean tweakSelectionIfNecessary(@NotNull MouseEvent e) { + if (!tweakSelectionEvent(e)) { + return false; + } + + int startSelectionOffset = getSelectionModel().getSelectionStart(); + int startVisLine = offsetToVisualLine(startSelectionOffset); + + int endSelectionOffset = getSelectionModel().getSelectionEnd(); + int endVisLine = offsetToVisualLine(endSelectionOffset - 1); + + int clickVisLine = xyToVisualPosition(e.getPoint()).line; + + if (clickVisLine < startVisLine) { + // Expand selection at backward direction. + int startOffset = logicalPositionToOffset(visualToLogicalPosition(new VisualPosition(clickVisLine, 0))); + getSelectionModel().setSelection(startOffset, endSelectionOffset); + getCaretModel().moveToOffset(startOffset); + } + else if (clickVisLine > endVisLine) { + // Expand selection at forward direction. + int endLineOffset = EditorUtil.getVisualLineEndOffset(this, clickVisLine); + getSelectionModel().setSelection(getSelectionModel().getSelectionStart(), endLineOffset); + getCaretModel().moveToOffset(endLineOffset, true); + } + else if (startVisLine == endVisLine) { + // Remove selection + getSelectionModel().removeSelection(); + } + else { + // Reduce selection in backward direction. + if (getSelectionModel().getLeadSelectionOffset() == endSelectionOffset) { + if (clickVisLine == startVisLine) { + clickVisLine++; + } + int startOffset = logicalPositionToOffset(visualToLogicalPosition(new VisualPosition(clickVisLine, 0))); + getSelectionModel().setSelection(startOffset, endSelectionOffset); + getCaretModel().moveToOffset(startOffset); + } + else { + // Reduce selection is forward direction. + if (clickVisLine == endVisLine) { + clickVisLine--; + } + int endLineOffset = EditorUtil.getVisualLineEndOffset(this, clickVisLine); + getSelectionModel().setSelection(startSelectionOffset, endLineOffset); + getCaretModel().moveToOffset(endLineOffset); + } + } + e.consume(); + return true; + } + private static final TooltipGroup FOLDING_TOOLTIP_GROUP = new TooltipGroup("FOLDING_TOOLTIP_GROUP", 10); private class MyMouseMotionListener implements MouseMotionListener { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java index 2defd4243717..3c09eaa8d853 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java @@ -608,17 +608,15 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark private TrafficTooltipRenderer myTrafficTooltipRenderer; private void showTrafficLightTooltip(MouseEvent e) { - //final String tooltipMessage = myErrorStripeRenderer.getTooltipMessage(); - //if (tooltipMessage == null) return; if (myTrafficTooltipRenderer == null) { myTrafficTooltipRenderer = myTooltipRendererProvider.createTrafficTooltipRenderer(new Runnable() { @Override public void run() { myTrafficTooltipRenderer = null; } - }); + }, myEditor); } - showTooltip(e, myTrafficTooltipRenderer, new HintHint(e).setAwtTooltip(true).setPreferredPosition(Balloon.Position.atLeft)); + showTooltip(e, myTrafficTooltipRenderer, new HintHint(e).setAwtTooltip(true).setMayCenterPosition(true).setContentActive(false).setPreferredPosition(Balloon.Position.atLeft)); } private void repaintTrafficTooltip() { @@ -655,6 +653,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark scrollbar.addMouseListener(handler); myErrorStripeButton.addMouseListener(myHandler); } + } private void showTooltip(MouseEvent e, final TooltipRenderer tooltipObject, HintHint hintHint) { @@ -737,7 +736,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark } @Override - public TrafficTooltipRenderer createTrafficTooltipRenderer(final Runnable onHide) { + public TrafficTooltipRenderer createTrafficTooltipRenderer(final Runnable onHide, Editor editor) { return new TrafficTooltipRenderer() { @Override public void repaintTooltipWindow() { diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java index da5c27a83384..b6d5793a953b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java @@ -23,9 +23,8 @@ import com.intellij.openapi.fileEditor.FileEditorProvider; import com.intellij.openapi.fileEditor.WeighedFileEditorProvider; import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager; import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider; -import com.intellij.openapi.project.Project; import com.intellij.openapi.project.DumbService; -import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,11 +48,11 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag mySharedProviderList = new ArrayList(); Extensions.getRootArea().getExtensionPoint(FileEditorProvider.EP_FILE_EDITOR_PROVIDER).addExtensionPointListener(new ExtensionPointListener() { - public void extensionAdded(final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) { + public void extensionAdded(@NotNull final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) { registerProvider(extension); } - public void extensionRemoved(final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) { + public void extensionRemoved(@NotNull final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) { unregisterProvider(extension); } }); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java index f88c47a08817..b2dd0d85eb9a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java @@ -134,6 +134,9 @@ class CacheUpdateRunner { final boolean[] isFinished = new boolean[1]; try { int threadsCount = Registry.intValue("caches.indexerThreadsCount"); + if (threadsCount == -1) { + threadsCount = Math.min(Runtime.getRuntime().availableProcessors(), 2); + } if (threadsCount == 1) { Runnable process = new MyRunnable(innerIndicator, queue, isFinished, progressUpdater, processInReadAction, application); ProgressManager.getInstance().runProcess(process, innerIndicator); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java index 10c098936fe0..6d05b65c28b1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java @@ -21,8 +21,10 @@ import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.impl.win32.Win32LocalFileSystem; import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.NewVirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; @@ -51,6 +53,8 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap private final FileWatcher myWatcher; + private final LocalFileSystemBase myNativeFileSystem; + private static class WatchRequestImpl implements WatchRequest { public final String myRootPath; @@ -117,6 +121,14 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap if (myWatcher.isOperational()) { new StoreRefreshStatusThread().start(); } + if (SystemInfo.isWindows && + Win32LocalFileSystem.isAvailable() && + Registry.is("filesystem.useNative")) { + myNativeFileSystem = null; //Win32LocalFileSystem.getWin32Instance(); + } + else { + myNativeFileSystem = null; + } } public void initComponent() { @@ -439,4 +451,28 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap } } + public boolean exists(final VirtualFile fileOrDirectory) { + if (myNativeFileSystem == null) return super.exists(fileOrDirectory); + else return myNativeFileSystem.exists(fileOrDirectory); + } + + public long getTimeStamp(final VirtualFile file) { + if (myNativeFileSystem == null) return super.getTimeStamp(file); + else return myNativeFileSystem.getTimeStamp(file); + } + + public boolean isDirectory(final VirtualFile file) { + if (myNativeFileSystem == null) return super.isDirectory(file); + else return myNativeFileSystem.isDirectory(file); + } + + public boolean isWritable(final VirtualFile file) { + if (myNativeFileSystem == null) return super.isWritable(file); + else return myNativeFileSystem.isWritable(file); + } + + public String[] list(final VirtualFile file) { + if (myNativeFileSystem == null) return super.list(file); + else return myNativeFileSystem.list(file); + } } diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java index 72a2a120a896..d1784df5402a 100644 --- a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java @@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; import java.awt.*; import java.awt.event.*; import java.awt.geom.GeneralPath; diff --git a/platform/platform-impl/src/com/intellij/ui/HeavyweightHint.java b/platform/platform-impl/src/com/intellij/ui/HeavyweightHint.java index 963d1db265dc..e6f2553604c3 100644 --- a/platform/platform-impl/src/com/intellij/ui/HeavyweightHint.java +++ b/platform/platform-impl/src/com/intellij/ui/HeavyweightHint.java @@ -17,6 +17,7 @@ package com.intellij.ui; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.wm.ex.WindowManagerEx; +import com.intellij.ui.awt.RelativePoint; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -94,7 +95,7 @@ public class HeavyweightHint implements Hint { } @Override - public void updateBounds() { + public void pack() { updateBounds(-1, -1, false); } @@ -113,6 +114,13 @@ public class HeavyweightHint implements Hint { } } + @Override + public void setLocation(RelativePoint point) { + if (myWindow != null) { + myWindow.setLocation(point.getScreenPoint().x, point.getScreenPoint().y); + } + } + public void addHintListener(HintListener listener) { myListenerList.add(HintListener.class, listener); } diff --git a/platform/platform-impl/src/com/intellij/ui/Hint.java b/platform/platform-impl/src/com/intellij/ui/Hint.java index d7492e489ccd..4acbb0c639a2 100644 --- a/platform/platform-impl/src/com/intellij/ui/Hint.java +++ b/platform/platform-impl/src/com/intellij/ui/Hint.java @@ -15,6 +15,7 @@ */ package com.intellij.ui; +import com.intellij.ui.awt.RelativePoint; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -41,7 +42,16 @@ public interface Hint { void removeHintListener(HintListener listener); - void updateBounds(); + void pack(); + void setLocation(RelativePoint point); + + /** + * Pack and set location + * @param x + * @param y + * @deprecated use {@link Hint#setLocation(com.intellij.ui.awt.RelativePoint)} ()} + */ void updateBounds(int x, int y); + } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ui/HintHint.java b/platform/platform-impl/src/com/intellij/ui/HintHint.java index d77a098c98aa..113d2f3a7202 100644 --- a/platform/platform-impl/src/com/intellij/ui/HintHint.java +++ b/platform/platform-impl/src/com/intellij/ui/HintHint.java @@ -36,6 +36,7 @@ public class HintHint { private boolean myContentActive = true; private boolean myQuickHint = false; + private boolean myMayCenterTooltip = false; public HintHint(MouseEvent e) { this(e.getComponent(), e.getPoint()); @@ -55,6 +56,15 @@ public class HintHint { return this; } + public HintHint setMayCenterPosition(boolean mayCenter) { + myMayCenterTooltip = mayCenter; + return this; + } + + public boolean isMayCenterTooltip() { + return myMayCenterTooltip; + } + public HintHint setPreferredPosition(Balloon.Position position) { myPreferredPosition = position; return this; diff --git a/platform/platform-impl/src/com/intellij/ui/LightweightHint.java b/platform/platform-impl/src/com/intellij/ui/LightweightHint.java index 4782c989d3a3..f1253b6e205f 100644 --- a/platform/platform-impl/src/com/intellij/ui/LightweightHint.java +++ b/platform/platform-impl/src/com/intellij/ui/LightweightHint.java @@ -58,6 +58,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint { private boolean myResizable; private IdeTooltip myCurrentIdeTooltip; + private HintHint myHintHint; public LightweightHint(@NotNull final JComponent component) { myComponent = component; @@ -107,6 +108,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint { final JComponent focusBackComponent, @NotNull final HintHint hintHint) { myParentComponent = parentComponent; + myHintHint = hintHint; myFocusBackComponent = focusBackComponent; @@ -125,7 +127,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint { if (hintHint.isAwtTooltip()) { - IdeTooltip tooltip = new IdeTooltip(hintHint.getOriginalComponent(), hintHint.getOriginalPoint(), myComponent) { + IdeTooltip tooltip = new IdeTooltip(hintHint.getOriginalComponent(), hintHint.getOriginalPoint(), myComponent, hintHint, myComponent) { @Override protected boolean canAutohideOn(TooltipEvent event) { if (event.getInputEvent() instanceof MouseEvent) { @@ -145,7 +147,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint { public boolean canBeDismissedOnTimeout() { return false; } - }.setToCenterIfSmall(false).setPreferredPosition(hintHint.getPreferredPosition()).setHighlighterType(hintHint.isHightlighterType()); + }.setToCenterIfSmall(hintHint.isMayCenterTooltip()).setPreferredPosition(hintHint.getPreferredPosition()).setHighlighterType(hintHint.isHightlighterType()); myComponent.validate(); myCurrentIdeTooltip = IdeTooltipManager.getInstance().show(tooltip, false); @@ -205,10 +207,10 @@ public class LightweightHint extends UserDataHolderBase implements Hint { } public boolean isVisible() { - return myIsRealPopup ? myPopup != null : myComponent.isShowing(); + return myIsRealPopup ? (myPopup != null && myPopup.isVisible()) : myComponent.isShowing(); } - protected final boolean isRealPopup() { + public final boolean isRealPopup() { return myIsRealPopup; } @@ -254,7 +256,7 @@ public class LightweightHint extends UserDataHolderBase implements Hint { } @Override - public void updateBounds() { + public void pack() { updateBounds(-1, -1, false); } @@ -264,22 +266,9 @@ public class LightweightHint extends UserDataHolderBase implements Hint { } private void updateBounds(int x, int y, boolean updateLocation) { - if (myIsRealPopup) { - if (myPopup == null) return; - if (updateLocation) ((AbstractPopup)myPopup).setLocation(new RelativePoint(myParentComponent, new Point(x, y))); - myPopup.setSize(myComponent.getPreferredSize()); - } - else { - if (updateLocation) { - JLayeredPane layeredPane = myParentComponent.getRootPane().getLayeredPane(); - myComponent.setLocation(SwingUtilities.convertPoint(myParentComponent, x, y, layeredPane)); - - } - Dimension preferredSize = myComponent.getPreferredSize(); - myComponent.setSize(preferredSize.width, preferredSize.height); - - myComponent.validate(); - myComponent.repaint(); + setSize(myComponent.getPreferredSize()); + if (updateLocation) { + setLocation(new RelativePoint(myParentComponent, new Point(x, y))); } } @@ -295,6 +284,60 @@ public class LightweightHint extends UserDataHolderBase implements Hint { myListenerList.remove(HintListener.class, listener); } + public Point getLocationOn(JComponent c) { + Point location; + if (isRealPopup()) { + location = myPopup.getLocationOnScreen(); + SwingUtilities.convertPointFromScreen(location, c); + } else { + location = SwingUtilities.convertPoint( + myComponent.getParent(), + myComponent.getLocation(), + c + ); + } + + return location; + } + + @Override + public void setLocation(RelativePoint point) { + if (isRealPopup()) { + myPopup.setLocation(point.getScreenPoint()); + } else { + if (myHintHint.isAwtTooltip()) { + //todo kirillk + throw new UnsupportedOperationException(); + } else { + Point targetPoint = point.getPoint(myComponent.getParent()); + myComponent.setLocation(targetPoint); + + myComponent.revalidate(); + myComponent.repaint(); + } + } + } + + public void setSize(Dimension size) { + if (myIsRealPopup) { + myPopup.setSize(size); + } else { + //todo kirillk + if (myHintHint.isAwtTooltip()) { + throw new UnsupportedOperationException(); + } else { + myComponent.setSize(size); + + myComponent.revalidate(); + myComponent.repaint(); + } + } + } + + public Dimension getSize() { + return myComponent.getSize(); + } + private final class MyEscListener implements ActionListener { public final void actionPerformed(final ActionEvent e) { hide(); @@ -309,4 +352,8 @@ public class LightweightHint extends UserDataHolderBase implements Hint { public boolean canControlAutoHide() { return myCurrentIdeTooltip != null && myCurrentIdeTooltip.getTipComponent().isShowing() ; } + + public IdeTooltip getCurrentIdeTooltip() { + return myCurrentIdeTooltip; + } } diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index b7d4f67e2565..32372448f71e 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -1136,6 +1136,18 @@ public class AbstractPopup implements JBPopup { return wnd; } + @Override + public Point getLocationOnScreen() { + Dimension headerCorrectionSize = myLocateByContent ? myHeaderPanel.getPreferredSize() : null; + Point screenPoint = myContent.getLocationOnScreen(); + if (headerCorrectionSize != null) { + screenPoint.y -= headerCorrectionSize.height; + } + + return screenPoint; + } + + public void setSize(@NotNull final Dimension size) { if (myPopup == null) { myForcedSize = size; diff --git a/platform/platform-resources-en/src/messages/DaemonBundle.properties b/platform/platform-resources-en/src/messages/DaemonBundle.properties index a66b57918c1a..25f2b9c07de2 100644 --- a/platform/platform-resources-en/src/messages/DaemonBundle.properties +++ b/platform/platform-resources-en/src/messages/DaemonBundle.properties @@ -9,27 +9,27 @@ method.implements.in=Implements method ''{0}'' in ''{1}'' method.overrides=Overrides method in ''{1}'' method.overrides.in=Overrides method ''{0}'' in ''{1}'' -analysis.hasnot.been.run=No analysis has been performed. +analysis.hasnot.been.run=No analysis has been performed -no.syntax.highlighting.performed=No syntax highlighting performed. -no.inspections.performed=No inspections performed. +no.syntax.highlighting.performed=No syntax highlighting performed +no.inspections.performed=No inspections performed # These two aren't unused! # suppress inspection "UnusedProperty" -no.syntax.highlighting.performed.for=No syntax highlighting performed for {0}. +no.syntax.highlighting.performed.for=No syntax highlighting performed for {0} # suppress inspection "UnusedProperty" -no.inspections.performed.for=No inspections performed {0}. +no.inspections.performed.for=No inspections performed {0} pass.syntax=Syntax analysis pass.inspection=Inspections pass.wolf=Checking red files pass.whole.inspections=Slow Inspections -analysis.completed=Analysis completed. +analysis.completed=Analysis completed -no.errors.or.warnings.found=No errors or warnings found. -no.errors.or.warnings.found.so.far=No errors or warnings found so far. -errors.found.so.far={0} {1} found so far. -errors.found={0} {1} found. +no.errors.or.warnings.found=No errors or warnings found +no.errors.or.warnings.found.so.far=No errors or warnings found so far +errors.found.so.far={0} {1} found so far +errors.found={0} {1} found error.highlighting.settings=Error highlighting settings method.is.implemented.header=Is implemented in
diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index cbd0908d87e9..84071a7b4a88 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -1042,7 +1042,7 @@ finished.with.exit.code.text.message=Process finished with exit code {0} # Encodings file.encodings.configurable=File Encodings encodings.dialog.caption=\ - To change encoding IntelliJ IDEA uses for a file, directory, or an entire project,
\ + To change encoding $productName uses for a file, directory, or an entire project,
\ click an item and then select encoding from the Default Encoding list.
\ Notes:
\ Built-in file encoding (e.g. JSP, HTML or XML) overrides encoding you specify here.
\ diff --git a/platform/platform-resources-en/src/messages/ProjectBundle.properties b/platform/platform-resources-en/src/messages/ProjectBundle.properties index 7cd51825a81b..2412db92b7d6 100644 --- a/platform/platform-resources-en/src/messages/ProjectBundle.properties +++ b/platform/platform-resources-en/src/messages/ProjectBundle.properties @@ -189,15 +189,15 @@ module.remove.action=Remove module.remove.last.confirmation=Are you sure you want to remove the only module from this project?\nNo files will be deleted on disk. module.remove.confirmation=Remove module \"{0}\" from the project?\nNo files will be deleted on disk. module.remove.confirmation.title=Remove Module -button.edit=&Edit... +module.classpath.button.edit=Ed&it... module.libraries.include.all.button=Include All module.libraries.exclude.all.button=Exclude All modules.order.export.title=Order/Export modules.classpath.title=Dependencies modules.order.export.export.column=Export modules.order.export.scope.column=Scope -button.move.up=Move &Up -button.move.down=Move &Down +module.classpath.button.move.up=Move &Up +module.classpath.button.move.down=Move &Down module.remove.confirmation.prompt=Remove {1, choice, 1#Module|2#Modules} {0} from the project?\nNo files will be deleted. module.remove.command=Detach module from project module.new.action=New Module @@ -454,8 +454,8 @@ project.new.wizard.module.name.title=Na&me: project.new.wizard.module.root.title=Content &root: project.new.wizard.module.file.title=Module &file location: -label.text.please.select.desired.technologies=Please select the desired technologies -label.text.framework.support.description=This will download all needed libraries and create Facets in project configuration +label.text.please.select.desired.technologies=Please select the desired technologies. +label.text.framework.support.description=This will download all needed libraries and create Facets in project configuration. file.chooser.directory.for.downloaded.libraries.title=Directory for Downloaded Libraries file.chooser.directory.for.downloaded.libraries.description=Downloaded libraries will be copied to selected directory dialog.title.library.downloading.settings=Library Downloading Settings diff --git a/resources-en/src/tips/ColorEditingInCss.html b/platform/platform-resources-en/src/tips/ColorEditingInCss.html similarity index 83% rename from resources-en/src/tips/ColorEditingInCss.html rename to platform/platform-resources-en/src/tips/ColorEditingInCss.html index 979146f40551..3d7af949994d 100644 --- a/resources-en/src/tips/ColorEditingInCss.html +++ b/platform/platform-resources-en/src/tips/ColorEditingInCss.html @@ -2,8 +2,8 @@ -

IntelliJ - IDEA simplifies working +

&productName; + simplifies working with colors in CSS files. The color properties are marked with the icons of the corresponding color in the left gutter area of the editor. Use these icons to view colors and change color values. When you point with your mouse cursor to the color icon, diff --git a/platform/platform-resources-en/src/tips/DragToOpen.html b/platform/platform-resources-en/src/tips/DragToOpen.html new file mode 100644 index 000000000000..be9f5a2af9e7 --- /dev/null +++ b/platform/platform-resources-en/src/tips/DragToOpen.html @@ -0,0 +1,10 @@ + +
+ +You can easily open an external file for editing, if you just drag it from the Explorer/Finder to the editor. + + +

+ +
+ diff --git a/platform/platform-resources-en/src/tips/EnterDirectoryInGotoFile.html b/platform/platform-resources-en/src/tips/EnterDirectoryInGotoFile.html new file mode 100644 index 000000000000..45d997c78afa --- /dev/null +++ b/platform/platform-resources-en/src/tips/EnterDirectoryInGotoFile.html @@ -0,0 +1,14 @@ + + + + +You can jump directly to any deeply buried file, if you press &shortcut:GotoFile;, and type just a couple +of characters of the enclosing directories and file names: + +

+ +Use either slash or backslash as the delimiters. + +
+ + \ No newline at end of file diff --git a/resources-en/src/tips/EvaluateExpressionInEditor.html b/platform/platform-resources-en/src/tips/EvaluateExpressionInEditor.html similarity index 100% rename from resources-en/src/tips/EvaluateExpressionInEditor.html rename to platform/platform-resources-en/src/tips/EvaluateExpressionInEditor.html diff --git a/resources-en/src/tips/IssueNavigation.html b/platform/platform-resources-en/src/tips/IssueNavigation.html similarity index 93% rename from resources-en/src/tips/IssueNavigation.html rename to platform/platform-resources-en/src/tips/IssueNavigation.html index cc4087a7c8d4..e19c64a46bb5 100644 --- a/resources-en/src/tips/IssueNavigation.html +++ b/platform/platform-resources-en/src/tips/IssueNavigation.html @@ -3,7 +3,7 @@
- Did you know that IntelliJ IDEA lets you jump from your checkin comment to an issue in tracker?
+ Did you know that &productName; lets you jump from your checkin comment to an issue in tracker?
All you have to do is to define issue navigation patterns in the Settings | Version Control dialog:
diff --git a/resources-en/src/tips/MenuItemsDescriptions.html b/platform/platform-resources-en/src/tips/MenuItemsDescriptions.html similarity index 100% rename from resources-en/src/tips/MenuItemsDescriptions.html rename to platform/platform-resources-en/src/tips/MenuItemsDescriptions.html diff --git a/resources-en/src/tips/TabInEditorClose.html b/platform/platform-resources-en/src/tips/TabInEditorClose.html similarity index 80% rename from resources-en/src/tips/TabInEditorClose.html rename to platform/platform-resources-en/src/tips/TabInEditorClose.html index 5fe10df8b5fa..8cc7b69cea5e 100644 --- a/resources-en/src/tips/TabInEditorClose.html +++ b/platform/platform-resources-en/src/tips/TabInEditorClose.html @@ -2,10 +2,10 @@ - + use the Shift+click combination.
Did you know that you can close tabs in the editor and the tool windows of IntelliJ IDEA without actually + Did you know that you can close tabs in the editor and the tool windows of &productName; without actually using the context menu commands? It is enough to point with your mouse cursor to a tab to be closed, and click the middle mouse button, or just - use the shift+click combination.
diff --git a/resources-en/src/tips/WordCompletion.html b/platform/platform-resources-en/src/tips/WordCompletion.html similarity index 100% rename from resources-en/src/tips/WordCompletion.html rename to platform/platform-resources-en/src/tips/WordCompletion.html diff --git a/resources-en/src/tips/images/cssColor.png b/platform/platform-resources-en/src/tips/images/cssColor.png similarity index 100% rename from resources-en/src/tips/images/cssColor.png rename to platform/platform-resources-en/src/tips/images/cssColor.png diff --git a/platform/platform-resources-en/src/tips/images/dragToOpen.png b/platform/platform-resources-en/src/tips/images/dragToOpen.png new file mode 100644 index 000000000000..66f3f6d8e21e Binary files /dev/null and b/platform/platform-resources-en/src/tips/images/dragToOpen.png differ diff --git a/platform/platform-resources-en/src/tips/images/enterDirectory.png b/platform/platform-resources-en/src/tips/images/enterDirectory.png new file mode 100644 index 000000000000..fc372245df70 Binary files /dev/null and b/platform/platform-resources-en/src/tips/images/enterDirectory.png differ diff --git a/resources-en/src/tips/images/issueNavigation.png b/platform/platform-resources-en/src/tips/images/issueNavigation.png similarity index 100% rename from resources-en/src/tips/images/issueNavigation.png rename to platform/platform-resources-en/src/tips/images/issueNavigation.png diff --git a/resources-en/src/tips/images/issueNavigation1.png b/platform/platform-resources-en/src/tips/images/issueNavigation1.png similarity index 100% rename from resources-en/src/tips/images/issueNavigation1.png rename to platform/platform-resources-en/src/tips/images/issueNavigation1.png diff --git a/resources-en/src/tips/images/word_completion.gif b/platform/platform-resources-en/src/tips/images/word_completion.gif similarity index 100% rename from resources-en/src/tips/images/word_completion.gif rename to platform/platform-resources-en/src/tips/images/word_completion.gif diff --git a/platform/platform-resources/src/META-INF/XmlActions.xml b/platform/platform-resources/src/META-INF/XmlActions.xml index b5250f3aef98..bec7f4d3634e 100644 --- a/platform/platform-resources/src/META-INF/XmlActions.xml +++ b/platform/platform-resources/src/META-INF/XmlActions.xml @@ -62,7 +62,7 @@ - + diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index e3ee16e276a8..8d42a53ac2d3 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -286,7 +286,6 @@ - - + diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 35ed153875e3..255839bfa47d 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -20,7 +20,6 @@ import com.intellij.analysis.AnalysisScope; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.codeInsight.completion.CodeCompletionHandlerBase; -import com.intellij.codeInsight.completion.CompletionContext; import com.intellij.codeInsight.completion.CompletionProgressIndicator; import com.intellij.codeInsight.completion.CompletionType; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; @@ -865,10 +864,10 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig } @Override - protected void completionFinished(final int offset1, final int offset2, final CompletionContext context, final CompletionProgressIndicator indicator, + protected void completionFinished(final int offset1, final int offset2, final CompletionProgressIndicator indicator, final LookupElement[] items) { myEmptyLookup = items.length == 0; - super.completionFinished(offset1, offset2, context, indicator, items); + super.completionFinished(offset1, offset2, indicator, items); } }; Editor editor = getCompletionEditor(); diff --git a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java index 35cacacd5065..30d4c0f9d2cd 100644 --- a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java +++ b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java @@ -16,6 +16,7 @@ package com.intellij.openapi.util; import com.intellij.openapi.diagnostic.Logger; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.LinkedList; @@ -67,9 +68,9 @@ public class ShutDownTracker implements Runnable { threads = getStopperThreads(); } - while (!myShutdownTasks.isEmpty()) { + + for (Runnable task = removeLast(myShutdownTasks); task != null; task = removeLast(myShutdownTasks)) { // task can change myShutdownTasks - final Runnable task = myShutdownTasks.removeLast(); try { task.run(); } @@ -78,14 +79,12 @@ public class ShutDownTracker implements Runnable { } } - if (!myShutdownThreads.isEmpty()) { - for (Thread thread = myShutdownThreads.removeLast(); thread != null; thread = myShutdownThreads.removeLast()) { - thread.start(); - try { - thread.join(); - } - catch (InterruptedException ignored) { - } + for (Thread thread = removeLast(myShutdownThreads); thread != null; thread = removeLast(myShutdownThreads)) { + thread.start(); + try { + thread.join(); + } + catch (InterruptedException ignored) { } } } @@ -106,19 +105,28 @@ public class ShutDownTracker implements Runnable { myThreads.remove(thread); } - public void registerShutdownThread(final Thread thread) { + public synchronized void registerShutdownThread(final Thread thread) { myShutdownThreads.addLast(thread); } - public void registerShutdownThread(int index, final Thread thread) { + public synchronized void registerShutdownThread(int index, final Thread thread) { myShutdownThreads.add(index, thread); } - public void registerShutdownTask(Runnable task) { + public synchronized void registerShutdownTask(Runnable task) { myShutdownTasks.addLast(task); } - public void unregisterShutdownTask(Runnable task) { + public synchronized void unregisterShutdownTask(Runnable task) { myShutdownTasks.remove(task); } + + @Nullable + private synchronized T removeLast(LinkedList list) { + return list.isEmpty()? null : list.removeLast(); + } + + private synchronized boolean isEmpty(LinkedList list) { + return list.isEmpty(); + } } diff --git a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java index 5b7e60d9a560..3bf3aa65052f 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java +++ b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java @@ -159,7 +159,7 @@ public class NameUtil { buffer.append(Character.toLowerCase(c)); } if (!firstIdentifierLetter) { - buffer.append("|[A-Za-z\\s0-9\\$]*[_-]["); + buffer.append("|[A-Za-z\\s0-9\\$]*[_-]+["); buffer.append(c); buffer.append(Character.toLowerCase(c)); buffer.append("]"); @@ -172,7 +172,7 @@ public class NameUtil { buffer.append(Character.toUpperCase(c)); buffer.append(']'); if (lowerCaseWords) { - buffer.append("([a-z\\s0-9\\$]*[-_])?"); + buffer.append("([a-z\\s0-9\\$]*[-_]+)?"); } } else { @@ -195,7 +195,7 @@ public class NameUtil { firstIdentifierLetter = true; } else if (c == ' ') { - buffer.append("([a-z\\s0-9\\$_-]*[\\ _-])+"); + buffer.append("([a-z\\s0-9\\$_-]*[\\ _-]+)+"); firstIdentifierLetter = true; } else { diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 6b0642fd2a73..f5c428670d96 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -1382,6 +1382,16 @@ public class UIUtil { } } + /** + * Avoid blinking while changing background + */ + public static void changeBackGround(final JComponent component, final Color background) { + final Color oldBackGround = component.getBackground(); + if (background == null || !background.equals(oldBackGround)){ + component.setBackground(background); + } + } + public static class MacTreeUI extends BasicTreeUI { public static final String SOURCE_LIST_CLIENT_PROPERTY = "mac.ui.source.list"; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java index fb3eea4db205..938e5097805d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java @@ -933,22 +933,76 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec return Collections.unmodifiableList(myExecutors); } + private static class MyDirtyFilesScheduler { + private final static int ourPiecesLimit = 100; + final List myFiles = new ArrayList(); + final List myDirs = new ArrayList(); + private boolean myEveryThing; + private int myCnt; + private final Project myProject; + + private MyDirtyFilesScheduler(final Project project) { + myProject = project; + myCnt = 0; + myEveryThing = false; + } + + public void accept(final Collection coll) { + for (VirtualFile vf : coll) { + if (myCnt > ourPiecesLimit) { + myEveryThing = true; + break; + } + if (vf.isDirectory()) { + myDirs.add(vf); + } else { + myFiles.add(vf); + } + ++ myCnt; + } + } + + public void arise() { + final VcsDirtyScopeManager vcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject); + if (myEveryThing) { + vcsDirtyScopeManager.markEverythingDirty(); + } else { + vcsDirtyScopeManager.filesDirty(myFiles, myDirs); + } + } + } + public void addFilesToIgnore(final IgnoredFileBean... filesToIgnore) { myIgnoredIdeaLevel.add(filesToIgnore); - scheduleUpdate(); + scheduleUnversionedUpdate(); + } + + private void scheduleUnversionedUpdate() { + final MyDirtyFilesScheduler scheduler = new MyDirtyFilesScheduler(myProject); + + synchronized (myDataLock) { + final VirtualFileHolder unversionedHolder = myComposite.getVFHolder(FileHolder.HolderType.UNVERSIONED); + final RecursiveFileHolder ignoredHolder = (RecursiveFileHolder) myComposite.get(FileHolder.HolderType.IGNORED); + + scheduler.accept(unversionedHolder.getFiles()); + scheduler.accept(ignoredHolder.values()); + } + + scheduler.arise(); } public void setFilesToIgnore(final IgnoredFileBean... filesToIgnore) { myIgnoredIdeaLevel.set(filesToIgnore); - scheduleUpdate(); + scheduleUnversionedUpdate(); } private void updateIgnoredFiles(final FileHolderComposite composite) { - List unversionedFiles = composite.getVFHolder(FileHolder.HolderType.UNVERSIONED).getFiles(); + final VirtualFileHolder vfHolder = composite.getVFHolder(FileHolder.HolderType.UNVERSIONED); + final List unversionedFiles = vfHolder.getFiles(); for(VirtualFile file: unversionedFiles) { if (isIgnoredFile(file)) { - composite.getVFHolder(FileHolder.HolderType.UNVERSIONED).removeFile(file); + vfHolder.removeFile(file); composite.getIgnoredFileHolder().addFile(file); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FileHolderComposite.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FileHolderComposite.java index 6be42f7d88f3..360db42f8eff 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FileHolderComposite.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FileHolderComposite.java @@ -29,7 +29,7 @@ public class FileHolderComposite implements FileHolder { myHolders.put(FileHolder.HolderType.UNVERSIONED, new VirtualFileHolder(project, FileHolder.HolderType.UNVERSIONED)); myHolders.put(FileHolder.HolderType.ROOT_SWITCH, new SwitchedFileHolder(project, HolderType.ROOT_SWITCH)); myHolders.put(FileHolder.HolderType.MODIFIED_WITHOUT_EDITING, new VirtualFileHolder(project, FileHolder.HolderType.MODIFIED_WITHOUT_EDITING)); - myHolders.put(FileHolder.HolderType.IGNORED, new RecursiveFileHolder(project, FileHolder.HolderType.IGNORED)); + myHolders.put(FileHolder.HolderType.IGNORED, new RecursiveFileHolder(project, FileHolder.HolderType.IGNORED)); myHolders.put(FileHolder.HolderType.LOCKED, new VirtualFileHolder(project, FileHolder.HolderType.LOCKED)); myHolders.put(FileHolder.HolderType.LOGICALLY_LOCKED, new LogicallyLockedHolder(project)); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java index 2c75079ba1f9..1c98412461b5 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/IgnoredSettingsPanel.java @@ -180,7 +180,7 @@ public class IgnoredSettingsPanel implements SearchableConfigurable { protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } IgnoredFileBean bean = (IgnoredFileBean) value; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointsTree.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointsTree.java index 56f2664559de..9668ffeed2fe 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointsTree.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointsTree.java @@ -192,7 +192,7 @@ public class XBreakpointsTree> extends CheckboxTree { // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } if (value instanceof BreakpointNode) { BreakpointNode node = (BreakpointNode)value; diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index 89f563978a6a..0e300c27036f 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1780,3 +1780,5 @@ method.name.pattern=Method name pattern query.column.name=Query name starts with update.column.name=Update name starts with assert.keyword.is.considered.an.assertion=assert keyword is considered an assertion +expected.exception.never.thrown.display.name=Expected exception never thrown in test method body +expected.exception.never.thrown.problem.descriptor=Expected #ref never thrown in body of ''{0}()'' diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/InspectionGadgetsPlugin.java b/plugins/InspectionGadgets/src/com/siyeh/ig/InspectionGadgetsPlugin.java index 3c56e8439c0f..788fe77b176c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/InspectionGadgetsPlugin.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/InspectionGadgetsPlugin.java @@ -1046,6 +1046,7 @@ public class InspectionGadgetsPlugin implements ApplicationComponent, m_inspectionClasses.add(AssertsWithoutMessagesInspection.class); m_inspectionClasses.add(BeforeClassOrAfterClassIsPublicStaticVoidNoArgInspection.class); m_inspectionClasses.add(BeforeOrAfterIsPublicVoidNoArgInspection.class); + m_inspectionClasses.add(ExpectedExceptionNeverThrownInspection.class); m_inspectionClasses.add(ParameterizedParametersStaticCollectionInspection.class); m_inspectionClasses.add(ConstantJUnitAssertArgumentInspection.class); m_inspectionClasses.add(JUnit4AnnotatedMethodInJUnit3TestCaseInspection.class); @@ -1070,6 +1071,7 @@ public class InspectionGadgetsPlugin implements ApplicationComponent, m_inspectionClasses.add(UnconstructableTestCaseInspection.class); } + @Override public void disposeComponent() { } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java index 7d825378e8a5..67988706b75a 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2007-2009 Bas Leijdekkers + * Copyright 2007-2010 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,12 +78,14 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { return; } final PsiElement parent = getParent(expression.getParent()); - if (parent instanceof PsiThrowStatement) { + if (parent instanceof PsiThrowStatement || + parent instanceof PsiReturnStatement) { return; - } else if (parent instanceof PsiReturnStatement) { + } + if (PsiTreeUtil.getParentOfType(parent, PsiCallExpression.class) != + null) { return; } - if (PsiTreeUtil.getParentOfType(parent, PsiCallExpression.class) != null) return; final PsiElement typedParent = PsiTreeUtil.getParentOfType(expression, PsiAssignmentExpression.class, @@ -125,12 +127,14 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { while (usageParent instanceof PsiParenthesizedExpression) { usageParent = usageParent.getParent(); } - if (usageParent instanceof PsiThrowStatement) { + if (usageParent instanceof PsiThrowStatement || + usageParent instanceof PsiReturnStatement) { return; - } else if (usageParent instanceof PsiReturnStatement) { + } + if (PsiTreeUtil.getParentOfType(usageParent, + PsiCallExpression.class) != null) { return; } - if (PsiTreeUtil.getParentOfType(usageParent, PsiCallExpression.class) != null) return; } } registerError(expression, expression); diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java new file mode 100644 index 000000000000..83fd78df4d21 --- /dev/null +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java @@ -0,0 +1,103 @@ +/* + * Copyright 2010 Bas Leijdekkers + * + * 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.siyeh.ig.junit; + +import com.intellij.codeInsight.AnnotationUtil; +import com.intellij.psi.*; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.BaseInspection; +import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.psiutils.ClassUtils; +import com.siyeh.ig.psiutils.ExceptionUtils; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +public class ExpectedExceptionNeverThrownInspection + extends BaseInspection { + @Nls + @NotNull + @Override + public String getDisplayName() { + return InspectionGadgetsBundle.message( + "expected.exception.never.thrown.display.name"); + } + + @NotNull + @Override + protected String buildErrorString(Object... infos) { + final PsiMethod method = (PsiMethod) infos[0]; + return InspectionGadgetsBundle.message( + "expected.exception.never.thrown.problem.descriptor", + method.getName()); + } + + @Override + public BaseInspectionVisitor buildVisitor() { + return new ExpectedExceptionNeverThrownVisitor(); + } + + private static class ExpectedExceptionNeverThrownVisitor + extends BaseInspectionVisitor { + + @Override + public void visitMethod(PsiMethod method) { + super.visitMethod(method); + final PsiAnnotation annotation = + AnnotationUtil.findAnnotation(method, "org.junit.Test"); + if (annotation == null) { + return; + } + final PsiAnnotationParameterList parameterList = + annotation.getParameterList(); + final PsiNameValuePair[] attributes = parameterList.getAttributes(); + PsiAnnotationMemberValue value = null; + for (PsiNameValuePair attribute : attributes) { + if ("expected".equals(attribute.getName())) { + value = attribute.getValue(); + break; + } + } + if (!(value instanceof PsiClassObjectAccessExpression)) { + return; + } + final PsiCodeBlock body = method.getBody(); + if (body == null) { + return; + } + final PsiClassObjectAccessExpression classObjectAccessExpression = + (PsiClassObjectAccessExpression) value; + final PsiTypeElement operand = + classObjectAccessExpression.getOperand(); + final PsiType type = operand.getType(); + if (!(type instanceof PsiClassType)) { + return; + } + final PsiClassType classType = (PsiClassType) type; + final PsiClass aClass = classType.resolve(); + if (ClassUtils.isSubclass(aClass, "java.lang.RuntimeException")) { + return; + } + final Set exceptionsThrown = + ExceptionUtils.calculateExceptionsThrown(body); + if (exceptionsThrown.contains(type)) { + return; + } + registerError(operand, method); + } + } +} diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ExceptionUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ExceptionUtils.java index abcc3c7c2419..b74a3e94c4c0 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ExceptionUtils.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ExceptionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2009 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.siyeh.ig.psiutils; +import com.intellij.openapi.project.Project; import com.intellij.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,9 +39,9 @@ public class ExceptionUtils{ } @NotNull public static Set calculateExceptionsThrown( - @NotNull PsiElement statement){ + @NotNull PsiElement element){ final ExceptionsThrownVisitor visitor = new ExceptionsThrownVisitor(); - statement.accept(visitor); + element.accept(visitor); return visitor.getExceptionsThrown(); } @@ -195,8 +196,9 @@ public class ExceptionUtils{ return; } final PsiReferenceList throwsList = method.getThrowsList(); - final PsiManager psiManager = expression.getManager(); - final PsiElementFactory factory = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory(); + final Project project = expression.getProject(); + final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); + final PsiElementFactory factory = psiFacade.getElementFactory(); final PsiJavaCodeReferenceElement[] list = throwsList.getReferenceElements(); for(final PsiJavaCodeReferenceElement referenceElement : list){ @@ -210,15 +212,17 @@ public class ExceptionUtils{ } } - @Override public void visitNewExpression(@NotNull PsiNewExpression expression){ + @Override public void visitNewExpression( + @NotNull PsiNewExpression expression){ super.visitNewExpression(expression); final PsiMethod method = expression.resolveMethod(); if(method == null){ return; } final PsiReferenceList throwsList = method.getThrowsList(); - final PsiManager psiManager = expression.getManager(); - final PsiElementFactory factory = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory(); + final Project project = expression.getProject(); + final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); + final PsiElementFactory factory = psiFacade.getElementFactory(); final PsiJavaCodeReferenceElement[] list = throwsList.getReferenceElements(); for(final PsiJavaCodeReferenceElement referenceElement : list){ diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExpectedExceptionNeverThrown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExpectedExceptionNeverThrown.html new file mode 100644 index 000000000000..a4f3ff5f2d76 --- /dev/null +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExpectedExceptionNeverThrown.html @@ -0,0 +1,7 @@ + +
+ +This inspection reports checked exceptions expected by a JUnit 4 test method, +which are never thrown inside the method body. +
Powered by InspectionGadgets
+ \ No newline at end of file diff --git a/plugins/IntentionPowerPak/src/META-INF/plugin.xml b/plugins/IntentionPowerPak/src/META-INF/plugin.xml index d52e6d7c632b..380808c9acdb 100644 --- a/plugins/IntentionPowerPak/src/META-INF/plugin.xml +++ b/plugins/IntentionPowerPak/src/META-INF/plugin.xml @@ -20,6 +20,16 @@ intention.category.numbers + + com.siyeh.ipp.integer.ConvertToEngineeringNotationIntention + intention.category.numbers + + + + com.siyeh.ipp.integer.ConvertToPlainIntention + intention.category.numbers + + com.siyeh.ipp.integer.ConvertIntegerToOctalIntention intention.category.numbers diff --git a/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties b/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties index 6ab49be6beb1..f5b26f806b72 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties +++ b/plugins/IntentionPowerPak/src/com/siyeh/IntentionPowerPackBundle.properties @@ -55,6 +55,10 @@ move.comment.to.separate.line.intention.name=Move comment to separate line move.comment.to.separate.line.intention.family.name=Move Comment to Separate Line convert.integer.to.hex.intention.name=Convert to hex convert.integer.to.hex.intention.family.name=Convert to Hexadecimal +convert.to.engineering.notation.intention.name=Convert to Engineering notation +convert.to.engineering.notation.intention.family.name=Convert to Engineering notation +convert.to.plain.intention.name=Convert to Plain +convert.to.plain.intention.family.name=Convert to Plain string.to.char.intention.name=Replace string literal with character string.to.char.intention.family.name=Replace String with Char convert.integer.to.decimal.intention.name=Convert to decimal diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/ReplaceForEachLoopWithIndexedForLoopIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/ReplaceForEachLoopWithIndexedForLoopIntention.java index d756d88033f8..cb3bace8866f 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/ReplaceForEachLoopWithIndexedForLoopIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/forloop/ReplaceForEachLoopWithIndexedForLoopIntention.java @@ -198,7 +198,7 @@ public class ReplaceForEachLoopWithIndexedForLoopIntention extends Intention { return createVariable(variableName, expression, context); } final PsiElement target = referenceElement.resolve(); - if (target instanceof PsiLocalVariable) { + if (target instanceof PsiVariable) { // maybe should not do this for local variables outside of // anonymous classes return variableName; diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToEngineeringNotationIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToEngineeringNotationIntention.java new file mode 100644 index 000000000000..508f57e6b629 --- /dev/null +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToEngineeringNotationIntention.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2010 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.siyeh.ipp.integer; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiExpression; +import com.intellij.util.IncorrectOperationException; +import com.siyeh.ipp.base.Intention; +import com.siyeh.ipp.base.PsiElementPredicate; +import org.jetbrains.annotations.NotNull; + +import java.text.DecimalFormat; + +/** + * @author Konstantin Bulenkov + */ +public class ConvertToEngineeringNotationIntention extends Intention { + + private static final DecimalFormat FORMAT = + new DecimalFormat("0.00000000000000E00"); + private static final ConvertToEngineeringNotationPredicate PREDICATE = + new ConvertToEngineeringNotationPredicate(); + + @Override + protected void processIntention(@NotNull PsiElement element) + throws IncorrectOperationException { + final String elementText = element.getText(); + if (elementText.length() == 0) { + return; + } + final int lastIndex = elementText.length() - 1; + final char lastChar = elementText.charAt(lastIndex); + String text = FORMAT.format(Double.parseDouble(elementText)).replace(',', '.'); + while (text.contains("0E") && !text.contains(".0E")) { + text = text.replace("0E", "E"); + } + if (lastChar == 'f' || lastChar == 'F') { + replaceExpression(text + lastChar, (PsiExpression)element); + } else { + replaceExpression(text, (PsiExpression)element); + } + } + + @NotNull + @Override + protected PsiElementPredicate getElementPredicate() { + return PREDICATE; + } +} diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToEngineeringNotationPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToEngineeringNotationPredicate.java new file mode 100644 index 000000000000..8e201fa3c52d --- /dev/null +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToEngineeringNotationPredicate.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2010 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.siyeh.ipp.integer; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiLiteralExpression; +import com.intellij.psi.PsiType; +import com.siyeh.ipp.base.PsiElementPredicate; + +/** + * @author Konstantin Bulenkov + */ +public class ConvertToEngineeringNotationPredicate implements PsiElementPredicate { + @Override + public boolean satisfiedBy(PsiElement element) { + if (element instanceof PsiLiteralExpression) { + final PsiLiteralExpression expression = (PsiLiteralExpression)element; + final PsiType type = expression.getType(); + + if (PsiType.DOUBLE.equals(type) || PsiType.FLOAT.equals(type)) { + String text = expression.getText(); + if (text != null) { + text = text.toLowerCase(); + if (text.startsWith("-")) { + text = text.substring(1); + } + if (!text.contains(".") && text.startsWith("0")) return false; //Octal integer + return !(text.contains("e")); + } + } + } + return false; + } +} diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToPlainIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToPlainIntention.java new file mode 100644 index 000000000000..ea0d42785008 --- /dev/null +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToPlainIntention.java @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2010 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.siyeh.ipp.integer; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiExpression; +import com.intellij.util.IncorrectOperationException; +import com.siyeh.ipp.base.Intention; +import com.siyeh.ipp.base.PsiElementPredicate; +import org.jetbrains.annotations.NotNull; + +import java.math.BigDecimal; + +/** + * @author Konstantin Bulenkov + */ +public class ConvertToPlainIntention extends Intention { + + private static final ConvertToPlainPredicate PREDICATE = + new ConvertToPlainPredicate(); + + @Override + protected void processIntention(@NotNull PsiElement element) + throws IncorrectOperationException { + try { + final String elementText = element.getText(); + if (elementText.length() == 0) { + return; + } + final int lastIndex = elementText.length() - 1; + final char lastChar = elementText.charAt(lastIndex); + if (lastChar == 'f' || lastChar == 'F') { + final BigDecimal bigDecimal = + new BigDecimal(elementText.substring(0, lastIndex)); + replaceExpression(bigDecimal.toPlainString() + lastChar, + (PsiExpression) element); + } else { + final BigDecimal bigDecimal = new BigDecimal(elementText); + replaceExpression(bigDecimal.toPlainString(), + (PsiExpression) element); + } + } catch (Exception e) {// + } + } + + @NotNull + @Override + protected PsiElementPredicate getElementPredicate() { + return PREDICATE; + } +} diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToPlainPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToPlainPredicate.java new file mode 100644 index 000000000000..25060ba0c2e9 --- /dev/null +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/integer/ConvertToPlainPredicate.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2010 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.siyeh.ipp.integer; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiLiteralExpression; +import com.intellij.psi.PsiType; +import com.siyeh.ipp.base.PsiElementPredicate; + +/** + * @author Konstantin Bulenkov + */ +public class ConvertToPlainPredicate implements PsiElementPredicate { + + public boolean satisfiedBy(PsiElement element) { + if (element instanceof PsiLiteralExpression) { + final PsiLiteralExpression expression = (PsiLiteralExpression)element; + final PsiType type = expression.getType(); + + if (PsiType.DOUBLE.equals(type) || PsiType.FLOAT.equals(type)) { + final String text = expression.getText(); + if (text != null) { + return text.contains("e") || text.contains("E"); + } + } + } + return false; + } +} diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/after.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/after.java.template new file mode 100644 index 000000000000..1f8fa2217f2a --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/after.java.template @@ -0,0 +1,5 @@ +public class X { + void f() { + double d = 1.23456789e3; + } +} diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/before.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/before.java.template new file mode 100644 index 000000000000..892fefba9b51 --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/before.java.template @@ -0,0 +1,5 @@ +public class X { + void f() { + double d = 1234.56789; + } +} diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/description.html b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/description.html new file mode 100644 index 000000000000..65facc7cf205 --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToEngineeringNotationIntention/description.html @@ -0,0 +1,7 @@ + + +This intention converts selected double or float literal written in decimal notation +into engineering notation. + + + diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/after.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/after.java.template new file mode 100644 index 000000000000..892fefba9b51 --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/after.java.template @@ -0,0 +1,5 @@ +public class X { + void f() { + double d = 1234.56789; + } +} diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/before.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/before.java.template new file mode 100644 index 000000000000..1f8fa2217f2a --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/before.java.template @@ -0,0 +1,5 @@ +public class X { + void f() { + double d = 1.23456789e3; + } +} diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/description.html b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/description.html new file mode 100644 index 000000000000..d5ef1e813cca --- /dev/null +++ b/plugins/IntentionPowerPak/src/intentionDescriptions/ConvertToPlainIntention/description.html @@ -0,0 +1,7 @@ + + +This intention converts selected double or float literal written in engineering notation +into plain notation. + + + diff --git a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java index 70b4a071aef9..47763dd6888b 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java +++ b/plugins/git4idea/src/git4idea/checkin/GitPushActiveBranchesDialog.java @@ -604,7 +604,7 @@ public class GitPushActiveBranchesDialog extends DialogWrapper { // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()) { final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } ColoredTreeCellRenderer r = getTextRenderer(); if (!(value instanceof DefaultMutableTreeNode)) { diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index 998c61a424c3..ee2dbf906d19 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -15,6 +15,7 @@ */ package git4idea.history; +import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; @@ -35,10 +36,7 @@ import com.intellij.util.concurrency.Semaphore; import com.intellij.util.text.StringTokenizer; import com.intellij.vcsUtil.VcsUtil; import git4idea.*; -import git4idea.commands.GitCommand; -import git4idea.commands.GitLineHandler; -import git4idea.commands.GitLineHandlerAdapter; -import git4idea.commands.GitSimpleHandler; +import git4idea.commands.*; import git4idea.history.browser.GitCommit; import git4idea.history.browser.SHAHash; import git4idea.history.wholeTree.CommitHashPlusParents; @@ -427,7 +425,7 @@ public class GitHistoryUtils { h.setNoSSH(true); h.setStdoutSuppressed(true); h.addParameters(parameters); - h.addParameters("--name-only", "--pretty=format:%x03%H%x00%ct%x00", "--encoding=UTF-8"); + h.addParameters("--pretty=format:%x03%H%x00%ct%x00", "--encoding=UTF-8"); h.endOptions(); h.addRelativePaths(path); String output = h.run(); @@ -566,39 +564,51 @@ public class GitHistoryUtils { // adjust path using change manager path = getLastCommitName(project, path); final VirtualFile root = GitUtil.getGitRoot(path); - GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG); + GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG); h.setNoSSH(true); h.setStdoutSuppressed(true); h.addParameters(parameters); - h.addParameters("--name-only", "--pretty=format:%x01%h%x00%ct%x00%p", "--encoding=UTF-8"); + h.addParameters("--pretty=format:%x01%h%x00%ct%x00%p", "--encoding=UTF-8"); h.endOptions(); h.addRelativePaths(path); - String output = h.run(); - final List rc = new ArrayList(); - StringTokenizer tk = new StringTokenizer(output, "\u0001", false); - while (tk.hasMoreTokens()) { - final String line = tk.nextToken(); - final String[] subLines = line.split("\n"); - final StringTokenizer tk2 = new StringTokenizer(subLines[0], "\u0000", false); + h.addLineListener(new GitLineHandlerListener() { + @Override + public void onLineAvailable(final String line, final Key outputType) { + if (ProcessOutputTypes.STDOUT.equals(outputType)) { + if (line.startsWith("\u0001")) { + final StringTokenizer tk2 = new StringTokenizer(line.substring(1), "\u0000", false); - final String hash = tk2.nextToken(); - final long time; - if (tk2.hasMoreTokens()) { - final String dateString = tk2.nextToken(); - time = Long.parseLong(dateString.trim()); - } else { - time = 0; + final String hash = tk2.nextToken(); + final long time; + if (tk2.hasMoreTokens()) { + final String dateString = tk2.nextToken(); + time = Long.parseLong(dateString.trim()); + } else { + time = 0; + } + final String[] parents; + if (tk2.hasMoreTokens()) { + parents = tk2.nextToken().split(" "); + } else { + parents = ArrayUtil.EMPTY_STRING_ARRAY; + } + consumer.consume(new CommitHashPlusParents(hash, parents, time)); // todo stop listen to output + } + } } - final String[] parents; - if (tk2.hasMoreTokens()) { - parents = tk2.nextToken().split(" "); - } else { - parents = ArrayUtil.EMPTY_STRING_ARRAY; + + @Override + public void processTerminated(int exitCode) { } - consumer.consume(new CommitHashPlusParents(hash, parents, time)); - } + + @Override + public void startFailed(Throwable exception) { + // todo + } + }); + h.start(); } @Nullable diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/FictiveAction.java b/plugins/git4idea/src/git4idea/history/wholeTree/FictiveAction.java index a2e0b28c490e..9dace3a79438 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/FictiveAction.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/FictiveAction.java @@ -18,7 +18,6 @@ package git4idea.history.wholeTree; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.vcs.BigArray; /** * @author irengrig @@ -30,27 +29,6 @@ public class FictiveAction extends AnAction { @Override public void actionPerformed(AnActionEvent e) { - final BigArray ba = new BigArray(4); - for (int i = 0; i < 100; i++) { - ba.add(new MyLine("Test" + i)); - } GitLogLongPanel.showDialog(PlatformDataKeys.PROJECT.getData(e.getDataContext())); } - - private static class MyLine implements VisibleLine { - private final String myLine; - - public MyLine(String line) { - myLine = line; - } - - @Override - public Object getData() { - return myLine; - } - @Override - public boolean isDecoration() { - return false; - } - } } diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/GitLogLongPanel.java b/plugins/git4idea/src/git4idea/history/wholeTree/GitLogLongPanel.java index ab0c69b613d6..c585753588dc 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/GitLogLongPanel.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/GitLogLongPanel.java @@ -196,6 +196,11 @@ public class GitLogLongPanel { new MyDialog(project, gitLogLongPanel).show(); } + public static void showDialog(final Project project, final VirtualFile root) { + final GitLogLongPanel gitLogLongPanel = new GitLogLongPanel(project, Collections.singletonList(root)); + new MyDialog(project, gitLogLongPanel).show(); + } + public UIRefresh getUIRefresh() { return myUIRefresh; } @@ -291,8 +296,8 @@ public class GitLogLongPanel { myTimer = new Timer(100, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - //final boolean shouldPing = (System.currentTimeMillis() - myRefreshMark) > 700; - final boolean shouldPing = false; + final boolean shouldPing = (System.currentTimeMillis() - myRefreshMark) > 300; + //final boolean shouldPing = false; if (((mySpeedometer.getSpeed() < 0.1) && mySpeedometer.hasData()) || shouldPing) { myRefreshMark = System.currentTimeMillis(); mySpeedometer.clear(); diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/LoaderImpl.java b/plugins/git4idea/src/git4idea/history/wholeTree/LoaderImpl.java index c631d4661780..a9bafd94f76e 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/LoaderImpl.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/LoaderImpl.java @@ -269,7 +269,7 @@ public class LoaderImpl implements Loader { @Override public void consume(List commitHashPlusParentses) { synchronized (myLock) { - if (myId != myLoadId) throw new MyStopListenToOutputException(); + if (myId != myLoadId) throw new MyStopListenToOutputException(); // TODO TODO TODO } for (CommitHashPlusParents item : commitHashPlusParentses) { myConsumer.consume(item); diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/SelectRepositoryAndShowLogAction.java b/plugins/git4idea/src/git4idea/history/wholeTree/SelectRepositoryAndShowLogAction.java new file mode 100644 index 000000000000..5e7a5dbae55c --- /dev/null +++ b/plugins/git4idea/src/git4idea/history/wholeTree/SelectRepositoryAndShowLogAction.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2010 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 git4idea.history.wholeTree; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.fileChooser.FileChooser; +import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; + +/** + * @author irengrig + */ +public class SelectRepositoryAndShowLogAction extends AnAction { + public SelectRepositoryAndShowLogAction() { + super("Select and browse git repo"); + } + + @Override + public void actionPerformed(AnActionEvent e) { + final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); + final VirtualFile[] virtualFiles = FileChooser.chooseFiles(project, new FileChooserDescriptor(false, true, false, true, false, false)); + if (virtualFiles == null || virtualFiles.length == 0) return; + GitLogLongPanel.showDialog(project, virtualFiles[0]); + } +} diff --git a/plugins/git4idea/src/git4idea/ui/GitConvertFilesDialog.java b/plugins/git4idea/src/git4idea/ui/GitConvertFilesDialog.java index f1eba0ba66a7..4f8680ffd28d 100644 --- a/plugins/git4idea/src/git4idea/ui/GitConvertFilesDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitConvertFilesDialog.java @@ -355,7 +355,7 @@ public class GitConvertFilesDialog extends DialogWrapper { // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } ColoredTreeCellRenderer r = getTextRenderer(); if (!(value instanceof CheckedTreeNode)) { diff --git a/plugins/git4idea/src/git4idea/ui/GitRefspecAddRefsDialog.java b/plugins/git4idea/src/git4idea/ui/GitRefspecAddRefsDialog.java index 2e601b29cb21..2b668f67a266 100644 --- a/plugins/git4idea/src/git4idea/ui/GitRefspecAddRefsDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitRefspecAddRefsDialog.java @@ -247,7 +247,7 @@ public class GitRefspecAddRefsDialog extends DialogWrapper { // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()) { final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } final CheckedTreeNode node = (CheckedTreeNode)value; final Object userObject = node.getUserObject(); diff --git a/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java b/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java index 39ac3fb76830..004b369f5caa 100644 --- a/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java +++ b/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java @@ -265,7 +265,7 @@ public class GitRootTracker implements VcsListener { if (!hasInvalidRoots) { // check if roots have a problem for (final VirtualFile root : rootSet) { - hasInvalidRoots = hasUnmappedSubroots(root, rootSet); + hasInvalidRoots = hasUnmappedSubroots(root, rootSet, 0); if (hasInvalidRoots) { break; } @@ -318,8 +318,12 @@ public class GitRootTracker implements VcsListener { * * @param directory the content root to check * @param rootSet the mapped root set + * @param depth */ - private static boolean hasUnmappedSubroots(final VirtualFile directory, final @NotNull HashSet rootSet) { + private static boolean hasUnmappedSubroots(final VirtualFile directory, final @NotNull HashSet rootSet, int depth) { + if (depth > 3) { // three is quite enough + return false; + } VirtualFile[] children = ApplicationManager.getApplication().runReadAction(new Computable() { public VirtualFile[] compute() { return directory.isValid() ? directory.getChildren() : VirtualFile.EMPTY_ARRAY; @@ -333,7 +337,7 @@ public class GitRootTracker implements VcsListener { if (child.getName().equals(".git")) { return !rootSet.contains(child.getParent()); } - if (hasUnmappedSubroots(child, rootSet)) { + if (hasUnmappedSubroots(child, rootSet, depth + 1)) { return true; } } diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index cb4c1cfbd659..7dc701c00fb6 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -534,7 +534,6 @@ text="Generate GroovyDoc" description="Generating Groovy Documentation" icon="/org/jetbrains/plugins/groovy/images/GroovyDoc.png"> - diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/AntTasksProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/AntTasksProvider.java index 5efefbf27e51..1cbfccdb47a7 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/AntTasksProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/AntTasksProvider.java @@ -111,7 +111,7 @@ public class AntTasksProvider { for (VirtualFile jar : jars) { urls.add(VfsUtil.convertToURL(PathUtil.getLocalFile(jar).getUrl())); } - final ClassLoader loader = new UrlClassLoader(urls, null); + final ClassLoader loader = new UrlClassLoader(urls, null, false, false, true); final ReflectedProject antProject = ReflectedProject.getProject(loader); final Map result = new HashMap(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyInsertHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyInsertHandler.java index 94244b4af9a1..0d0f898e5c10 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyInsertHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyInsertHandler.java @@ -88,9 +88,9 @@ public class GroovyInsertHandler implements InsertHandler { PsiDocumentManager docManager = PsiDocumentManager.getInstance(method.getProject()); docManager.commitDocument(document); PsiFile psiFile = docManager.getPsiFile(document); - /*if (method.getParameterList().getParametersCount() > 0 && isTopLevelStatement(psiFile, context.getStartOffset())) { + if (method.getParameterList().getParametersCount() > 0 && isTopLevelStatement(psiFile, context.getStartOffset())) { return; - }*/ + } if (isExpressionStatement(psiFile, context.getStartOffset()) && (PsiType.VOID.equals(PsiUtil.getSmartReturnType(method)) || method instanceof GrMethod && ((GrMethod)method).getReturnTypeElementGroovy() == null) && diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/UnaryExpressionNotPlusMinus.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/UnaryExpressionNotPlusMinus.java index 13a36c6b76c5..7a4846e047c4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/UnaryExpressionNotPlusMinus.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/UnaryExpressionNotPlusMinus.java @@ -60,8 +60,7 @@ public class UnaryExpressionNotPlusMinus implements GroovyElementTypes { marker.rollbackTo(); return fail; } - if (TokenSets.BUILT_IN_TYPE.contains(builder.getTokenType()) || - mIDENT.equals(builder.getTokenType())) { + if (TokenSets.BUILT_IN_TYPE.contains(builder.getTokenType()) || mIDENT.equals(builder.getTokenType())) { final ReferenceElement.ReferenceElementResult result = TypeSpec.parseStrict(builder); if (result == fail) { marker.rollbackTo(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/relational/RelationalExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/relational/RelationalExpression.java index 2cdde95fc220..754be6c99ec5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/relational/RelationalExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/relational/RelationalExpression.java @@ -22,7 +22,6 @@ import org.jetbrains.plugins.groovy.GroovyBundle; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arithmetic.ShiftExpression; -import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement; import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeSpec; import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils; @@ -46,8 +45,7 @@ public class RelationalExpression implements GroovyElementTypes { PsiBuilder.Marker marker = builder.mark(); if (ShiftExpression.parse(builder, parser)) { - if (ParserUtils.getToken(builder, RELATIONS) || - getCompositeSign(builder)) { + if (ParserUtils.getToken(builder, RELATIONS) || getCompositeSign(builder)) { ParserUtils.getToken(builder, mNLS); ShiftExpression.parse(builder, parser); marker.done(RELATIONAL_EXPRESSION); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/types/TypeArguments.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/types/TypeArguments.java index 62a852a33c34..49c913a49a80 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/types/TypeArguments.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/types/TypeArguments.java @@ -41,6 +41,7 @@ public class TypeArguments implements GroovyElementTypes { return false; } + boolean hasComma = ParserUtils.lookAhead(builder, mCOMMA); while (ParserUtils.getToken(builder, mCOMMA)) { ParserUtils.getToken(builder, mNLS); @@ -54,10 +55,17 @@ public class TypeArguments implements GroovyElementTypes { if (ParserUtils.getToken(builder, mGT)) { rb.drop(); - } else { + } + else if (hasComma) { rb.rollbackTo(); builder.error(GroovyBundle.message("gt.expected")); } + else { + rb.drop(); + marker.rollbackTo(); + return false; + } + marker.done(TYPE_ARGUMENTS); return true; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrApplicationStatementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrApplicationStatementImpl.java index 9a7407a6b1cb..32840884e8a4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrApplicationStatementImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrApplicationStatementImpl.java @@ -32,11 +32,6 @@ public class GrApplicationStatementImpl extends GrMethodCallImpl implements GrAp super(node); } - @Override - public boolean isCommandExpression() { - return true; - } - public void accept(GroovyElementVisitor visitor) { visitor.visitApplicationStatement(this); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrMethodCallImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrMethodCallImpl.java index 6e35a7d60ae2..19e4e40d3ddf 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrMethodCallImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrMethodCallImpl.java @@ -79,4 +79,11 @@ public abstract class GrMethodCallImpl extends GrCallExpressionImpl implements G return GroovyPsiManager.getInstance(getProject()).getType(this, METHOD_CALL_TYPES_CALCULATOR); } + @Override + public boolean isCommandExpression() { + final GrExpression expression = getInvokedExpression(); + if (!(expression instanceof GrReferenceExpression) || ((GrReferenceExpression)expression).getQualifier() == null) return false; + + return ((GrReferenceExpression)expression).getDotToken() == null; + } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrMethodCallExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrMethodCallExpressionImpl.java index 6e822eac8c5e..3d2f3e0ff549 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrMethodCallExpressionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrMethodCallExpressionImpl.java @@ -25,7 +25,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrMethodCallImpl; @@ -106,13 +105,4 @@ public class GrMethodCallExpressionImpl extends GrMethodCallImpl implements GrMe } return null; } - - @Override - public boolean isCommandExpression() { - final GrExpression expression = getInvokedExpression(); - if (!(expression instanceof GrReferenceExpression) || ((GrReferenceExpression)expression).getQualifier() == null) return false; - - return ((GrReferenceExpression)expression).getDotToken() == null; - } - } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduceVariable/GroovyIntroduceVariableBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduceVariable/GroovyIntroduceVariableBase.java index a494d2a335b2..ece0e8a02fcd 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduceVariable/GroovyIntroduceVariableBase.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduceVariable/GroovyIntroduceVariableBase.java @@ -180,7 +180,7 @@ public abstract class GroovyIntroduceVariableBase implements RefactoringActionHa if (selectedExpr instanceof GrReferenceExpression && selectedExpr.getParent() instanceof GrMethodCall && - ((GrMethodCall)selectedExpr.getParent()).isCommandExpression()) { + (((GrMethodCall)selectedExpr.getParent()).isCommandExpression() || selectedExpr.getParent() instanceof GrApplicationStatement)) { String message = RefactoringBundle.getCannotRefactorMessage(GroovyRefactoringBundle.message("selected.expression.in.command.expression")); showErrorMessage(project, editor, message); return false; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyClassNameCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyClassNameCompletionTest.groovy index 1c049def885d..ba97a15eb995 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyClassNameCompletionTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyClassNameCompletionTest.groovy @@ -115,13 +115,17 @@ class Foo { static def abcmethod1(int a) {} static def abcmethod2(int a) {} }""") - myFixture.configureByText("a.groovy", "abcme") + myFixture.configureByText("a.groovy", """def foo() { + abcme +}""") def item = myFixture.complete(CompletionType.CLASS_NAME)[0] ((StaticallyImportable) item).shouldBeImported = true myFixture.type('\n') myFixture.checkResult """import static Foo.abcmethod1 -abcmethod1()""" +def foo() { + abcmethod1 +}""" } @@ -130,11 +134,15 @@ abcmethod1()""" class Foo { static def abcmethod(int a) {} }""") - myFixture.configureByText("a.groovy", "abcme") + myFixture.configureByText("a.groovy", """def foo() { + abcme +}""") myFixture.complete(CompletionType.CLASS_NAME) myFixture.checkResult """import foo.Foo -Foo.abcmethod()""" +def foo() { + Foo.abcmethod +}""" } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy index 5f9a93e26f04..d0291b81b1e3 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy @@ -122,6 +122,7 @@ public class ExpressionsParsingTest extends GroovyParsingTestCase { public void testpath$path8() throws Throwable { doTest(); } public void testpath$path9() throws Throwable { doTest(); } public void testpath$path10() throws Throwable {doTest(); } + public void testpath$typeVsExpr() {doTest();} public void testreferences$ref1() throws Throwable { doTest(); } public void testreferences$ref2() throws Throwable { doTest(); } public void testreferences$ref3() throws Throwable { doTest(); } diff --git a/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForList.groovy b/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForList.groovy index 148a40093f1e..be0e98311a1c 100644 --- a/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForList.groovy +++ b/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForList.groovy @@ -1,2 +1,4 @@ -List list=['a', 'b'] -list[0].substr \ No newline at end of file +def foo() { + List list=['a', 'b'] + list[0].substr +} \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForList_after.groovy b/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForList_after.groovy index 1183d1a937d2..e5f06e0fea48 100644 --- a/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForList_after.groovy +++ b/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForList_after.groovy @@ -1,2 +1,4 @@ -List list=['a', 'b'] -list[0].substring() \ No newline at end of file +def foo() { + List list=['a', 'b'] + list[0].substring() +} \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForMap.groovy b/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForMap.groovy index 48b304a610ba..53fb3df1ebbd 100644 --- a/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForMap.groovy +++ b/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForMap.groovy @@ -1,2 +1,4 @@ -map=[1:'a', 3:'b', 2:'c'] -map[2].substr \ No newline at end of file +def foo() { + map=[1:'a', 3:'b', 2:'c'] + map[2].substr +} \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForMap_after.groovy b/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForMap_after.groovy index af7ca058ab20..90f20ad5f46e 100644 --- a/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForMap_after.groovy +++ b/plugins/groovy/testdata/groovy/completion/ArrayLikeAccessForMap_after.groovy @@ -1,2 +1,4 @@ -map=[1:'a', 3:'b', 2:'c'] -map[2].substring() \ No newline at end of file +def foo() { + map=[1:'a', 3:'b', 2:'c'] + map[2].substring() +} \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/dsl/DelegateToArgument2_after.groovy b/plugins/groovy/testdata/groovy/dsl/DelegateToArgument2_after.groovy index df00af3672ac..5d873cc0a7af 100644 --- a/plugins/groovy/testdata/groovy/dsl/DelegateToArgument2_after.groovy +++ b/plugins/groovy/testdata/groovy/dsl/DelegateToArgument2_after.groovy @@ -10,5 +10,5 @@ class Runner { def runner = new Runner() runner.boo new MyDelegate(), { - saySomething() + saySomething } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/dsl/DelegateToArgument_after.groovy b/plugins/groovy/testdata/groovy/dsl/DelegateToArgument_after.groovy index ddc2cfb45a0b..bbaa0f3ec417 100644 --- a/plugins/groovy/testdata/groovy/dsl/DelegateToArgument_after.groovy +++ b/plugins/groovy/testdata/groovy/dsl/DelegateToArgument_after.groovy @@ -13,5 +13,5 @@ class Runner { def runner = new Runner() runner.boo(new MyDelegate()) { - saySomething() + saySomething } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/dsl/DelegateToThrowable.groovy b/plugins/groovy/testdata/groovy/dsl/DelegateToThrowable.groovy index 94c1b563cd4f..5ec73c86aa83 100644 --- a/plugins/groovy/testdata/groovy/dsl/DelegateToThrowable.groovy +++ b/plugins/groovy/testdata/groovy/dsl/DelegateToThrowable.groovy @@ -1 +1,3 @@ -"".init \ No newline at end of file +def foo() { + "".init +} \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/dsl/DelegateToThrowable_after.groovy b/plugins/groovy/testdata/groovy/dsl/DelegateToThrowable_after.groovy index 36e101248223..2cc741907560 100644 --- a/plugins/groovy/testdata/groovy/dsl/DelegateToThrowable_after.groovy +++ b/plugins/groovy/testdata/groovy/dsl/DelegateToThrowable_after.groovy @@ -1 +1,3 @@ -"".initCause() \ No newline at end of file +def foo() { + "".initCause() +} \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/dsl/transform/BindableTransform_after.groovy b/plugins/groovy/testdata/groovy/dsl/transform/BindableTransform_after.groovy index d10217d6ff9f..988d22ca9120 100644 --- a/plugins/groovy/testdata/groovy/dsl/transform/BindableTransform_after.groovy +++ b/plugins/groovy/testdata/groovy/dsl/transform/BindableTransform_after.groovy @@ -6,4 +6,4 @@ class MyBean { def bean = new MyBean() -bean.firePropertyChange \ No newline at end of file +bean.firePropertyChange \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/dsl/transform/DelegateAnnotation_after.groovy b/plugins/groovy/testdata/groovy/dsl/transform/DelegateAnnotation_after.groovy index 685101bd59fa..f4df12c746b2 100644 --- a/plugins/groovy/testdata/groovy/dsl/transform/DelegateAnnotation_after.groovy +++ b/plugins/groovy/testdata/groovy/dsl/transform/DelegateAnnotation_after.groovy @@ -12,4 +12,4 @@ def gr8conf = new Event(title: "GR8 Conference", when: df.parse("2009/05/18")) -gr8conf.before() \ No newline at end of file +gr8conf.before \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/dsl/transform/VetoableTransform_after.groovy b/plugins/groovy/testdata/groovy/dsl/transform/VetoableTransform_after.groovy index e72c8e0502cc..8610d6331944 100644 --- a/plugins/groovy/testdata/groovy/dsl/transform/VetoableTransform_after.groovy +++ b/plugins/groovy/testdata/groovy/dsl/transform/VetoableTransform_after.groovy @@ -6,4 +6,4 @@ class MyBean { def bean = new MyBean() -bean.fireVetoableChange \ No newline at end of file +bean.fireVetoableChange \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/field.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/field.test similarity index 100% rename from plugins/groovy/testdata/groovy/refactoring/introduceVariable/field.test rename to plugins/groovy/testdata/groovy/refactoring/inlineLocal/field.test diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/typeVsExpr.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/typeVsExpr.test new file mode 100644 index 000000000000..9a94767c74ef --- /dev/null +++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/typeVsExpr.test @@ -0,0 +1,53 @@ +def foo() { + def a, b + return (a + PsiElement())(')') + PsiWhiteSpace(' ') + Throw clause + + Open block + PsiElement({)('{') + PsiWhiteSpace('\n ') + Variable definitions + Modifiers + PsiElement(def)('def') + PsiWhiteSpace(' ') + Variable + PsiElement(identifier)('a') + PsiElement(,)(',') + PsiWhiteSpace(' ') + Variable + PsiElement(identifier)('b') + PsiElement(new line)('\n ') + RETURN statement + PsiElement(return)('return') + PsiWhiteSpace(' ') + Conditional expression + Parenthesized expression + PsiElement(()('(') + Relational expression + Reference expression + PsiElement(identifier)('a') + PsiElement(<)('<') + Reference expression + PsiElement(identifier)('b') + PsiElement())(')') + PsiElement(?)('?') + Literal + PsiElement(Integer)('1') + PsiElement(:)(':') + Literal + PsiElement(Integer)('2') + PsiElement(new line)('\n') + PsiElement(})('}') \ No newline at end of file diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SelectBranchPopup.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SelectBranchPopup.java index 07fffc508e01..a52008a80e34 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SelectBranchPopup.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SelectBranchPopup.java @@ -240,7 +240,7 @@ public class SelectBranchPopup { final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(branchList) .setTitle(SVNPathUtil.tail(selectedValue)) .setResizable(true) - .setDimensionServiceKey("Svn.CompareWithBranchPopup") + //.setDimensionServiceKey("Svn.CompareWithBranchPopup") .setItemChoosenCallback(new Runnable() { public void run() { if (REFRESH_MESSAGE.equals(branchList.getSelectedValue())) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectIgnorePatternsToRemoveOnDeleteDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectIgnorePatternsToRemoveOnDeleteDialog.java index ca830d30be47..f34cbb0b5209 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectIgnorePatternsToRemoveOnDeleteDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectIgnorePatternsToRemoveOnDeleteDialog.java @@ -187,7 +187,7 @@ public class SelectIgnorePatternsToRemoveOnDeleteDialog extends DialogWrapper { // Fix GTK backround if (UIUtil.isUnderGTKLookAndFeel()){ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); - setBackground(background); + UIUtil.changeBackGround(this, background); } final ColoredTreeCellRenderer textRenderer = getTextRenderer(); if (value instanceof MyConsumer) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/quickFixes/QuickFixManager.java b/plugins/ui-designer/src/com/intellij/uiDesigner/quickFixes/QuickFixManager.java index 3a74020397b8..3f26f67d58f3 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/quickFixes/QuickFixManager.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/quickFixes/QuickFixManager.java @@ -174,7 +174,7 @@ public abstract class QuickFixManager { Rectangle hintRect = new Rectangle(rc.x - myIcon.getIconWidth() - 4, rc.y, myIcon.getIconWidth() + 4, myIcon.getIconHeight() + 4); LOG.debug("hintRect=" + hintRect); if (getHintClipRect(viewPort).contains(hintRect)) { - myHint.updateBounds(); + myHint.pack(); } else { myHint.hide(); diff --git a/resources-en/src/tips/tips.xml b/resources-en/src/tips/tips.xml index 38e9139da496..f4463faadd44 100644 --- a/resources-en/src/tips/tips.xml +++ b/resources-en/src/tips/tips.xml @@ -103,4 +103,7 @@ + + + diff --git a/xml/impl/resources/liveTemplates/zen_html.xml b/xml/impl/resources/liveTemplates/zen_html.xml index 97584af43ad1..16191af32e4e 100644 --- a/xml/impl/resources/liveTemplates/zen_html.xml +++ b/xml/impl/resources/liveTemplates/zen_html.xml @@ -6,7 +6,6 @@