From f6cbef0fbeb58de396c726cd343fa177ca109099 Mon Sep 17 00:00:00 2001 From: Stephan Wahlbrink Date: Tue, 14 Feb 2017 22:31:38 +0100 Subject: Bug 512251 - Fix IllegalArgumentException in ContextInformationPopup Change-Id: I7c6eec0871e7f2b3a2a71c401b19e52a687f126e Signed-off-by: Stephan Wahlbrink --- .../contentassist/ContextInformationPopup.java | 37 +++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java') diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java index f733d6dad4c..8315265a97f 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Stephan Wahlbrink - Bug 512251 - Fix IllegalArgumentException in ContextInformationPopup *******************************************************************************/ package org.eclipse.jface.text.contentassist; @@ -274,7 +275,7 @@ class ContextInformationPopup implements IContentAssistListener { * @since 3.0 */ private void internalShowContextInfo(ContextFrame frame) { - if (frame != null) { + if (frame != null && canShowFrame(frame)) { fContextFrameStack.push(frame); if (fContextFrameStack.size() == 1) fLastContext= null; @@ -335,6 +336,19 @@ class ContextInformationPopup implements IContentAssistListener { return frame != null && frame.equals(fLastContext); } + /** + * Pre-checks if the given context frame can be (re)shown. + * + * The function checks if the frame has valid position data. It does not call the context + * information validator. + * + * @param frame the frame to check + * @return true if the context frame OK to use, otherwise false + */ + private boolean canShowFrame(ContextFrame frame) { + return fContentAssistSubjectControlAdapter.isValidWidgetOffset(frame.fVisibleOffset); + } + /** * Shows the given context frame. * @@ -457,16 +471,23 @@ class ContextInformationPopup implements IContentAssistListener { if (Helper.okToUse(fContextInfoPopup)) { int size= fContextFrameStack.size(); - if (size > 0) { + while (size > 0) { fLastContext= fContextFrameStack.pop(); -- size; - } - - if (size > 0) { - ContextFrame current= fContextFrameStack.peek(); - internalShowContextFrame(current, false); - } else { + if (size > 0) { + ContextFrame current= fContextFrameStack.peek(); + if (canShowFrame(current)) { + internalShowContextFrame(current, false); + return; + } + // continue - try next + } + else { + break; + } + } + { fContentAssistant.removeContentAssistListener(this, ContentAssistant.CONTEXT_INFO_POPUP); if (fContentAssistSubjectControlAdapter.getControl() != null) -- cgit v1.2.3