类org.eclipse.jface.text.contentassist.IContextInformation源码实例Demo

下面列出了怎么用org.eclipse.jface.text.contentassist.IContextInformation的API类实例代码及写法,或者点击链接到github查看源代码。

public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
    List<ICompletionProposal> propList = new ArrayList<ICompletionProposal>();
    List<ICompletionProposal> newpropList = new ArrayList<ICompletionProposal>();
    List<IContextInformation> propList2 = new ArrayList<IContextInformation>();

    ICompletionProposal first;
    DataManager datamanger = new DataManager(context,monitor);
    Activator.applyoperationlist.add(new ApplyOperation(ConsoleOperationListener2.ope.getStart(), ConsoleOperationListener2.ope.getAuthor(), ConsoleOperationListener2.ope.getFilePath(), propList));
    List<String> list = new ArrayList();
    CompletionProposal proposal;
    propList = datamanger.JavaDefaultProposal();
    propList2 = datamanger.ContextInformation();
    ApplyOperation ao = new ApplyOperation(ConsoleOperationListener2.ope.getStart(), ConsoleOperationListener2.ope.getAuthor(), ConsoleOperationListener2.ope.getFilePath(), propList);
    System.out.println(ao.toString());
    return newpropList;
}
 
/**
 * createProposal
 * 
 * @param displayName
 * @param name
 * @param image
 * @param description
 * @param userAgents
 * @param fileLocation
 * @param offset
 * @param length
 * @return
 */
protected CommonCompletionProposal createProposal(String displayName, String name, Image image, String description,
		String[] userAgentIds, String fileLocation, int offset, int length)
{
	IContextInformation contextInfo = null;

	// TEMP:
	int replaceLength = 0;

	if (this._replaceRange != null)
	{
		offset = this._replaceRange.getStartingOffset();
		replaceLength = this._replaceRange.getLength();
	}

	Image[] userAgents = UserAgentManager.getInstance().getUserAgentImages(getProject(), userAgentIds);

	// build proposal
	CommonCompletionProposal proposal = new CommonCompletionProposal(name, offset, replaceLength, length, image,
			displayName, contextInfo, description);
	proposal.setFileLocation(fileLocation);
	proposal.setUserAgentImages(userAgents);
	return proposal;
}
 
/**
 * createProposal
 * 
 * @param displayName
 * @param name
 * @param image
 * @param description
 * @param userAgents
 * @param fileLocation
 * @param offset
 * @return
 */
protected CommonCompletionProposal createProposal(String displayName, String name, Image image, String description,
		String[] userAgentIds, String fileLocation, int offset)
{
	int length = name.length();
	IContextInformation contextInfo = null;
	int replaceLength = 0;

	if (this._replaceRange != null)
	{
		offset = this._replaceRange.getStartingOffset();
		replaceLength = this._replaceRange.getLength();
	}

	// build proposal
	Image[] userAgents = UserAgentManager.getInstance().getUserAgentImages(getProject(), userAgentIds);

	CommonCompletionProposal proposal = new CommonCompletionProposal(name, offset, replaceLength, length, image,
			displayName, contextInfo, description);
	proposal.setFileLocation(fileLocation);
	proposal.setUserAgentImages(userAgents);
	proposal.setTriggerCharacters(getProposalTriggerCharacters());
	return proposal;
}
 
源代码4 项目: APICloud-Studio   文件: ContextInformationPopup.java
/**
 * 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;
}
 
/**
 * Creates a new completion proposal. All fields are initialized based on the provided information.
 *
 * @param replacementString the actual string to be inserted into the document
 * @param replacementOffset the offset of the text to be replaced
 * @param replacementLength the length of the text to be replaced
 * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
 * @param image the image to display for this proposal
 * @param displayString the string to be displayed for the proposal
 * @param contextInformation the context information associated with this proposal
 * @param additionalProposalInfo the additional information associated with this proposal
 */
public ModulaContextualCompletionProposal(String replacementString, int replacementOffset, int replacementLength, 
        int cursorPosition, Image image, StyledString displaySString, IContextInformation contextInformation, String additionalProposalInfo) {
    Assert.isNotNull(replacementString);
    Assert.isTrue(replacementOffset >= 0);
    Assert.isTrue(replacementLength >= 0);
    Assert.isTrue(cursorPosition >= 0);

    fReplacementString= replacementString;
    fReplacementOffset= replacementOffset;
    fReplacementLength= replacementLength;
    fCursorPosition= cursorPosition;
    fImage= image;
    fDisplaySString= displaySString;
    fContextInformation= contextInformation;
    fAdditionalProposalInfo= additionalProposalInfo;
}
 
源代码6 项目: APICloud-Studio   文件: ContentAssistant.java
/**
 * Returns an array of context information objects computed based on the specified document position. The position
 * is used to determine the appropriate code assist processor to invoke.
 * 
 * @param viewer
 *            the viewer for which to compute the context information
 * @param offset
 *            a document offset
 * @return an array of context information objects
 * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
 */
IContextInformation[] computeContextInformation(ITextViewer viewer, int offset)
{
	fLastErrorMessage = null;

	IContextInformation[] result = null;

	IContentAssistProcessor p = getProcessor(viewer, offset);
	if (p != null)
	{
		result = p.computeContextInformation(viewer, offset);
		fLastErrorMessage = p.getErrorMessage();
	}

	return result;
}
 
/**
 * createProsal
 * 
 * @param displayName
 * @param name
 * @param image
 * @param description
 * @param userAgents
 * @param fileLocation
 * @param offset
 * @param length
 * @return
 */
protected CommonCompletionProposal createProposal(String displayName, String name, Image image, String description,
		Image[] userAgents, String fileLocation, int offset, int length)
{
	IContextInformation contextInfo = null;

	// TEMP:
	int replaceLength = 0;

	if (this._replaceRange != null)
	{
		offset = this._replaceRange.getStartingOffset();
		replaceLength = this._replaceRange.getLength();
	}

	// build proposal
	CommonCompletionProposal proposal = new CommonCompletionProposal(name, offset, replaceLength, length, image,
			displayName, contextInfo, description);
	proposal.setFileLocation(fileLocation);
	proposal.setUserAgentImages(userAgents);
	proposal.setTriggerCharacters(getProposalTriggerCharacters());
	return proposal;
}
 
源代码8 项目: n4js   文件: N4JSCompletionProposal.java
/**
 * Creates a new proposal.
 */
public N4JSCompletionProposal(String replacementString, int replacementOffset, int replacementLength,
		int cursorPosition, Image image, StyledString displayString, IContextInformation contextInformation,
		String additionalProposalInfo) {
	super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString,
			contextInformation, additionalProposalInfo);
}
 
源代码9 项目: http4e   文件: HContentAssistProcessor.java
public IContextInformation[] computeContextInformation( ITextViewer viewer, int documentOffset){
   // viewer.getSelectedRange();
   // if (selectedRange.y > 0) Text is selected. Create a context information array.
   // ContextInformation[] contextInfos = new
   // ContextInformation[STYLELABELS.length];
   // // Create one context information item for each style
   // for (int i = 0; i < STYLELABELS.length; i++)
   // contextInfos[i] = new ContextInformation("<" + STYLETAGS[i] + ">",
   // STYLELABELS[i] + " Style");
   // return contextInfos;
   // }
   return new ContextInformation[0];
}
 
@Override
public boolean isContextInformationValid(int offset) {
	if (fContextInformation instanceof ISmartContextInformation) {
		return ((ISmartContextInformation) fContextInformation).isContextInformationValid(fViewer, offset);
	} else {
		IContextInformation[] infos= fProcessor.computeContextInformation(fViewer, offset);
		if (infos != null && infos.length > 0) {
			for (int i= 0; i < infos.length; i++)
				if (fContextInformation.equals(infos[i]))
					return true;
		}
		return false;
	}
}
 
@Override
public IContextInformation[] computeContextInformation(final ITextViewer viewer, final int offset) {
	if (contextInformationProvider == null)
		return null;
	
	IXtextDocument document = xtextDocumentUtil.getXtextDocument(viewer);
	return document.priorityReadOnly(createContextInformationComputer(viewer, offset));
}
 
源代码12 项目: xtext-eclipse   文件: ContextInformationComputer.java
public ContextInformationComputer(State state, ITextViewer viewer, int offset) {
	super();
	this.information = new LinkedHashSet<IContextInformation>();
	this.state = state;
	this.offset = offset;
	this.viewer = viewer;
}
 
源代码13 项目: xtext-eclipse   文件: ContextInformationComputer.java
@Override
public IContextInformation[] exec(XtextResource resource) throws Exception {
	IContextInformationAcceptor acceptor = state.decorateAcceptor(this);
	ContentAssistContext[] contexts = state.getContextFactory().create(viewer, offset, resource);
	for (ContentAssistContext context: contexts) {
		if (acceptor.canAcceptMoreInformation())
			state.getContextInformationProvider().getContextInformation(context, acceptor);
	}
	if (information.isEmpty())
		return null;
	return information.toArray(new IContextInformation[information.size()]);
}
 
源代码14 项目: texlipse   文件: TexStyleCompletionManager.java
/**
 * Returns the style context.
 * 
 * @return Array of style contexts
 */
public IContextInformation[] getStyleContext() {
    ContextInformation[] contextInfos = new ContextInformation[STYLELABELS.length];
    
    // Create one context information item for each style
    for (int i = 0; i < STYLELABELS.length; i++) {
        contextInfos[i] = new ContextInformation(null, STYLELABELS[i]+" Style");
    }
    return contextInfos;
}
 
public void install(IContextInformation info, ITextViewer viewer, int offset)
{
	this._contextInformation = info;
	this._viewer = viewer;

	if (info instanceof IContextInformationExtension)
	{
		this._startingOffset = ((IContextInformationExtension) info).getContextInformationPosition();
	}
	else
	{
		this._startingOffset = offset;
	}
}
 
源代码16 项目: tlaplus   文件: ToolboxCompletionProcessor.java
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
	// Retrieve selected range
	final Point selectedRange = viewer.getSelectedRange();
	if (selectedRange.y > 0) {
		// Text is selected. Create a context information array.
		final IContextInformation[] contextInfos = new ContextInformation[ITLAReserveredWords.ALL_WORDS_ARRAY.length];

		// Create one context information item for each style
		for (int i = 0; i < ITLAReserveredWords.ALL_WORDS_ARRAY.length; i++) {
			contextInfos[i] = new ContextInformation(null, ITLAReserveredWords.ALL_WORDS_ARRAY[i] + " Style");
		}
		return contextInfos;
	}
	return new ContextInformation[0];
}
 
源代码17 项目: tlaplus   文件: ToolboxCompletionProcessor.java
public CompletionProposalTemplate(String replacementString, Image image, String dipslayString,
		IContextInformation contextInformation, String additionalProposalInfo) {
	this.fReplacementString = replacementString;
	this.fImage = image;
	this.fDisplayString = dipslayString;
	this.fContextInformation = contextInformation;
	this.fAdditionalProposalInfo = additionalProposalInfo;
}
 
源代码18 项目: tlaplus   文件: TLACompletionProcessor.java
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
	// Retrieve selected range
	final Point selectedRange = viewer.getSelectedRange();
	if (selectedRange.y > 0) {
		// Text is selected. Create a context information array.
		final IContextInformation[] contextInfos = new ContextInformation[ITLAReserveredWords.ALL_WORDS_ARRAY.length];

		// Create one context information item for each style
		for (int i = 0; i < ITLAReserveredWords.ALL_WORDS_ARRAY.length; i++) {
			contextInfos[i] = new ContextInformation(null, ITLAReserveredWords.ALL_WORDS_ARRAY[i] + " Style");
		}
		return contextInfos;
	}
	return new ContextInformation[0];
}
 
@Override
public IContextInformation getContextInformation() {
	if (contextInformationComputed) {
		return contextInformation;
	}
	this.contextInformation = createContextInformation();
	contextInformationComputed = true;
	return contextInformation;
}
 
private IContextInformation createContextInformation() {
	try {
		String information = null;
		List<CompletionEntryDetails> entryDetails = super.getEntryDetails();
		if (entryDetails == null || entryDetails.size() < 1) {
			return null;
		}
		if (isFunction()) {
			information = TypeScriptHelper.extractFunctionParameters(entryDetails.get(0).getDisplayParts());
		}
		return information != null ? new ContextInformation("", information) : null;
	} catch (TypeScriptException e) {
	}
	return null;
}
 
源代码21 项目: APICloud-Studio   文件: CommonCompletionProposal.java
/**
 * CommonCompletionProposal
 * 
 * @param replacementString
 * @param replacementOffset
 * @param replacementLength
 * @param cursorPosition
 * @param image
 * @param displayString
 * @param contextInformation
 * @param additionalProposalInfo
 */
public CommonCompletionProposal(String replacementString, int replacementOffset, int replacementLength,
		int cursorPosition, Image image, String displayString, IContextInformation contextInformation,
		String additionalProposalInfo)
{
	this._replacementString = (replacementString == null) ? StringUtil.EMPTY : replacementString;
	this._replacementOffset = replacementOffset;
	this._replacementLength = replacementLength;
	this._cursorPosition = cursorPosition;
	this._image = image;
	this._displayString = (displayString == null) ? StringUtil.EMPTY : displayString;
	this._contextInformation = contextInformation;
	this._additionalProposalInformation = additionalProposalInfo;
}
 
@Override
public IContextInformation getContextInformation() {
    if (markerResolution instanceof IMarkerResolution2) {
        IMarkerResolution2 mr2 = (IMarkerResolution2) markerResolution;
        String displayString = mr2.getDescription() == null ? mr2.getLabel() : mr2.getDescription();

        return new ContextInformation(mr2.getImage(), mr2.getLabel(), displayString);
    }
    return null;
}
 
源代码23 项目: APICloud-Studio   文件: ContextInformationPopup.java
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;
}
 
源代码24 项目: APICloud-Studio   文件: ContextInformationPopup.java
/**
 * Displays the given context information for the given offset.
 * 
 * @param info
 *            the context information
 * @param offset
 *            the offset
 * @since 2.0
 */
public void showContextInformation(final IContextInformation info, final int offset)
{
	Control control = fContentAssistSubjectControlAdapter.getControl();
	BusyIndicator.showWhile(control.getDisplay(), new Runnable()
	{
		public void run()
		{
			if (info == null)
			{
				validateContextInformation();
			}
			else
			{
				ContextFrame frame = createContextFrame(info, offset);
				if (isDuplicate(frame))
				{
					validateContextInformation();
				}
				else
				{
					internalShowContextInfo(frame);
				}
				hideContextSelector();
			}
		}
	});
}
 
@Override
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
  return null;
}
 
@Override
public IContextInformation[] computeContextInformation(
        IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) {
  return null;
}
 
源代码27 项目: eclipse-cs   文件: RegExContentAssistProcessor.java
@Override
public IContextInformation[] computeContextInformation(
        IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) {
  return null;
}
 
源代码28 项目: n4js   文件: JSDocContentAssistProcessor.java
@Override
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
	return null;
}
 
源代码29 项目: ContentAssist   文件: getProposalResult.java
public List<IContextInformation> getAllProposalResultInformation(){
	return computeContextInformation(context, monitor);
}
 
源代码30 项目: ContentAssist   文件: DataManager.java
public List<IContextInformation> ContextInformation(){	
	return getproposalresult.getAllProposalResultInformation();
}
 
 类所在包
 同包方法