org.objectweb.jac.ide.swing
Class MethodBodyCompletionEngine

java.lang.Object
  |
  +--org.objectweb.jac.aspects.gui.swing.CompletionEngine
        |
        +--org.objectweb.jac.ide.swing.MethodBodyCompletionEngine

public class MethodBodyCompletionEngine
extends CompletionEngine

This class implements a completion engine for method bodies Java editors of the UMLAF IDE.


Field Summary
 
Fields inherited from class org.objectweb.jac.aspects.gui.swing.CompletionEngine
BACKWARD, baseWords, FORWARD
 
Constructor Summary
MethodBodyCompletionEngine(Method method, SHEditor editor)
          Creates a completion engine for a given method.
 
Method Summary
 List buildClassWords(Class c)
          Get all the accessible words in the context of a given IDE class (fields,methods).
 List buildThisWords()
          Builds the list of method and field names that are directly accessible within the class of the method and the parameters of the method, as well as the names of the types of those fields.
 List buildTypeWords(Type type)
          Get all the accessible words in the context of a given type.
 List getContextualChoices(String text, int position, String writtenText)
          Get the contextual possible choices.
 boolean isAutomaticCompletionChar(char c)
          Returns true if c=='('.
 void runAutomaticCompletion(SHEditor editor, String text, int position, char c)
          Help the programmer to write useful control structure such as for or while.
 
Methods inherited from class org.objectweb.jac.aspects.gui.swing.CompletionEngine
addBaseWord, addBaseWords, clearBaseWords, getBaseWords, getProposal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodBodyCompletionEngine

public MethodBodyCompletionEngine(Method method,
                                  SHEditor editor)
Creates a completion engine for a given method.

Method Detail

getContextualChoices

public List getContextualChoices(String text,
                                 int position,
                                 String writtenText)
Get the contextual possible choices.

Supported contextual completions are like class_typed_symbol.{methods}. In the long term, any typed expression should be supported even if it is not that important in clean developments (because of the Demeter's Law!!).

Specified by:
getContextualChoices in class CompletionEngine
Parameters:
text - the editor's full text
position - the cursor position
writtenText - the already written text
Returns:
a list of strings which must not contain duplicates

buildThisWords

public List buildThisWords()
Builds the list of method and field names that are directly accessible within the class of the method and the parameters of the method, as well as the names of the types of those fields.


buildTypeWords

public List buildTypeWords(Type type)
Get all the accessible words in the context of a given type.

If type is an internal IDE class, all the method plus the generated methods (getters, setters, adders, removers, clearers) are returned. If type is an external library class, all the public methods are returned.

See Also:
buildClassWords(Class)

buildClassWords

public List buildClassWords(Class c)
Get all the accessible words in the context of a given IDE class (fields,methods).

Parameters:
c - the class for which to get accessible words

isAutomaticCompletionChar

public boolean isAutomaticCompletionChar(char c)
Returns true if c=='('.

Specified by:
isAutomaticCompletionChar in class CompletionEngine

runAutomaticCompletion

public void runAutomaticCompletion(SHEditor editor,
                                   String text,
                                   int position,
                                   char c)
Help the programmer to write useful control structure such as for or while.

Specified by:
runAutomaticCompletion in class CompletionEngine