mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 02:05:39 +02:00
Bug 261727 - Extensions to ICHelpInvocationContext interface, patch by Jeff Johnston
This commit is contained in:
parent
2c8f56b3fe
commit
7cf033c0bd
5 changed files with 92 additions and 5 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.IRequiredInclude;
|
||||||
import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
|
import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
|
||||||
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
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.CHelpProviderManager;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
|
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
|
||||||
|
@ -55,10 +56,11 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
final IRegion hoverRegion = region;
|
||||||
|
|
||||||
// call the Help to get info
|
// call the Help to get info
|
||||||
|
|
||||||
ICHelpInvocationContext context = new ICHelpInvocationContext() {
|
ICHelpInvocationContext context = new IHoverHelpInvocationContext() {
|
||||||
|
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
ITranslationUnit unit = getTranslationUnit();
|
ITranslationUnit unit = getTranslationUnit();
|
||||||
|
@ -72,6 +74,11 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
IEditorInput editorInput= getEditor().getEditorInput();
|
IEditorInput editorInput= getEditor().getEditorInput();
|
||||||
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
|
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IRegion getHoverRegion() {
|
||||||
|
return hoverRegion;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
|
IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IFunctionSummary;
|
import org.eclipse.cdt.ui.IFunctionSummary;
|
||||||
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
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.CHelpProviderManager;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||||
|
@ -63,8 +64,11 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
}
|
}
|
||||||
|
|
||||||
final ITranslationUnit tu = cContext.getTranslationUnit();
|
final ITranslationUnit tu = cContext.getTranslationUnit();
|
||||||
|
final IASTCompletionNode cn = completionNode;
|
||||||
|
final int cc = cContext.getInvocationOffset();
|
||||||
|
|
||||||
// Find matching functions
|
// Find matching functions
|
||||||
ICHelpInvocationContext helpContext = new ICHelpInvocationContext() {
|
ICHelpInvocationContext helpContext = new IContentAssistHelpInvocationContext() {
|
||||||
|
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
return tu.getCProject().getProject();
|
return tu.getCProject().getProject();
|
||||||
|
@ -73,6 +77,14 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
|
||||||
public ITranslationUnit getTranslationUnit() {
|
public ITranslationUnit getTranslationUnit() {
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getInvocationOffset() {
|
||||||
|
return cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTCompletionNode getCompletionNode() {
|
||||||
|
return cn;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IFunctionSummary[] summaries = CHelpProviderManager.getDefault()
|
IFunctionSummary[] summaries = CHelpProviderManager.getDefault()
|
||||||
|
|
|
@ -19,6 +19,9 @@ import org.eclipse.core.resources.IProject;
|
||||||
*
|
*
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
|
*
|
||||||
|
* @see IHoverHelpInvocationContext
|
||||||
|
* @see IContentAssistHelpInvocationContext
|
||||||
*/
|
*/
|
||||||
public interface ICHelpInvocationContext {
|
public interface ICHelpInvocationContext {
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
}
|
|
@ -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();
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue