本文整理汇总了Java中org.eclipse.jface.text.contentassist.ICompletionProposalExtension2类的典型用法代码示例。如果您正苦于以下问题:Java ICompletionProposalExtension2类的具体用法?Java ICompletionProposalExtension2怎么用?Java ICompletionProposalExtension2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICompletionProposalExtension2类属于org.eclipse.jface.text.contentassist包,在下文中一共展示了ICompletionProposalExtension2类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
@Override
public void apply(final ITextViewer viewer, char trigger, int stateMask, final int offset)
{
delegateTemplateProposal = null;
if (contains(triggerChars, trigger))
{
if (triggerChar == trigger)
{
doApply(viewer, trigger, stateMask, offset);
}
else
{
delegateTemplateProposal = templateProposals[trigger - '1'];
((ICompletionProposalExtension2) templateProposals[trigger - '1']).apply(viewer, trigger, stateMask,
offset);
}
}
else
{
doApply(viewer, trigger, stateMask, offset);
}
}
示例2: createProposal
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
/**
* When executed it'll create a proposal and apply it.
*/
/*default*/void execute(RefactoringInfo refactoringInfo, String actTok, List<String> parametersAfterCall,
int locationStrategy) {
try {
ICompletionProposal proposal = createProposal(refactoringInfo, actTok, locationStrategy,
parametersAfterCall);
if (proposal != null) {
if (proposal instanceof ICompletionProposalExtension2) {
ICompletionProposalExtension2 extension2 = (ICompletionProposalExtension2) proposal;
extension2.apply(targetEditor.getPySourceViewer(), '\n', 0, 0);
} else {
proposal.apply(refactoringInfo.getDocument());
}
}
} catch (Exception e) {
Log.log(e);
}
}
示例3: waitForQuickFixProps
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
private ICompletionProposalExtension2 waitForQuickFixProps(TddCodeGenerationQuickFixParticipant quickFix,
PySelection ps, int offset, String expectedCompletion) throws MisconfigurationException,
BadLocationException {
long initialTime = System.currentTimeMillis();
List<ICompletionProposal> props;
while (true) {
props = waitForQuickFixProps(quickFix, ps, offset);
ICompletionProposalExtension2 completion = findCompletion(props, expectedCompletion, false);
if (completion != null) {
return completion;
}
if (System.currentTimeMillis() - initialTime > 10000) {
break; //Give it 10 seconds to work.
}
goToManual(200);
}
// throws exception if not used.
return findCompletion(props, expectedCompletion);
}
示例4: findCompletion
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
private ICompletionProposalExtension2 findCompletion(List<ICompletionProposal> props, String expectedCompletion,
boolean throwException) {
List<String> buf = new ArrayList<String>(1 + (2 * props.size()));
buf.add("Available:");
for (ICompletionProposal iCompletionProposal : props) {
if (iCompletionProposal.getDisplayString().equals(expectedCompletion)) {
ICompletionProposalExtension2 p = (ICompletionProposalExtension2) iCompletionProposal;
return p;
}
buf.add("\n");
buf.add(iCompletionProposal.getDisplayString());
}
if (throwException) {
throw new AssertionError("Could not find completion: " + expectedCompletion +
"\n"
+ StringUtils.join("\n", buf));
}
return null;
}
示例5: unregister
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
/**
* Unregister this completion proposal popup.
*
* @since 3.0
*/
private void unregister()
{
if (fDocumentListener != null)
{
IDocument document = fContentAssistSubjectControlAdapter.getDocument();
if (document != null)
{
document.removeDocumentListener(fDocumentListener);
}
fDocumentListener = null;
}
fDocumentEvents.clear();
if (fKeyListener != null && Helper.okToUse(fContentAssistSubjectControlAdapter.getControl()))
{
fContentAssistSubjectControlAdapter.removeKeyListener(fKeyListener);
fKeyListener = null;
}
if (fLastProposal != null)
{
if (fLastProposal instanceof ICompletionProposalExtension2 && fViewer != null)
{
ICompletionProposalExtension2 extension = (ICompletionProposalExtension2) fLastProposal;
extension.unselected(fViewer);
}
fLastProposal = null;
}
fFilteredProposals = null;
fComputedProposals = null;
fContentAssistant.possibleCompletionsClosed();
}
示例6: selectProposal
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
/**
* Selects the entry with the given index in the proposal selector and feeds the selection to the additional info
* controller.
*
* @param index
* the index in the list
* @param smartToggle
* <code>true</code> if the smart toggle key has been pressed
* @param autoScroll
* Do we scroll the item into view at the middle of the list
* @since 2.1
*/
private void selectProposal(int index, boolean smartToggle, boolean autoScroll)
{
if (fFilteredProposals == null)
{
return;
}
ICompletionProposal oldProposal = getSelectedProposal();
if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null)
{
((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
}
ICompletionProposal proposal = fFilteredProposals[index];
if (proposal instanceof ICompletionProposalExtension2 && fViewer != null)
{
((ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle);
}
fLastProposal = proposal;
fProposalTable.setSelection(index);
if (autoScroll)
{
setScroll(index);
}
fProposalTable.showSelection();
if (fAdditionalInfoController != null)
{
fAdditionalInfoController.handleTableSelectionChanged();
}
}
示例7: getActionsFromProposals
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
private static IAction[] getActionsFromProposals(IJavaCompletionProposal[] proposals, final int offset, final ITextViewer viewer) {
List<Action> result= new ArrayList<Action>();
for (int i= 0, j= 1; i < proposals.length; i++) {
if (proposals[i] instanceof ICompletionProposalExtension2) {
final IJavaCompletionProposal proposal= proposals[i];
StringBuffer actionName= new StringBuffer();
if (j<10) {
actionName.append('&').append(j).append(' ');
}
actionName.append(proposals[i].getDisplayString());
Action action= new Action(actionName.toString()) {
/**
* {@inheritDoc}
*/
@Override
public void run() {
applyProposal(proposal, viewer, (char)0, 0, offset);
}
};
action.setImageDescriptor(JavaPluginImages.DESC_OBJS_TEMPLATE);
result.add(action);
j++;
}
}
if (result.size() == 0)
return null;
return result.toArray(new IAction[result.size()]);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:SurroundWithTemplateMenuAction.java
示例8: setProposals
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
/**
* Initializes the proposal selector with these given proposals.
*
* @param proposals
* the proposals
* @param isFilteredSubset
* if <code>true</code>, the proposal table is not cleared, but the proposals that are not in the passed
* array are removed from the displayed set
*/
private void setProposals(ICompletionProposal[] proposals, boolean isFilteredSubset)
{
ICompletionProposal[] oldProposals = fFilteredProposals;
ICompletionProposal oldProposal = getSelectedProposal(); // may trigger filtering and a reentrant call to
// setProposals()
if (oldProposals != fFilteredProposals)
return;
if (!(Helper.okToUse(fProposalTable)))
return;
if ((oldProposal instanceof ICompletionProposalExtension2) && (fViewer != null))
{
((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
}
if (proposals == null)
{
proposals = new ICompletionProposal[0];
}
fFilteredProposals = proposals;
int length = proposals.length;
TableItem[] items;
if (USE_VIRTUAL)
{
fProposalTable.clearAll();
fProposalTable.setItemCount(length);
items = fProposalTable.getItems();
for (int i = 0; i < items.length; ++i)
{
setItem(items, i);
}
}
else
{
fProposalTable.setRedraw(false);
fProposalTable.setItemCount(length);
items = fProposalTable.getItems();
for (int i = 0; i < items.length; i++)
{
TableItem item = items[i];
ICompletionProposal proposal = proposals[i];
item.setData("isAlt", "false");
item.setImage(0, proposal.getImage());
item.setText(1, proposal.getDisplayString());
setDefaultStyle(item);
item.setData(proposal);
}
fProposalTable.setRedraw(true);
}
// Custom code for modifying selection/size
int defaultIndex = -1;
int suggestedIndex = -1;
// select the first proposal
if (proposals.length > 0)
{
defaultIndex = 0;
suggestedIndex = 0;
}
modifySelection(defaultIndex, suggestedIndex);
if (!(isFilteredSubset))
{
resizeTable(0, 0);
}
}
示例9: computeFilteredProposals
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; //导入依赖的package包/类
/**
* Computes the subset of already computed proposals that are still valid for the given offset.
*
* @param offset
* the offset
* @param event
* the merged document event
* @return the set of filtered proposals
* @since 3.0
*/
private ICompletionProposal[] computeFilteredProposals(int offset, DocumentEvent event)
{
if (offset == fInvocationOffset && event == null)
{
fIsFilteredSubset = false;
return fComputedProposals;
}
IDocument document = fContentAssistSubjectControlAdapter.getDocument();
// this does go through the array twice (once to figure out if it's okay to use the else case, and the second
// time to actual filter the proposals, but it is what the original logic suggests
if ((offset < fInvocationOffset) || ((event != null) && (event.fText.startsWith("("))))
{
fIsFilteredSubset = false;
fInvocationOffset = offset;
fComputedProposals = computeProposals(fInvocationOffset, false);
fComputedProposals = filterProposals(fComputedProposals, document, fInvocationOffset, event);
return fComputedProposals;
}
ICompletionProposal[] proposals;
if (offset < fFilterOffset)
{
proposals = fComputedProposals;
fIsFilteredSubset = false;
}
else
{
proposals = fFilteredProposals;
fIsFilteredSubset = true;
}
if (proposals == null)
{
fIsFilteredSubset = false;
return null;
}
for (int i = 0; i < proposals.length; i++)
{
ICompletionProposal proposal = proposals[i];
if ((proposal instanceof ICompletionProposalExtension2)
|| (proposal instanceof ICompletionProposalExtension))
{
continue;
}
fIsFilteredSubset = false;
fInvocationOffset = offset;
fComputedProposals = computeProposals(fInvocationOffset, false);
return fComputedProposals;
}
ICompletionProposal[] filtered = filterProposals(proposals, document, offset, event);
return filtered;
}