CEditor里鼠标悬停在word上显示对应声明代码的提示框的代码
来源:互联网 发布:vesa图形编程系统 pdf 编辑:程序博客网 时间:2024/05/17 04:26
org.eclipse.jface.text.TextViewerHoverManager
/** * Determines all necessary details and delegates the computation into * a background thread. */protected void computeInformation() {if (!fProcessMouseHoverEvent) {setInformation(null, null);return;}Point location= getHoverEventLocation();int offset= computeOffsetAtLocation(location.x, location.y);if (offset == -1) {setInformation(null, null);return;}final ITextHover hover= fTextViewer.getTextHover(offset, getHoverEventStateMask());if (hover == null) {setInformation(null, null);return;}final IRegion region= hover.getHoverRegion(fTextViewer, offset);if (region == null) {setInformation(null, null);return;}final Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer);if (area == null || area.isEmpty()) {setInformation(null, null);return;}if (fThread != null) {setInformation(null, null);return;}fThread= new Thread("Text Viewer Hover Presenter") { //$NON-NLS-1$public void run() {// http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693boolean hasFinished= false;try {if (fThread != null) {Object information;try { //此处获取提示信息if (hover instanceof ITextHoverExtension2)information= ((ITextHoverExtension2)hover).getHoverInfo2(fTextViewer, region);elseinformation= hover.getHoverInfo(fTextViewer, region);} catch (ArrayIndexOutOfBoundsException x) {/* * This code runs in a separate thread which can * lead to text offsets being out of bounds when * computing the hover info (see bug 32848). */information= null;}if (hover instanceof ITextHoverExtension)setCustomInformationControlCreator(((ITextHoverExtension) hover).getHoverControlCreator());elsesetCustomInformationControlCreator(null);setInformation(information, area);//此处设置提示信息if (information != null)fTextHover= hover;} else {setInformation(null, null);}hasFinished= true;} catch (RuntimeException ex) {String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID));log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Unexpected runtime error while computing a text hover", ex)); //$NON-NLS-1$} finally {synchronized (fMutex) {if (fTextViewer != null)fTextViewer.removeTextListener(fStopper);fThread= null;// https://bugs.eclipse.org/bugs/show_bug.cgi?id=44756if (!hasFinished)setInformation(null, null);}}}};fThread.setDaemon(true);fThread.setPriority(Thread.MIN_PRIORITY);synchronized (fMutex) {fTextViewer.addTextListener(fStopper);fThread.start();}}
org.eclipse.cdt.internal.ui.text.c.hover.CSourceHover
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {IEditorPart editor = getEditor();if (editor != null) {IEditorInput input= editor.getEditorInput();IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();IWorkingCopy copy = manager.getWorkingCopy(input);try {if (copy == null || !copy.isConsistent()) {return null;}} catch (CModelException exc) {return null;}String expression;try {expression = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());expression = expression.trim();if (expression.length() == 0)return null;//Before trying a search lets make sure that the user is not hovering over a keyword if (selectionIsKeyword(expression))return null;String source= null;// Try with the indexer 在indexer中查找source= searchInIndex(copy, hoverRegion);if (source == null || source.trim().length() == 0)return null;// we are actually interested in the comments, too.//source= removeLeadingComments(source);String delim= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$String[] sourceLines= Strings.convertIntoLines(source);String firstLine= sourceLines[0];boolean ignoreFirstLine = firstLine.length() > 0 && !Character.isWhitespace(firstLine.charAt(0));Strings.trimIndentation(sourceLines, getTabWidth(), getTabWidth(), !ignoreFirstLine);source = Strings.concatenate(sourceLines, delim);return source;} catch (BadLocationException e) {}}return null;}
相关类:
org.eclipse.jface.text.AbstractInformationControlManager
org.eclipse.cdt.internal.ui.text.c.hover.BestMatchHover
org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor
org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy
org.eclipse.cdt.internal.ui.text.c.hover.CSourceHover
org.eclipse.cdt.internal.ui.text.c.hover.CSourceHover.ComputeSourceRunnable
org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl
org.eclipse.jface.text.TextViewerHoverManager
0 0
- CEditor里鼠标悬停在word上显示对应声明代码的提示框的代码
- 鼠标悬停提示代码
- 鼠标悬停时反白显示的导航条代码(原创)
- 鼠标悬停在小图上,自动出现大图的代码
- Eclipse鼠标悬停某方法调用上的描述,显示图片和提示样式
- 在Mac上解决Android Studio 鼠标悬停文档显示fetching documentation的问题
- jquery 鼠标悬停显示信息提示框
- AndroidStudio鼠标放到代码上自动显示代码的信息
- 在word中显示漂亮的代码
- 实现鼠标悬停上之后才显示下拉的内容
- Myeclipse的xml,鼠标悬停在bean配置上,只有元素和属性提示,没有属性值提示
- 鼠标放在图片上 显示提示的文字
- Android studio设置鼠标悬停上会显示文档提示
- Android studio设置鼠标悬停上会显示文档提示
- Treeview 鼠标悬停时的问题提示
- Treeview 鼠标悬停时的问题提示
- chrome 鼠标悬停在链接上时不显示提示状态栏
- Word域代码的显示
- iTween.ValueTo实现tk2d的sprite渐隐效果
- N皇后问题
- 华为机试——五分制成绩:break和continue的区分
- mysql 高级之运算符
- 随笔
- CEditor里鼠标悬停在word上显示对应声明代码的提示框的代码
- android—Intent发送文本email
- C# WinForm多线程开发(二) ThreadPool 与 Timer
- 第七周作业项目---体验常成员函数
- 内存泄露检测—VLD工具
- 机器学习-Random Forest算法简介
- 感冒了
- Spring 3.0参考手册之SpEL
- AnkhSvn安装及使用