mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DBE-1091: track modification count to update QuickDocs
This commit is contained in:
+17
-2
@@ -48,6 +48,7 @@ import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.SideBorder;
|
||||
@@ -94,6 +95,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
|
||||
private DocumentationManager myManager;
|
||||
private SmartPsiElementPointer myElement;
|
||||
private long myModificationCount;
|
||||
|
||||
private final Stack<Context> myBackStack = new Stack<Context>();
|
||||
private final Stack<Context> myForwardStack = new Stack<Context>();
|
||||
@@ -485,6 +487,19 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
return myElement != null ? myElement.getElement() : null;
|
||||
}
|
||||
|
||||
private void setElement(SmartPsiElementPointer element) {
|
||||
myElement = element;
|
||||
myModificationCount = getCurrentModificationCount();
|
||||
}
|
||||
|
||||
public boolean isUpToDate() {
|
||||
return getElement() != null && myModificationCount == getCurrentModificationCount();
|
||||
}
|
||||
|
||||
private long getCurrentModificationCount() {
|
||||
return myElement != null ? PsiModificationTracker.SERVICE.getInstance(myElement.getProject()).getModificationCount() : -1;
|
||||
}
|
||||
|
||||
public void setNavigateCallback(Consumer<PsiElement> navigateCallback) {
|
||||
myNavigateCallback = navigateCallback;
|
||||
}
|
||||
@@ -531,7 +546,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
: null;
|
||||
|
||||
if (element != null) {
|
||||
myElement = element;
|
||||
setElement(element);
|
||||
}
|
||||
|
||||
myIsEmpty = false;
|
||||
@@ -546,7 +561,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
}
|
||||
|
||||
private void setDataInternal(SmartPsiElementPointer element, String text, final Rectangle viewRect, boolean skip) {
|
||||
myElement = element;
|
||||
setElement(element);
|
||||
|
||||
boolean justShown = false;
|
||||
if (!myIsShown && myHint != null) {
|
||||
|
||||
+3
-2
@@ -395,7 +395,8 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
Content content = myToolWindow.getContentManager().getSelectedContent();
|
||||
if (content != null) {
|
||||
DocumentationComponent component = (DocumentationComponent)content.getComponent();
|
||||
if (element.getManager().areElementsEquivalent(component.getElement(), element)) {
|
||||
boolean sameElement = element.getManager().areElementsEquivalent(component.getElement(), element);
|
||||
if (sameElement) {
|
||||
JComponent preferredFocusableComponent = content.getPreferredFocusableComponent();
|
||||
// focus toolwindow on the second actionPerformed
|
||||
boolean focus = requestFocus || CommandProcessor.getInstance().getCurrentCommand() != null;
|
||||
@@ -403,7 +404,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(preferredFocusableComponent, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!sameElement || !component.isUpToDate()) {
|
||||
content.setDisplayName(getTitle(element, true));
|
||||
fetchDocInfo(getDefaultCollector(element, originalElement), component, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user