diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java index c8a3670b40b..19198be3f89 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext; +import org.eclipse.cdt.ui.text.contentassist.ICEditorContentAssistInvocationContext; import org.eclipse.cdt.internal.ui.text.CHeuristicScanner; import org.eclipse.cdt.internal.ui.text.Symbols; @@ -38,7 +39,7 @@ import org.eclipse.cdt.internal.ui.text.Symbols; * * @since 4.0 */ -public class CContentAssistInvocationContext extends ContentAssistInvocationContext { +public class CContentAssistInvocationContext extends ContentAssistInvocationContext implements ICEditorContentAssistInvocationContext { private final IEditorPart fEditor; private final boolean fIsCompletion; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java new file mode 100644 index 00000000000..1e874ef6adb --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.text.contentassist; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.ui.IEditorPart; + +import org.eclipse.cdt.core.dom.ast.IASTCompletionNode; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.ITranslationUnit; + +/** + * Describes the context of a content assist invocation in a C/C++ editor. + */ +public interface ICEditorContentAssistInvocationContext { + + /** + * Returns the translation unit that content assist is invoked in, null if there + * is none. + * + * @return the translation unit that content assist is invoked in, possibly null + */ + ITranslationUnit getTranslationUnit(); + + /** + * Returns the project of the translation unit that content assist is invoked in, + * null if none. + * + * @return the current C project, possibly null + */ + ICProject getProject(); + + /** + * Returns the IASTCompletionNode of the location where content assist was invoked. + * @return the IASTCompletionNode of the location where context assist was invoked. + */ + IASTCompletionNode getCompletionNode(); + + /** + * Returns the offset which was used to compute the IASTCompletionNode when content + * assist was invoked. + * @return the offset used to compute the IASTCompletionNode. + */ + int getParseOffset(); + + /** + * Returns the offset where context information starts. + * @return the offset where context information (parameter hints) starts. + */ + int getContextInformationOffset(); + + /** + * Get the editor content assist is invoked in. + * + * @return the editor, may be null + */ + IEditorPart getEditor(); + + /** + * Returns the viewer, null if not available. + * + * @return the viewer, possibly null + */ + ITextViewer getViewer(); + + /** + * Returns the invocation offset. + * + * @return the invocation offset + */ + int getInvocationOffset(); + + /** + * Returns true if the current content assist invocation + * is for revealing context information, or false otherwise. + * + * @return true if the current content assist invocation + * is for revealing context information. + */ + boolean isContextInformationStyle(); + + /** + * Returns the document that content assist is invoked on, or null if not known. + * + * @return the document or null + */ + IDocument getDocument(); + + /** + * Computes the identifier (as specified by {@link Character#isJavaIdentifierPart(char)}) that + * immediately precedes the invocation offset. + * + * @return the prefix preceding the content assist invocation offset, null if + * there is no document + * @throws BadLocationException if accessing the document fails + */ + CharSequence computeIdentifierPrefix() throws BadLocationException; +} \ No newline at end of file