Java Code Examples for org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply()

The following examples show how to use org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected ContentAssistProcessorTestBuilder appendAndApplyProposal(ICompletionProposal proposal, ISourceViewer sourceViewer, String model, int position)
		throws Exception {
	IDocument document = sourceViewer.getDocument();
	int offset = position;
	if (model != null) {
		document.set(getModel() + model);
		offset += model.length();
	}
	if (proposal instanceof ICompletionProposalExtension2) {
		ICompletionProposalExtension2 proposalExtension2 = (ICompletionProposalExtension2) proposal;
		proposalExtension2.apply(sourceViewer, (char) 0, SWT.NONE, offset);	
	} else if (proposal instanceof ICompletionProposalExtension) {
		ICompletionProposalExtension proposalExtension = (ICompletionProposalExtension) proposal;
		proposalExtension.apply(document, (char) 0, offset);	
	} else  {
		proposal.apply(document);
	}
	return reset().append(document.get());
}
 
Example 2
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected ContentAssistProcessorTestBuilder appendAndApplyProposal(ICompletionProposal proposal, ISourceViewer sourceViewer, String model, int position)
		throws Exception {
	IDocument document = sourceViewer.getDocument();
	int offset = position;
	if (model != null) {
		document.set(getModel() + model);
		offset += model.length();
	}
	if (proposal instanceof ICompletionProposalExtension2) {
		ICompletionProposalExtension2 proposalExtension2 = (ICompletionProposalExtension2) proposal;
		proposalExtension2.apply(sourceViewer, (char) 0, SWT.NONE, offset);	
	} else if (proposal instanceof ICompletionProposalExtension) {
		ICompletionProposalExtension proposalExtension = (ICompletionProposalExtension) proposal;
		proposalExtension.apply(document, (char) 0, offset);	
	} else  {
		proposal.apply(document);
	}
	return reset().append(document.get());
}
 
Example 3
Source File: AbstractPyCreateClassOrMethodOrField.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * When executed it'll create a proposal and apply it.
 */
/*default*/void execute(RefactoringInfo refactoringInfo, String actTok, List<String> parametersAfterCall,
        int locationStrategy) {
    try {
        ICompletionProposalHandle proposal = createProposal(refactoringInfo, actTok, locationStrategy,
                parametersAfterCall);
        if (proposal != null) {
            if (proposal instanceof ICompletionProposalExtension2) {
                ICompletionProposalExtension2 extension2 = (ICompletionProposalExtension2) proposal;
                extension2.apply(((PyEdit) targetEditor).getPySourceViewer(), '\n', 0, 0);
            } else {
                proposal.apply(refactoringInfo.getDocument());
            }
        }

    } catch (Exception e) {
        Log.log(e);
    }
}