1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Bug 261727 - Extensions to ICHelpInvocationContext interface, patch by Jeff Johnston

This commit is contained in:
Anton Leherbauer 2009-02-23 11:17:03 +00:00
parent 2c8f56b3fe
commit 7cf033c0bd
5 changed files with 92 additions and 5 deletions

View file

@ -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);

View file

@ -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()

View file

@ -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 {

View file

@ -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();
}

View file

@ -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();
}