public abstract class SourceCodeAnalysis extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SourceCodeAnalysis.Completeness
Describes the completeness of the given input.
|
static interface |
SourceCodeAnalysis.CompletionInfo
The result of
analyzeCompletion(String input) . |
static class |
SourceCodeAnalysis.QualifiedNames
List of possible qualified names.
|
static interface |
SourceCodeAnalysis.SnippetWrapper
The wrapping of a snippet of Java source into valid top-level Java
source.
|
static interface |
SourceCodeAnalysis.Suggestion
A candidate for continuation of the given user's input.
|
Modifier and Type | Method and Description |
---|---|
abstract SourceCodeAnalysis.CompletionInfo |
analyzeCompletion(String input)
Given an input string, find the first snippet of code (one statement,
definition, import, or expression) and evaluate if it is complete.
|
abstract String |
analyzeType(String code,
int cursor)
Infer the type of the given expression.
|
abstract List<SourceCodeAnalysis.Suggestion> |
completionSuggestions(String input,
int cursor,
int[] anchor)
Compute possible follow-ups for the given input.
|
abstract Collection<Snippet> |
dependents(Snippet snippet)
Returns a collection of
Snippet s which might need updating if the
given Snippet is updated. |
abstract String |
documentation(String input,
int cursor)
Compute a description/help string for the given user's input.
|
abstract SourceCodeAnalysis.QualifiedNames |
listQualifiedNames(String code,
int cursor)
List qualified names known for the simple name in the given code immediately
to the left of the given cursor position.
|
abstract SourceCodeAnalysis.SnippetWrapper |
wrapper(Snippet snippet)
Returns the wrapper information for the
Snippet . |
abstract List<SourceCodeAnalysis.SnippetWrapper> |
wrappers(String input)
Returns the wrapper information for the snippet within the
input source string.
|
public abstract SourceCodeAnalysis.CompletionInfo analyzeCompletion(String input)
input
- the input source stringpublic abstract List<SourceCodeAnalysis.Suggestion> completionSuggestions(String input, int cursor, int[] anchor)
JShell
state, including
type information, to filter the suggestions.input
- the user input, so farcursor
- the current position of the cursors in the given input
textanchor
- outgoing parameter - when an option will be completed, the text between
the anchor and cursor will be deleted and replaced with the given optionpublic abstract String documentation(String input, int cursor)
input
- the snippet the user wrote so farcursor
- the current position of the cursors in the given input
textpublic abstract String analyzeType(String code, int cursor)
code
to the given cursor
position. Returns null if the type of the expression cannot
be inferred.code
- the expression for which the type should be inferredcursor
- current cursor position in the given codepublic abstract SourceCodeAnalysis.QualifiedNames listQualifiedNames(String code, int cursor)
JShell.addToClasspath(java.lang.String)
).code
- the expression for which the candidate qualified names should be computedcursor
- current cursor position in the given codepublic abstract SourceCodeAnalysis.SnippetWrapper wrapper(Snippet snippet)
Snippet
. The wrapper changes as
the environment changes, so calls to this method at different times may
yield different results.snippet
- the Snippet
from which to retrieve the wrapperpublic abstract List<SourceCodeAnalysis.SnippetWrapper> wrappers(String input)
Wrapper information for malformed and incomplete snippets also generate wrappers. The list is in snippet encounter order. The wrapper changes as the environment changes, so calls to this method at different times may yield different results.
The input should be
exactly one complete snippet of source code, that is, one expression,
statement, variable declaration, method declaration, class declaration,
or import.
To break arbitrary input into individual complete snippets, use
analyzeCompletion(String)
.
The wrapper may not match that returned by
wrapper(Snippet)
,
were the source converted to a Snippet
.
input
- the source input from which to generate wrapperspublic abstract Collection<Snippet> dependents(Snippet snippet)
Snippet
s which might need updating if the
given Snippet
is updated. The returned collection is designed to
be inclusive and may include many false positives.snippet
- the Snippet
whose dependents are requested
Copyright © 2015, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-08-10-220919.robert.dev