diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java index 6aec0ae9fcad..a0e3b1d389e4 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefClassImpl.java @@ -65,9 +65,11 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass { private Set myInTypeReferences; private Set myInstanceReferences; private List myClassExporters; + private RefModule myRefModule; RefClassImpl(PsiClass psiClass, RefManager manager) { super(psiClass, manager); + myRefModule = manager.getRefModule(ModuleUtilCore.findModuleForPsiElement(psiClass)); } @Override @@ -226,6 +228,12 @@ public class RefClassImpl extends RefJavaElementImpl implements RefClass { return (PsiClass)super.getElement(); } + @Nullable + @Override + public RefModule getModule() { + return myRefModule; + } + private static boolean isSelfInheritor(PsiClass psiClass, ArrayList visited) { if (visited.contains(psiClass)) return true; diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java index 1783d36d0a0b..80af5c532a9a 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java @@ -34,8 +34,10 @@ import org.jetbrains.annotations.Nullable; public class RefImplicitConstructorImpl extends RefMethodImpl implements RefImplicitConstructor { + private final RefClass myOwnerClass; RefImplicitConstructorImpl(@NotNull RefClass ownerClass) { super(InspectionsBundle.message("inspection.reference.implicit.constructor.name", ownerClass.getName()), ownerClass); + myOwnerClass = ownerClass; } @Override diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java index 701f97358019..88e3a763927b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/reference/RefMethodImpl.java @@ -57,24 +57,20 @@ public class RefMethodImpl extends RefJavaElementImpl implements RefMethod { private RefParameter[] myParameters; private String myReturnValueTemplate; - protected final RefClass myOwnerClass; RefMethodImpl(@NotNull RefClass ownerClass, PsiMethod method, RefManager manager) { super(method, manager); ((RefClassImpl)ownerClass).add(this); - - myOwnerClass = ownerClass; } // To be used only from RefImplicitConstructor. protected RefMethodImpl(@NotNull String name, @NotNull RefClass ownerClass) { super(name, ownerClass); - myOwnerClass = ownerClass; ((RefClassImpl)ownerClass).add(this); - addOutReference(getOwnerClass()); - ((RefClassImpl)getOwnerClass()).addInReference(this); + addOutReference(ownerClass); + ((RefClassImpl)ownerClass).addInReference(this); setConstructor(true); } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java index 3cbfb282631d..2e21b9c33931 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefDirectoryImpl.java @@ -26,8 +26,10 @@ import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class RefDirectoryImpl extends RefElementImpl implements RefDirectory{ + private RefModule myRefModule; protected RefDirectoryImpl(PsiDirectory psiElement, RefManager refManager) { super(psiElement.getName(), psiElement, refManager); final PsiDirectory parentDirectory = psiElement.getParentDirectory(); @@ -38,13 +40,10 @@ public class RefDirectoryImpl extends RefElementImpl implements RefDirectory{ return; } } - final Module module = ModuleUtilCore.findModuleForPsiElement(psiElement); - if (module != null) { - final RefModuleImpl refModule = (RefModuleImpl)refManager.getRefModule(module); - if (refModule != null) { - refModule.add(this); - return; - } + myRefModule = refManager.getRefModule(ModuleUtilCore.findModuleForPsiElement(psiElement)); + if (myRefModule != null) { + ((RefModuleImpl)myRefModule).add(this); + return; } ((RefProjectImpl)refManager.getRefProject()).add(this); } @@ -54,6 +53,12 @@ public class RefDirectoryImpl extends RefElementImpl implements RefDirectory{ ApplicationManager.getApplication().runReadAction(() -> visitor.visitDirectory(this)); } + @Nullable + @Override + public RefModule getModule() { + return myRefModule; + } + @Override protected void initialize() { } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java index ceab3be73205..5bf052b6f5a7 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java @@ -61,14 +61,12 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement private String[] mySuppressions = null; private boolean myIsDeleted ; - private final Module myModule; protected static final int IS_REACHABLE_MASK = 0x40; protected RefElementImpl(@NotNull String name, @NotNull RefElement owner) { super(name, owner.getRefManager()); myID = null; myFlags = 0; - myModule = ModuleUtilCore.findModuleForPsiElement(owner.getElement()); } protected RefElementImpl(PsiFile file, RefManager manager) { @@ -79,7 +77,6 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement super(name, manager); myID = SmartPointerManager.getInstance(manager.getProject()).createSmartPsiElementPointer(element); myFlags = 0; - myModule = ModuleUtilCore.findModuleForPsiElement(element); } @Override @@ -114,7 +111,8 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement @Override public RefModule getModule() { - return myManager.getRefModule(myModule); + final RefEntity owner = getOwner(); + return owner instanceof RefElement ? ((RefElement)owner).getModule() : null; } @Override diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index e5df233f038d..65322446cb83 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -470,7 +470,10 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool(); ProblemDescriptionsProcessor problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, map); tool.inspectionFinished(inspectionManager, this, problemDescriptionProcessor); + } + + addProblemsToView(globalSimpleTools); } private void inspectFile(@NotNull final PsiFile file, @@ -656,12 +659,8 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp LOG.error(e); } } - if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) { - if (myView == null && !ReadAction.compute(() -> InspectionResultsView.hasProblems(globalTools, this, createContentProvider())).booleanValue()) { - return; - } - initializeViewIfNeed().doWhenDone(() -> myView.addTools(globalTools)); - } + + addProblemsToView(globalTools); } public ActionCallback initializeViewIfNeed() { @@ -994,4 +993,14 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp private InspectionRVContentProvider createContentProvider() { return new InspectionRVContentProviderImpl(getProject()); } + + private void addProblemsToView(List tools) { + if (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isHeadlessEnvironment()) { + return; + } + if (myView == null && !ReadAction.compute(() -> InspectionResultsView.hasProblems(tools, this, createContentProvider())).booleanValue()) { + return; + } + initializeViewIfNeed().doWhenDone(() -> myView.addTools(tools)); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java index 7b1f0c458421..75a5dec19f50 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java @@ -211,7 +211,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro if (context.isViewClosed() || !(refElement instanceof RefElement)) { return; } - if (!ApplicationManager.getApplication().isUnitTestMode()) { + if (myToolWrapper instanceof LocalInspectionToolWrapper && !ApplicationManager.getApplication().isUnitTestMode()) { context.initializeViewIfNeed().doWhenDone(() -> context.getView().addProblemDescriptors(myToolWrapper, refElement, descriptors)); } } @@ -313,7 +313,13 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro @Override public void ignoreElement(@NotNull final RefEntity refEntity) { - getProblemElements().remove(refEntity); + final CommonProblemDescriptor[] removedDescriptors = getProblemElements().remove(refEntity); + if (removedDescriptors != null) { + for (CommonProblemDescriptor descriptor : removedDescriptors) { + getProblemToElements().remove(descriptor); + } + } + getQuickFixActions().remove(refEntity); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java index cb85ba7ae702..3758a78aa777 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java @@ -32,6 +32,7 @@ import com.intellij.codeInspection.reference.RefEntity; import com.intellij.codeInspection.reference.RefFile; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigTreeComparator; @@ -107,8 +108,18 @@ public class InspectionResultsViewComparator implements Comparator { if (diff != 0) { return diff; } - return PsiUtilCore.compareElementsByPosition(((ProblemDescriptor)descriptor2).getEndElement(), + diff = PsiUtilCore.compareElementsByPosition(((ProblemDescriptor)descriptor2).getEndElement(), ((ProblemDescriptor)descriptor1).getEndElement()); + if (diff != 0) return diff; + + final TextRange range1 = ((ProblemDescriptor)descriptor1).getTextRangeInElement(); + final TextRange range2 = ((ProblemDescriptor)descriptor2).getTextRangeInElement(); + if (range1 != null && range2 != null) { + diff = range1.getStartOffset() - range2.getStartOffset(); + if (diff != 0) return diff; + diff = range1.getEndOffset() - range2.getEndOffset(); + if (diff != 0) return diff; + } } if (descriptor1 != null && descriptor2 != null) { return descriptor1.getDescriptionTemplate().compareToIgnoreCase(descriptor2.getDescriptionTemplate()); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index b75d14bb19aa..7613749fa73f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -1010,7 +1010,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj JScrollPane optionsPane = ScrollPaneFactory.createScrollPane(myAdditionalOptionsPanel, true); JPanel infoPanel = JBUI.Panels.simplePanel(optionsPane).withBorder(JBUI.Borders.emptyLeft(10)); - mainPanel = new JPanel(new MyOptionsLayout(mySplitter, infoPanel, JBUI.scale(250))); + mainPanel = new JPanel(new MyOptionsLayout(mySplitter, infoPanel, JBUI.scale(150), JBUI.scale(400))); mainPanel.add(mySplitter); mainPanel.add(infoPanel); } else { @@ -1348,11 +1348,13 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj private final JComponent myPanel; private final JComponent myOptions; private final int myMinOptionsWidth; + private final int myMaxOptionsWidth; - public MyOptionsLayout(@NotNull JComponent panel, @NotNull JComponent options, int minOptionsWidth) { + public MyOptionsLayout(@NotNull JComponent panel, @NotNull JComponent options, int minOptionsWidth, int maxOptionsWidth) { myPanel = panel; myOptions = options; myMinOptionsWidth = minOptionsWidth; + myMaxOptionsWidth = maxOptionsWidth; } @Override @@ -1365,9 +1367,8 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj @Override public void layoutContainer(Container parent) { Rectangle bounds = parent.getBounds(); - int availableWidth = bounds.width - myPanel.getPreferredSize().width; int preferredWidth = myOptions.getPreferredSize().width; - int optionsWidth = Math.max(Math.min(availableWidth, preferredWidth), myMinOptionsWidth); + int optionsWidth = Math.max(Math.min(myMaxOptionsWidth, preferredWidth), myMinOptionsWidth); myPanel.setBounds(new Rectangle(0, 0, bounds.width - optionsWidth, bounds.height)); myOptions.setBounds(new Rectangle(bounds.width - optionsWidth, 0, optionsWidth, bounds.height)); }