diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java index 3ff06e0a1b1..e9122204de5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,6 +25,7 @@ import org.eclipse.cdt.ui.IFunctionSummary; import org.eclipse.cdt.ui.IRequiredInclude; import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary; import org.eclipse.cdt.ui.text.ICHelpInvocationContext; +import org.eclipse.cdt.ui.text.IHoverHelpInvocationContext; import org.eclipse.cdt.internal.ui.CHelpProviderManager; import org.eclipse.cdt.internal.ui.editor.CEditorMessages; @@ -55,10 +56,11 @@ public class CDocHover extends AbstractCEditorTextHover { return null; StringBuilder buffer = new StringBuilder(); + final IRegion hoverRegion = region; // call the Help to get info - ICHelpInvocationContext context = new ICHelpInvocationContext() { + ICHelpInvocationContext context = new IHoverHelpInvocationContext() { public IProject getProject() { ITranslationUnit unit = getTranslationUnit(); @@ -71,7 +73,12 @@ public class CDocHover extends AbstractCEditorTextHover { public ITranslationUnit getTranslationUnit() { IEditorInput editorInput= getEditor().getEditorInput(); return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput); - } + } + + public IRegion getHoverRegion() { + return hoverRegion; + } + }; IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java index a80ef79fe50..babe0ab8df0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 QNX Software Systems and others. + * Copyright (c) 2007, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,6 +27,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.IFunctionSummary; import org.eclipse.cdt.ui.text.ICHelpInvocationContext; +import org.eclipse.cdt.ui.text.IContentAssistHelpInvocationContext; import org.eclipse.cdt.internal.ui.CHelpProviderManager; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; @@ -63,8 +64,11 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer } final ITranslationUnit tu = cContext.getTranslationUnit(); + final IASTCompletionNode cn = completionNode; + final int cc = cContext.getInvocationOffset(); + // Find matching functions - ICHelpInvocationContext helpContext = new ICHelpInvocationContext() { + ICHelpInvocationContext helpContext = new IContentAssistHelpInvocationContext() { public IProject getProject() { return tu.getCProject().getProject(); @@ -73,6 +77,14 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer public ITranslationUnit getTranslationUnit() { return tu; } + + public int getInvocationOffset() { + return cc; + } + + public IASTCompletionNode getCompletionNode() { + return cn; + } }; IFunctionSummary[] summaries = CHelpProviderManager.getDefault() diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java index 10029c1edc8..5a27dca844d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java @@ -19,6 +19,9 @@ import org.eclipse.core.resources.IProject; * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. + * + * @see IHoverHelpInvocationContext + * @see IContentAssistHelpInvocationContext */ public interface ICHelpInvocationContext { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java new file mode 100644 index 00000000000..95c5560752e --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java @@ -0,0 +1,35 @@ +/********************************************************************** + * Copyright (c) 2009 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat Inc. - Initial API and implementation + **********************************************************************/ + +package org.eclipse.cdt.ui.text; + +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; + +/** + * Invocation context for content assist. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 5.1 + */ +public interface IContentAssistHelpInvocationContext extends ICHelpInvocationContext { + + /** + * @return the offset of the content assist. + */ + int getInvocationOffset(); + + /** + * @return the AST completion node or null. + */ + IASTCompletionNode getCompletionNode(); + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java new file mode 100644 index 00000000000..351ec1b0962 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java @@ -0,0 +1,30 @@ +/********************************************************************** + * Copyright (c) 2009 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat Inc. - Initial API and implementation + **********************************************************************/ + +package org.eclipse.cdt.ui.text; + +import org.eclipse.jface.text.IRegion; + +/** + * Invocation context for the CHelpProviderManager. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 5.1 + */ +public interface IHoverHelpInvocationContext extends ICHelpInvocationContext { + + /** + * @return the hover region or null + */ + IRegion getHoverRegion(); + +}