1 11 package org.eclipse.jdt.internal.ui.text.java; 12 13 import java.util.Hashtable ; 14 import java.util.List ; 15 16 import org.eclipse.core.runtime.IProgressMonitor; 17 18 import org.eclipse.jface.text.ITextViewer; 19 import org.eclipse.jface.text.contentassist.ContentAssistant; 20 import org.eclipse.jface.text.contentassist.IContextInformationValidator; 21 22 import org.eclipse.ui.IEditorPart; 23 24 import org.eclipse.jdt.core.JavaCore; 25 26 import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; 27 import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; 28 29 32 public class JavaCompletionProcessor extends ContentAssistProcessor { 33 34 private final static String VISIBILITY= JavaCore.CODEASSIST_VISIBILITY_CHECK; 35 private final static String ENABLED= "enabled"; private final static String DISABLED= "disabled"; 38 private IContextInformationValidator fValidator; 39 protected final IEditorPart fEditor; 40 41 public JavaCompletionProcessor(IEditorPart editor, ContentAssistant assistant, String partition) { 42 super(assistant, partition); 43 fEditor= editor; 44 } 45 46 52 public void restrictProposalsToVisibility(boolean restrict) { 53 Hashtable options= JavaCore.getOptions(); 54 Object value= options.get(VISIBILITY); 55 if (value instanceof String ) { 56 String newValue= restrict ? ENABLED : DISABLED; 57 if ( !newValue.equals(value)) { 58 options.put(VISIBILITY, newValue); 59 JavaCore.setOptions(options); 60 } 61 } 62 } 63 64 70 public void restrictProposalsToMatchingCases(boolean restrict) { 71 } 73 74 77 public IContextInformationValidator getContextInformationValidator() { 78 if (fValidator == null) 79 fValidator= new JavaParameterListValidator(); 80 return fValidator; 81 } 82 83 86 protected List filterAndSortProposals(List proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) { 87 ProposalSorterRegistry.getDefault().getCurrentSorter().sortProposals(context, proposals); 88 return proposals; 89 } 90 91 94 protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset) { 95 return new JavaContentAssistInvocationContext(viewer, offset, fEditor); 96 } 97 } 98 | Popular Tags |