langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java
changeset 41865 3ef02797070d
parent 40498 f54048be4a57
child 43770 a321bed02000
equal deleted inserted replaced
41864:f7dbab23003a 41865:3ef02797070d
    61      * @return list of candidate continuations of the given input.
    61      * @return list of candidate continuations of the given input.
    62      */
    62      */
    63     public abstract List<Suggestion> completionSuggestions(String input, int cursor, int[] anchor);
    63     public abstract List<Suggestion> completionSuggestions(String input, int cursor, int[] anchor);
    64 
    64 
    65     /**
    65     /**
    66      * Compute a description/help string for the given user's input.
    66      * Compute documentation for the given user's input. Multiple {@code Documentation} objects may
       
    67      * be returned when multiple elements match the user's input (like for overloaded methods).
    67      * @param input the snippet the user wrote so far
    68      * @param input the snippet the user wrote so far
    68      * @param cursor the current position of the cursors in the given {@code input} text
    69      * @param cursor the current position of the cursors in the given {@code input} text
    69      * @return description/help string for the given user's input
    70      * @param computeJavadoc true if the javadoc for the given input should be computed in
    70      */
    71      *                       addition to the signature
    71     public abstract String documentation(String input, int cursor);
    72      * @return the documentations for the given user's input, if multiple elements match the input,
       
    73      *         multiple {@code Documentation} objects are returned.
       
    74      */
       
    75     public abstract List<Documentation> documentation(String input, int cursor, boolean computeJavadoc);
    72 
    76 
    73     /**
    77     /**
    74      * Infer the type of the given expression. The expression spans from the beginning of {@code code}
    78      * Infer the type of the given expression. The expression spans from the beginning of {@code code}
    75      * to the given {@code cursor} position. Returns null if the type of the expression cannot
    79      * to the given {@code cursor} position. Returns null if the type of the expression cannot
    76      * be inferred.
    80      * be inferred.
   264          */
   268          */
   265         boolean matchesType();
   269         boolean matchesType();
   266     }
   270     }
   267 
   271 
   268     /**
   272     /**
       
   273      * A documentation for a candidate for continuation of the given user's input.
       
   274      */
       
   275     public interface Documentation {
       
   276 
       
   277         /**
       
   278          * The signature of the given element.
       
   279          *
       
   280          * @return the signature
       
   281          */
       
   282         String signature();
       
   283 
       
   284         /**
       
   285          * The javadoc of the given element.
       
   286          *
       
   287          * @return the javadoc, or null if not found or not requested
       
   288          */
       
   289         String javadoc();
       
   290     }
       
   291 
       
   292     /**
   269      * List of possible qualified names.
   293      * List of possible qualified names.
   270      */
   294      */
   271     public static final class QualifiedNames {
   295     public static final class QualifiedNames {
   272 
   296 
   273         private final List<String> names;
   297         private final List<String> names;