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/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/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/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/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-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/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/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/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/completion/CodeCompletionHandlerBase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java index 823a501692dd..c3d13ac3a5ab 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java @@ -188,31 +188,32 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { final int offset2, final CompletionContext context, final FileCopyPatcher patcher, final Editor editor, final 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); - - PsiFile originalFile = context.file; - - 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, 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(); @@ -245,22 +246,28 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { } startSemaphore.waitFor(); + return data; + } - 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; + 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)); + } + }); } - } + }); - indicator.notifyBackgrounded(); - indicator.showLookup(); + 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( 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/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/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/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/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/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/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/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/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/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/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/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/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/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 5e7968265635..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 @@ -286,7 +286,8 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap public void invalidateActionsFor(DocumentReference ref) { ApplicationManager.getApplication().assertIsDispatchThread(); - LOG.assertTrue(!isInsideCommand()); + myMerger.invalidateActionsFor(ref); + if (myCurrentMerger != null) myCurrentMerger.invalidateActionsFor(ref); myUndoStacksHolder.invalidateActionsFor(ref); myRedoStacksHolder.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 24121177f499..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,7 +51,7 @@ class UndoableGroup { private final Project myProject; private final UndoConfirmationPolicy myConfirmationPolicy; - private boolean myValid = true; + private boolean myValid; public UndoableGroup(String commandName, boolean isGlobal, @@ -61,7 +61,8 @@ class UndoableGroup { List actions, int commandTimestamp, UndoConfirmationPolicy confirmationPolicy, - boolean transparent) { + boolean transparent, + boolean valid) { myCommandName = commandName; myGlobal = isGlobal; myCommandTimestamp = commandTimestamp; @@ -71,6 +72,7 @@ class UndoableGroup { myStateAfter = stateAfter; myConfirmationPolicy = confirmationPolicy; myTransparent = transparent; + myValid = valid; } public boolean isGlobal() { 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/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/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 db370ba6b4da..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 @@ -4219,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); @@ -4248,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)); @@ -4287,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) { @@ -4367,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; @@ -4447,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/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-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/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 3c3ccb37a04d..8d42a53ac2d3 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -295,7 +295,7 @@ - + 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/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/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/junit/ExpectedExceptionNeverThrownInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java new file mode 100644 index 000000000000..1113db1bbb4e --- /dev/null +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java @@ -0,0 +1,104 @@ +/* + * 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 com.siyeh.ig.psiutils.TypeUtils; +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/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/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/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/test/org/jetbrains/plugins/groovy/GroovyClassNameCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyClassNameCompletionTest.groovy index dc1a39a94328..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/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/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/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) {