--- old/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java 2016-01-22 02:17:10.422145011 -0800 +++ new/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysis.java 2016-01-22 02:17:10.188143379 -0800 @@ -74,6 +74,24 @@ */ SourceCodeAnalysis() {} + /**Infer the type of the given expression. Returns null if the type of the expression cannot + * be inferred. + * + * @param code the expression for which the type should be inferred + * @param cursor current cursor position in the given code + * @return the inferred type, or null if it cannot be inferred + */ + public abstract String analyzeType(String code, int cursor); + + /**List the possible FQNs for an identifier in the given code immediately + * to the right of the given cursor position. + * + * @param code the expression for which the candidate FQNs should be computed + * @param cursor current cursor position in the given code + * @return the gathered FQNs + */ + public abstract IndexResult getDeclaredSymbols(String code, int cursor); + /** * The result of analyzeCompletion(String input). * Describes the completeness and position of the first snippet in the given input. @@ -198,4 +216,56 @@ */ public final boolean isSmart; } + + /**List of possible qualified names. + */ + public static final class IndexResult { + + private final List fqns; + private final int simpleNameLength; + private final boolean upToDate; + private final boolean resolvable; + + public IndexResult(List fqns, int simpleNameLength, boolean upToDate, boolean resolvable) { + this.fqns = fqns; + this.simpleNameLength = simpleNameLength; + this.upToDate = upToDate; + this.resolvable = resolvable; + } + + /**Candidate fully qualified names (FQNs). + * + * @return possible fully qualified names + */ + public List getFqns() { + return fqns; + } + + /**The length of the unresolvable simple name in the original code for which the + * FQNs where computed. + * + * @return the length of the simple name; -1 if there is no name right left to the cursor for + * which the candidates could be computed + */ + public int getSimpleNameLength() { + return simpleNameLength; + } + + /**Whether the result is based on up to date data. + * + * @return true iff the results is based on up-to-date data + */ + public boolean isUpToDate() { + return upToDate; + } + + /**The given identifier refers to a resolvable element. + * + * @return true iff the given identifier refers to a resolvable element + */ + public boolean isResolvable() { + return resolvable; + } + + } }