1 /* 2 * The contents of this file are subject to the terms of the Common Development 3 * and Distribution License (the License). You may not use this file except in 4 * compliance with the License. 5 * 6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html 7 * or http://www.netbeans.org/cddl.txt. 8 * 9 * When distributing Covered Code, include this CDDL Header Notice in each file 10 * and include the License file at http://www.netbeans.org/cddl.txt. 11 * If applicable, add the following below the CDDL Header, with the fields 12 * enclosed by brackets [] replaced by your own identifying information: 13 * "Portions Copyrighted [year] [name of copyright owner]" 14 * 15 * The Original Software is NetBeans. The Initial Developer of the Original 16 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun 17 * Microsystems, Inc. All Rights Reserved. 18 */ 19 20 package org.netbeans.spi.editor.completion; 21 22 /** 23 * The inteface of a task performing a code completion query. 24 * <br> 25 * The support class 26 * {@link org.netbeans.spi.editor.completion.support.AsyncCompletionTask} 27 * can be used for convenience when the task requires an asynchronous evaluation. 28 * 29 * @see CompletionProvider 30 * 31 * @author Miloslav Metelka, Dusan Balek 32 * @version 1.01 33 */ 34 35 public interface CompletionTask { 36 37 /** 38 * Called by the code completion infrastructure to ask the task 39 * to do a query and return the results through the given completion listener. 40 * <br> 41 * This method is called only once during the lifetime of the completion task 42 * object. 43 * 44 * <p> 45 * This method is always called in AWT thread but it may reschedule 46 * its processing into another thread and fire the given listener 47 * once the computing is finished. 48 * 49 * @param resultSet non-null result set to which the results 50 * of the query must be added. 51 */ 52 public void query(CompletionResultSet resultSet); 53 54 /** 55 * Called by the code completion infrastructure to inform the task about 56 * changes in the corresponding document. The task should reflect these 57 * changes while creating the query result. 58 * <br> 59 * This method can be called multiple times on a single task instance. 60 * <br> 61 * Typically it is called AFTER the <code>query()</code> was invoked 62 * but it may also be invoked BEFORE the <code>query()</code> in case 63 * the user types even before the <code>query()</code> 64 * was called by the infrastructure. In such 65 * case the <code>resultSet</code> parameter will be <code>null</code>. 66 * <br> 67 * It is guaranteed that this method will not be invoked in case 68 * the document instance set in the component would change since the last invocation 69 * of either the <code>query()</code> or <code>refresh()</code>. 70 * 71 * <p> 72 * This method is always called in AWT thread but it may reschedule 73 * its processing into another thread and fire the given listener 74 * once the computing is finished. 75 * 76 * @param resultSet non-null result set to which the results 77 * of the refreshing must be added. 78 * <br/> 79 * Null result set may be passed in case the <code>query()</code> 80 * was not invoked yet and user has typed a character. In this case 81 * the provider may hide the completion 82 * by using <code>Completion.get().hideAll()</code> 83 * if the typed character is inappropriate e.g. ";" for java completion. 84 */ 85 public void refresh(CompletionResultSet resultSet); 86 87 /** 88 * Called by the code completion infrastructure to cancel the task. 89 * <br> 90 * Once the cancel is done on the task no more querying or refreshing 91 * is done on it. 92 * 93 * <p> 94 * This method may potentially be called from any thread. 95 */ 96 public void cancel(); 97 98 } 99