1 11 package org.eclipse.jdt.internal.debug.ui; 12 13 import org.eclipse.jdt.core.IJavaProject; 14 import org.eclipse.jdt.core.IType; 15 import org.eclipse.jdt.core.JavaModelException; 16 import org.eclipse.jdt.internal.debug.ui.display.DisplayCompletionProcessor; 17 import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateEngine; 18 import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateProposal; 19 import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; 20 import org.eclipse.jface.text.ITextSelection; 21 import org.eclipse.jface.text.ITextViewer; 22 import org.eclipse.jface.text.contentassist.ICompletionProposal; 23 24 public class BreakpointConditionCompletionProcessor extends DisplayCompletionProcessor { 25 26 private IType fType; 27 28 private int fPosition; 29 30 public BreakpointConditionCompletionProcessor(IType type) { 31 fType= type; 32 } 33 34 37 public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { 38 try { 39 setErrorMessage(null); 40 if (fType == null) { 41 setErrorMessage(DebugUIMessages.BreakpointConditionCompletionProcessor_0); return new ICompletionProposal[0]; 43 } 44 45 IJavaProject project= fType.getJavaProject(); 46 try { 47 ITextSelection textSelection= (ITextSelection)viewer.getSelectionProvider().getSelection(); 49 configureResultCollector(project, textSelection); 50 fType.codeComplete(viewer.getDocument().get().toCharArray(), fPosition, documentOffset, 51 new char[0][], new char[0][], 52 new int[0], false, getCollector()); 53 54 IJavaCompletionProposal[] results= getCollector().getJavaCompletionProposals(); 55 56 TemplateEngine templateEngine= getTemplateEngine(); 58 if (templateEngine != null) { 59 templateEngine.reset(); 60 templateEngine.complete(viewer, documentOffset, null); 61 TemplateProposal[] templateResults= templateEngine.getResults(); 62 63 IJavaCompletionProposal[] total= new IJavaCompletionProposal[results.length + templateResults.length]; 65 System.arraycopy(templateResults, 0, total, 0, templateResults.length); 66 System.arraycopy(results, 0, total, templateResults.length, results.length); 67 results= total; 68 } 69 return order(results); 72 } catch (JavaModelException x) { 73 handle(viewer, x); 74 } 75 return null; 76 } finally { 77 releaseCollector(); 78 } 79 } 80 84 public void setType(IType type) { 85 fType= type; 86 } 87 88 92 public void setPosition(int position) { 93 fPosition= position; 94 } 95 96 } 97 | Popular Tags |