Package org.eclipse.jdt.ui.text.java
Class JavaContentAssistInvocationContext
- java.lang.Object
-
- org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext
-
- org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext
-
public class JavaContentAssistInvocationContext extends ContentAssistInvocationContext
Describes the context of a content assist invocation in a Java editor.Clients may use but not subclass this class.
- Since:
- 3.2
- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Constructor Summary
Constructors Constructor Description JavaContentAssistInvocationContext(ICompilationUnit unit)Creates a new context.JavaContentAssistInvocationContext(IJavaProject javaProject)Creates a new context.JavaContentAssistInvocationContext(ITextViewer viewer, int offset, IEditorPart editor)Creates a new context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ICompilationUnitgetCompilationUnit()Returns the compilation unit that content assist is invoked in,nullif there is none.CompletionContextgetCoreContext()Returns thecore completion contextif available,nullotherwise.ITypegetExpectedType()Returns the expected type if any,nullotherwise.floatgetHistoryRelevance(String qualifiedTypeName)Returns an float in [0.0, 1.0] based on whether the type has been recently used as a right hand side for the type expected in the current context. 0 signals that thequalifiedTypeNamedoes not match the expected type, while 1.0 signals thatqualifiedTypeNamehas most recently been used in a similar context.IJavaCompletionProposal[]getKeywordProposals()Returns the keyword proposals that are available in this context, possibly none.CompletionProposalLabelProvidergetLabelProvider()Returns a label provider that can be used to compute proposal labels.IJavaProjectgetProject()Returns the project of the compilation unit that content assist is invoked in,nullif none.-
Methods inherited from class org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext
computeIdentifierPrefix, equals, getDocument, getInvocationOffset, getTextSelection, getViewer, hashCode
-
-
-
-
Constructor Detail
-
JavaContentAssistInvocationContext
public JavaContentAssistInvocationContext(ITextViewer viewer, int offset, IEditorPart editor)
Creates a new context.- Parameters:
viewer- the viewer used by the editoroffset- the invocation offseteditor- the editor that content assist is invoked in
-
JavaContentAssistInvocationContext
public JavaContentAssistInvocationContext(ICompilationUnit unit)
Creates a new context.- Parameters:
unit- the compilation unit indocument
-
JavaContentAssistInvocationContext
public JavaContentAssistInvocationContext(IJavaProject javaProject)
Creates a new context.- Parameters:
javaProject- the Java project- Since:
- 3.9
-
-
Method Detail
-
getCompilationUnit
public ICompilationUnit getCompilationUnit()
Returns the compilation unit that content assist is invoked in,nullif there is none.- Returns:
- the compilation unit that content assist is invoked in, possibly
null
-
getProject
public IJavaProject getProject()
Returns the project of the compilation unit that content assist is invoked in,nullif none.- Returns:
- the current java project, possibly
null
-
getKeywordProposals
public IJavaCompletionProposal[] getKeywordProposals()
Returns the keyword proposals that are available in this context, possibly none.Note: This method may run codeComplete on the compilation unit.
- Returns:
- the available keyword proposals
-
getCoreContext
public CompletionContext getCoreContext()
Returns thecore completion contextif available,nullotherwise.Note: This method may run codeComplete on the compilation unit.
- Returns:
- the core completion context if available,
nullotherwise
-
getHistoryRelevance
public float getHistoryRelevance(String qualifiedTypeName)
Returns an float in [0.0, 1.0] based on whether the type has been recently used as a right hand side for the type expected in the current context. 0 signals that thequalifiedTypeNamedoes not match the expected type, while 1.0 signals thatqualifiedTypeNamehas most recently been used in a similar context.Note: This method may run codeComplete on the compilation unit.
- Parameters:
qualifiedTypeName- the type name of the type of interest- Returns:
- a relevance in [0.0, 1.0] based on previous content assist invocations
-
getExpectedType
public IType getExpectedType()
Returns the expected type if any,nullotherwise.Note: This method may run codeComplete on the compilation unit.
- Returns:
- the expected type if any,
nullotherwise
-
getLabelProvider
public CompletionProposalLabelProvider getLabelProvider()
Returns a label provider that can be used to compute proposal labels.- Returns:
- a label provider that can be used to compute proposal labels
-
-