Class VariableCompletion

  • All Implemented Interfaces:
    Comparable<Completion>, Completion
    Direct Known Subclasses:
    FunctionCompletion

    public class VariableCompletion
    extends BasicCompletion
    A completion for a variable (or constant) in a programming language.

    This completion type uses its shortDescription property as part of its summary returned by getSummary(); for this reason, it may be a little longer (even much longer), if desired, than what is recommended for BasicCompletions (where the shortDescription is used in toString() for ListCellRenderers).

    Version:
    1.0
    Author:
    Robert Futrell
    • Constructor Detail

      • VariableCompletion

        public VariableCompletion​(CompletionProvider provider,
                                  String name,
                                  String type)
        Constructor.
        Parameters:
        provider - The parent provider.
        name - The name of this variable.
        type - The type of this variable (e.g. "int", "String", etc.).
    • Method Detail

      • addDefinitionString

        protected void addDefinitionString​(StringBuilder sb)
      • getDefinitionString

        public String getDefinitionString()
      • getDefinedIn

        public String getDefinedIn()
        Returns where this variable is defined.
        Returns:
        Where this variable is defined.
        See Also:
        setDefinedIn(String)
      • getName

        public String getName()
        Returns the name of this variable.
        Returns:
        The name.
      • getSummary

        public String getSummary()
        Returns the description of this auto-complete choice. This can be used in a popup "description window."
        Specified by:
        getSummary in interface Completion
        Overrides:
        getSummary in class BasicCompletion
        Returns:
        This item's description. This should be HTML. It may be null if there is no description for this completion.
      • getType

        public String getType()
        Returns the type of this variable.
        Returns:
        The type.
      • possiblyAddDefinedIn

        protected void possiblyAddDefinedIn​(StringBuilder sb)
        Adds some HTML describing where this variable is defined, if this information is known.
        Parameters:
        sb - The buffer to append to.
      • possiblyAddDescription

        protected boolean possiblyAddDescription​(StringBuilder sb)
        Adds the description text as HTML to a buffer, if a description is defined.
        Parameters:
        sb - The buffer to append to.
        Returns:
        Whether there was a description to add.
      • setDefinedIn

        public void setDefinedIn​(String definedIn)
        Sets where this variable is defined.
        Parameters:
        definedIn - Where this variable is defined.
        See Also:
        getDefinedIn()
      • toString

        public String toString()
        Overridden to return the name of the variable being completed.
        Overrides:
        toString in class BasicCompletion
        Returns:
        A string representation of this completion.