/** * Creates a context frame for the given offset. * * @param information * the context information * @param offset * the offset * @return the created context frame * @since 3.0 */ private ContextFrame createContextFrame(IContextInformation information, int offset) { IContextInformationValidator validator = fContentAssistSubjectControlAdapter.getContextInformationValidator( fContentAssistant, offset); if (validator != null) { int beginOffset = (information instanceof IContextInformationExtension) ? ((IContextInformationExtension) information) .getContextInformationPosition() : offset; if (beginOffset == -1) { beginOffset = offset; } int visibleOffset = fContentAssistSubjectControlAdapter.getWidgetSelectionRange().x - (offset - beginOffset); IContextInformationPresenter presenter = fContentAssistSubjectControlAdapter .getContextInformationPresenter(fContentAssistant, offset); return new ContextFrame(information, beginOffset, offset, visibleOffset, validator, presenter); } return null; }
public ContextFrame(IContextInformation information, int beginOffset, int offset, int visibleOffset, IContextInformationValidator validator, IContextInformationPresenter presenter) { fInformation = information; fBeginOffset = beginOffset; fOffset = offset; fVisibleOffset = visibleOffset; fValidator = validator; fPresenter = presenter; }
private ContextInformationDelegator(IContextInformationValidator defaultContextInformationValidator) { Assert.isTrue(defaultContextInformationValidator instanceof IContextInformationPresenter); this.defaultContextInformationValidator = defaultContextInformationValidator; }
@Override public boolean updatePresentation(int offset, TextPresentation presentation) { return ((IContextInformationPresenter) defaultContextInformationValidator).updatePresentation(offset, presentation); }
/** * Returns the context information presenter that should be used to display context information. The position is * used to determine the appropriate code assist processor to invoke. * * @param contentAssistant * the code assistant * @param offset * a document offset * @return a presenter */ public IContextInformationPresenter getContextInformationPresenter(ContentAssistant contentAssistant, int offset) { if (fContentAssistSubjectControl != null) { return contentAssistant.getContextInformationPresenter(fContentAssistSubjectControl, offset); } return contentAssistant.getContextInformationPresenter(fViewer, offset); }
/** * Returns the context information presenter that should be used to display context information. The position is * used to determine the appropriate code assist processor to invoke. * * @param viewer * the text viewer * @param offset * a document offset * @return a presenter * @since 2.0 */ IContextInformationPresenter getContextInformationPresenter(ITextViewer viewer, int offset) { IContextInformationValidator validator = getContextInformationValidator(viewer, offset); if (validator instanceof IContextInformationPresenter) { return (IContextInformationPresenter) validator; } return null; }
/** * Returns the context information presenter that should be used to display context information. The position is * used to determine the appropriate code assist processor to invoke. * * @param contentAssistSubjectControl * the code assist subject control * @param offset * a document offset * @return a presenter * @since 3.0 */ IContextInformationPresenter getContextInformationPresenter( IContentAssistSubjectControl contentAssistSubjectControl, int offset) { IContextInformationValidator validator = getContextInformationValidator(contentAssistSubjectControl, offset); if (validator instanceof IContextInformationPresenter) { return (IContextInformationPresenter) validator; } return null; }