cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java
changeset 111 c2563c416525
parent 110 9262ca4bdfff
equal deleted inserted replaced
110:9262ca4bdfff 111:c2563c416525
    16 import java.util.regex.Pattern;
    16 import java.util.regex.Pattern;
    17 
    17 
    18 import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
    18 import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
    19 import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
    19 import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
    20 import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
    20 import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
       
    21 import org.eclipse.core.runtime.IAdaptable;
    21 import org.eclipse.debug.core.DebugException;
    22 import org.eclipse.debug.core.DebugException;
    22 import org.eclipse.debug.ui.IDebugUIConstants;
    23 import org.eclipse.debug.ui.IDebugUIConstants;
    23 import org.eclipse.jface.text.BadLocationException;
    24 import org.eclipse.jface.text.BadLocationException;
    24 import org.eclipse.jface.text.IDocument;
    25 import org.eclipse.jface.text.IDocument;
    25 import org.eclipse.jface.text.IInformationControlCreator;
    26 import org.eclipse.jface.text.IInformationControlCreator;
    26 import org.eclipse.jface.text.IRegion;
    27 import org.eclipse.jface.text.IRegion;
    27 import org.eclipse.jface.text.ITextHoverExtension;
    28 import org.eclipse.jface.text.ITextHoverExtension;
    28 import org.eclipse.jface.text.ITextViewer;
    29 import org.eclipse.jface.text.ITextViewer;
    29 import org.eclipse.jface.viewers.ISelection;
    30 import org.eclipse.jface.viewers.ISelection;
       
    31 import org.eclipse.jface.viewers.IStructuredSelection;
    30 import org.eclipse.ui.IEditorPart;
    32 import org.eclipse.ui.IEditorPart;
    31 import org.eclipse.ui.IPartListener;
    33 import org.eclipse.ui.IPartListener;
    32 import org.eclipse.ui.ISelectionListener;
    34 import org.eclipse.ui.ISelectionListener;
    33 import org.eclipse.ui.IWorkbenchPage;
    35 import org.eclipse.ui.IWorkbenchPage;
    34 import org.eclipse.ui.IWorkbenchPart;
    36 import org.eclipse.ui.IWorkbenchPart;
    73 	}
    75 	}
    74 }
    76 }
    75 
    77 
    76 /**
    78 /**
    77  * The text hovering support for C/C++ debugger.
    79  * The text hovering support for C/C++ debugger.
       
    80  * 
       
    81  * @since 6.1
    78  */
    82  */
    79 
    83 
    80 public abstract class AbstractDebugTextHover implements ICEditorTextHover, ITextHoverExtension,
    84 public abstract class AbstractDebugTextHover implements ICEditorTextHover, ITextHoverExtension,
    81 		ISelectionListener, IPartListener {
    85 		ISelectionListener, IPartListener {
    82 
    86 
    83 	static final private int MAX_HOVER_INFO_SIZE = 100;
    87 	static final private int MAX_HOVER_INFO_SIZE = 100;
    84 
    88 
    85 	protected ISelection fSelection = null;
    89 	private ISelection fSelection = null;
    86 
    90 
    87 	protected IEditorPart fEditor;
    91 	private IEditorPart fEditor;
    88 
    92 
    89 	protected abstract boolean canEvaluate();
    93 	protected abstract boolean canEvaluate();
    90 	
    94 	
    91 	protected abstract String evaluateExpression(String expression);
    95 	protected abstract String evaluateExpression(String expression);
    92 	
    96 	
   224 
   228 
   225 	public IInformationControlCreator getHoverControlCreator() {
   229 	public IInformationControlCreator getHoverControlCreator() {
   226 		return null;
   230 		return null;
   227 	}
   231 	}
   228 
   232 
       
   233 	protected ISelection getSelection() {
       
   234 	    return fSelection;
       
   235 	}
       
   236 
       
   237 	protected IAdaptable getSelectionAdaptable() {
       
   238         if (fSelection instanceof IStructuredSelection) {
       
   239             IStructuredSelection selection = (IStructuredSelection) fSelection;
       
   240             if (selection.size() == 1) {
       
   241                 Object element = selection.getFirstElement();
       
   242                 if (element instanceof IAdaptable) {
       
   243                     return (IAdaptable) element;
       
   244                 }
       
   245             }
       
   246         }
       
   247         return null;
       
   248     }
       
   249 
       
   250 
       
   251 	protected IEditorPart getEditor() {
       
   252 	    return fEditor;
       
   253 	}
       
   254 	
   229 	/**
   255 	/**
   230 	 * Replace any characters in the given String that would confuse an HTML parser with their escape sequences.
   256 	 * Replace any characters in the given String that would confuse an HTML parser with their escape sequences.
   231 	 */
   257 	 */
   232 	private static String makeHTMLSafe(String string) {
   258 	private static String makeHTMLSafe(String string) {
   233 		StringBuffer buffer = new StringBuffer(string.length());
   259 		StringBuffer buffer = new StringBuffer(string.length());